Skip to content

Commit

Permalink
[nrfconnect] Make flashing_script hex selection reliable (#23003)
Browse files Browse the repository at this point in the history
When building via

  west build -b nrf52840dk_nrf52840 -t flashing_script

the wrong hex file is flashed, and doesn't boot. We need to flash
zephyr/merged.hex, not zephyr/zephyr.hex.

The copy step attempts to do this, but does so incorrectly based upon a
file existence test for which it has no declared dependency. This does
not work reliably.

It's a bit tricky to figure out which file we need to use, but for nRF
Connect there is a global variable ${merged_hex_to_flash} that suffices.
  • Loading branch information
mspang authored and pull[bot] committed Jul 24, 2023
1 parent 28e90fe commit 657cb62
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 31 deletions.
25 changes: 0 additions & 25 deletions config/nrfconnect/app/copy-flashbundle-firmware.cmake

This file was deleted.

11 changes: 8 additions & 3 deletions config/nrfconnect/app/flashing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ add_custom_command(OUTPUT "${FLASHBUNDLE_FLASHER_PLATFORM}"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${PROJECT_SOURCE_DIR}/third_party/connectedhomeip/scripts/flashing/nrfconnect_firmware_utils.py" "${FLASHBUNDLE_FLASHER_PLATFORM}"
VERBATIM)

if (merged_hex_to_flash)
set(flashbundle_hex_to_copy "${merged_hex_to_flash}")
else()
set(flashbundle_hex_to_copy "zephyr/${KERNEL_HEX_NAME}")
endif()

add_custom_command(OUTPUT "${FLASHBUNDLE_FIRMWARE}"
DEPENDS zephyr/${KERNEL_HEX_NAME}
COMMAND ${CMAKE_COMMAND} ARGS -DFLASHBUNDLE_FIRMWARE=${FLASHBUNDLE_FIRMWARE} -DKERNEL_HEX_NAME=${KERNEL_HEX_NAME} -P "${CHIP_ROOT}/config/nrfconnect/app/copy-flashbundle-firmware.cmake"
VERBATIM)
DEPENDS ${flashbundle_hex_to_copy}
COMMAND ${CMAKE_COMMAND} -E copy "${flashbundle_hex_to_copy}" "${FLASHBUNDLE_FIRMWARE}")

add_custom_command(OUTPUT "${CMAKE_PROJECT_NAME}/${CMAKE_PROJECT_NAME}.flash.py"
COMMAND ${python}
Expand Down
11 changes: 8 additions & 3 deletions config/zephyr/app/flashing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ add_custom_command(OUTPUT "${FLASHBUNDLE_FLASHER_PLATFORM}"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${PROJECT_SOURCE_DIR}/third_party/connectedhomeip/scripts/flashing/nrfconnect_firmware_utils.py" "${FLASHBUNDLE_FLASHER_PLATFORM}"
VERBATIM)

if (merged_hex_to_flash)
set(flashbundle_hex_to_copy "${merged_hex_to_flash}")
else()
set(flashbundle_hex_to_copy "zephyr/${KERNEL_HEX_NAME}")
endif()

add_custom_command(OUTPUT "${FLASHBUNDLE_FIRMWARE}"
DEPENDS zephyr/${KERNEL_HEX_NAME}
COMMAND ${CMAKE_COMMAND} ARGS -DFLASHBUNDLE_FIRMWARE=${FLASHBUNDLE_FIRMWARE} -DKERNEL_HEX_NAME=${KERNEL_HEX_NAME} -P "${CHIP_ROOT}/config/nrfconnect/app/copy-flashbundle-firmware.cmake"
VERBATIM)
DEPENDS ${flashbundle_hex_to_copy}
COMMAND ${CMAKE_COMMAND} -E copy "${flashbundle_hex_to_copy}" "${FLASHBUNDLE_FIRMWARE}")

add_custom_command(OUTPUT "${CMAKE_PROJECT_NAME}/${CMAKE_PROJECT_NAME}.flash.py"
COMMAND ${python}
Expand Down

0 comments on commit 657cb62

Please sign in to comment.