Hi fellas,
First of all sorry for the long post but I'm stuck for quite some time now and I need your help. I guess better provide more info than less.
I am working with a custom board which is very-very similar to the evaluation kit using the nRF5340.
The image I currently have is quite hefty around 500K.
So using the MCU boot loader with dual banks is not feasible. Also we would like to use the remaining flash for other actions.
I have been reading all around the net for a possible solution.
There must be something that I am missing, mostly concerning the conf file
SDK nRF Connect 1.9.1
My starting point is the smp sample.
I have tried it with simple smaller applications using both newtmgr and mcumgr and they work perfectly fine.
I am able to list, upload, confirm and finally erase unwanted slots.
All previously described actions have been done using ACM0 (usb-serial), using the cdc-overlay.
Default overlays:
proj.conf
# Enable mcumgr. CONFIG_MCUMGR=y # Some command handlers require a large stack. CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304 CONFIG_MAIN_STACK_SIZE=2048 # Ensure an MCUboot-compatible binary is generated. CONFIG_BOOTLOADER_MCUBOOT=y # Enable flash operations. CONFIG_FLASH=y # Required by the `taskstat` command. CONFIG_THREAD_MONITOR=y # Support for taskstat command CONFIG_OS_MGMT_TASKSTAT=y # Enable statistics and statistic names. CONFIG_STATS=y CONFIG_STATS_NAMES=y # Enable most core commands. CONFIG_MCUMGR_CMD_IMG_MGMT=y CONFIG_MCUMGR_CMD_OS_MGMT=y CONFIG_MCUMGR_CMD_STAT_MGMT=y # Enable logging CONFIG_LOG=y CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y
cdc-overlay.conf
# Enable USB subsystem CONFIG_USB_DEVICE_STACK=y CONFIG_SERIAL=y CONFIG_UART_LINE_CTRL=y # USB backend is serial device CONFIG_MCUMGR_SMP_UART=y
I created an overlay (nrf5340dk_nrf5340_cpuapp.overlay)
/delete-node/ &boot_partition; /delete-node/ &slot0_partition; &flash0 { /* * For more information, see: * https://docs.zephyrproject.org/latest/guides/dts/legacy-macros.html#legacy-flash-partitions */ partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { label = "mcuboot"; reg = <0x00000000 0x10000>; }; slot0_partition: partition@10000 { label = "image-0"; reg = <0x00010000 0xF0000>; }; }; }; / { chosen { zephyr,code-partition = &slot0_partition; zephyr,flash = &flash0; }; };
giving 65KB to the bootloader and the rest (1MB-65KB) for the application
I also declared
CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000 CONFIG_SINGLE_APPLICATION_SLOT=y
inside
\ncs\v1.9.1\bootloader\mcuboot\boot\zephyr\prj.conf
I know that the last one might not be elegant or approved and maybe I should've used KConfig for that
While compiling I get the following:
In file included from C:\***\v1.9.1\zephyr\include\storage\flash_map.h:260, from C:\***\v1.9.1\zephyr\subsys\mgmt\mcumgr\lib\cmd\img_mgmt\src\zephyr_img_mgmt.c:14: C:/Users/dnin/ncs/v1.9.1/zephyr/subsys/mgmt/mcumgr/lib/cmd/img_mgmt/src/zephyr_img_mgmt.c: In function 'zephyr_img_mgmt_flash_area_id': C:\***\v1.9.1\nrf\include\flash_map_pm.h:30:22: error: 'PM_mcuboot_secondary_ID' undeclared (first use in this function); did you mean 'PM_mcuboot_primary_ID'? 30 | #define PM_ID(label) PM_##label##_ID | ^~~ C:\***\v1.9.1\nrf\include\flash_map_pm.h:35:30: note: in expansion of macro 'PM_ID' 35 | #define FLASH_AREA_ID(label) PM_ID(label) | ^~~~~ C:\***\v1.9.1\zephyr\subsys\mgmt\mcumgr\lib\cmd\img_mgmt\src\zephyr_img_mgmt.c:120:11: note: in expansion of macro 'FLASH_AREA_ID' 120 | fa_id = FLASH_AREA_ID(image_1); | ^~~~~~~~~~~~~ C:\***\v1.9.1\nrf\include\flash_map_pm.h:30:22: note: each undeclared identifier is reported only once for each function it appears in 30 | #define PM_ID(label) PM_##label##_ID | ^~~ C:\***\v1.9.1\nrf\include\flash_map_pm.h:35:30: note: in expansion of macro 'PM_ID' 35 | #define FLASH_AREA_ID(label) PM_ID(label) | ^~~~~ C:\***\v1.9.1\zephyr\subsys\mgmt\mcumgr\lib\cmd\img_mgmt\src\zephyr_img_mgmt.c:120:11: note: in expansion of macro 'FLASH_AREA_ID' 120 | fa_id = FLASH_AREA_ID(image_1); | ^~~~~~~~~~~~~ [74/226] Building C object zephyr/soc/arm/common/cortex_m/CMakeFiles/soc__arm__common__cortex_m.dir/arm_mpu_regions.c.obj ninja: build stopped: subcommand failed. FATAL ERROR: command exited with status 1: 'c:\***\v1.9.1\toolchain\opt\bin\cmake.EXE' --build 'c:\Users\dnin\wrks\smp_svr_9\build'
From what I can understand it's looking for "image-1" which he is not finding.
When I remove
CONFIG_SINGLE_APPLICATION_SLOT=y
it works and compiles fine. Then again I don't have enough space to use the dual slots.
It all boils up to these questions:
- Am looking at this the wrong way?
- Do I need to provide a mapping of the memory (from what I've seen around probably yes)
- Are there any configurations options that I can add inside proj.conf to solve this issue
If you need any other information which I did not include please feel free to ask for them.