From 4022f206e4803a7fbdd9291c6617d308e718bf6f Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Fri, 11 Sep 2026 15:26:16 +0200 Subject: [PATCH] Fixes --- .github/actions/build-simulator/action.yml | 7 +++++++ Devices/unphone/CMakeLists.txt | 2 +- Modules/crypt-module/source/crypt.cpp | 14 ++++++-------- .../source/drivers/bluetooth/esp32_ble.cpp | 11 ++++++++++- Tactility/Source/file/File.cpp | 6 +++++- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/actions/build-simulator/action.yml b/.github/actions/build-simulator/action.yml index 80eeb5ae8..ac41dbf20 100644 --- a/.github/actions/build-simulator/action.yml +++ b/.github/actions/build-simulator/action.yml @@ -40,6 +40,13 @@ runs: uses: jwlawson/actions-setup-cmake@v2 with: cmake-version: '3.31.x' + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + - name: Install mbedtls codegen Python dependencies + shell: bash + run: pip install -r Libraries/mbedtls/scripts/driver.requirements.txt - name: "Prepare Project" shell: bash run: cmake -S ./ -B buildsim diff --git a/Devices/unphone/CMakeLists.txt b/Devices/unphone/CMakeLists.txt index 21b60ea5c..740104fd0 100644 --- a/Devices/unphone/CMakeLists.txt +++ b/Devices/unphone/CMakeLists.txt @@ -3,5 +3,5 @@ file(GLOB_RECURSE SOURCE_FILES source/*.c*) idf_component_register( SRCS ${SOURCE_FILES} INCLUDE_DIRS "source" - REQUIRES TactilityKernel TactilityFreeRtos bq24295-module driver + REQUIRES TactilityKernel TactilityFreeRtos bq24295-module driver esp_driver_gpio ) diff --git a/Modules/crypt-module/source/crypt.cpp b/Modules/crypt-module/source/crypt.cpp index 4281aa11e..9ee477457 100644 --- a/Modules/crypt-module/source/crypt.cpp +++ b/Modules/crypt-module/source/crypt.cpp @@ -156,19 +156,17 @@ static void getKey(uint8_t key[32]) { // psa_crypto_init() is safe to call more than once (subsequent calls are a cheap no-op); ESP-IDF // calls it during startup already, but the simulator has no equivalent, so call it here too // rather than depend on init order across callers. -static void ensure_psa_crypto_init() { - static bool initialized = false; - if (!initialized) { - psa_crypto_init(); - initialized = true; - } +static psa_status_t ensure_psa_crypto_init() { + return psa_crypto_init(); } void crypt_get_iv(const void* data, size_t dataLength, uint8_t iv[16]) { - ensure_psa_crypto_init(); + check(ensure_psa_crypto_init() == PSA_SUCCESS); uint8_t hash[32]; size_t hash_length; - psa_hash_compute(PSA_ALG_SHA_256, static_cast(data), dataLength, hash, sizeof(hash), &hash_length); + check(psa_hash_compute(PSA_ALG_SHA_256, static_cast(data), + dataLength, hash, sizeof(hash), &hash_length) == PSA_SUCCESS); + check(hash_length == sizeof(hash)); memcpy(iv, hash, 16); mbedtls_platform_zeroize(hash, sizeof(hash)); } diff --git a/Platforms/platform-esp32/source/drivers/bluetooth/esp32_ble.cpp b/Platforms/platform-esp32/source/drivers/bluetooth/esp32_ble.cpp index 34d81c207..6768c0ec1 100644 --- a/Platforms/platform-esp32/source/drivers/bluetooth/esp32_ble.cpp +++ b/Platforms/platform-esp32/source/drivers/bluetooth/esp32_ble.cpp @@ -688,13 +688,22 @@ static void dispatch_enable(BleCtx* ctx) { } esp_hosted_bt_host_stack_cfg_t hosted_bt_cfg = ESP_HOSTED_BT_HOST_STACK_CONFIG_DEFAULT(); if (esp_hosted_bt_host_stack_setup(&hosted_bt_cfg) != ESP_OK) { - LOG_W(TAG, "esp_hosted_bt_host_stack_setup failed"); + LOG_E(TAG, "esp_hosted_bt_host_stack_setup failed"); + ctx->radio_state.store(BT_RADIO_STATE_OFF); + struct BtEvent e = {}; + e.type = BT_EVENT_RADIO_STATE_CHANGED; + e.radio_state = BT_RADIO_STATE_OFF; + ble_publish_event(ctx->device, e); + return; } #endif int rc = nimble_port_init(); if (rc != 0) { LOG_E(TAG, "nimble_port_init failed (rc=%d)", rc); +#if defined(CONFIG_ESP_HOSTED_HOST) + esp_hosted_bt_host_stack_teardown(); +#endif ctx->radio_state.store(BT_RADIO_STATE_OFF); struct BtEvent e = {}; e.type = BT_EVENT_RADIO_STATE_CHANGED; diff --git a/Tactility/Source/file/File.cpp b/Tactility/Source/file/File.cpp index 46e794ec5..570636649 100644 --- a/Tactility/Source/file/File.cpp +++ b/Tactility/Source/file/File.cpp @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -195,7 +196,10 @@ static bool findOrCreateDirectoryInternal(const std::string& path, mode_t mode) return S_ISDIR(dir_stat.st_mode); } - return mkdir(path.c_str(), mode) == 0; + if (mkdir(path.c_str(), mode) == 0) { + return true; + } + return errno == EEXIST && stat(path.c_str(), &dir_stat) == 0 && S_ISDIR(dir_stat.st_mode); } std::string getLastPathSegment(const std::string& path) {