feat: create firmware skeleton and reproducible build

This commit is contained in:
2026-09-03 01:02:40 +03:00
parent dd16bc7ade
commit 9c274800b5
24 changed files with 827 additions and 31 deletions
+4 -6
View File
@@ -1,6 +1,4 @@
# This file was automatically generated for projects
# without default 'CMakeLists.txt' file.
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)
idf_component_register(SRCS ${app_sources})
idf_component_register(
SRCS "main.c"
REQUIRES esp_event esp_netif maze32_platform maze32_web
)
+83 -1
View File
@@ -1 +1,83 @@
void app_main() {}
#include "esp_app_desc.h"
#include "esp_err.h"
#include "esp_event.h"
#include "esp_littlefs.h"
#include "esp_log.h"
#include "esp_netif.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "maze32_health.h"
#include "maze32_web.h"
static const char *TAG = "maze32";
static maze32_health_t health;
static httpd_handle_t web_server;
static esp_err_t mount_littlefs(void)
{
const esp_vfs_littlefs_conf_t configuration = {
.base_path = "/littlefs",
.partition_label = "littlefs",
.format_if_mount_failed = false,
.dont_mount = false,
};
esp_err_t result = esp_vfs_littlefs_register(&configuration);
if (result != ESP_OK) {
return result;
}
size_t total_bytes = 0;
size_t used_bytes = 0;
result = esp_littlefs_info(configuration.partition_label, &total_bytes, &used_bytes);
if (result != ESP_OK) {
esp_vfs_littlefs_unregister(configuration.partition_label);
return result;
}
ESP_LOGI(TAG, "LittleFS mounted: total=%u bytes, used=%u bytes",
(unsigned int)total_bytes, (unsigned int)used_bytes);
return ESP_OK;
}
void app_main(void)
{
const esp_app_desc_t *application = esp_app_get_description();
maze32_health_init(&health, application->version);
vTaskDelay(pdMS_TO_TICKS(1500));
ESP_LOGI(TAG, "maze32 firmware version %s starting", application->version);
esp_err_t result = mount_littlefs();
if (result != ESP_OK) {
maze32_health_set(&health, MAZE32_HEALTH_ERROR, (int)result);
ESP_LOGE(TAG, "LittleFS mount failed: %s", esp_err_to_name(result));
return;
}
maze32_health_set(&health, MAZE32_HEALTH_FILESYSTEM_READY, 0);
result = esp_netif_init();
if (result != ESP_OK) {
maze32_health_set(&health, MAZE32_HEALTH_ERROR, (int)result);
ESP_LOGE(TAG, "TCP/IP stack initialization failed: %s", esp_err_to_name(result));
return;
}
result = esp_event_loop_create_default();
if (result != ESP_OK) {
maze32_health_set(&health, MAZE32_HEALTH_ERROR, (int)result);
ESP_LOGE(TAG, "Default event loop initialization failed: %s", esp_err_to_name(result));
return;
}
maze32_health_set(&health, MAZE32_HEALTH_SERVING, 0);
result = maze32_web_start(&web_server, &health);
if (result != ESP_OK) {
maze32_health_set(&health, MAZE32_HEALTH_ERROR, (int)result);
ESP_LOGE(TAG, "HTTP server startup failed: %s", esp_err_to_name(result));
return;
}
ESP_LOGI(TAG, "Health state: %s", maze32_health_state_name(health.state));
}