From ca9e7aaf98d74d0fc62f90770a48c559f3fba1b0 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Mon, 30 Jun 2025 10:10:13 +0100 Subject: [PATCH 1/4] Add FLASH option to pico_package_uf2_output Allows passing FLASH instead of 0x10000000 (eg pico_package_uf2_output(hello_serial FLASH)) --- tools/CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 7a0b56160..f63b15cd4 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -277,9 +277,15 @@ endfunction() # \param\ PACKADDR The address to package the UF2 to function(pico_package_uf2_output TARGET PACKADDR) picotool_check_configurable(${TARGET}) - set_target_properties(${TARGET} PROPERTIES - PICOTOOL_UF2_PACKAGE_ADDR ${PACKADDR} - ) + if (${PACKADDR} STREQUAL "FLASH") + set_target_properties(${TARGET} PROPERTIES + PICOTOOL_UF2_PACKAGE_ADDR 0x10000000 + ) + else() + set_target_properties(${TARGET} PROPERTIES + PICOTOOL_UF2_PACKAGE_ADDR ${PACKADDR} + ) + endif() endfunction() # pico_set_otp_key_output_file(TARGET OTPFILE) From 6dac21fff2b728b9891dc0e974a47ef6f5806139 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Mon, 30 Jun 2025 15:10:17 +0100 Subject: [PATCH 2/4] Add `pico_ensure_load_map` function --- tools/CMakeLists.txt | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index f63b15cd4..eccfde79b 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -95,6 +95,12 @@ define_property(TARGET BRIEF_DOCS "Extra arguments to pass to uf2 conversion" FULL_DOCS "Extra arguments to pass to uf2 conversion" ) +define_property(TARGET + PROPERTY PICOTOOL_LOAD_MAP + INHERITED + BRIEF_DOCS "Ensure a load map is added" + FULL_DOCS "Ensure a load map is added" +) # Check pioasm is installed, or build it if not installed function(pico_init_pioasm) @@ -267,12 +273,27 @@ function(pico_generate_pio_header TARGET) endif() endfunction() +# pico_ensure_load_map(TARGET) +# \brief\ Ensure a load map is added to the target. +# This can be used to ensure a load map is present, so the bootrom knows where +# to load the binary if it's stored in a different location (e.g. a packaged +# binary). +# +# This sets the target property PICOTOOL_LOAD_MAP to true. +function(pico_ensure_load_map TARGET) + picotool_check_configurable(${TARGET}) + set_target_properties(${TARGET} PROPERTIES + PICOTOOL_LOAD_MAP true + ) +endfunction() + # pico_package_uf2_output(TARGET PACKADDR) # \brief\ Package a UF2 output to be written to the PACKADDR address. # This can be used with a no_flash binary to write the UF2 to flash when dragging & # dropping, and it will be copied to SRAM by the bootrom before execution. # -# This sets the target property PICOTOOL_UF2_PACKAGE_ADDR to PACKADDR. +# This sets the target property PICOTOOL_UF2_PACKAGE_ADDR to PACKADDR and calls +# pico_ensure_load_map(TARGET). # # \param\ PACKADDR The address to package the UF2 to function(pico_package_uf2_output TARGET PACKADDR) @@ -286,6 +307,7 @@ function(pico_package_uf2_output TARGET PACKADDR) PICOTOOL_UF2_PACKAGE_ADDR ${PACKADDR} ) endif() + pico_ensure_load_map(${TARGET}) endfunction() # pico_set_otp_key_output_file(TARGET OTPFILE) @@ -635,7 +657,7 @@ function(picotool_postprocess_binary TARGET) if (NOT otp_file) set(otp_file "") endif() - get_target_property(uf2_package_addr ${TARGET} PICOTOOL_UF2_PACKAGE_ADDR) + get_target_property(ensure_load_map ${TARGET} PICOTOOL_LOAD_MAP) # Embed PT properties get_target_property(picotool_embed_pt ${TARGET} PICOTOOL_EMBED_PT) @@ -674,7 +696,7 @@ function(picotool_postprocess_binary TARGET) # Signing/hashing/load maps for packaging if (picotool_sign_output OR picotool_hash_output OR - uf2_package_addr OR + ensure_load_map OR extra_process_args) # We don't need the extra end block, as picotool seal will add one target_compile_definitions(${TARGET} PRIVATE PICO_CRT0_INCLUDE_PICOBIN_END_BLOCK=0) From c3fdf919625f4db00801d16f21dff53b925d79bf Mon Sep 17 00:00:00 2001 From: will-v-pi <108662275+will-v-pi@users.noreply.github.com> Date: Mon, 30 Jun 2025 16:22:37 +0100 Subject: [PATCH 3/4] Update tools/CMakeLists.txt --- tools/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index eccfde79b..8f28747ce 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -295,7 +295,7 @@ endfunction() # This sets the target property PICOTOOL_UF2_PACKAGE_ADDR to PACKADDR and calls # pico_ensure_load_map(TARGET). # -# \param\ PACKADDR The address to package the UF2 to +# \param\ PACKADDR The address to package the UF2 to, either "FLASH" or a specific address function(pico_package_uf2_output TARGET PACKADDR) picotool_check_configurable(${TARGET}) if (${PACKADDR} STREQUAL "FLASH") From 972404730df116f98e302f665fb583fffaa28e02 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Tue, 15 Jul 2025 11:49:45 +0100 Subject: [PATCH 4/4] Remove FLASH option and just make PACKADDR optional --- tools/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 8f28747ce..5a6795ef2 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -287,7 +287,7 @@ function(pico_ensure_load_map TARGET) ) endfunction() -# pico_package_uf2_output(TARGET PACKADDR) +# pico_package_uf2_output(TARGET [PACKADDR]) # \brief\ Package a UF2 output to be written to the PACKADDR address. # This can be used with a no_flash binary to write the UF2 to flash when dragging & # dropping, and it will be copied to SRAM by the bootrom before execution. @@ -295,16 +295,16 @@ endfunction() # This sets the target property PICOTOOL_UF2_PACKAGE_ADDR to PACKADDR and calls # pico_ensure_load_map(TARGET). # -# \param\ PACKADDR The address to package the UF2 to, either "FLASH" or a specific address -function(pico_package_uf2_output TARGET PACKADDR) +# \param\ PACKADDR The address to package the UF2 to, defaults to start of flash +function(pico_package_uf2_output TARGET) picotool_check_configurable(${TARGET}) - if (${PACKADDR} STREQUAL "FLASH") + if (ARGC EQUAL 1) set_target_properties(${TARGET} PROPERTIES PICOTOOL_UF2_PACKAGE_ADDR 0x10000000 ) else() set_target_properties(${TARGET} PROPERTIES - PICOTOOL_UF2_PACKAGE_ADDR ${PACKADDR} + PICOTOOL_UF2_PACKAGE_ADDR ${ARGV1} ) endif() pico_ensure_load_map(${TARGET})