Fota anomaly based on Ncs 1.9.0 sdk

I developed a product for the customer with 9160. It used to run on the sdk of ncs1.2.0, and its fota function is normal; Now I have upgraded the sdk to ncs1.9.0, and found that the fota function is abnormal. The device can connect to the background and download apps normally_ update. The bin data is written to the img. After the writing, the device is restarted, but the device still runs the old firmware instead of the new one. Why? This is my prj.con and logs show:

#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#
# General config
CONFIG_FPU=y
CONFIG_NRF_MODEM_LIB=y
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_ASSERT=y
CONFIG_REBOOT=y
CONFIG_GPIO=y
CONFIG_TRUSTED_EXECUTION_NONSECURE=y
CONFIG_NEWLIB_LIBC_NANO=n
CONFIG_STDOUT_CONSOLE=y

# Log
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_DEFAULT_LEVEL=4
CONFIG_LOG_MODE_OVERFLOW=y
CONFIG_LOG_BACKEND_RTT_MODE_DROP=y
CONFIG_LOG_BACKEND_SHOW_COLOR=n
CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP=n

# watch dog
CONFIG_WATCHDOG=y
CONFIG_WATCHDOG_TIMEOUT_MSEC=10000

# Modem info
CONFIG_MODEM_INFO=y

# BSD library
#CONFIG_BSD_LIBRARY=y
#CONFIG_BSD_LIBRARY_TRACE_ENABLED=n

# NVS
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_NVS=y
CONFIG_NVS_LOG_LEVEL_DBG=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

# GPS
# Enable to use an external GNSS antenna
CONFIG_GNSS_SAMPLE_ANTENNA_EXTERNAL=y
# Enable to use nRF Cloud A-GPS
CONFIG_GNSS_SAMPLE_ASSISTANCE_NRF_CLOUD=n
# Secure User-Plane Location (SUPL) client library (https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/others/supl_os_client.html)
CONFIG_GNSS_SAMPLE_ASSISTANCE_SUPL=y

# AT_CMD
#CONFIG_AT_HOST_LIBRARY=y
#CONFIG_UART_INTERRUPT_DRIVEN=y

# Console
CONFIG_CONSOLE_SUBSYS=n
CONFIG_CONSOLE_HANDLER=n
CONFIG_CONSOLE_GETCHAR=n
CONFIG_CONSOLE=n
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=n

# Enable SUPL client support AGPS
CONFIG_SUPL_CLIENT_LIB=n

# Network
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_SOCKOPT_TLS=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
CONFIG_LTE_NETWORK_USE_FALLBACK=y
CONFIG_LTE_NETWORK_TIMEOUT=60
CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=n
CONFIG_LTE_NETWORK_MODE_NBIOT_GPS=y
#CONFIG_LTE_LEGACY_PCO_MODE=y

# PSM
CONFIG_MODEM_AUTO_REQUEST_POWER_SAVING_FEATURES=y
# Set Periodic-TAU timer to 1 hour and Active-Time to 10 seconds.
CONFIG_LTE_PSM_REQ_RPTAU="01000110"
CONFIG_LTE_PSM_REQ_RAT="00000101"

# MQTT
CONFIG_MQTT_LIB=y
CONFIG_MQTT_LIB_TLS=n
CONFIG_MQTT_KEEPALIVE=300
CONFIG_MQTT_PUB_TOPIC="device/e2/pushdata"
CONFIG_MQTT_SUB_TOPIC="device/e2/"
CONFIG_MQTT_CLIENT_ID="my-client-id"
CONFIG_MQTT_USER_NAME="admin123"
CONFIG_MQTT_PASSWORD="admin123"
CONFIG_MQTT_DOMESTIC_BROKER_HOSTNAME="47.107.51.89"
CONFIG_MQTT_DOMESTIC_BROKER_PORT=1883
CONFIG_MQTT_FOREIGN_BROKER_HOSTNAME="18.135.53.53"
CONFIG_MQTT_FOREIGN_BROKER_PORT=1883

# Library for buttons and LEDs
CONFIG_DK_LIBRARY=y
CONFIG_DK_LIBRARY_INVERT_LEDS=n

# Heap and stacks
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_HW_STACK_PROTECTION=y

# SPI
CONFIG_SPI=y

# I2C
CONFIG_I2C=y

# UART
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y

# ANIMATION
CONFIG_ANIMATION_SUPPORT=y

# PPG
CONFIG_PPG_SUPPORT=y

# IMU
CONFIG_IMU_SUPPORT=y
CONFIG_STEP_SUPPORT=n
CONFIG_SLEEP_SUPPORT=n
CONFIG_FALL_DETECT_SUPPORT=n

# WIFI
CONFIG_WIFI=n

# TP
CONFIG_TOUCH_SUPPORT=y

# AUDIO
CONFIG_AUDIO_SUPPORT=n

# Data Sync
CONFIG_SYNC_SUPPORT=y

# Temperature
CONFIG_TEMP_SUPPORT=y

# CRC Check
CONFIG_CRC_SUPPORT=y

# DEVICE POWER MANAGEMENT
CONFIG_PM_DEVICE=y

# Download client
CONFIG_DOWNLOAD_CLIENT=y
CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096

# DATA UPDATE
CONFIG_DATA_DOWNLOAD_SUPPORT=n
CONFIG_DATA_DOWNLOAD_HOST_HK="aug-fm-files-hk.oss-cn-hongkong.aliyuncs.com"
CONFIG_DATA_DOWNLOAD_HOST_CN="aug-fm-files-cn.oss-cn-shenzhen.aliyuncs.com"
# IMG
CONFIG_IMG_DATA_UPDATE=y
CONFIG_IMG_DATA_DOWNLOAD_FILE="e2_img.bin"
# FONT
CONFIG_FONT_DATA_UPDATE=y
CONFIG_FONT_DATA_DOWNLOAD_FILE="e2_font.bin"
# PPG
CONFIG_PPG_DATA_UPDATE=y
CONFIG_PPG_DATA_DOWNLOAD_FILE="e2_ppg.bin"

# fota download
CONFIG_FOTA_DOWNLOAD=y
CONFIG_FOTA_DOWNLOAD_PROGRESS_EVT=y
CONFIG_FOTA_DOWNLOAD_HOST_HK="aug-fm-files-hk.oss-cn-hongkong.aliyuncs.com"
CONFIG_FOTA_DOWNLOAD_HOST_CN="aug-fm-files-cn.oss-cn-shenzhen.aliyuncs.com"
CONFIG_FOTA_DOWNLOAD_FILE="e2_update.bin"

# Image manager
CONFIG_IMG_MANAGER=y
CONFIG_FLASH=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

# DFU Target
CONFIG_DFU_TARGET=y

# Modem key management
CONFIG_MODEM_KEY_MGMT=y

# Application Upgrade support
CONFIG_BOOTLOADER_MCUBOOT=y

00> [18605369] <inf> download_client: Downloaded 442368/443887 bytes (99%)
00> [18606133] <inf> E2: [10:35:55:813]..fota_dl_handler>>Received progress:99
00> 
00> [18644803] <inf> download_client: Downloaded 443887/443887 bytes (100%)
00> [18654254] <inf> E2: [10:35:57:282]..fota_dl_handler>>Received progress:100
00> 
00> [18654264] <inf> download_client: Download complete
00> [18686654] <inf> dfu_target_mcuboot: MCUBoot image upgrade scheduled. Reset device to apply
00> [18686687] <inf> E2: [10:35:58:272]..fota_dl_handler>>Received finished!
00> 
00> 
00> [00022995] <inf> E2: [00:00:00:701]..fota_init>>begin
00> 
00> [00023007] <inf> E2: [00:00:00:702]..fota_init>>default error:0
00> 
00> [00023019] <inf> E2: [00:00:00:702]..fota_init>>Initialized bsdlib
00> 
00> [00023034] <inf> E2: [00:00:00:702]..fota_init>>boot_write_img_confirmed:0
00> 
00> [00023047] <inf> E2: [00:00:00:703]..fota_init>>done
00> 
00> [00023057] <dbg> fs_nvs.nvs_recover_last_ate: Recovering last ate from sector 2
00> [00023167] <inf> fs_nvs: 6 Sectors of 4096 bytes
00> [00023176] <inf> fs_nvs: alloc wra: 2, 8a0
00> [00023184] <inf> fs_nvs: data wra: 2, 748

Parents Reply Children
  • Thanks for your reply. My current operation is to create an app on ncs1.9.0_ update. Bin, and then modified the interface to compile and burn it to the device. That is to say, when testing, the old firmware of the device and the new firmware of FOTA are compiled on ncs1.9.0, which should have nothing to do with slot partitions. Later, I found out that if Add CONFIG to conf_ BSD_ LIBRARY_ SYS_ INIT=n, after compiling and burning, my device will switch to the new firmware that was fota last time after it is powered on again, but it cannot operate the modem. It is strange whether the modem is turned on or off. By the way, the firmware version of my modem is v1.3.1.

  • What SDK version are you building the app with now? I read it as being 1.9.0, but this version does not define the CONFIG_BSD_LIBRARY_SYS_INIT symbol (BSD lib was renamed to modem lib in v1.5.0), so I don't understand how you can still use this symbol and build your project.

  • Sorry, I made a mistake. It is the CONFIG_NRF_MODEM_ IB_SYS_INIT.

  • OK, thanks for confirming. Could you try to initialize the modem library yourself from main(),etc and see if it works then (i.e. both DFU and modem lib).

  • OK.This is my initialization code:

    void work_init(void)
    {
    	k_work_q_start(&nb_work_q, nb_stack_area,
    					K_THREAD_STACK_SIZEOF(nb_stack_area),
    					CONFIG_APPLICATION_WORKQUEUE_PRIORITY);
    #ifdef CONFIG_IMU_SUPPORT	
    	k_work_q_start(&imu_work_q, imu_stack_area,
    					K_THREAD_STACK_SIZEOF(imu_stack_area),
    					CONFIG_APPLICATION_WORKQUEUE_PRIORITY);
    #endif
    	
    	if(IS_ENABLED(CONFIG_WATCHDOG))
    	{
    		watchdog_init_and_start(&k_sys_work_q);
    	}
    }
    
    static int application_init(void)
    {
    	int err;
    
    	err = fota_download_init(fota_dl_handler);
    	if(err != 0)
    	{
    		return err;
    	}
    
    	return 0;
    }
    
    void fota_init(void)
    {
    	int err;
    
    #ifdef FOTA_DEBUG
    	LOGD("begin");
    #endif
    
    #if 0
    	nrf_modem_lib_init(NORMAL_MODE);
    #else
    	err = nrf_modem_lib_get_init_ret();
    	switch(err)
    	{
    	case 0:
    		/* Initialization successful, no action required. */
    	#ifdef FOTA_DEBUG
    		LOGD("Initialization successful");
    	#endif		
    		break;
    
    	case MODEM_DFU_RESULT_OK:
    	#ifdef FOTA_DEBUG	
    		LOGD("Modem firmware update successful!");
    		LOGD("Modem will run the new firmware after reboot");
    	#endif
    		k_thread_suspend(k_current_get());
    		break;
    		
    	case MODEM_DFU_RESULT_UUID_ERROR:
    	case MODEM_DFU_RESULT_AUTH_ERROR:
    	#ifdef FOTA_DEBUG
    		LOGD("Modem firmware update failed");
    		LOGD("Modem will run non-updated firmware on reboot.");
    	#endif
    		break;
    		
    	case MODEM_DFU_RESULT_HARDWARE_ERROR:
    	case MODEM_DFU_RESULT_INTERNAL_ERROR:
    	#ifdef FOTA_DEBUG
    		LOGD("Modem firmware update failed");
    		LOGD("Fatal error.");
    	#endif
    		break;
    		
    	default:
    		break;
    	}
    #endif
    
    	boot_write_img_confirmed();
    
    	err = application_init();
    	if(err != 0)
    	{
    		return;
    	}
    
    #ifdef FOTA_DEBUG
    	LOGD("done");
    #endif
    }
    
    void system_init(void)
    {
    	k_sleep(K_MSEC(500));//xb test 2022-03-11 启动时候延迟0.5S,等待其他外设完全启动
    	
    #ifdef CONFIG_FOTA_DOWNLOAD
    	fota_init();
    #endif
    
    	InitSystemSettings();
    
    	init_imu_int1();//xb add 2022-05-27
    	PPG_i2c_off();
    	
    	pmu_init();
    	flash_init();
    	LCD_Init();
    	
    	ShowBootUpLogo();
    
    	key_init();
    #ifdef CONFIG_AUDIO_SUPPORT	
    	audio_init();
    #endif
    	ble_init();
    #ifdef CONFIG_PPG_SUPPORT	
    	PPG_init();
    #endif
    #ifdef CONFIG_IMU_SUPPORT
    	IMU_init(&imu_work_q);
    #endif
    #ifdef CONFIG_TEMP_SUPPORT
    	temp_init();
    #endif
    #ifdef CONFIG_DATA_DOWNLOAD_SUPPORT
    	dl_init();
    #endif
    	NB_init(&nb_work_q);
    	GPS_init();
    }
    
    int main(void)
    {
    	work_init();
    	system_init();
    
    	while(1)
    	{
    		KeyMsgProcess();
    		TimeMsgProcess();
    		NBMsgProcess();
    	#ifdef CONFIG_WIFI	
    		WifiProcess();
    	#endif
    		GPSMsgProcess();
    		PMUMsgProcess();
    	#ifdef CONFIG_IMU_SUPPORT	
    		IMUMsgProcess();
    	#ifdef CONFIG_FALL_DETECT_SUPPORT
    		FallMsgProcess();
    	#endif
    	#endif
    	#ifdef CONFIG_PPG_SUPPORT	
    		PPGMsgProcess();
    	#endif
    		LCDMsgProcess();
    	#ifdef CONFIG_TOUCH_SUPPORT
    		TPMsgProcess();
    	#endif
    		AlarmMsgProcess();
    		SettingsMsgPorcess();
    		SOSMsgProc();
    		UartMsgProc();
    	#ifdef CONFIG_ANIMATION_SUPPORT
    		AnimaMsgProcess();
    	#endif		
    		ScreenMsgProcess();
    	#ifdef CONFIG_DATA_DOWNLOAD_SUPPORT
    		DlMsgProc();
    	#endif
    	#ifdef CONFIG_FOTA_DOWNLOAD
    		FotaMsgProc();
    	#endif
    	#ifdef CONFIG_AUDIO_SUPPORT
    		AudioMsgProcess();
    	#endif
    	#ifdef CONFIG_SYNC_SUPPORT
    		SyncMsgProcess();
    	#endif
    	#ifdef CONFIG_TEMP_SUPPORT
    		TempMsgProcess();
    	#endif
    		system_init_completed();
    		k_cpu_idle();
    	}
    }
    

Related