From 6ef3374b7851df51dfe6bd91d54ead008863a6b0 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Mon, 24 Nov 2025 18:20:36 +0100 Subject: [PATCH 1/4] Implement support for C6 and P4 SOCs Based on https://github.com/ByteWelder/Tactility/pull/394 --- .github/workflows/build-sdk.yml | 26 ------------ .../{build-firmware.yml => build.yml} | 40 ++++++++++++++----- CMakeLists.txt | 6 ++- Devices/generic-esp32/CMakeLists.txt | 7 ++++ .../generic-esp32/Source/Configuration.cpp | 3 ++ Devices/generic-esp32/device.properties | 9 +++++ Devices/generic-esp32c6/CMakeLists.txt | 7 ++++ .../generic-esp32c6/Source/Configuration.cpp | 3 ++ Devices/generic-esp32c6/device.properties | 9 +++++ Devices/generic-esp32p4/CMakeLists.txt | 7 ++++ .../generic-esp32p4/Source/Configuration.cpp | 3 ++ Devices/generic-esp32p4/device.properties | 9 +++++ Devices/generic-esp32s3/CMakeLists.txt | 7 ++++ .../generic-esp32s3/Source/Configuration.cpp | 3 ++ Devices/generic-esp32s3/device.properties | 9 +++++ Firmware/idf_component.yml | 22 ++++++++-- .../Include/Tactility/service/espnow/EspNow.h | 5 +++ .../Tactility/service/espnow/EspNowService.h | 12 +++--- .../Tactility/service/espnow/EspNowWifi.h | 8 ++++ Tactility/Source/Tactility.cpp | 16 +++++++- Tactility/Source/app/chat/ChatApp.cpp | 4 ++ .../Source/app/crashdiagnostics/QrUrl.cpp | 17 +++++--- Tactility/Source/hal/sdcard/SdmmcDevice.cpp | 2 +- Tactility/Source/service/espnow/EspNow.cpp | 4 ++ .../Source/service/espnow/EspNowService.cpp | 4 ++ .../Source/service/espnow/EspNowWifi.cpp | 4 ++ Tactility/Source/service/wifi/WifiEsp.cpp | 4 ++ Tactility/Source/service/wifi/WifiMock.cpp | 2 +- TactilityC/Source/symbols/gcc_soft_float.cpp | 4 ++ TactilityC/Source/tt_init.cpp | 6 ++- TactilityCore/Source/CpuAffinity.cpp | 28 +++++++++++-- TactilityCore/Source/kernel/PanicHandler.cpp | 36 ++++++++++++++--- device.py | 6 ++- 33 files changed, 267 insertions(+), 65 deletions(-) delete mode 100644 .github/workflows/build-sdk.yml rename .github/workflows/{build-firmware.yml => build.yml} (79%) create mode 100644 Devices/generic-esp32/CMakeLists.txt create mode 100644 Devices/generic-esp32/Source/Configuration.cpp create mode 100644 Devices/generic-esp32/device.properties create mode 100644 Devices/generic-esp32c6/CMakeLists.txt create mode 100644 Devices/generic-esp32c6/Source/Configuration.cpp create mode 100644 Devices/generic-esp32c6/device.properties create mode 100644 Devices/generic-esp32p4/CMakeLists.txt create mode 100644 Devices/generic-esp32p4/Source/Configuration.cpp create mode 100644 Devices/generic-esp32p4/device.properties create mode 100644 Devices/generic-esp32s3/CMakeLists.txt create mode 100644 Devices/generic-esp32s3/Source/Configuration.cpp create mode 100644 Devices/generic-esp32s3/device.properties diff --git a/.github/workflows/build-sdk.yml b/.github/workflows/build-sdk.yml deleted file mode 100644 index 9e8a4ba2a..000000000 --- a/.github/workflows/build-sdk.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Build SDK -on: - push: - branches: - - main - pull_request: - types: [ opened, synchronize, reopened ] - -permissions: read-all - -jobs: - Build: - strategy: - matrix: - board: [ - { id: cyd-2432s028r, arch: esp32 }, - { id: lilygo-tdeck, arch: esp32s3 }, - ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: "Build" - uses: ./.github/actions/build-sdk - with: - board_id: ${{ matrix.board.id }} - arch: ${{ matrix.board.arch }} \ No newline at end of file diff --git a/.github/workflows/build-firmware.yml b/.github/workflows/build.yml similarity index 79% rename from .github/workflows/build-firmware.yml rename to .github/workflows/build.yml index ab1b6484e..650584b1d 100644 --- a/.github/workflows/build-firmware.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,24 @@ on: permissions: read-all jobs: - Build: + BuildSdk: + strategy: + matrix: + board: [ + { id: generic-esp32, arch: esp32 }, + { id: generic-esp32c6, arch: esp32c6 }, + { id: generic-esp32p4, arch: esp32p4 }, + { id: generic-esp32s3, arch: esp32s3 }, + ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: "Build SDK" + uses: ./.github/actions/build-sdk + with: + board_id: ${{ matrix.board.id }} + arch: ${{ matrix.board.arch }} + BuildFirmware: strategy: matrix: board: [ @@ -52,30 +69,31 @@ jobs: { id: waveshare-s3-touch-lcd-43, arch: esp32s3 } ] runs-on: ubuntu-latest + needs: [ BuildSdk ] steps: - uses: actions/checkout@v4 - - name: "Build" + - name: "Build Firmware" uses: ./.github/actions/build-firmware with: board_id: ${{ matrix.board.id }} arch: ${{ matrix.board.arch }} - Bundle: + BundleFirmware: runs-on: ubuntu-latest - needs: [ Build ] + needs: [ BuildFirmware ] if: | (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) steps: - uses: actions/checkout@v4 - - name: "Bundle" + - name: "Bundle Firmware" uses: ./.github/actions/bundle-firmware - PublishSnapshot: + PublishFirmwareSnapshot: runs-on: ubuntu-latest - needs: [ Bundle ] + needs: [ BundleFirmware ] if: (github.event_name == 'push' && github.ref == 'refs/heads/main') steps: - uses: actions/checkout@v4 - - name: "Publish Snapshot" + - name: "Publish Firmware Snapshot" env: CDN_ID: ${{ secrets.CDN_ID }} CDN_TOKEN_NAME: ${{ secrets.CDN_TOKEN_NAME }} @@ -83,13 +101,13 @@ jobs: uses: ./.github/actions/publish-firmware with: cdn_version: snapshot - PublishRelease: + PublishFirmwareStable: runs-on: ubuntu-latest - needs: [ Bundle ] + needs: [ BundleFirmware ] if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) steps: - uses: actions/checkout@v4 - - name: "Publish Stable" + - name: "Publish Firmware Stable" env: CDN_ID: ${{ secrets.CDN_ID }} CDN_TOKEN_NAME: ${{ secrets.CDN_TOKEN_NAME }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 7355c21af..b71b15b2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,11 @@ if (DEFINED ENV{ESP_IDF_VERSION}) set(EXCLUDE_COMPONENTS "Simulator") - idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND) + # Panic handler wrapping is only available on Xtensa architecture + if (CONFIG_IDF_TARGET_ARCH_XTENSA) + idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND) + endif () + idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=lv_button_create" APPEND) idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=lv_dropdown_create" APPEND) idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=lv_list_create" APPEND) diff --git a/Devices/generic-esp32/CMakeLists.txt b/Devices/generic-esp32/CMakeLists.txt new file mode 100644 index 000000000..b2352d223 --- /dev/null +++ b/Devices/generic-esp32/CMakeLists.txt @@ -0,0 +1,7 @@ +file(GLOB_RECURSE SOURCE_FILES Source/*.c*) + +idf_component_register( + SRCS ${SOURCE_FILES} + INCLUDE_DIRS "Source" + REQUIRES Tactility +) diff --git a/Devices/generic-esp32/Source/Configuration.cpp b/Devices/generic-esp32/Source/Configuration.cpp new file mode 100644 index 000000000..180cffb23 --- /dev/null +++ b/Devices/generic-esp32/Source/Configuration.cpp @@ -0,0 +1,3 @@ +#include + +extern const tt::hal::Configuration hardwareConfiguration = {}; diff --git a/Devices/generic-esp32/device.properties b/Devices/generic-esp32/device.properties new file mode 100644 index 000000000..188322fd2 --- /dev/null +++ b/Devices/generic-esp32/device.properties @@ -0,0 +1,9 @@ +[general] +vendor=Generic +name=ESP32 + +[hardware] +target=ESP32 +flashSize=4MB +spiRam=false + diff --git a/Devices/generic-esp32c6/CMakeLists.txt b/Devices/generic-esp32c6/CMakeLists.txt new file mode 100644 index 000000000..b2352d223 --- /dev/null +++ b/Devices/generic-esp32c6/CMakeLists.txt @@ -0,0 +1,7 @@ +file(GLOB_RECURSE SOURCE_FILES Source/*.c*) + +idf_component_register( + SRCS ${SOURCE_FILES} + INCLUDE_DIRS "Source" + REQUIRES Tactility +) diff --git a/Devices/generic-esp32c6/Source/Configuration.cpp b/Devices/generic-esp32c6/Source/Configuration.cpp new file mode 100644 index 000000000..180cffb23 --- /dev/null +++ b/Devices/generic-esp32c6/Source/Configuration.cpp @@ -0,0 +1,3 @@ +#include + +extern const tt::hal::Configuration hardwareConfiguration = {}; diff --git a/Devices/generic-esp32c6/device.properties b/Devices/generic-esp32c6/device.properties new file mode 100644 index 000000000..3ba13f1a8 --- /dev/null +++ b/Devices/generic-esp32c6/device.properties @@ -0,0 +1,9 @@ +[general] +vendor=Generic +name=ESP32-C6 + +[hardware] +target=ESP32C6 +flashSize=4MB +spiRam=false + diff --git a/Devices/generic-esp32p4/CMakeLists.txt b/Devices/generic-esp32p4/CMakeLists.txt new file mode 100644 index 000000000..b2352d223 --- /dev/null +++ b/Devices/generic-esp32p4/CMakeLists.txt @@ -0,0 +1,7 @@ +file(GLOB_RECURSE SOURCE_FILES Source/*.c*) + +idf_component_register( + SRCS ${SOURCE_FILES} + INCLUDE_DIRS "Source" + REQUIRES Tactility +) diff --git a/Devices/generic-esp32p4/Source/Configuration.cpp b/Devices/generic-esp32p4/Source/Configuration.cpp new file mode 100644 index 000000000..180cffb23 --- /dev/null +++ b/Devices/generic-esp32p4/Source/Configuration.cpp @@ -0,0 +1,3 @@ +#include + +extern const tt::hal::Configuration hardwareConfiguration = {}; diff --git a/Devices/generic-esp32p4/device.properties b/Devices/generic-esp32p4/device.properties new file mode 100644 index 000000000..a708ad619 --- /dev/null +++ b/Devices/generic-esp32p4/device.properties @@ -0,0 +1,9 @@ +[general] +vendor=Generic +name=ESP32-P4 + +[hardware] +target=ESP32P4 +flashSize=4MB +spiRam=false + diff --git a/Devices/generic-esp32s3/CMakeLists.txt b/Devices/generic-esp32s3/CMakeLists.txt new file mode 100644 index 000000000..b2352d223 --- /dev/null +++ b/Devices/generic-esp32s3/CMakeLists.txt @@ -0,0 +1,7 @@ +file(GLOB_RECURSE SOURCE_FILES Source/*.c*) + +idf_component_register( + SRCS ${SOURCE_FILES} + INCLUDE_DIRS "Source" + REQUIRES Tactility +) diff --git a/Devices/generic-esp32s3/Source/Configuration.cpp b/Devices/generic-esp32s3/Source/Configuration.cpp new file mode 100644 index 000000000..180cffb23 --- /dev/null +++ b/Devices/generic-esp32s3/Source/Configuration.cpp @@ -0,0 +1,3 @@ +#include + +extern const tt::hal::Configuration hardwareConfiguration = {}; diff --git a/Devices/generic-esp32s3/device.properties b/Devices/generic-esp32s3/device.properties new file mode 100644 index 000000000..b46a520fd --- /dev/null +++ b/Devices/generic-esp32s3/device.properties @@ -0,0 +1,9 @@ +[general] +vendor=Generic +name=ESP32-S3 + +[hardware] +target=ESP32S3 +flashSize=4MB +spiRam=false + diff --git a/Firmware/idf_component.yml b/Firmware/idf_component.yml index 98c1b02e0..cb204ce0d 100644 --- a/Firmware/idf_component.yml +++ b/Firmware/idf_component.yml @@ -1,9 +1,21 @@ dependencies: - espressif/esp_lcd_ili9341: "2.0.1" - atanisoft/esp_lcd_ili9488: "1.0.10" - teriyakigod/esp_lcd_st7735: "0.0.1" + espressif/esp_lcd_ili9341: + version: "2.0.1" + rules: + - if: "target in [esp32, esp32s3]" + atanisoft/esp_lcd_ili9488: + version: "1.0.10" + rules: + - if: "target in [esp32, esp32s3]" + teriyakigod/esp_lcd_st7735: + version: "0.0.1" + rules: + - if: "target in [esp32, esp32s3]" espressif/esp_lcd_touch: "1.1.2" - atanisoft/esp_lcd_touch_xpt2046: "1.0.5" + atanisoft/esp_lcd_touch_xpt2046: + version: "1.0.5" + rules: + - if: "target in [esp32, esp32s3]" espressif/esp_lcd_touch_cst816s: "1.0.3" espressif/esp_lcd_touch_gt911: "1.1.3" espressif/esp_lcd_touch_ft5x06: "1.0.6~1" @@ -15,6 +27,8 @@ dependencies: - if: "target in [esp32s3, esp32p4]" espressif/esp_lcd_st7796: version: "1.3.4" + rules: + - if: "target in [esp32, esp32s3]" espressif/esp_lcd_gc9a01: "2.0.3" espressif/esp_lcd_panel_io_additions: "1.0.1" espressif/esp_tinyusb: diff --git a/Tactility/Include/Tactility/service/espnow/EspNow.h b/Tactility/Include/Tactility/service/espnow/EspNow.h index 044ba9daa..80cbd76db 100644 --- a/Tactility/Include/Tactility/service/espnow/EspNow.h +++ b/Tactility/Include/Tactility/service/espnow/EspNow.h @@ -1,5 +1,10 @@ #pragma once + #ifdef ESP_PLATFORM +#include +#endif + +#ifdef CONFIG_ESP_WIFI_ENABLED #include #include diff --git a/Tactility/Private/Tactility/service/espnow/EspNowService.h b/Tactility/Private/Tactility/service/espnow/EspNowService.h index 277a1580c..ef2d1ce9a 100644 --- a/Tactility/Private/Tactility/service/espnow/EspNowService.h +++ b/Tactility/Private/Tactility/service/espnow/EspNowService.h @@ -1,9 +1,13 @@ #pragma once + #ifdef ESP_PLATFORM +#include +#endif + +#ifdef CONFIG_ESP_WIFI_ENABLED -#include "Tactility/MessageQueue.h" -#include "Tactility/service/Service.h" -#include "Tactility/service/espnow/EspNow.h" +#include +#include #include @@ -13,8 +17,6 @@ namespace tt::service::espnow { class EspNowService final : public Service { -private: - struct ReceiverSubscriptionData { ReceiverSubscription id; std::function onReceive; diff --git a/Tactility/Private/Tactility/service/espnow/EspNowWifi.h b/Tactility/Private/Tactility/service/espnow/EspNowWifi.h index 2b031f829..1e3d4ff22 100644 --- a/Tactility/Private/Tactility/service/espnow/EspNowWifi.h +++ b/Tactility/Private/Tactility/service/espnow/EspNowWifi.h @@ -1,5 +1,11 @@ #pragma once +#ifdef ESP_PLATFORM +#include +#endif + +#ifdef CONFIG_ESP_WIFI_ENABLED + #include "Tactility/service/espnow/EspNow.h" namespace tt::service::espnow { @@ -9,3 +15,5 @@ bool initWifi(const EspNowConfig& config); bool deinitWifi(); } + +#endif \ No newline at end of file diff --git a/Tactility/Source/Tactility.cpp b/Tactility/Source/Tactility.cpp index 6c2016359..c53c25302 100644 --- a/Tactility/Source/Tactility.cpp +++ b/Tactility/Source/Tactility.cpp @@ -1,3 +1,7 @@ +#ifdef ESP_PLATFORM +#include +#endif + #include #include @@ -38,6 +42,8 @@ namespace service { namespace sdcard { extern const ServiceManifest manifest; } #ifdef ESP_PLATFORM namespace development { extern const ServiceManifest manifest; } +#endif +#ifdef CONFIG_ESP_WIFI_ENABLED namespace espnow { extern const ServiceManifest manifest; } #endif // Secondary (UI) @@ -64,7 +70,9 @@ namespace app { namespace applist { extern const AppManifest manifest; } namespace appsettings { extern const AppManifest manifest; } namespace boot { extern const AppManifest manifest; } +#ifdef CONFIG_ESP_WIFI_ENABLED namespace chat { extern const AppManifest manifest; } +#endif namespace development { extern const AppManifest manifest; } namespace display { extern const AppManifest manifest; } namespace files { extern const AppManifest manifest; } @@ -135,8 +143,11 @@ static void registerInternalApps() { addAppManifest(app::screenshot::manifest); #endif -#ifdef ESP_PLATFORM +#ifdef CONFIG_ESP_WIFI_ENABLED addAppManifest(app::chat::manifest); +#endif + +#ifdef ESP_PLATFORM addAppManifest(app::crashdiagnostics::manifest); addAppManifest(app::development::manifest); #endif @@ -231,6 +242,9 @@ static void registerAndStartPrimaryServices() { addService(service::wifi::manifest); #ifdef ESP_PLATFORM addService(service::development::manifest); +#endif + +#ifdef CONFIG_ESP_WIFI_ENABLED addService(service::espnow::manifest); #endif } diff --git a/Tactility/Source/app/chat/ChatApp.cpp b/Tactility/Source/app/chat/ChatApp.cpp index 7a5ca044a..885db4bf7 100644 --- a/Tactility/Source/app/chat/ChatApp.cpp +++ b/Tactility/Source/app/chat/ChatApp.cpp @@ -1,4 +1,8 @@ #ifdef ESP_PLATFORM +#include +#endif + +#ifdef CONFIG_ESP_WIFI_ENABLED #include #include diff --git a/Tactility/Source/app/crashdiagnostics/QrUrl.cpp b/Tactility/Source/app/crashdiagnostics/QrUrl.cpp index 8daefd474..d2b65eb2d 100644 --- a/Tactility/Source/app/crashdiagnostics/QrUrl.cpp +++ b/Tactility/Source/app/crashdiagnostics/QrUrl.cpp @@ -1,20 +1,29 @@ #ifdef ESP_PLATFORM -#include "Tactility/app/crashdiagnostics/QrUrl.h" - +#include #include #include +#include + +#if CONFIG_IDF_TARGET_ARCH_XTENSA #include +#else +#include +#endif #include std::string getUrlFromCrashData() { auto crash_data = getRtcCrashData(); - auto* stack_buffer = (uint32_t*) malloc(crash_data.callstackLength * 2 * sizeof(uint32_t)); + std::vector stack_buffer(crash_data.callstackLength * 2); for (int i = 0; i < crash_data.callstackLength; ++i) { const CallstackFrame&frame = crash_data.callstack[i]; +#if CONFIG_IDF_TARGET_ARCH_XTENSA uint32_t pc = esp_cpu_process_stack_pc(frame.pc); +#else + uint32_t pc = frame.pc; // No processing needed on RISC-V +#endif #if CRASH_DATA_INCLUDES_SP uint32_t sp = frame.sp; #endif @@ -41,8 +50,6 @@ std::string getUrlFromCrashData() { #endif } - free(stack_buffer); - return stream.str(); } diff --git a/Tactility/Source/hal/sdcard/SdmmcDevice.cpp b/Tactility/Source/hal/sdcard/SdmmcDevice.cpp index 8bbb198ae..37bf97af0 100644 --- a/Tactility/Source/hal/sdcard/SdmmcDevice.cpp +++ b/Tactility/Source/hal/sdcard/SdmmcDevice.cpp @@ -1,4 +1,4 @@ -#ifdef ESP_PLATFORM +#if defined(ESP_PLATFORM) && defined(SOC_SDMMC_HOST_SUPPORTED) #include #include diff --git a/Tactility/Source/service/espnow/EspNow.cpp b/Tactility/Source/service/espnow/EspNow.cpp index 7d09f7ddf..ca1aec118 100644 --- a/Tactility/Source/service/espnow/EspNow.cpp +++ b/Tactility/Source/service/espnow/EspNow.cpp @@ -1,4 +1,8 @@ #ifdef ESP_PLATFORM +#include +#endif + +#ifdef CONFIG_ESP_WIFI_ENABLED #include "Tactility/service/espnow/EspNow.h" #include "Tactility/service/espnow/EspNowService.h" diff --git a/Tactility/Source/service/espnow/EspNowService.cpp b/Tactility/Source/service/espnow/EspNowService.cpp index 81ab0da8b..393491d13 100644 --- a/Tactility/Source/service/espnow/EspNowService.cpp +++ b/Tactility/Source/service/espnow/EspNowService.cpp @@ -1,4 +1,8 @@ #ifdef ESP_PLATFORM +#include +#endif + +#ifdef CONFIG_ESP_WIFI_ENABLED #include #include diff --git a/Tactility/Source/service/espnow/EspNowWifi.cpp b/Tactility/Source/service/espnow/EspNowWifi.cpp index 30e4c423b..46f6ba128 100644 --- a/Tactility/Source/service/espnow/EspNowWifi.cpp +++ b/Tactility/Source/service/espnow/EspNowWifi.cpp @@ -1,4 +1,8 @@ #ifdef ESP_PLATFORM +#include +#endif + +#ifdef CONFIG_ESP_WIFI_ENABLED #include "Tactility/service/espnow/EspNow.h" #include "Tactility/service/wifi/Wifi.h" diff --git a/Tactility/Source/service/wifi/WifiEsp.cpp b/Tactility/Source/service/wifi/WifiEsp.cpp index 9194e92a2..636d007fe 100644 --- a/Tactility/Source/service/wifi/WifiEsp.cpp +++ b/Tactility/Source/service/wifi/WifiEsp.cpp @@ -1,4 +1,8 @@ #ifdef ESP_PLATFORM +#include +#endif + +#ifdef CONFIG_ESP_WIFI_ENABLED #include diff --git a/Tactility/Source/service/wifi/WifiMock.cpp b/Tactility/Source/service/wifi/WifiMock.cpp index 1e45277cb..2969b9bea 100644 --- a/Tactility/Source/service/wifi/WifiMock.cpp +++ b/Tactility/Source/service/wifi/WifiMock.cpp @@ -1,4 +1,4 @@ -#ifndef ESP_PLATFORM +#ifndef CONFIG_ESP_WIFI_ENABLED #include diff --git a/TactilityC/Source/symbols/gcc_soft_float.cpp b/TactilityC/Source/symbols/gcc_soft_float.cpp index b6b2921e3..891ba3f82 100644 --- a/TactilityC/Source/symbols/gcc_soft_float.cpp +++ b/TactilityC/Source/symbols/gcc_soft_float.cpp @@ -1,3 +1,5 @@ +#ifndef CONFIG_IDF_TARGET_ESP32P4 + #include #include @@ -282,3 +284,5 @@ const esp_elfsym gcc_soft_float_symbols[] = { ESP_ELFSYM_END }; + +#endif \ No newline at end of file diff --git a/TactilityC/Source/tt_init.cpp b/TactilityC/Source/tt_init.cpp index 37ba4a810..9a4f0a574 100644 --- a/TactilityC/Source/tt_init.cpp +++ b/TactilityC/Source/tt_init.cpp @@ -28,10 +28,12 @@ #include "symbols/esp_event.h" #include "symbols/esp_http_client.h" -#include "symbols/gcc_soft_float.h" #include "symbols/pthread.h" #include "symbols/stl.h" #include "symbols/cplusplus.h" +#ifndef CONFIG_IDF_TARGET_ESP32P4 +#include "symbols/gcc_soft_float.h" +#endif #include #include @@ -591,7 +593,9 @@ uintptr_t resolve_symbol(const esp_elfsym* source, const char* symbolName) { uintptr_t tt_symbol_resolver(const char* symbolName) { static const std::vector all_symbols = { main_symbols, +#ifndef CONFIG_IDF_TARGET_ESP32P4 gcc_soft_float_symbols, +#endif stl_symbols, cplusplus_symbols, esp_event_symbols, diff --git a/TactilityCore/Source/CpuAffinity.cpp b/TactilityCore/Source/CpuAffinity.cpp index 290c1df61..229dd23fe 100644 --- a/TactilityCore/Source/CpuAffinity.cpp +++ b/TactilityCore/Source/CpuAffinity.cpp @@ -1,3 +1,7 @@ +#ifdef ESP_PLATFORM +#include +#endif + #include "Tactility/CpuAffinity.h" #include @@ -6,25 +10,39 @@ namespace tt { #ifdef ESP_PLATFORM +#ifdef CONFIG_ESP_WIFI_ENABLED + static CpuAffinity getEspWifiAffinity() { -#ifdef CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0 +#if CONFIG_FREERTOS_NUMBER_OF_CORES == 1 + return 0; +#elif defined(CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0) return 0; #elif defined(CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1) return 1; +#else // Assume core 0 (risky, but safer than "None") + return 0; #endif } +#endif + // Warning: Must watch ESP WiFi, as this task is used by WiFi static CpuAffinity getEspMainSchedulerAffinity() { -#ifdef CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0 +#if CONFIG_FREERTOS_NUMBER_OF_CORES == 1 + return 0; +#elif defined(CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0) return 0; #elif defined(CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1) return 1; +#else + return None; #endif } static CpuAffinity getFreeRtosTimerAffinity() { -#if defined(CONFIG_FREERTOS_TIMER_TASK_NO_AFFINITY) +#if CONFIG_FREERTOS_NUMBER_OF_CORES == 1 + return 0; +#elif defined(CONFIG_FREERTOS_TIMER_TASK_NO_AFFINITY) return None; #elif defined(CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU0) return 0; @@ -48,7 +66,11 @@ static const CpuAffinityConfiguration esp = { static const CpuAffinityConfiguration esp = { .system = 0, .graphics = 1, +#ifdef CONFIG_ESP_WIFI_ENABLED .wifi = getEspWifiAffinity(), +#else + .wifi = 0, +#endif .mainDispatcher = getEspMainSchedulerAffinity(), .apps = 1, .timer = getFreeRtosTimerAffinity() diff --git a/TactilityCore/Source/kernel/PanicHandler.cpp b/TactilityCore/Source/kernel/PanicHandler.cpp index 160c9598d..3fdc1c481 100644 --- a/TactilityCore/Source/kernel/PanicHandler.cpp +++ b/TactilityCore/Source/kernel/PanicHandler.cpp @@ -1,11 +1,13 @@ -#ifdef ESP_PLATFORM +#if defined(ESP_PLATFORM) && defined(CONFIG_IDF_TARGET_ARCH_XTENSA) #include "Tactility/kernel/PanicHandler.h" #include #include #include +#include #include +#include extern "C" { @@ -35,10 +37,15 @@ void __wrap_esp_panic_handler(void* info) { #endif crashData.callstackLength++; - crashData.callstackCorrupted = !(esp_stack_ptr_is_sane(frame.sp) && - (esp_ptr_executable((void *)esp_cpu_process_stack_pc(frame.pc)) || - /* Ignore the first corrupted PC in case of InstrFetchProhibited */ - (frame.exc_frame && ((XtExcFrame *)frame.exc_frame)->exccause == EXCCAUSE_INSTR_PROHIBITED))); + uint32_t processed_pc = esp_cpu_process_stack_pc(frame.pc); + bool pc_is_valid = esp_ptr_executable((void *)processed_pc); + + /* Ignore the first corrupted PC in case of InstrFetchProhibited on Xtensa */ + if (frame.exc_frame && ((XtExcFrame *)frame.exc_frame)->exccause == EXCCAUSE_INSTR_PROHIBITED) { + pc_is_valid = true; + } + + crashData.callstackCorrupted = !(esp_stack_ptr_is_sane(frame.sp) && pc_is_valid); while ( frame.next_pc != 0 && @@ -46,6 +53,14 @@ void __wrap_esp_panic_handler(void* info) { && crashData.callstackLength < CRASH_DATA_CALLSTACK_LIMIT ) { if (esp_backtrace_get_next_frame(&frame)) { + // Validate the current frame + uint32_t processed_frame_pc = esp_cpu_process_stack_pc(frame.pc); + bool frame_pc_is_valid = esp_ptr_executable((void *)processed_frame_pc); + + if (!esp_stack_ptr_is_sane(frame.sp) || !frame_pc_is_valid) { + crashData.callstackCorrupted = true; + break; + } crashData.callstack[crashData.callstackLength].pc = frame.pc; #if CRASH_DATA_INCLUDES_SP crashData.callstack[crashData.callstackLength].sp = frame.sp; @@ -66,4 +81,15 @@ void __wrap_esp_panic_handler(void* info) { const CrashData& getRtcCrashData() { return crashData; } +#elif defined(ESP_PLATFORM) + +// Stub implementation for RISC-V and other architectures +// TODO: Implement crash data collection for RISC-V using frame pointer or EH frame + +#include + +static CrashData emptyCrashData = {}; + +const CrashData& getRtcCrashData() { return emptyCrashData; } + #endif \ No newline at end of file diff --git a/device.py b/device.py index e30fa276f..307dc1cfb 100644 --- a/device.py +++ b/device.py @@ -52,6 +52,9 @@ def read_device_properties(device_id): exit_with_error(f"Device file not found: {device_file_path}") return read_properties_file(device_file_path) +def has_group(properties: ConfigParser, group: str): + return group in properties.sections() + def get_property_or_exit(properties: ConfigParser, group: str, key: str): if group not in properties.sections(): exit_with_error(f"Device properties does not contain group: {group}") @@ -212,10 +215,11 @@ def write_properties(output_file, device_properties: ConfigParser, device_id: st write_flash_variables(output_file, device_properties) write_partition_table(output_file, device_properties, is_dev) write_spiram_variables(output_file, device_properties) - write_lvgl_variables(output_file, device_properties) write_performance_improvements(output_file, device_properties) write_usb_variables(output_file, device_properties) write_custom_sdkconfig(output_file, device_properties) + if has_group(device_properties, "display"): + write_lvgl_variables(output_file, device_properties) def main(device_id: str, is_dev: bool): device_properties_path = get_properties_file_path(device_id) From f6b75d83f8795397ebea09019fea31decb3bed04 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Mon, 24 Nov 2025 18:41:51 +0100 Subject: [PATCH 2/4] PR feedback --- TactilityCore/Source/CpuAffinity.cpp | 8 ++++---- device.py | 15 ++++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/TactilityCore/Source/CpuAffinity.cpp b/TactilityCore/Source/CpuAffinity.cpp index 229dd23fe..19ac23b6f 100644 --- a/TactilityCore/Source/CpuAffinity.cpp +++ b/TactilityCore/Source/CpuAffinity.cpp @@ -15,9 +15,9 @@ namespace tt { static CpuAffinity getEspWifiAffinity() { #if CONFIG_FREERTOS_NUMBER_OF_CORES == 1 return 0; -#elif defined(CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0) +#elif defined(CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0) return 0; -#elif defined(CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1) +#elif defined(CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_1) return 1; #else // Assume core 0 (risky, but safer than "None") return 0; @@ -30,9 +30,9 @@ static CpuAffinity getEspWifiAffinity() { static CpuAffinity getEspMainSchedulerAffinity() { #if CONFIG_FREERTOS_NUMBER_OF_CORES == 1 return 0; -#elif defined(CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0) +#elif defined(CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0) return 0; -#elif defined(CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1) +#elif defined(CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_1) return 1; #else return None; diff --git a/device.py b/device.py index 307dc1cfb..e66eb5ce8 100644 --- a/device.py +++ b/device.py @@ -174,13 +174,15 @@ def write_performance_improvements(output_file, device_properties: ConfigParser) output_file.write("CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y\n") def write_lvgl_variables(output_file, device_properties: ConfigParser): - dpi = get_property_or_exit(device_properties, "display", "dpi") output_file.write("# LVGL\n") + if has_group(device_properties, "display"): + dpi = get_property_or_exit(device_properties, "display", "dpi") + output_file.write(f"CONFIG_LV_DPI_DEF={dpi}\n") + if has_group(device_properties, "lvgl"): + color_depth = get_property_or_exit(device_properties, "lvgl", "colorDepth") + output_file.write(f"CONFIG_LV_COLOR_DEPTH={color_depth}\n") + output_file.write(f"CONFIG_LV_COLOR_DEPTH_{color_depth}=y\n") output_file.write("CONFIG_LV_DISP_DEF_REFR_PERIOD=10\n") - output_file.write(f"CONFIG_LV_DPI_DEF={dpi}\n") - color_depth = get_property_or_exit(device_properties, "lvgl", "colorDepth") - output_file.write(f"CONFIG_LV_COLOR_DEPTH={color_depth}\n") - output_file.write(f"CONFIG_LV_COLOR_DEPTH_{color_depth}=y\n") theme = get_property_or_none(device_properties, "lvgl", "theme") if theme is None or theme == "DefaultDark": output_file.write("CONFIG_LV_THEME_DEFAULT_DARK=y\n") @@ -218,8 +220,7 @@ def write_properties(output_file, device_properties: ConfigParser, device_id: st write_performance_improvements(output_file, device_properties) write_usb_variables(output_file, device_properties) write_custom_sdkconfig(output_file, device_properties) - if has_group(device_properties, "display"): - write_lvgl_variables(output_file, device_properties) + write_lvgl_variables(output_file, device_properties) def main(device_id: str, is_dev: bool): device_properties_path = get_properties_file_path(device_id) From d105e0e2802528b4f34ab2f298fef1d0f6014c61 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Mon, 24 Nov 2025 18:54:49 +0100 Subject: [PATCH 3/4] Fix for preprocessor --- Tactility/Source/hal/sdcard/SdmmcDevice.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tactility/Source/hal/sdcard/SdmmcDevice.cpp b/Tactility/Source/hal/sdcard/SdmmcDevice.cpp index 37bf97af0..22fdb0eed 100644 --- a/Tactility/Source/hal/sdcard/SdmmcDevice.cpp +++ b/Tactility/Source/hal/sdcard/SdmmcDevice.cpp @@ -1,4 +1,8 @@ -#if defined(ESP_PLATFORM) && defined(SOC_SDMMC_HOST_SUPPORTED) +#ifdef ESP_PLATFORM +#include +#endif + +#if defined(ESP_PLATFORM) && defined(CONFIG_SOC_SDMMC_HOST_SUPPORTED) #include #include From 70d90b8f50cfaa23446a0ee4b8b778e79303756a Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Mon, 24 Nov 2025 19:03:59 +0100 Subject: [PATCH 4/4] PR feedback --- Tactility/Source/hal/sdcard/SdmmcDevice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tactility/Source/hal/sdcard/SdmmcDevice.cpp b/Tactility/Source/hal/sdcard/SdmmcDevice.cpp index 22fdb0eed..b0875ab18 100644 --- a/Tactility/Source/hal/sdcard/SdmmcDevice.cpp +++ b/Tactility/Source/hal/sdcard/SdmmcDevice.cpp @@ -1,8 +1,8 @@ #ifdef ESP_PLATFORM -#include +#include #endif -#if defined(ESP_PLATFORM) && defined(CONFIG_SOC_SDMMC_HOST_SUPPORTED) +#if defined(ESP_PLATFORM) && defined(SOC_SDMMC_HOST_SUPPORTED) #include #include