<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mapping a binary file to a flash partition</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113047/mapping-a-binary-file-to-a-flash-partition</link><description>Hi there, 
 I have multiple flash partitions defined in pm_static.yml. 
 I want one specific partition to contain a binary data file so that when I flash the image with J-Link, the bootloader, the application firmware, and the binary file are flashed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 09 Aug 2024 21:27:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113047/mapping-a-binary-file-to-a-flash-partition" /><item><title>RE: Mapping a binary file to a flash partition</title><link>https://devzone.nordicsemi.com/thread/497686?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2024 21:27:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a5d3cde-196f-4265-893b-fa4849c1a7f3</guid><dc:creator>Ben K</dc:creator><description>&lt;p&gt;Well this is an extremely vague response. Here are two approaches I have tried so far, without success:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;First relatively naive approach: use Zephyr&amp;#39;s cmake linker tooling to create a custom linker section, insert the binary in there with assembly .incbin, and link it to the final image. No build errors, but also no effect. Application&amp;#39;s CMakeLists.txt code that was used:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;set(CONFIG_BIN_PATH &amp;quot;${CMAKE_CURRENT_SOURCE_DIR}/config.bin&amp;quot;)

# create linker script section for user configuration from DT information
dt_nodelabel(USER_CONFIG_PARTITION_PATH NODELABEL &amp;quot;user_config_partition&amp;quot;)
dt_reg_addr(USER_CONFIG_PARTITION_ADDRESS PATH ${USER_CONFIG_PARTITION_PATH})
dt_reg_size(USER_CONFIG_PARTITION_SIZE PATH ${USER_CONFIG_PARTITION_PATH})

zephyr_linker_memory(NAME USER_CONFIG
    FLAGS r
    START ${USER_CONFIG_PARTITION_ADDRESS}
    SIZE ${USER_CONFIG_PARTITION_SIZE}
)
zephyr_linker_section(NAME .userconfig KEEP GROUP USER_CONFIG)

# the assembly file places the binaries in the correct memory regions
set(CONFIGS_ASM_FILE &amp;quot;${CMAKE_BINARY_DIR}/configs_assembly.S&amp;quot;)
file(WRITE &amp;quot;${CONFIGS_ASM_FILE}&amp;quot; &amp;quot;.section .userconfig
.incbin \&amp;quot;${CONFIG_BIN_PATH}\&amp;quot;
&amp;quot;)
set_source_files_properties(${CONFIGS_ASM_FILE} PROPERTIES GENERATED TRUE)

# add it to the final elf image target
target_sources(${logical_target_for_zephyr_elf} PRIVATE ${CONFIGS_ASM_FILE})&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Second approach: use nRF SDK partition manager tooling. This is the static configuration:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;app:
  address: 0x10200
  end_address: 0xfd000
  region: flash_primary
  size: 0xece00
mcuboot:
  address: 0x0
  end_address: 0x10000
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  size: 0x10000
mcuboot_pad:
  address: 0x10000
  end_address: 0x10200
  placement:
    align:
      start: 0x1000
    before:
    - mcuboot_primary_app
  region: flash_primary
  size: 0x200
mcuboot_primary:
  address: 0x10000
  end_address: 0xed000
  orig_span: &amp;amp;id001
  - app
  - mcuboot_pad
  region: flash_primary
  size: 0xdd000
  span: *id001
mcuboot_primary_app:
  address: 0x10200
  end_address: 0xed000
  orig_span: &amp;amp;id002
  - app
  region: flash_primary
  size: 0xdce00
  span: *id002
hardware_config_partition:
  address: 0xec000
  end_address: 0xed000
  size: 0x1000
user_config_partition:
  address: 0xed000
  end_address: 0xfd000
  placement:
    align:
      start: 0x1000
    before:
    - end
  region: flash_primary
  size: 0x10000
settings_storage:
  address: 0xfd000
  end_address: 0x100000
  placement:
    align:
      start: 0x1000
    before:
    - end
  region: flash_primary
  size: 0x3000
sram_primary:
  address: 0x20000000
  end_address: 0x20040000
  region: sram_primary
  size: 0x40000
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;and this is the CMakeLists.txt addition I used, again build goes without error or warning, but no effect:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;set(CONFIG_BIN_PATH &amp;quot;${CMAKE_CURRENT_SOURCE_DIR}/config.bin&amp;quot;)
set(USER_CONFIG_HEX &amp;quot;${CMAKE_BINARY_DIR}/user_config.hex&amp;quot;)

add_custom_command(
    COMMAND ${CMAKE_OBJCOPY} -I binary -O ihex ${CONFIG_BIN_PATH} ${USER_CONFIG_HEX}
    OUTPUT ${USER_CONFIG_HEX}
    DEPENDS ${CONFIG_BIN_PATH}
    COMMENT &amp;quot;Converting user config to hex&amp;quot;
    VERBATIM
)
add_custom_target(user_config
    DEPENDS ${USER_CONFIG_HEX}
)
set_property(GLOBAL PROPERTY
  user_config_partition_PM_HEX_FILE ${USER_CONFIG_HEX}
)
set_property(GLOBAL PROPERTY
  user_config_partition_PM_TARGET user_config
)&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Can we get some more concrete pointers on how to solve this?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Thanks in advance&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mapping a binary file to a flash partition</title><link>https://devzone.nordicsemi.com/thread/495228?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2024 13:09:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8625161-8963-4733-834f-bd3c6574562a</guid><dc:creator>Menon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry for the delayed response. It&amp;#39;s summer vacation here in Norway, and we have a limited number of staff working, which is why it took me some time to get back to you.&lt;/p&gt;
&lt;p&gt;I am not 100% sure, as I haven&amp;#39;t tried this before, but I think this can be achievable. Define the partition for the binary in the `pm_static.yml` file and keep your binary file in the root of your application. Edit your main `CMakeLists.txt` file to include the binary file in the custom partition. In the CMake configuration, you need to define the binary file to be included and then add the binary to the build system.&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Abhijith&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mapping a binary file to a flash partition</title><link>https://devzone.nordicsemi.com/thread/494242?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2024 19:48:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7aaa3d1b-b41b-4d1c-bfee-1e0c52a83870</guid><dc:creator>mlac</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Abhijith,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;m using the nRF Connect SDK 2.6.1, but I&amp;#39;m about to upgrade to 2.7.0 very soon.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;m not using a development kit but a custom board featuring a nRF52840.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The application firmware uses a sophisticated binary configuration format stored on a dedicated partition. The file can be updated via USB and Bluetooth, but I&amp;#39;d prefer to pre-flash it in the factory along with the firmware with a J-Link probe.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mapping a binary file to a flash partition</title><link>https://devzone.nordicsemi.com/thread/494168?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2024 13:38:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:597d7679-8635-4a55-a0af-269a0772d6e3</guid><dc:creator>Menon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Could you please share the SDK version and the Nordic chip or development kit (DK) you are using&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user=""]I want one specific partition to contain a binary data file so that when I flash the image with J-Link, the bootloader, the application firmware, and the binary file are flashed together.[/quote]
&lt;p&gt;To ensure we proceed correctly, could you please clarify the intended use or purpose of the binary data file within the flashing process?&lt;/p&gt;
&lt;p&gt;Kind Regards,&lt;/p&gt;
&lt;p&gt;Abhijith&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>