<?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>NRF5340: zephyr child image image build issue.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102918/nrf5340-zephyr-child-image-image-build-issue</link><description>Hello. 
 Hardware setup NRF5340DK Base Application ipc_service IDE CLion 
 I&amp;#39;m facing a rather embarrassing issue. I&amp;#39;ve been using CLion to develop embedded software since I first got into MCUs. Needless to say, my productivity takes a nosedive whenever</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 Aug 2023 05:20:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102918/nrf5340-zephyr-child-image-image-build-issue" /><item><title>RE: NRF5340: zephyr child image image build issue.</title><link>https://devzone.nordicsemi.com/thread/441995?ContentTypeID=1</link><pubDate>Fri, 18 Aug 2023 05:20:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa3cfdcd-9a24-4857-97c8-6ee0612211c1</guid><dc:creator>pauleffect</dc:creator><description>&lt;p&gt;Apparently this seems to work out nicely.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;cmake_minimum_required(VERSION 3.15)

# MAIN CMAKE FILE ~ PROJECT ROOT


# CROSS COMPILING WORKAROUNDS
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

project(NONE)

add_subdirectory(Multicore.Network)
add_subdirectory(Multicore.Application)


add_custom_target(
        BUILD_WIRELESS_FIRMWARE
        COMMAND &amp;quot;west build E:/Development/Tmp/MinimalMulticore/Multicore.Network -b nrf5340dk_nrf5340_cpunet&amp;quot;
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cmake_minimum_required(VERSION 3.20.0)


message(&amp;quot;###################################&amp;quot;)
message(&amp;quot;####                               &amp;quot;)
message(&amp;quot;####                               &amp;quot;)
message(&amp;quot;#### APPLICATION CORE FIRMWARE     &amp;quot;)
message(&amp;quot;####                               &amp;quot;)
message(&amp;quot;####                               &amp;quot;)
message(&amp;quot;###################################&amp;quot;)

set(ENV{BOARD} nrf5340dk_nrf5340_cpuapp)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(Multicore.Application)

target_sources(app PRIVATE src/main.c)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cmake_minimum_required(VERSION 3.20.0)


message(&amp;quot;###################################&amp;quot;)
message(&amp;quot;####                               &amp;quot;)
message(&amp;quot;####                               &amp;quot;)
message(&amp;quot;#### NETWORK CORE FIRMWARE         &amp;quot;)
message(&amp;quot;####                               &amp;quot;)
message(&amp;quot;####                               &amp;quot;)
message(&amp;quot;###################################&amp;quot;)

set(ENV{BOARD} nrf5340dk_nrf5340_cpunet)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(Multicore.Network)

target_sources(app PRIVATE src/main.c)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And building via west.&lt;br /&gt;Note, as per&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/tedhavelka"&gt;tedhavelka&lt;/a&gt;&amp;nbsp; observiation in a prev. post, west should be invoked from your app folder. Also, its location needs to be in Path (windows). God, I need to dual boot. I miss Linux.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;@echo off
setlocal
SET PATH=E:\ncs\toolchains\31f4403e35;E:\ncs\toolchains\31f4403e35\mingw64\bin;E:\ncs\toolchains\31f4403e35\bin;E:\ncs\toolchains\31f4403e35\opt\bin;E:\ncs\toolchains\31f4403e35\opt\bin\Scripts;E:\ncs\toolchains\31f4403e35\opt\nanopb\generator-bin;E:\ncs\toolchains\31f4403e35\opt\zephyr-sdk\aarch64-zephyr-elf\bin;E:\ncs\toolchains\31f4403e35\opt\zephyr-sdk\x86_64-zephyr-elf\bin;E:\ncs\toolchains\31f4403e35\opt\zephyr-sdk\arm-zephyr-eabi\bin;%PATH%
SET PYTHONPATH=E:\ncs\toolchains\31f4403e35\opt\bin;E:\ncs\toolchains\31f4403e35\opt\bin\Lib;E:\ncs\toolchains\31f4403e35\opt\bin\Lib\site-packages
SET ZEPHYR_TOOLCHAIN_VARIANT=zephyr
SET ZEPHYR_SDK_INSTALL_DIR=E:\ncs\toolchains\31f4403e35\opt\zephyr-sdk
SET ZEPHYR_BASE=E:\ncs\v2.4.0\zephyr

REM Build Multicore.Application
west build -b nrf5340dk_nrf5340_cpuapp -d %~dp0\.build\Multicore.Application %~dp0\\Multicore.Application

REM Check the exit code
if %ERRORLEVEL% NEQ 0 (
    echo Error: Multicore.Application build failed.
    endlocal
    exit /b 1
)

REM Build Multicore.Network
west build -b nrf5340dk_nrf5340_cpunet -d %~dp0\.build\Multicore.Network %~dp0\\Multicore.Network

REM Check the exit code
if %ERRORLEVEL% NEQ 0 (
    echo Error: Multicore.Network build failed.
    endlocal
    exit /b 1
)



REM Merge the hex files
mergehex -m %~dp0\.build\Multicore.Application\zephyr\zephyr.hex %~dp0\.build\Multicore.Network\zephyr\zephyr.hex -o %~dp0\.output\zephyr.hex

REM Flash the merged hex file
west flash --hex-file %~dp0\.output\zephyr.hex --snr 1050020819

@REM nrfjprog --family NRF53 --coprocessor CP_NETWORK --snr 1050020819 --program %~dp0\.build\Multicore.Network\zephyr\zephyr.hex --sectorerase
@REM nrfjprog --family NRF53 --coprocessor CP_APPLICATION --snr 1050020819 --program %~dp0\.build\Multicore.Application\zephyr\zephyr.hex --sectorerase --reset

endlocal&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Weirdly enough, after flashing the project a couple of times, west refuses to flash it anymore.&lt;/p&gt;
&lt;p&gt;The script executes right until the west flash. And it&amp;#39;s the same command i used the first time, when it did work.&lt;/p&gt;
&lt;p&gt;Anyway, it&amp;#39;s not a perfect solution, ... but it works.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2477.Multicore.zip"&gt;devzone.nordicsemi.com/.../2477.Multicore.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5340: zephyr child image image build issue.</title><link>https://devzone.nordicsemi.com/thread/441982?ContentTypeID=1</link><pubDate>Fri, 18 Aug 2023 00:53:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:359f91e3-58b4-4a92-92d6-1ef4507bf68e</guid><dc:creator>pauleffect</dc:creator><description>&lt;p&gt;1. This is the first dual-core MCU I&amp;#39;ve actually used. Up until this point I&amp;#39;ve never had the opportunity (or the need) to work with multi-image builds. All the multi-core mcus I&amp;#39;ve used were flashed with a vendor binary. It would have been possible that the merge-hex tool also &amp;quot;formatted&amp;quot; the image. By that I mean, insert special markers or whatnot - like NXPs tools for the&amp;nbsp;MIMX RT&amp;#39;s do when you run binaries off SD/MMC cards (god, that&amp;#39;s awesome). So, thank you for clearing that up for me.&lt;/p&gt;
&lt;p&gt;2. That&amp;#39;s something I didn&amp;#39;t think of. And, truth be told, the scenario is not acceptable. Electrical damage aside (highly unlikely, I would think), what if you&amp;#39;re performing an upgrade and the filesystem running on an external flash gets blown to bits because it so happened the mcu was writing to the boot sector of the flash? Or, gods forbid, something regarding encryption/ persistent settings etc.&lt;/p&gt;
&lt;p&gt;3. Well, you are correct, .Net is basically java. Only more beautiful and better structured.&amp;nbsp;But the new console templates (.net 6 and above, i think) have basically the same structure as a regular script.&lt;/p&gt;
&lt;p&gt;Anyway, I won&amp;#39;t take up any more of your time. Thanks again for all the insights and help! And I will post my final solution here (god, that came out wrong).&lt;/p&gt;
&lt;p&gt;Have a great weekend, sir!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5340: zephyr child image image build issue.</title><link>https://devzone.nordicsemi.com/thread/441976?ContentTypeID=1</link><pubDate>Fri, 18 Aug 2023 00:33:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca354e86-b534-486f-8862-f4a537732e9c</guid><dc:creator>tedhavelka</dc:creator><description>&lt;p&gt;Hi Paul,&lt;/p&gt;
&lt;p&gt;I think you already know so, but a concatenating utility such as mergehex is not required to program applications to be run by each core in a multi-core target processor.&amp;nbsp; Mergehex &amp;quot;fits in&amp;quot; the build sequence very near the end, just before programming.&amp;nbsp; The flasher actually doesn&amp;#39;t know more or less from `mergehex` or `srec_cat`.&amp;nbsp; With a merged image the flashing utility simply has one thing to flash rather then two or more.&lt;/p&gt;
&lt;p&gt;One important benefit however of a combined image is that the flashing of all cores&amp;#39; code is time contiguous.&amp;nbsp; The target MCU is held in a reset state until the combined image is flashed and verified.&amp;nbsp; As a result the processor does not boot up after the first core is flashed.&lt;/p&gt;
&lt;p&gt;This is to say that when flashing images separately to a multi-core target there will likely be a couple to few seconds where the first core begins running its latest image and the next core begins to run the older image.&amp;nbsp; We&amp;#39;ve seen this happen when we flash images separately -- no mergehex used -- and we need to be cautious in this situation that our hardware and firmware are electrically safe for those few seconds, running the differently versioned apps.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know anything about C#, which I thought was a programming language rather than a scripting or shell oriented language.&amp;nbsp; But it sounds like you are on your way.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A couple years ago I was asked to get our project then building both at command line with Zephyr toolchain and Segger Studio, which has a python based &amp;quot;import project&amp;quot; applet.&amp;nbsp; That importer worked most of the way, but if I ever added source files or created new project directories and moved sources, headers, cmake files and related, I had to re-import the project into Segger IDE all over again.&amp;nbsp; I found the python script which I believe was part of a special version of Segger with support for Nordic ncs SDK projects.&amp;nbsp; But from what I understand of cmake and of IDEs, they&amp;#39;re both aiming to support and control the same &amp;quot;high level down to detailed levels&amp;quot; project configuration.&lt;/p&gt;
&lt;p&gt;For this reason I don&amp;#39;t know that there&amp;#39;s a clean, intelligent way yet among any of the IDEs to import a Zephyr based application.&amp;nbsp; The dual-core Zephyr based apps add a wrinkle to this, so yours is a &amp;quot;challenge question&amp;quot; for sure.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll keep this Devzone post bookmarked because I am interested to learn your solution.&amp;nbsp; Even if I don&amp;#39;t have need of CLion.&lt;/p&gt;
&lt;p&gt;Good weekend to you, and keep safe Paul,&lt;/p&gt;
&lt;p&gt;- Ted&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5340: zephyr child image image build issue.</title><link>https://devzone.nordicsemi.com/thread/441974?ContentTypeID=1</link><pubDate>Thu, 17 Aug 2023 23:38:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:896e0c98-96aa-4e3a-8255-44d205475e31</guid><dc:creator>pauleffect</dc:creator><description>&lt;p&gt;First off, thanks for the detailed answer and the idea. Actually, regarding the shell scripts, I&amp;#39;m not above putting in work - one hour spent writing a utility now saves dozens in the long run.&lt;/p&gt;
&lt;p&gt;I was thinking along the same lines: whip up a quick c# console app&amp;nbsp; that&amp;nbsp;will *somehow* handle the build process - to complement the built-in capabilities of cmake.&lt;br /&gt;I think I&amp;#39;ll go with an (empty) top-level cmake that adds two subdirectories. Each is a stand-alone application that will get burnt on the flash in the required order: app, network core, reset. Seems the most reasonable, by far. nrfjprog to the rescue.&lt;/p&gt;
&lt;p&gt;I must confess, I got seriously spooked by west + zephyr + python and I didn&amp;#39;t exactly get what happens under the hood, once you hit that build button.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span style="font-size:75%;"&gt;And with a single character changed in one of the myriad of files .conf, dts, dtsi, fragments, kconfigs etc, everything gets rebuilt. And it taskes forever. So, and for any trivial task, for a zephyr beginner) there go another 12 hours.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Right now I&amp;#39;m using an empty app image core and I have a standalone firmware I&amp;#39;m working on for the network core.&lt;/p&gt;
&lt;p&gt;Cmake handles the building, a c# script handles the burning of the images. The next logical step would be including a simple hello world app for the main core and editing the project *.conf file to boot the net image. If I&amp;#39;m not mistaken, the relevant config is&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_BOARD_ENABLE_CPUNET=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;What I don&amp;#39;t understand is where does mergehex factor into all this. Is it simply to have one convenient image a flasher &amp;quot;knows&amp;quot; where to put? Does it serve any other purpose?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5340: zephyr child image image build issue.</title><link>https://devzone.nordicsemi.com/thread/441971?ContentTypeID=1</link><pubDate>Thu, 17 Aug 2023 23:19:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f4e5084-9c29-48ce-bad6-afdf85714ba6</guid><dc:creator>tedhavelka</dc:creator><description>&lt;p&gt;Hello Paul,&lt;/p&gt;
&lt;p&gt;While I won&amp;#39;t have a working solution to your CLion, Zephyr &amp;quot;dual app&amp;quot; import situation, I may be able to offer an idea in a useful direction.&amp;nbsp; I&amp;#39;m not familiar with Jetbrains or their CLion IDE, but I have been working with a dual core ARM processor and Zephyr v3.4.0 as the scheduler/RTOS on each of the two cores in my team&amp;#39;s chosen microcontroller.&lt;/p&gt;
&lt;p&gt;The first dual-core Zephyr application I succeeded in building, flashing and running is the IPM or inter-processor mailbox sample app from Zephyr v3.2.0.&amp;nbsp; That version of Zephyr has the sample app structured with a parent project for the first core and a child project for the second one.&amp;nbsp; In a couple of this sample app&amp;#39;s `cmake` files I think these are also named &amp;quot;local project&amp;quot; and &amp;quot;remote project&amp;quot;.&lt;/p&gt;
&lt;p&gt;The remote project seems to be in a way subservient to the parent project.&amp;nbsp; One of the final build steps involves concatenating the image for each core.&amp;nbsp; Because the project cmake files specify building &amp;quot;dot bin&amp;quot; final executables, the merging of the two cores&amp;#39; images here required a special tool `srec_cat` which is not part of Zephyr&amp;#39;s standard toolchain.&amp;nbsp; That was mentioned in the sample app README or nearby, but still represents a more complex build process than typical.&amp;nbsp; I imagine this could also create a gap in needed build utils which CLion might need to call during multi-core (multi-project) builds.&lt;/p&gt;
&lt;p&gt;More recently my team migrated our project to Zephyr v3.4.0, which changed and simplified a dual-core sample project.&amp;nbsp; The new multi-project hierarchy has each project as its own stand-alone project.&amp;nbsp; One is not the child of the other nor the parent.&amp;nbsp; We ended up writing a short shell script to build each project in turn, and adjusted final output format to Intel hex file format.&amp;nbsp; This permits us to merge the two cores&amp;#39; images with `mergehex`, which seems a little more commonplace than `srec_cat`.&lt;/p&gt;
&lt;p&gt;The shell script accepts a couple of options:&amp;nbsp; one to build the projects, and one to flash them to the target hardware.&lt;/p&gt;
&lt;p&gt;I know that you&amp;#39;re not looking to write and use shell scripts, but this has been a clear and straightforward solution for our team.&lt;/p&gt;
&lt;p&gt;To that point I am building on a Linux host using the standard Zephyr toolchain described at &lt;a title="Zephyr's Getting Started Guide" href="https://docs.zephyrproject.org/latest/develop/getting_started/index.html" rel="noopener noreferrer" target="_blank"&gt;Zephyr&amp;#39;s Getting Started Guide&lt;/a&gt;.&amp;nbsp; I think that&amp;#39;s the arcane piece you refer to in your post.&lt;/p&gt;
&lt;p&gt;So I wonder whether CLion supports building two or more apps with two or more final executable files as final output?&amp;nbsp; If you can build the two projects you would possibly just have that step of merging each core&amp;#39;s image file into a single combined image.&amp;nbsp; Then CLion should be able to call your programming utility and carry out the flash operation as normal.&lt;/p&gt;
&lt;p&gt;I realize that you may be obtaining your Zephyr release as part of Nordic&amp;#39;s `ncs` SDK.&amp;nbsp; That might make it hard to move to Zephyr v3.4.0.&amp;nbsp; But even if you stay with a Zephyr release earlier than 3.4.0, if you can find a way to build parent and child projects as stand alone projects and confirm that the binaries before merging are the same as building in the original way, then you may be able to manually move files outside of CLion and create stand alone projects which could then be imported one per time into a &amp;quot;multi project&amp;quot; CLion project.&lt;/p&gt;
&lt;p&gt;Paul I&amp;#39;m sorry I do not have time to install and learn CLion.&amp;nbsp; But perhaps something here can help you to a useful next question or next step toward a solution for your work.&lt;/p&gt;
&lt;p&gt;- Ted&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5340: zephyr child image image build issue.</title><link>https://devzone.nordicsemi.com/thread/441818?ContentTypeID=1</link><pubDate>Thu, 17 Aug 2023 10:44:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4904b13-ad63-4589-b998-d307c4ca1e3d</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi Paul,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve looked around and unfortunately I couldn&amp;#39;t find anything on how to do this outside the Zephyr build system.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll leave this thread open, hopefully someone else on this forum have some tips on how to do this,&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>