nrf52840 bootloader questions

Hi Devzone,

I am building an application for a nrf52840 mounted on a custom board. I wanted to implement the DFU functionality, and I have a few general questions, as well as some issues implementing it.

Questions: 

  1. From what I gather, BLE DFU can only be done using MCUBoot as bootloader, am I correct ?
  2. There is a LTE module mounted on the board, communicating with the nrf52840 via UART. Is MCUBoot capable of receiving an update sent via LTE ?
  3. Since I want to be able to update the bootloader if needed, I wanted to implement a 2 stage bootloader chain. Following the instructions here: https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/config_and_build/bootloaders/bootloader_adding.html, this can be done by enabling the CONFIG_SECURE_BOOT and CONFIG_BOOTLOADER_MCUBOOT options in the app prj.conf file. From my understanding, Zephyr’s sysbuild can be used to handle multi-image builds, so it could be suited to handle the two bootloader and application images. Are there benefits to doing it one way or the other ?

Issues:

4. I first started to implement only the NSIB by adding CONFIG_SECURE_BOOT=y to my prj.conf file. Because I have no available UART to use as the console, I would like to use RTT to do the logging. This means that I have no zephyr,console defined in the chosen node of my board dts file, which leads to some errors, because the UART console seems to be enabled by default by the NSIB. I tried to disable the UART console by creating a child_image/b0.conf file:

CONFIG_UART_CONSOLE=n

However I get the following warning and errors:

warning: CONSOLE (defined at drivers/console/Kconfig:9) was assigned the value 'n' but got the value
'y'. See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_CONSOLE and/or look up CONSOLE in
the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration
Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too.


warning: UART_CONSOLE (defined at drivers/console/Kconfig:43) was assigned the value 'n' but got the
value 'y'. See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_UART_CONSOLE and/or look up
UART_CONSOLE in the menuconfig/guiconfig interface. The Application Development Primer, Setting
Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
too.

In file included from /home/vboxuser/Documents/eqs-motion-s-zephyr/zephyr/include/zephyr/toolchain/gcc.h:98,
                 from /home/vboxuser/Documents/eqs-motion-s-zephyr/zephyr/include/zephyr/toolchain.h:50,
                 from /home/vboxuser/Documents/eqs-motion-s-zephyr/zephyr/include/zephyr/kernel_includes.h:23,
                 from /home/vboxuser/Documents/eqs-motion-s-zephyr/zephyr/include/zephyr/kernel.h:17,
                 from /home/vboxuser/Documents/eqs-motion-s-zephyr/zephyr/drivers/console/uart_console.c:16:
/home/vboxuser/Documents/eqs-motion-s-zephyr/zephyr/include/zephyr/device.h:89:41: error: '__device_dts_ord_DT_CHOSEN_zephyr_console_ORD' undeclared here (not in a function)
   89 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
      |                                         ^~~~~~~~~
/home/vboxuser/Documents/eqs-motion-s-zephyr/zephyr/include/zephyr/toolchain/common.h:137:26: note: in definition of macro '_DO_CONCAT'
  137 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/home/vboxuser/Documents/eqs-motion-s-zephyr/zephyr/include/zephyr/device.h:89:33: note: in expansion of macro '_CONCAT'
   89 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
      |                                 ^~~~~~~
/home/vboxuser/Documents/eqs-motion-s-zephyr/zephyr/include/zephyr/device.h:216:37: note: in expansion of macro 'DEVICE_NAME_GET'
  216 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
      |                                     ^~~~~~~~~~~~~~~
/home/vboxuser/Documents/eqs-motion-s-zephyr/zephyr/include/zephyr/device.h:233:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
  233 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
      |                                  ^~~~~~~~~~~~~~~~~~
/home/vboxuser/Documents/eqs-motion-s-zephyr/zephyr/drivers/console/uart_console.c:40:9: note: in expansion of macro 'DEVICE_DT_GET'
   40 |         DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
      |         ^~~~~~~~~~~~~
[105/139] Linking C static library modules/nrf/drivers/hw_cc3xx/lib..__nrf__drivers__hw_cc3xx.a
[106/139] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/nrfx_glue.c.obj
ninja: build stopped: subcommand failed.
[146/402] Linking C static library zephyr/subsys/bluetooth/common/libsubsys__bluetooth__common.a
FAILED: modules/nrf/samples/b0_subimage-prefix/src/b0_subimage-stamp/b0_subimage-build b0/zephyr/zephyr.hex b0/zephyr/zephyr.elf 
cd /home/vboxuser/Documents/eqs-motion-s-zephyr/eqs-motion-s-zephyr.git/app/build/b0 && /home/vboxuser/ncs/toolchains/7795df4459/usr/local/bin/cmake --build . --
[148/402] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/long_wq.c.obj
[149/402] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/data.c.obj
ninja: build stopped: subcommand failed.

Is there a way to disable the uart console and enable the RTT logs on the NSIB bootloader ?

Alternatively, can I send the bootloader logs to a USB connection ? I tried to get some inspiration from the USB console sample, but to no avail.

5. Also, when I compile my application without the bootloader, I get the following memory report at the end:

When I compile using the NSIB, I get the following two:

I imagine the first one refers to the NSIB, and the second one to my application. The application Flash region size in this case is much smaller than when compiling without the bootloader. I imagine it is used by the bootloader ? Is there a way to configure the size available for my program, and if so, what are the best practices with respect to sizes when using a single or 2 stage bootloader ?

6. In order to go a little further, I used a temporary uart as the chosen zephyr,console node. Doing this I could compile and flash my application, and it works fine. I then tried to add MCU Boot as the upgradable bootloader by adding CONFIG_BOOTLOADER_MCUBOOT=y in my prj.conf. This time, I I get the following error:

/home/vboxuser/ncs/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj):(.rodata.spi_nor_config_0+0x0): undefined reference to `__device_dts_ord_124'

However, if I go to check the generated devicetree file, device n°124 corresponds to a spi node that otherwise works in my standalone application.

Do you have any pointers on what I can look into to solve this issue ?

Thanks in advance.

Nicolas Goualard

Related