NRF5340: zephyr child image image build issue.

Hello.

Hardware setup    NRF5340DK
Base Application ipc_service
IDE CLion


I'm facing a rather embarrassing issue. I've been using CLion to develop embedded software since I first got into MCUs. Needless to say, my productivity takes a nosedive whenever I'm forced to use another IDE. I'm now working on a project centered around the 5340. I created, build and flashed the ipc multi-core sample using Visual Code, than "imported" the project into CLion. Everything works, the image builds accordingly, it runs as expected, but with a tiny hiccup. Because CLion uses the top-level CMakeLists.txt to index the project, it doesn't "see" the child image. Because of the zephyr's arcane build system, CLion fails to detect the child CMake, ergo every file in the child image is seen as not being part of the project.

I know what I'm asking is technically not your concern - your official hardware & software combination works, but would you guys be so kind as to help me link the child image via the main CMake file only? Without using zephyr's rather arcane build system? Right now, I'm guessing the child image gets linked via the yml / hci folder - I think that's basically a zephyr module.

Or, another possible solution would be a link/ tutorial about how to build a net core app and a main core app completely separately and then merge them together. I must confess, I've crawled this support forum up and down, read the docs - I can't, for the life of me, figure out how to actually do that.

Thank you kindly for your time (and for all the detailed forum posts, made by your coleagues, that got me this far).

  • Apparently this seems to work out nicely.

    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 "west build E:/Development/Tmp/MinimalMulticore/Multicore.Network -b nrf5340dk_nrf5340_cpunet"
            WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    )

    cmake_minimum_required(VERSION 3.20.0)
    
    
    message("###################################")
    message("####                               ")
    message("####                               ")
    message("#### APPLICATION CORE FIRMWARE     ")
    message("####                               ")
    message("####                               ")
    message("###################################")
    
    set(ENV{BOARD} nrf5340dk_nrf5340_cpuapp)
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(Multicore.Application)
    
    target_sources(app PRIVATE src/main.c)

    cmake_minimum_required(VERSION 3.20.0)
    
    
    message("###################################")
    message("####                               ")
    message("####                               ")
    message("#### NETWORK CORE FIRMWARE         ")
    message("####                               ")
    message("####                               ")
    message("###################################")
    
    set(ENV{BOARD} nrf5340dk_nrf5340_cpunet)
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(Multicore.Network)
    
    target_sources(app PRIVATE src/main.c)

    And building via west.
    Note, as per   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.

    @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
     

    Weirdly enough, after flashing the project a couple of times, west refuses to flash it anymore.

    The script executes right until the west flash. And it's the same command i used the first time, when it did work.

    Anyway, it's not a perfect solution, ... but it works. 

    2477.Multicore.zip

Related