Initial commit
This commit is contained in:
commit
4ac2bbba62
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.direnv/
|
||||
.devenv/
|
2
firmware/.envrc
Normal file
2
firmware/.envrc
Normal file
@ -0,0 +1,2 @@
|
||||
watch_file default.nix
|
||||
use flake ..#firmware --override-input rootdir "file+file://"<(printf %s "$PWD")
|
3
firmware/.gitignore
vendored
Normal file
3
firmware/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/build/
|
||||
sdkconfig
|
||||
sdkconfig.old
|
8
firmware/CMakeLists.txt
Normal file
8
firmware/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
# For more information about build system see
|
||||
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
|
||||
# The following five lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(valconomy)
|
24
firmware/default.nix
Normal file
24
firmware/default.nix
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
perSystem = { libMy, pkgs, ... }: {
|
||||
devenv.shells.firmware = libMy.withRootdir {
|
||||
packages = with pkgs; [
|
||||
esp-idf-esp32s3
|
||||
picocom
|
||||
];
|
||||
|
||||
env = {
|
||||
# PICO_SDK_PATH = "${pkgs.pico-sdk}/lib/pico-sdk";
|
||||
};
|
||||
|
||||
scripts = {
|
||||
# build.exec = ''
|
||||
# cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -D PICO_STDIO_SEMIHOSTING=1
|
||||
# cmake --build build --parallel
|
||||
# '';
|
||||
init.exec = ''
|
||||
idf.py set-target esp32s3
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
2
firmware/main/CMakeLists.txt
Normal file
2
firmware/main/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "valconomy.c"
|
||||
INCLUDE_DIRS ".")
|
46
firmware/main/valconomy.c
Normal file
46
firmware/main/valconomy.c
Normal file
@ -0,0 +1,46 @@
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_chip_info.h"
|
||||
#include "esp_flash.h"
|
||||
#include "esp_system.h"
|
||||
|
||||
void app_main(void) {
|
||||
printf("Hello world!\n");
|
||||
|
||||
/* Print chip information */
|
||||
esp_chip_info_t chip_info;
|
||||
uint32_t flash_size;
|
||||
esp_chip_info(&chip_info);
|
||||
printf("This is %s chip with %d CPU core(s), %s%s%s%s, ",
|
||||
CONFIG_IDF_TARGET,
|
||||
chip_info.cores,
|
||||
(chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
|
||||
(chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
|
||||
(chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
|
||||
(chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : "");
|
||||
|
||||
unsigned major_rev = chip_info.revision / 100;
|
||||
unsigned minor_rev = chip_info.revision % 100;
|
||||
printf("silicon revision v%d.%d, ", major_rev, minor_rev);
|
||||
if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
|
||||
printf("Get flash size failed");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024),
|
||||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
|
||||
|
||||
printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());
|
||||
|
||||
for (int i = 10; i >= 0; i--) {
|
||||
printf("Restarting in %d seconds...\n", i);
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
printf("Restarting now.\n");
|
||||
fflush(stdout);
|
||||
esp_restart();
|
||||
}
|
4
firmware/sdkconfig.defaults
Normal file
4
firmware/sdkconfig.defaults
Normal file
@ -0,0 +1,4 @@
|
||||
# This file was generated using idf.py save-defconfig. It can be edited manually.
|
||||
# Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration
|
||||
#
|
||||
CONFIG_ESP_WIFI_DPP_SUPPORT=y
|
53
flake.nix
Normal file
53
flake.nix
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
inputs = {
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
devenv.url = "github:cachix/devenv";
|
||||
devenv.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
esp-dev.url = "github:mirrexagon/nixpkgs-esp-dev";
|
||||
esp-dev.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
rootdir = {
|
||||
url = "file+file:///dev/null";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = inputs@{ nixpkgs, flake-parts, devenv, esp-dev, rootdir, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
imports = [
|
||||
devenv.flakeModule
|
||||
|
||||
./firmware
|
||||
];
|
||||
systems = [ "x86_64-linux" ];
|
||||
|
||||
perSystem = { inputs', system, lib, pkgs, config, ... }:
|
||||
let
|
||||
inherit (lib) mkMerge;
|
||||
|
||||
rootdirOpt =
|
||||
let
|
||||
rootFileContent = builtins.readFile rootdir.outPath;
|
||||
in
|
||||
pkgs.lib.mkIf (rootFileContent != "") rootFileContent;
|
||||
in
|
||||
{
|
||||
_module.args = {
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
esp-dev.overlays.default
|
||||
];
|
||||
};
|
||||
|
||||
libMy = {
|
||||
withRootdir = c: mkMerge [
|
||||
c
|
||||
{ devenv.root = rootdirOpt; }
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user