@@ -95,6 +95,12 @@ define_property(TARGET
9595 BRIEF_DOCS "Extra arguments to pass to uf2 conversion"
9696 FULL_DOCS "Extra arguments to pass to uf2 conversion"
9797)
98+ define_property (TARGET
99+ PROPERTY PICOTOOL_LOAD_MAP
100+ INHERITED
101+ BRIEF_DOCS "Ensure a load map is added"
102+ FULL_DOCS "Ensure a load map is added"
103+ )
98104
99105# Check pioasm is installed, or build it if not installed
100106function (pico_init_pioasm)
@@ -267,19 +273,41 @@ function(pico_generate_pio_header TARGET)
267273 endif ()
268274endfunction ()
269275
270- # pico_package_uf2_output(TARGET PACKADDR)
276+ # pico_ensure_load_map(TARGET)
277+ # \brief\ Ensure a load map is added to the target.
278+ # This can be used to ensure a load map is present, so the bootrom knows where
279+ # to load the binary if it's stored in a different location (e.g. a packaged
280+ # binary).
281+ #
282+ # This sets the target property PICOTOOL_LOAD_MAP to true.
283+ function (pico_ensure_load_map TARGET )
284+ picotool_check_configurable(${TARGET} )
285+ set_target_properties (${TARGET} PROPERTIES
286+ PICOTOOL_LOAD_MAP true
287+ )
288+ endfunction ()
289+
290+ # pico_package_uf2_output(TARGET [PACKADDR])
271291# \brief\ Package a UF2 output to be written to the PACKADDR address.
272292# This can be used with a no_flash binary to write the UF2 to flash when dragging &
273293# dropping, and it will be copied to SRAM by the bootrom before execution.
274294#
275- # This sets the target property PICOTOOL_UF2_PACKAGE_ADDR to PACKADDR.
295+ # This sets the target property PICOTOOL_UF2_PACKAGE_ADDR to PACKADDR and calls
296+ # pico_ensure_load_map(TARGET).
276297#
277- # \param\ PACKADDR The address to package the UF2 to
278- function (pico_package_uf2_output TARGET PACKADDR )
298+ # \param\ PACKADDR The address to package the UF2 to, defaults to start of flash
299+ function (pico_package_uf2_output TARGET )
279300 picotool_check_configurable(${TARGET} )
280- set_target_properties (${TARGET} PROPERTIES
281- PICOTOOL_UF2_PACKAGE_ADDR ${PACKADDR}
282- )
301+ if (ARGC EQUAL 1)
302+ set_target_properties (${TARGET} PROPERTIES
303+ PICOTOOL_UF2_PACKAGE_ADDR 0x10000000
304+ )
305+ else ()
306+ set_target_properties (${TARGET} PROPERTIES
307+ PICOTOOL_UF2_PACKAGE_ADDR ${ARGV1}
308+ )
309+ endif ()
310+ pico_ensure_load_map(${TARGET} )
283311endfunction ()
284312
285313# pico_set_otp_key_output_file(TARGET OTPFILE)
@@ -629,7 +657,7 @@ function(picotool_postprocess_binary TARGET)
629657 if (NOT otp_file)
630658 set (otp_file "" )
631659 endif ()
632- get_target_property (uf2_package_addr ${TARGET} PICOTOOL_UF2_PACKAGE_ADDR )
660+ get_target_property (ensure_load_map ${TARGET} PICOTOOL_LOAD_MAP )
633661
634662 # Embed PT properties
635663 get_target_property (picotool_embed_pt ${TARGET} PICOTOOL_EMBED_PT)
@@ -668,7 +696,7 @@ function(picotool_postprocess_binary TARGET)
668696 # Signing/hashing/load maps for packaging
669697 if (picotool_sign_output OR
670698 picotool_hash_output OR
671- uf2_package_addr OR
699+ ensure_load_map OR
672700 extra_process_args)
673701 # We don't need the extra end block, as picotool seal will add one
674702 target_compile_definitions (${TARGET} PRIVATE PICO_CRT0_INCLUDE_PICOBIN_END_BLOCK=0)
0 commit comments