nRF5340: CPUNET: "Image in the secondary slot is not valid!" at BT-DFU

Hi there 

During updating nRF5340 over bluetooth, really rarely the CPUNet fails to be updated over bluetooth.

The mcuboot says: Image in the secondary slot is not valid!

But with the exact same Smartphone, bootloader on nRF5340 and dfu_application.zip, the update also works later.

What could be the reason for this and how can I debug it?

Our customer is saying that the update always fails with Google Pixel Android Version 13 nrfconnect Version 4.28.0.

I tried a Galaxy S21 (Android 12) with nRF Connect App 4.28.1, but here it is working several times.

What is even worse, is that the CPUAPP is still updated and then the bluetooth communication fails and no new update can be tried.

How can I prevent the mcuboot bootloader to update the CPUAPP when the validation of the image 1 fails?

prj.conf:

#*****************************************************************************/
#*                                Logging                                    */
#*****************************************************************************/
CONFIG_LOG=y
# TODO: Belongs this to here, or to debug.conf?
CONFIG_LOG_RUNTIME_FILTERING=y
CONFIG_LOG_DEFAULT_LEVEL=1

#*****************************************************************************/
#*                                Memory                                     */
#*****************************************************************************/
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

#*****************************************************************************/
#*                                C Standard library                         */
#*****************************************************************************/
# Use the minimal C library to reduce flash usage
# TODO: Really check if this is the smallest flash usage
CONFIG_MINIMAL_LIBC=y
# More infos: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/develop/languages/c/minimal_libc.html

#*****************************************************************************/
#*            Hardware support only for application needed, not mcuboot      */
#*****************************************************************************/
# PWM for buzzer
CONFIG_PWM=y

# I2C for MS8891 (Cap-Touch)
CONFIG_I2C=y

# ADC & SENSOR for NTC-Temp-Sensors
CONFIG_ADC=y
CONFIG_SENSOR=y

#*****************************************************************************/
#*                                Bluetooth & NUS                            */
#*****************************************************************************/
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
# Enable Dynamic name modification
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
# Set fallback anme
CONFIG_BT_DEVICE_NAME="HYG2_NA"
# Maximum character of the device name (HYG2K_ + device_name[19])
CONFIG_BT_DEVICE_NAME_MAX=25
# Enable extended advertising for longer device name 
# (don't forget to set this Config also in cpunet)
CONFIG_BT_EXT_ADV=y
# Only allow one device to connect
CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=1

# Enable the NUS service
CONFIG_BT_NUS=y

#*****************************************************************************/
#*                                 FOTA                                      */
#*****************************************************************************/
CONFIG_BOOTLOADER_MCUBOOT=y

## Configs from CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU
# Must
CONFIG_MCUMGR=y
CONFIG_NET_BUF=y
CONFIG_ZCBOR=y
CONFIG_CRC=y
CONFIG_MCUMGR_TRANSPORT_BT=y
# Needed because secondary firmware on external flash
CONFIG_STREAM_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH=y
# Impled by CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y
CONFIG_IMG_MANAGER=y
CONFIG_MCUMGR_GRP_IMG=y
CONFIG_MCUMGR_GRP_OS=y
CONFIG_MCUMGR_GRP_OS_BOOTLOADER_INFO=y
CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y
# Sets MTU-Size to 495bytes, yay!
# CONFIG_BT_MAX_CONN=1 in \child_image\multiprotocol_rpmsg.conf needed
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_VALIDATION=y
# More configs, but not set directly by CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
# Found at comparing .conf with enabled and disabled CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU
CONFIG_IMG_ERASE_PROGRESSIVELY=y
CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y
CONFIG_MCUMGR_GRP_ZBASIC=y
CONFIG_MCUMGR_GRP_ZBASIC_STORAGE_ERASE=y

CONFIG_MCUMGR_GRP_ZBASIC_LOG_LEVEL_DEFAULT=y
CONFIG_STREAM_FLASH_ERASE=y

# Enable updates for the network core
# Revert of application core is not possible anymore, because netcore can't be reverted
CONFIG_NRF53_UPGRADE_NETWORK_CORE=y
CONFIG_UPDATEABLE_IMAGE_NUMBER=2

#*****************************************************************************/
#*                                 Thread                                    */
#*****************************************************************************/
# Enable CoAP utils and CoAP protocol
#CONFIG_COAP=y
#CONFIG_COAP_UTILS=y

# Generic networking options
#CONFIG_NETWORKING=y

# L2 OpenThread enabling
#CONFIG_NET_L2_OPENTHREAD=y

# Network shell
#CONFIG_SHELL=y
#CONFIG_OPENTHREAD_SHELL=y
#CONFIG_SHELL_ARGC_MAX=26
#CONFIG_SHELL_CMD_BUFF_SIZE=416

# Network sockets
#CONFIG_NET_SOCKETS=y
#CONFIG_NET_SOCKETS_POSIX_NAMES=y
#CONFIG_NET_SOCKETS_POLL_MAX=4

# Same network Master Key for client and server
#CONFIG_OPENTHREAD_NETWORKKEY="00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff"

#CONFIG_MBEDTLS_SHA1_C=n
#CONFIG_FPU=y

#*****************************************************************************/
#*                              Persistent settings                          */
#*****************************************************************************/
CONFIG_SETTINGS=y
CONFIG_NVS=y
CONFIG_SETTINGS_NVS=y
# Enable usage of CRC over Data (needs 4 more metadata bytes)
# TODO: At 2.7.0 CONFIG_NVS_DATA_CRC=y
# Reduce store and load time
CONFIG_NVS_LOOKUP_CACHE=y
# Reduces load time of all setting by 600ms and store of all by 500ms compared to default (128)
CONFIG_NVS_LOOKUP_CACHE_SIZE=256
# 64kB for settings see in pm_static.yml
# Settings are on external flash, because external flash has more erease cycles
CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y

# Only static settings handlers are used 
CONFIG_SETTINGS_DYNAMIC_HANDLERS=n
# BT_SETTINGS need to be active, otherwise BT device name is N/A at advertisement until first connection
# BT_SETTINGS would not be needed in persistent memory, because bt_dev.name is also stored by app
# TODO: Invistigate why without BT_SETTINGS advertised device name is N/A (could safe some kBs rom)
CONFIG_BT_SETTINGS=y

child_image/mcuboot/prj.conf

#*****************************************************************************/
#*                                Source                                     */
#*****************************************************************************/
# TODO: Ask devzone nordic, if only delta is possible
# Some parts of this file were sourced from 
# ..ncs_2_6_0\bootloader\mcuboot\boot\zephyr\prj.conf

#*****************************************************************************/
#*                                Logging                                    */
#*****************************************************************************/
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y
### Ensure Zephyr logging changes don't use more resources
CONFIG_LOG_DEFAULT_LEVEL=0
### Hide boot banner
CONFIG_BOOT_BANNER=n

#*****************************************************************************/
#*                                Debugging                                  */
#*****************************************************************************/
# FIXME not for release
### Use info log level for MCUBOOT
CONFIG_MCUBOOT_LOG_LEVEL_INF=y
### Show errors, warnings and info of all modules in bootloader 
CONFIG_LOG_DEFAULT_LEVEL=3
### Show boot banner
CONFIG_BOOT_BANNER=y

#*****************************************************************************/
#*                                NCS-Defaults                               */
#*****************************************************************************/
### Protect mcuboot partition from write operations
CONFIG_FPROTECT=y

#*****************************************************************************/
#*                                Minimal footprint                          */
#*****************************************************************************/
### Decrease footprint by ~4 KB in comparison to CBPRINTF_COMPLETE=y
CONFIG_CBPRINTF_NANO=y
# Use the minimal C library to reduce flash usage
CONFIG_MINIMAL_LIBC=y

#*****************************************************************************/
#*                     Simultaenous multi-core updates                       */
#*****************************************************************************/
CONFIG_MAIN_STACK_SIZE=10240
CONFIG_BOOT_MAX_IMG_SECTORS=256
CONFIG_NRF53_MULTI_IMAGE_UPDATE=y
CONFIG_UPDATEABLE_IMAGE_NUMBER=2
CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_PCD_APP=y

# Needed so that it gets SPI-Drivers
CONFIG_MULTITHREADING=y

### Dependencies for CONFIG_NRF53_MULTI_IMAGE_UPDATE
CONFIG_FLASH=y
CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
CONFIG_FLASH_SIMULATOR_STATS=n

#*****************************************************************************/
#*                     Custom-key for boot-signature                         */
#*****************************************************************************/
# Key files see in boards folder
CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y 

SDK: v2.6.1

Smartphone: iPhone SE from IT (MX9R2ZD, iOS 16.3) with nRF Connect App 2.7.6

Related