Fix ESP-IDF 5.x firmware compilation for ESP32-S3 build
Port firmware/main to ESP-IDF 5.2 API: - Add idf_component.yml with mdns and esp_websocket_client managed deps - Rename esp_ota → app_update, esp_wifi_csi_info_t → wifi_csi_info_t - Fix freertos/semphr.h include path rename - Add missing headers: esp_mac.h, esp_netif.h, driver/temperature_sensor.h, string.h, math.h - Add led.c to SRCS, fix xTaskCreate arg count (7→6) - Use IDF 5.x temperature_sensor API in place of stub - Fix mdns_query_ptr signature (add max_results arg) - Fix url_decode isxdigit unsigned char cast - Add flash size config (16MB) to sdkconfig.defaults - Pin managed component versions in dependencies.lock - Add sdkconfig (generated) to .gitignore Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
12b8f39d02
commit
d7c1adc260
12 changed files with 61 additions and 15 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -16,6 +16,8 @@ Thumbs.db
|
|||
firmware/build/
|
||||
firmware/managed_components/
|
||||
firmware/.cache/
|
||||
firmware/sdkconfig
|
||||
firmware/sdkconfig.old
|
||||
|
||||
# Test and coverage
|
||||
*.test
|
||||
|
|
|
|||
15
firmware/dependencies.lock
Normal file
15
firmware/dependencies.lock
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
dependencies:
|
||||
espressif/mdns:
|
||||
component_hash: 1ebe3bd675bb9d1c58f52bc0b609b32f74e572b01c328f9e61282040c775495c
|
||||
source:
|
||||
service_url: https://api.components.espressif.com/
|
||||
type: service
|
||||
version: 1.11.0
|
||||
idf:
|
||||
component_hash: null
|
||||
source:
|
||||
type: idf
|
||||
version: 5.2.0
|
||||
manifest_hash: a992e70b09ad37a4feedff824c5e65dd614da5cb2c82b738b9b86cdfd9e94072
|
||||
target: esp32s3
|
||||
version: 1.0.0
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# Ensure the generated headers directory exists before ESP-IDF validates include paths
|
||||
set(GENERATED_HEADERS_DIR "${CMAKE_BINARY_DIR}/spaxel-firmware/main")
|
||||
file(MAKE_DIRECTORY "${GENERATED_HEADERS_DIR}")
|
||||
|
||||
idf_component_register(
|
||||
SRCS "main.c"
|
||||
"wifi.c"
|
||||
|
|
@ -8,6 +12,6 @@ idf_component_register(
|
|||
"nvs_migration.c"
|
||||
"ntp.c"
|
||||
"led.c"
|
||||
INCLUDE_DIRS "." "${CMAKE_BINARY_DIR}/spaxel-firmware/main"
|
||||
REQUIRES esp_wifi esp_netif nvs_flash mdns esp_http_client esp_timer bt driver log esp_http_server mbedtls esp_ota
|
||||
INCLUDE_DIRS "." "${GENERATED_HEADERS_DIR}"
|
||||
REQUIRES esp_wifi esp_netif nvs_flash esp_http_client esp_timer bt driver log esp_http_server mbedtls app_update json freertos
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "esp_gap_ble_api.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semaphore.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "cJSON.h"
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
static const char *TAG = "csi";
|
||||
|
||||
|
|
@ -38,11 +39,11 @@ static bool s_passive_filter_enabled = false;
|
|||
static void csi_rx_task(void *arg);
|
||||
static void csi_tx_task(void *arg);
|
||||
static float compute_amplitude_variance(float new_amp);
|
||||
static void wifi_csi_cb(void *ctx, esp_wifi_csi_info_t *info);
|
||||
static void wifi_csi_cb(void *ctx, wifi_csi_info_t *info);
|
||||
|
||||
esp_err_t csi_init(void) {
|
||||
// Create CSI queue
|
||||
s_csi_queue = xQueueCreate(SPAXEL_CSI_QUEUE_SIZE, sizeof(esp_wifi_csi_info_t *));
|
||||
s_csi_queue = xQueueCreate(SPAXEL_CSI_QUEUE_SIZE, sizeof(wifi_csi_info_t *));
|
||||
if (!s_csi_queue) {
|
||||
ESP_LOGE(TAG, "Failed to create CSI queue");
|
||||
return ESP_ERR_NO_MEM;
|
||||
|
|
@ -86,7 +87,7 @@ esp_err_t csi_init(void) {
|
|||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void wifi_csi_cb(void *ctx, esp_wifi_csi_info_t *info) {
|
||||
static void wifi_csi_cb(void *ctx, wifi_csi_info_t *info) {
|
||||
s_stats.frames_received++;
|
||||
|
||||
// Apply passive BSSID filter if enabled
|
||||
|
|
@ -99,9 +100,9 @@ static void wifi_csi_cb(void *ctx, esp_wifi_csi_info_t *info) {
|
|||
}
|
||||
|
||||
// Copy CSI info to queue (pointer to heap-allocated copy)
|
||||
esp_wifi_csi_info_t *copy = malloc(sizeof(esp_wifi_csi_info_t));
|
||||
wifi_csi_info_t *copy = malloc(sizeof(wifi_csi_info_t));
|
||||
if (copy) {
|
||||
memcpy(copy, info, sizeof(esp_wifi_csi_info_t));
|
||||
memcpy(copy, info, sizeof(wifi_csi_info_t));
|
||||
if (xQueueSend(s_csi_queue, ©, 0) != pdPASS) {
|
||||
free(copy);
|
||||
s_stats.frames_dropped++;
|
||||
|
|
@ -112,7 +113,7 @@ static void wifi_csi_cb(void *ctx, esp_wifi_csi_info_t *info) {
|
|||
}
|
||||
|
||||
static void csi_rx_task(void *arg) {
|
||||
esp_wifi_csi_info_t *info;
|
||||
wifi_csi_info_t *info;
|
||||
|
||||
while (1) {
|
||||
if (xQueueReceive(s_csi_queue, &info, portMAX_DELAY) == pdPASS) {
|
||||
|
|
|
|||
|
|
@ -4,3 +4,4 @@
|
|||
dependencies:
|
||||
idf: ">=5.0"
|
||||
espressif/mdns: ">=1.3.0"
|
||||
espressif/esp_websocket_client: ">=1.0.0"
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@ esp_err_t led_blink_identify(uint32_t duration_ms) {
|
|||
2048,
|
||||
(void *)(uintptr_t)duration_ms,
|
||||
5, // Priority
|
||||
NULL,
|
||||
&s_led_state.task_handle
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include "nvs.h"
|
||||
#include "esp_mac.h"
|
||||
#include "freertos/task.h"
|
||||
#include <string.h>
|
||||
|
||||
static const char *TAG = "spaxel";
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@
|
|||
#include "esp_log.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_netif.h"
|
||||
#include "driver/temperature_sensor.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_http_client.h"
|
||||
#include "mbedtls/sha256.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semaphore.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "cJSON.h"
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
|
@ -336,8 +338,18 @@ esp_err_t websocket_send_health(void) {
|
|||
esp_timer_get_time() / 1000);
|
||||
|
||||
// Temperature (if available)
|
||||
extern float esp_temp_get_celsius(void);
|
||||
cJSON_AddNumberToObject(root, "temperature_c", esp_temp_get_celsius());
|
||||
{
|
||||
float tsens_value = 0.0f;
|
||||
temperature_sensor_handle_t tsens = NULL;
|
||||
temperature_sensor_config_t tsens_cfg = TEMPERATURE_SENSOR_CONFIG_DEFAULT(10, 50);
|
||||
if (temperature_sensor_install(&tsens_cfg, &tsens) == ESP_OK) {
|
||||
temperature_sensor_enable(tsens);
|
||||
temperature_sensor_get_celsius(tsens, &tsens_value);
|
||||
temperature_sensor_disable(tsens);
|
||||
temperature_sensor_uninstall(tsens);
|
||||
}
|
||||
cJSON_AddNumberToObject(root, "temperature_c", tsens_value);
|
||||
}
|
||||
|
||||
cJSON_AddNumberToObject(root, "csi_rate_hz", g_state.packet_rate);
|
||||
cJSON_AddNumberToObject(root, "wifi_channel", wifi_get_channel());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "wifi.h"
|
||||
#include "spaxel.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_mac.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_netif.h"
|
||||
|
|
@ -13,6 +14,10 @@
|
|||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
static const char *TAG = "wifi";
|
||||
|
||||
static bool s_connected = false;
|
||||
|
|
@ -181,7 +186,7 @@ bool wifi_discover_mothership(char *ip_buf, size_t buf_len, uint16_t *port) {
|
|||
// Query mDNS for the mothership service
|
||||
mdns_result_t *results = NULL;
|
||||
esp_err_t err = mdns_query_ptr(SPAXEL_MDNS_SERVICE, SPAXEL_MDNS_PROTO,
|
||||
5000, &results);
|
||||
5000, 10, &results);
|
||||
|
||||
if (err != ESP_OK || results == NULL) {
|
||||
ESP_LOGW(TAG, "mDNS query failed or no results");
|
||||
|
|
@ -308,7 +313,7 @@ static void url_decode(char *dst, const char *src, size_t dst_size) {
|
|||
if (src[i] == '+') {
|
||||
dst[j++] = ' ';
|
||||
i++;
|
||||
} else if (src[i] == '%' && isxdigit(src[i+1]) && isxdigit(src[i+2])) {
|
||||
} else if (src[i] == '%' && isxdigit((unsigned char)src[i+1]) && isxdigit((unsigned char)src[i+2])) {
|
||||
char hex[3] = {src[i+1], src[i+2], 0};
|
||||
dst[j++] = (char)strtol(hex, NULL, 16);
|
||||
i += 3;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@
|
|||
# Chip target
|
||||
CONFIG_IDF_TARGET="esp32s3"
|
||||
|
||||
# Flash size — partitions.csv requires 12.1MB (factory 4MB + ota_0 4MB + ota_1 4MB)
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE="16MB"
|
||||
|
||||
# WiFi CSI Configuration
|
||||
CONFIG_ESP_WIFI_RX_BCN_ADAPT=y
|
||||
CONFIG_ESP_WIFI_RX_BCN_ADAPT_THRESHOLD=10
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue