From bae5d10d0eff9c975d42ab56c6f201a01b466d89 Mon Sep 17 00:00:00 2001 From: Peter Feerick <5500713+pfeerick@users.noreply.github.com> Date: Sun, 25 Oct 2026 18:13:07 +1000 Subject: [PATCH 1/4] fix(cpn): set correct WAMR build target per slice in macOS universal builds WAMR derives a single BUILD_TARGET_* from the host CPU. On the arm64 CI runner a universal (x86_64;arm64) build therefore compiles the x86_64 slice with BUILD_TARGET_AARCH64, so wasm_runtime_invoke_native lays out 8 integer register slots while invokeNative_em64.s expects 6. Native and WASI calls passing stack arguments (e.g. path_open) receive garbage and the simulator hangs on Intel Macs. Override the target define per architecture with -Xarch_ flags. Fixes #7660 Co-Authored-By: Claude Opus 5.5 --- cmake/FetchWamr.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmake/FetchWamr.cmake b/cmake/FetchWamr.cmake index defb032d2a1..afe8017f055 100644 --- a/cmake/FetchWamr.cmake +++ b/cmake/FetchWamr.cmake @@ -61,4 +61,19 @@ if(NOT wamr_POPULATED) WASM_API_EXTERN= ) endif() + + if(APPLE AND "arm64" IN_LIST CMAKE_OSX_ARCHITECTURES + AND "x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES) + # WAMR picks a single BUILD_TARGET_* from the host CPU, so a universal + # build on an arm64 host compiles the x86_64 slice as AARCH64. That breaks + # native call argument marshalling (8 vs 6 integer registers) against + # invokeNative_em64.s. Set the correct target per slice; compile options + # follow the directory -D definitions on the command line, so these win. + target_compile_options(vmlib PRIVATE + "SHELL:-Xarch_x86_64 -UBUILD_TARGET_AARCH64" + "SHELL:-Xarch_x86_64 -DBUILD_TARGET_X86_64" + "SHELL:-Xarch_arm64 -UBUILD_TARGET_X86_64" + "SHELL:-Xarch_arm64 -DBUILD_TARGET_AARCH64" + ) + endif() endif() From 534214771c673a4b471a3108408f45650b1ee67b Mon Sep 17 00:00:00 2001 From: Peter Feerick <5500713+pfeerick@users.noreply.github.com> Date: Sun, 25 Oct 2026 18:19:10 +1000 Subject: [PATCH 2/4] chore(cpn): only apply WAMR win_file.c patch when not already applied The patch was re-applied on every configure against the cached WAMR source, failing with "patch does not apply" and a warning on repeat runs. Check with git apply --reverse --check first and skip if present. Co-Authored-By: Claude Opus 5.5 --- cmake/FetchWamr.cmake | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cmake/FetchWamr.cmake b/cmake/FetchWamr.cmake index afe8017f055..2a923453f32 100644 --- a/cmake/FetchWamr.cmake +++ b/cmake/FetchWamr.cmake @@ -33,13 +33,23 @@ if(NOT wamr_POPULATED) # WAMR 2.4.4 win_file.c has trailing backslashes in comments that # clang treats as line continuations, causing compile errors. + # Skip if a previous configure already patched the cached source. + set(_wamr_patch "${CMAKE_CURRENT_LIST_DIR}/wamr-fix-win-backslash-comments.patch") execute_process( - COMMAND git apply "${CMAKE_CURRENT_LIST_DIR}/wamr-fix-win-backslash-comments.patch" + COMMAND git apply --reverse --check "${_wamr_patch}" WORKING_DIRECTORY "${wamr_SOURCE_DIR}" - RESULT_VARIABLE _patch_result + RESULT_VARIABLE _patch_applied + OUTPUT_QUIET ERROR_QUIET ) - if(_patch_result) - message(WARNING "WAMR win_file.c patch failed (may already be applied)") + if(NOT _patch_applied EQUAL 0) + execute_process( + COMMAND git apply "${_wamr_patch}" + WORKING_DIRECTORY "${wamr_SOURCE_DIR}" + RESULT_VARIABLE _patch_result + ) + if(_patch_result) + message(WARNING "WAMR win_file.c patch failed") + endif() endif() add_subdirectory("${wamr_SOURCE_DIR}" "${wamr_BINARY_DIR}" EXCLUDE_FROM_ALL) From e4773cefafd19027eb691ae4bd9c3757e507f5f1 Mon Sep 17 00:00:00 2001 From: Peter Feerick <5500713+pfeerick@users.noreply.github.com> Date: Sun, 25 Oct 2026 19:03:02 +1000 Subject: [PATCH 3/4] ci(cpn): run companion workflow on WAMR build config changes FetchWamr.cmake and its patches affect the Companion simulator build but were not in the workflow path filters, so changes to them did not trigger CI. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/companion.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/companion.yml b/.github/workflows/companion.yml index ee3b9bd9a37..ee8969d06b0 100644 --- a/.github/workflows/companion.yml +++ b/.github/workflows/companion.yml @@ -16,6 +16,8 @@ on: - 'tools/build-companion.sh' - 'tools/build-wasm-modules.sh' - 'cmake/wasm/CMakeLists.txt' + - 'cmake/FetchWamr.cmake' + - 'cmake/wamr-*.patch' pull_request: paths: @@ -28,6 +30,8 @@ on: - 'tools/build-companion.sh' - 'tools/build-wasm-modules.sh' - 'cmake/wasm/CMakeLists.txt' + - 'cmake/FetchWamr.cmake' + - 'cmake/wamr-*.patch' workflow_dispatch: inputs: From 59f3803b034b00cd3cbaef4cf622488f70a874f9 Mon Sep 17 00:00:00 2001 From: Peter Feerick <5500713+pfeerick@users.noreply.github.com> Date: Sun, 25 Oct 2026 20:15:07 +1000 Subject: [PATCH 4/4] fix(simu): add CSD203 sensor stubs for simulator builds #7496 added CSD203 module/system current and voltage readouts to the module setup page and charge UI, but the getters only exist in the STM32 csd203_sensor driver, so the v16 WASM simulator failed to link. Co-Authored-By: Claude Opus 5.5 --- radio/src/targets/simu/adc_driver.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/radio/src/targets/simu/adc_driver.cpp b/radio/src/targets/simu/adc_driver.cpp index 09a15dce47b..b190f6e42e6 100644 --- a/radio/src/targets/simu/adc_driver.cpp +++ b/radio/src/targets/simu/adc_driver.cpp @@ -55,6 +55,15 @@ uint16_t getRTCBatteryVoltage() return 300; } +#if defined(CSD203_SENSOR) +// No CSD203 current/voltage sensors in the simulator +uint16_t getBatteryMidVoltage() { return 0; } +uint16_t getExtModuleVoltage() { return 0; } +int16_t getExtModuleCurrent() { return 0; } +int16_t getSystemCurrent() { return 0; } +int16_t getIntModuleCurrent() { return 0; } +#endif + extern uint16_t simuGetAnalog(uint8_t idx); // Negative = no override, fall back to the vBatWarn-derived default below.