This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF Connect SDK customized mcuboot with Zephyr

Hello!

I'm tinkering with the NCS libraries, and I'm really liking the way this is turning out coming from the nRF5 SDK! My question is what is the best practice for creating a customized mcuboot build? My current setup is on Linux using primarily command line and CLion for development (SDK v1.4.2). My current configuration is following the getting started guide, where "my_project" is a git repo with my app:

.
├── bootloader
├── my_project
├── mbedtls
├── modules
├── nrf
├── nrfxlib
├── smp_svr
├── test
├── tools
└── zephyr

And the app repo has the following structure, which has room for a bootloader to be in the same repo if possible:

.
├── app
│   ├── CMakeLists.txt
│   ├── docker-compose.yml
│   ├── Dockerfile
│   ├── overlay-bt.conf
│   ├── overlay-bt-tiny.conf
│   ├── overlay-cdc.conf
│   ├── overlay-fs.conf
│   ├── overlay-serial.conf
│   ├── overlay-serial-console.conf
│   ├── overlay-shell.conf
│   ├── overlay-shell-mgmt.conf
│   ├── overlay-udp.conf
│   ├── prj.conf
│   ├── README.rst
│   ├── sample.yaml
│   └── src
│       ├── bluetooth.c
│       ├── common.h
│       ├── main.c
│       └── udp.c
├── CMakeLists.txt
└── west.yml

As a bonus question, is it necessary to leave my project as a subfolder of the NCS tools folder? I tried locating my repo in a different development folder and defining ZEPHYR_BASEZEPHYR_TOOLCHAIN_VARIANT, and GNUARMEMB_TOOLCHAIN_PATH, but the build system seems super finicky when I do that. It seems to work if I build e.g. the SMP sample from inside the NCS folder, then build from my app folder; but if I just go straight to building my app, zephyr will complain about the SDK not being installed. Super weird.

Thanks in advance!

Parents
  • Hello,

    My question is what is the best practice for creating a customized mcuboot build?

     Have a look at the answer from my colleague Heidi here: https://devzone.nordicsemi.com/f/nordic-q-a/69344/how-to-create-a-mcuboot-image-and-an-application-image-without-modifying-the-sdk/286319#286319

    is it necessary to leave my project as a subfolder of the NCS tools folder?

     No, you can build out of tree. Have a look at "Setting up the command line build environment". For linux you need to run: 

    source zephyr/zephyr-env.sh

    Hope this helps.

    Kind regards,
    Øyvind

  • Thanks for the fast reply, I think answer #1 will help me in the near future. What I'm looking to do is add a line of code to the bootloader to hold a pin high. In the architecture I'm working with, this pin is required to be kept on through all stages of the boot process: bootloader->mcuboot->app. So I need to slightly modify the source code for the provided software (to my knowledge).

    I'm guessing the best way to maintain the portability of the project would be to keep my own copy of the bootloader that's cloned for the upstream repo, and periodically updated via rebasing. Is it possible to tell the build system where to look to build the child project?

    For answer #2, I had followed those instructions (a couple of times TBH), but I got mixed results. The only way I could get the examples to compile reliable out-of-tree was to throw everything into a docker container, but that's not an ideal solution. What's really odd is that I checked my environment variables during a successful build, and during a failed build and they were exactly the same. The error always seems to have something to do with being unable to find the SDK. But I know it's finding the cmake files since that reside in the zephyr folder.

    It also will periodically inform me that "west build" is not an option when I'm building from the app directory (see original post), even immediately after sourcing the env script. For example, here's a trimmed down version of my current environment:

    ZEPHYR_BASE=/home/user/devel/ncs/zephyr
    ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
    GNUARMEMB_TOOLCHAIN_PATH=/home/user/gnuarmemb

  • macklenc said:
    For answer #2, I had followed those instructions (a couple of times TBH), but I got mixed results.

     I've discussed the issue with one of our Linux experts. When running the command from my last comment, you need to run this in the current terminal you are working in. If you are standing in the out-of-tree folder, then it would be:

    source /home/user/devel/ncs/zephyr/zephyr.sh

    Also, you should delete the build folder in your out-of-tree folder to see if this can help to remove the issues you are seeing.

    One suggestion from our Linux expert is to add the following to your ~/.bashrc:

    export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
    export GCCARMEMB_TOOLCHAIN_PATH=/home/user/gnuarmemb
    source /home/user/devel/zephyr/zephyr-env.sh


    This way your script will be called every time you open a terminal. 

  • I added the exports you specified to my bashrc and tried swapping over to bash (I usually use zsh). But it doesn't seem to have improved anything. I went to the ncs folder and tried building the smp_svr example again using:

    west build -b nrf52dk_nrf52832 zephyr/samples/subsys/mgmt/mcumgr/smp_svr -- -DOVERLAY_CONFIG=overlay-bt-tiny.conf
    and I got this error:

    usage: west [-h] [-z ZEPHYR_BASE] [-v] [-V] <command> ...
    west: error: argument <command>: invalid choice: 'build' (choose from 'init', 'update', 'list', 'manifest', 'diff', 'status', 'forall', 'help', 'config', 'topdir', 'selfupdate')
    I'm running the above command in /home/user/devel/ncs, and ncs does have a .west folder:

    bootloader  project  mbedtls  modules  nrf  nrfxlib  smp_svr  test  tools  .west  zephyr

    Although, the .west/config file doesn't look like what I'd expect:

    [manifest]
    path = smp_svr
    file = west.yml
    
    [zephyr]
    base = zephyr

  • Try to change .west/config to the following:

    [manifest]
    path = nrf
    [zephyr]
    base = zephyr
    

    What version of west are you running?

Reply Children
Related