Hello,
I need to make the OTA DFU work and I followed the instructions here:
https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/README.html#smp-svr
In some situations I'm getting this error: "W: Not enough free space to run swap upgrade"
Environment:
- nRF52 development kit (PCA10040)
- nRF Connect SDK nRF Connect SDK v2.7.0-5cb85570ca43
- Zephyr OS v3.6.99-100befc70c74
- MCUboot v2.1.0-dev-daf2946a0f07
This is how I'm testing this:
- I have a simple application that blinks LED1, advertises a custom BLE service and implements the SMP server. Let's call that "app1".
- Another slightly different version of the application above that blinks LED2 instead. Let's call that "app2".
I enable McuBoot, flash the board with the merged firmware and I'm able to use nRF Connect App and Device Manager App to do DFU ota. I can easily update from app1 to app2 and vice versa.
When I add CONFIG_SHELL=y, I can get a nice shell command over uart port (let's call this "app3"). The problem is, this image gets bigger, and when I try to do DFU OTA with it, I get this message:
I: Starting swap using move algorithm. W: Not enough free space to run swap upgrade W: required 192512 bytes but only 188416 are available
which is understandable as there's no space to do the swap.
The scenario now is the following. App3 failed to update and App1 is still running as it should. But when I try to upload app2 (same smaller image from before, no shell enabled),
I keep getting the same error message and cannot upload anything else because the App3 is still there in flash filling the memory.
Questions:
1 - If there's no space to swap, why the bootloader lets the upload to start? How to prevent that?
2 - If an image fails to upload completely for any reason, how to erase it from flash so it does not block future updates?
3 - If this is something related to a specific NCS/Zephyr/MCUboot version, could you point an older version that doesn't show this issue?
Thank you!
More information:
B0 compilation: Memory region Used Size Region Size %age Used FLASH: 22648 B 28 KB 78.99% RAM: 5576 B 64 KB 8.51% IDT_LIST: 0 GB 32 KB 0.00% MCUBoot compilation: Memory region Used Size Region Size %age Used FLASH: 34720 B 48 KB 70.64% RAM: 25920 B 64 KB 39.55% IDT_LIST: 0 GB 32 KB 0.00% Apllication compilation (CONFIG_SHELL=n): Memory region Used Size Region Size %age Used FLASH: 162084 B 192000 B 84.42% RAM: 49528 B 64 KB 75.57% IDT_LIST: 0 GB 32 KB 0.00% Apllication compilation (CONFIG_SHELL=y): Memory region Used Size Region Size %age Used FLASH: 186416 B 192000 B 97.09% RAM: 54264 B 64 KB 82.80% IDT_LIST: 0 GB 32 KB 0.00%
west build -t partition_manager_report flash_primary (0x80000 - 512kB): +--------------------------------------------------+ +---0x0: b0_container (0x8000 - 32kB)--------------+ | 0x0: b0 (0x7000 - 28kB) | | 0x7000: provision (0x1000 - 4kB) | +---0x8000: s0 (0xc200 - 48kB)---------------------+ | 0x8000: s0_pad (0x200 - 512B) | +---0x8200: s0_image (0xc000 - 48kB)---------------+ | 0x8200: mcuboot (0xc000 - 48kB) | +--------------------------------------------------+ | 0x14200: EMPTY_0 (0xe00 - 3kB) | +---0x15000: s1 (0xc200 - 48kB)--------------------+ | 0x15000: s1_pad (0x200 - 512B) | | 0x15200: s1_image (0xc000 - 48kB) | +--------------------------------------------------+ | 0x21200: EMPTY_1 (0xe00 - 3kB) | +---0x22000: mcuboot_primary (0x2f000 - 188kB)-----+ | 0x22000: mcuboot_pad (0x200 - 512B) | +---0x22200: app_image (0x2ee00 - 187kB)-----------+ +---0x22200: mcuboot_primary_app (0x2ee00 - 187kB)-+ | 0x22200: app (0x2ee00 - 187kB) | +--------------------------------------------------+ | 0x51000: mcuboot_secondary (0x2f000 - 188kB) | +--------------------------------------------------+ sram_primary (0x10000 - 64kB): +-------------------------------------------+ | 0x20000000: sram_primary (0x10000 - 64kB) | +-------------------------------------------+