<?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>Migration from NCS v2.1.3 to v2.6.0 with prebuilt B0 binaries</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110077/migration-from-ncs-v2-1-3-to-v2-6-0-with-prebuilt-b0-binaries</link><description>Hello, We are in the process of migrating from NCS v2.1.3 to NCS v2.6.0. Since we have many devices fielded already, one of our requirements is to continue using pre-built hex files for NSIB/B0 and mcuboot. As such, we also have a separate pre-built hex</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 11 Apr 2024 14:53:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110077/migration-from-ncs-v2-1-3-to-v2-6-0-with-prebuilt-b0-binaries" /><item><title>RE: Migration from NCS v2.1.3 to v2.6.0 with prebuilt B0 binaries</title><link>https://devzone.nordicsemi.com/thread/478372?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2024 14:53:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3633fc2-6d7d-4519-abf6-bc54dac4555f</guid><dc:creator>matharman</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;Thank you for the suggested workaround&lt;/p&gt;
&lt;p&gt;I managed to implement it in CMake so that it will be automatic and replace the default merged.hex. Thought I would share it here for future readers.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;list(APPEND TO_MERGE
    # Pre-built B0 bootloader
    ${CONFIG_B0_HEX_FILE}
    # Mcuboot built from source, signed for B0
    # You can also use CONFIG_MCUBOOT_HEX_FILE if using a pre-built mcuboot.
    ${CMAKE_BINARY_DIR}/zephyr/signed_by_b0_s0_image.hex
    # TFM+Application built from source, signed for mcuboot
    ${CMAKE_BINARY_DIR}/zephyr/app_signed.hex
)

set(MERGED_HEX ${CMAKE_BINARY_DIR}/zephyr/merged.hex)
set(MERGED_FIXED_HEX ${CMAKE_BINARY_DIR}/zephyr/merged-fixed.hex)

# Manually merge the components of the final binary, excluding provision.hex
add_custom_command(
    OUTPUT ${MERGED_FIXED_HEX}
    DEPENDS ${TO_MERGE}
    COMMAND
        ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/build/mergehex.py
        -o ${MERGED_FIXED_HEX}
        --overlap=replace
        ${TO_MERGE}
    )
add_custom_target(merged_fixed_hex
    ALL
    COMMENT &amp;quot;Creating patched merged.hex&amp;quot;
    DEPENDS ${TO_MERGE}
    )

# Unconditionally copy our merged binary over the default merged.hex
# so we can use west flash as normal.
# The DEPENDS clause ensures it always runs after the
# hex files of interest are generated.
add_custom_target(patch_merged_hex
    ALL
    COMMENT &amp;quot;Replacing NCS merged.hex with ours&amp;quot;
    COMMAND
        ${CMAKE_COMMAND} -E copy ${MERGED_FIXED_HEX} ${MERGED_HEX}
    DEPENDS ${MERGED_HEX} ${MERGED_FIXED_HEX}
    )&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If like us your B0 binary is from NCS &amp;lt;=v2.1.3, then you cannot use the generated provision.hex in NCS v2.2.0+; however, if you disable the generation of provision.hex, then MCUBoot source builds will not be signed for B0. You can also use a prebuilt MCUBoot hex file to avoid that problem, but this demonstrates how you would merge with an update image for MCUBoot in S0/S1.&lt;/p&gt;
&lt;p&gt;For our application we generate one binary with provision.hex, and one without. For the binary &lt;strong&gt;with&lt;/strong&gt; provision.hex, I have the pre-generated provision.hex that paired with the B0 binary for NCS v2.1.3. We simply add that file to the list of hex files to merge.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migration from NCS v2.1.3 to v2.6.0 with prebuilt B0 binaries</title><link>https://devzone.nordicsemi.com/thread/478344?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2024 13:30:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edba5589-e688-4c24-8178-62268c69b832</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;We do not have a solution for this at the moment. However, perhaps you can do something like this:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Get the&amp;nbsp;merged output file that contain&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;everything&lt;/em&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;which&amp;nbsp;you find here: &amp;lt;build folder&amp;gt;/zephyr/merged.hex.&lt;/li&gt;
&lt;li&gt;Take the immutable bootloader from the old build (which you find under &amp;lt;build folder&amp;gt;/b0/zephyr/zephyr.hex&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Then do like this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;python &amp;lt;NCS folder&amp;gt;/zephyr/scripts/build/mergehex.py -o&amp;nbsp;merged_with_old_b0.hex --overlap=replace&amp;nbsp;&amp;lt;path to new merged.hex file&amp;gt;&amp;nbsp;&amp;lt;path to old b0 zephyr.hex file&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If you do this separately/in some custom build script you can replace the bootloader(s) wihtout&amp;nbsp;needing updates in the build system. Of course building bootloader(s) you don&amp;#39;t use and supsequently overwriting them in the merged .hex file is not very elegant, but it should&amp;nbsp;function as a workaround.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migration from NCS v2.1.3 to v2.6.0 with prebuilt B0 binaries</title><link>https://devzone.nordicsemi.com/thread/478130?ContentTypeID=1</link><pubDate>Wed, 10 Apr 2024 18:16:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8985c42-7ed9-4683-b26b-fee4ac05a586</guid><dc:creator>matharman</dc:creator><description>&lt;p&gt;Hmm, this seems to have the unfortunate side effect of preventing an MCUBoot built from source from being signed.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This backwards compatibility story is not great. IMO the signing of the MCUBoot image should not be coupled to the generation of provision.hex, especially when there is no way to generate a provision.hex that is compatible with versions that don&amp;#39;t have knowledge of the PRoT lifecycle state and implementation ID.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migration from NCS v2.1.3 to v2.6.0 with prebuilt B0 binaries</title><link>https://devzone.nordicsemi.com/thread/477903?ContentTypeID=1</link><pubDate>Tue, 09 Apr 2024 19:39:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84bb3683-7473-447e-8395-d29f303bd220</guid><dc:creator>matharman</dc:creator><description>&lt;p&gt;Correction: I have stumbled on &lt;strong&gt;CONFIG_BOOTLOADER_PROVISION_HEX&lt;/strong&gt;, but it has no prompt so is not user configurable:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;error: BOOTLOADER_PROVISION_HEX (defined at /opt/ncs2/nrf/subsys/bootloader/Kconfig:34) is assigned
in a configuration file, but is not directly user-configurable (has no prompt). It gets its value
indirectly from other symbols. See&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I was able to override the selected value with the following change to my app&amp;#39;s Kconfig file and setting &lt;code&gt;CONFIG_BOOTLOADER_PROVISION_HEX=n&lt;/code&gt; in prj.conf. It &lt;strong&gt;must&lt;/strong&gt; appear before &lt;code&gt;source $(ZEPHYR_BASE)/Kconfig.zephyr&lt;/code&gt;, or else the NCS default will be used first.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;+config BOOTLOADER_PROVISION_HEX
+    bool &amp;quot;Generate provision.hex for B0&amp;quot;
+
 menu &amp;quot;Zephyr Kernel&amp;quot;
 source &amp;quot;$ZEPHYR_BASE/Kconfig.zephyr&amp;quot;
 endmenu&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This can be resolved with a conditional prompt for this Kconfig option when B0&amp;#39;s build strategy is USE_HEX_FILE. I will be opening a pull request suggesting this change shortly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>