-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mcumgr: fail to upgrade nRF target using nRF Connect #24706
Comments
cc @philips77 |
@nvlsianpu and @de-nordic could you please comment on what the root cause might be? |
@carlescufi Image size is not page aligned (most of the time). However it is passed directly to flash_erase() API in which it fails, because nRF SoC flash driver treats such request as invalid. The reason why it stopped working (and obviously it was working some time ago) is most probably (I didn't check that, but I am pretty sure) related to mcumgr updates that were made recently. The real question is: on which layer should that issue be solved and how? In other words: where should unaligned new image size be rounded up to next page boundary? Possible answers: mcumgr, flash area/map API, flash driver and maybe some more candidates in between. |
@mniestroj - thanks for this description. I'm going to investigate and fix that. |
@mniestroj Your diagnose is proper. This looks like not well implemented feature (and zephyr shim layer as well which is the issue root). Looks like image status are is never erased as well. Preparing the patch. |
@nvlsianpu will you address this in time for 2.3? |
@carlescufi Yes, fix is almost ready: zephyrproject-rtos/mcumgr#22 |
fixes zephyrproject-rtos#24706 Fixed issue of possible try to erase non page aligned size of flash while serving image write command. The new version has this bug fixed. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
fixes #24706 Fixed issue of possible try to erase non page aligned size of flash while serving image write command. The new version has this bug fixed. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
fixes zephyrproject-rtos#24706 Fixed issue of possible try to erase non page aligned size of flash while serving image write command. The new version has this bug fixed. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Describe the bug
First of all, this is not nRF Connect fault, it is just possible to reproduce bug using this application. nRF Connect application fails to upgrade when there are two image slots already filled in Zephyr. It just goes back to "connected device tab" very quickly, with no popup.
There is no such problem when using
mcumgr
console application. They however differ in commands that they execute within mcumgr SMP protocol.mcumgr
application sends "image erase" first, then continues with "image upload" requests. nRF connect does NOT send "image erase". In theory (based on the mcumgr/smp implementation) sending "image upload" as the first command should work as well, because erase should be done implicitly. In fact mcumgr in Zephyr tries to do that.size
argument passed toflash_erase()
function is the size of image that is going to be uploaded. This fails with -EINVAL, becausesoc_flash_nrf.c
expects size to be page aligned. So here is the reason whymcumgr
console application succeeds: explicit "image erase" mcumgr/smp command results in erase of the whole slot, which is obviously page aligned.One possible workaround so far is to enable
CONFIG_IMG_ERASE_PROGRESSIVELY=y
, so implicit flash erase operations are done one sector at a time (with proper page alignment).A clear and concise description of what the bug is.
What have you tried to diagnose or workaround this issue?
To Reproduce
Steps to reproduce the behavior:
mcumgr <...> image upload
command (or just make sure there is somethin detected on second slot when doingmcumgr <...> image list
)Expected behavior
New application image should be transfered over BT and then booted after waiting some additional time (few seconds).
In the implementation: most likely mcumgr code should "ceil" image size, so flash erase request to flash drivers is sent with page aligned size.
Impact
On a "fresh" target (when there is only one image slot filled) it is only possible to upgrade firmware only once. Any further attempt using nRF Connect application fails.
Screenshots or console output
No logs are printed, because mcumgr implementation is very quiet, when handling errors.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: