Provisioning Certificates Kills GNSS in the asset tracker v2

Hi There. 

I'm using the Asset Trackerv2 as a base for my application. 

If I provision certificates at boot pior to enabling the LTE connection. the GNSS is never enabled. 

*** Booting Zephyr OS build v3.1.99-ncs1 ***
[00:00:00.483,428] <err> i2c_nrfx_twim: Error 0x0BAE0001 occurred for message 0
[00:00:00.483,489] <err> board_secure: Could not set buck to 1.8 V, error: -5

[00:00:00.483,489] <err> board_secure: power_mgmt_init failed with error: -5
[00:00:00.491,180] <err> ADXL362: wrong part_id: 255

[00:00:00.491,333] <err> ADXL372: failed to read id (0xFF:0xFF)
[00:00:00.491,455] <err> i2c_nrfx_twim: Error 0x0BAE0001 occurred for message 0
[00:00:00.492,919] <inf> lis2dh: fs=2, odr=0x4 lp_en=0x0 scale=9576
[00:00:00.497,131] <inf> at_host: UART check failed: 12. Dropping buffer and retrying.
[00:00:00.507,324] <dbg> watchdog: watchdog_timeout_install: Watchdog timeout installed. Timeout: 60
[00:00:00.507,354] <dbg> watchdog: watchdog_start: Watchdog started
[00:00:00.507,385] <dbg> watchdog: watchdog_feed_enable: Watchdog feed enabled. Timeout: 30000
[00:00:00.507,568] <inf> opito: Provisioning certificates                                                                               <-----------------HERE 
[00:00:00.599,884] <dbg> cloud_module: state_set: State: STATE_LTE_INIT
[00:00:00.599,914] <dbg> cloud_module: sub_state_set: Sub state: SUB_STATE_CLOUD_DISCONNECTED
[00:00:00.600,006] <dbg> data_module: state_set: State: STATE_CLOUD_DISCONNECTED
[00:00:00.600,433] <dbg> data_module: config_settings_handler: Device configuration loaded from flash
[00:00:00.600,463] <dbg> settings: settings_call_set_handler: set-value OK. key: data_module/config
[00:00:00.600,555] <dbg> date_time: date_time_core_register_handler: Registering handler 0x44737
[00:00:00.600,646] <dbg> modem_module: state_set: State transition STATE_INIT --> STATE_DISCONNECTED
[00:00:00.601,226] <dbg> gnss_module: state_set: State transition STATE_INIT --> STATE_RUNNING   <------------------------HERE
[00:00:00.601,470] <dbg> sensor_module: state_set: State: STATE_INIT
[00:00:00.601,501] <err> ext_sensors: Temperature sensor device is not ready
[00:00:00.601,501] <err> sensor_module: EXT_SENSOR_EVT_TEMPERATURE_ERROR
[00:00:00.601,531] <err> ext_sensors: Humidity sensor device is not ready
[00:00:00.601,562] <err> sensor_module: EXT_SENSOR_EVT_HUMIDITY_ERROR
[00:00:00.601,562] <err> ext_sensors: Pressure sensor device is not ready
[00:00:00.601,593] <err> sensor_module: EXT_SENSOR_EVT_PRESSURE_ERROR
[00:00:00.601,593] <err> ext_sensors: Low-power accelerometer device is not ready
[00:00:00.601,623] <err> sensor_module: EXT_SENSOR_EVT_ACCELEROMETER_ERROR
[00:00:00.601,715] <dbg> cloud_module: state_set: State transition STATE_LTE_INIT --> STATE_LTE_DISCONNECTED
[00:00:00.764,343] <inf> app_event_manager: APP_EVT_START
[00:00:00.764,434] <dbg> gnss_module: state_set: State transition STATE_RUNNING --> STATE_INIT                    <-------------------DEFINITELY HERE
[00:00:00.764,526] <dbg> ui_module: state_set: State transition STATE_INIT --> STATE_RUNNING
[00:00:00.764,556] <dbg> ui_module: sub_state_set: Sub state: SUB_STATE_ACTIVE
[00:00:00.764,556] <dbg> ui_module: sub_sub_state_set: Sub state: SUB_SUB_STATE_GNSS_INACTIVE

I've definitely tracked it to provisioning certificates - after hours of work. 

The function call is standard 

#if defined(CONFIG_MQTT_LIB_TLS)
static int certificates_provision(void){
    int err = 0;

    LOG_INF("Provisioning certificates");

#if defined(CONFIG_NRF_MODEM_LIB) && defined(CONFIG_MODEM_KEY_MGMT)

    //err = modem_key_mgmt_write(CONFIG_MQTT_TLS_SEC_TAG,
    err = modem_key_mgmt_write(24,
                   MODEM_KEY_MGMT_CRED_TYPE_CA_CHAIN,
                   ca_certificate,
                   strlen(ca_certificate));
    if (err) {
        LOG_ERR("Failed to provision CA certificate: %d", err);
        return err;
    }
#endif  
    return err;
}
#endif /* defined(CONFIG_MQTT_LIB_TLS) */

Any ideas? 

Thanks 

Marshall

Parents
  • Hello Marshall,

    Could you provide me the .conf file your are using? And could you run CEREG for me?

    Regards,

    Elfving

  • Hi Elfving - here is the complete prj.conf

    at+cereg? = +CEREG: 0,1,"A680","00054B02",7

    at+cereg=? = +CEREG: (0,1,2)

    I also have the aws.conf and the debug.conf as fragments in the build (these are unchanged) 

    #
    # Copyright (c) 2021 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # General config
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    CONFIG_ASSERT=y
    CONFIG_REBOOT=y
    CONFIG_FPU=y
    
    # Heap and stacks
    CONFIG_HEAP_MEM_POOL_SIZE=47250
    CONFIG_MAIN_STACK_SIZE=1408
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    CONFIG_HW_STACK_PROTECTION=y
    # Increase AT monitor heap size to be able to fit both neighbor cell measurement
    # and other AT notifications that may come in rapid succession.
    CONFIG_AT_MONITOR_HEAP_SIZE=1024
    
    # Logging
    CONFIG_LOG=y
    CONFIG_LOG_MODE_DEFERRED=y
    
    # nRF modem library
    CONFIG_NRF_MODEM_LIB=y
    
    # AT Host library - Used to send AT commands directy from an UART terminal and to allow
    #		    integration with nRF Connect for Desktop LTE Link monitor application.
    CONFIG_AT_HOST_LIBRARY=y
    
    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_NATIVE=n
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_OFFLOAD=y
    CONFIG_NET_IPV6=y
    CONFIG_NET_IPV4=y
    
    # LTE link control
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y
    ## Power saving timers.
    ### 320 hours PSM.
    CONFIG_LTE_PSM_REQ_RPTAU="11000001"
    ### 20 seconds active time.
    CONFIG_LTE_PSM_REQ_RAT="00001010"
    
    # Settings - Used to store real-time device configuration to flash.
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_FCB=y
    CONFIG_FCB=y
    
    # FOTA
    CONFIG_FOTA_DOWNLOAD=y
    CONFIG_DFU_TARGET=y
    CONFIG_DOWNLOAD_CLIENT=y
    CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=y
    CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
    CONFIG_DOWNLOAD_CLIENT_BUF_SIZE=2300
    CONFIG_DOWNLOAD_CLIENT_MAX_HOSTNAME_SIZE=128
    
    # Flash - Used in FOTA, settings and storage for P-GPS.
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_STREAM_FLASH=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    # MCUBOOT
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUBOOT_IMG_MANAGER=y
    CONFIG_IMG_ERASE_PROGRESSIVELY=y
    
    # Watchdog
    CONFIG_WATCHDOG_APPLICATION=y
    
    # Application Event Manager
    CONFIG_APP_EVENT_MANAGER=y
    CONFIG_APP_EVENT_MANAGER_LOG_EVENT_TYPE=n
    
    # cJSON - Used in cloud data encoding.
    CONFIG_CJSON_LIB=y
    
    # CAF - Common Application Framework
    CONFIG_CAF=y
    CONFIG_LED=y
    CONFIG_CAF_LEDS=y
    CONFIG_CAF_INIT_LOG_LED_READY_EVENTS=n
    CONFIG_CAF_INIT_LOG_LED_EVENTS=n
    CONFIG_CAF_INIT_LOG_MODULE_STATE_EVENTS=n
    
    # Default cloud transport service
    CONFIG_NRF_CLOUD_AGPS=n
    CONFIG_MODEM_ANTENNA_AT_MAGPIO="AT%XMAGPIO=1,1,1,7,1,746,803,2,698,748,2,1710,2200,3,824,894,4,880,960,5,791,849,7,1565,1586"
    CONFIG_MODEM_ANTENNA_AT_COEX0="AT%XCOEX0=1,1,1565,1586"
    CONFIG_NRFX_PWM1=y
    CONFIG_NRFX_PWM2=y
    CONFIG_NEWLIB_LIBC_MIN_REQUIRED_HEAP_SIZE=2048
    
    
    #MKB Additions Oct 22
    #for key loading automatically.
    CONFIG_MODEM_KEY_MGMT=y
    CONFIG_MAIN_STACK_SIZE=4096 
    
    
    #for Flash
    
    
    
    #for LED WS2812.
    CONFIG_LED_STRIP=y
    CONFIG_WS2812_STRIP=y
    #CONFIG_TFM_KEY_FILE_S="C:/ncs/v2.1.0/modules/tee/tf-m/trusted-firmware-m/bl2/ext/mcuboot/root-RSA-3072.pem"
    #CONFIG_TFM_KEY_FILE_NS="C:/ncs/v2.1.0/modules/tee/tf-m/trusted-firmware-m/bl2/ext/mcuboot/root-RSA-3072_1.pem"
    CONFIG_NRFX_SPIM1=y
    CONFIG_NRFX_TWIM2=y
    
    CONFIG_SPI_NOR=y
    CONFIG_SPI_NOR_IDLE_IN_DPD=y
    
    
    CONFIG_LIS2DH=y
    CONFIG_LIS2DH_TRIGGER_GLOBAL_THREAD=y
    CONFIG_LIS2DH_ACCEL_RANGE_2G=y
    

  • %XMONITOR: 1,"One NZ","One NZ","53001","A680",7,28,"00166103",,,,,"","00001010","11000001","01001111"

  • I know this thread a couple of months old, however the problem persists. 

    I'm now a (little) bit more familiar with AT2 and I think I know what the issue is, just not how to resolve it. 

    The nrf9160 manual states that the modem needs to have the "%XCOEX0 command needs to be sent before any modem activity occurs" (Nordic Semiconductor Infocenter)

    I was sending the modem the certificate checks first thing, so this of course violates the condition for writing the COEX0 command first. 

    However the certificate check must be done (write and delete operations) are allowed only when the modem is not activated. Nordic Semiconductor Infocenter

    So.... 

    How to I trap a "location setup complete event" and insert another command before the "modem setup event" 

    ie. The init flow needs to be sequenced like this. 

    boot -> LED -> GNSS -> Certificate Check/write -> Modem -> etc

    This is the same in V2.1.0 and V2.2.0

    Thank you. 

    Regards

    Marshall

  • I think I sorted it; it pays to express the problem sometimes. 

    I subscribed to the modems events and hooked out - MODEM_EVT_INITIALIZED

    Modem module — nRF Connect SDK 2.2.99 documentation (nordicsemi.com)

    When I see this, we simply check the certificates, I'm not sure if there are any timing issues, associated with this, i.e what if the certficate doesn't exist and we have to write it, will the modem carry on with it's connect events? 

    Anyway good to get it sorted finally. 

    /* Message handler for all states. */
    static void on_all_states(struct opito_msg_data *msg)
    {
    	if (IS_EVENT(msg, util, UTIL_EVT_SHUTDOWN_REQUEST)) {
    		/* The module doesn't have anything to shut down and can
    		 * report back immediately.
    		 */
    		SEND_SHUTDOWN_ACK(opito, OPITO_EVT_SHUTDOWN_READY, self.id);
    		state_set(STATE_SHUTDOWN);
    	}
    
    
    	if (IS_EVENT(msg, modem, MODEM_EVT_INITIALIZED)){
    		opito_check_certificates();
    	}
    
    }
    

    Regards 
    Marshall

Reply
  • I think I sorted it; it pays to express the problem sometimes. 

    I subscribed to the modems events and hooked out - MODEM_EVT_INITIALIZED

    Modem module — nRF Connect SDK 2.2.99 documentation (nordicsemi.com)

    When I see this, we simply check the certificates, I'm not sure if there are any timing issues, associated with this, i.e what if the certficate doesn't exist and we have to write it, will the modem carry on with it's connect events? 

    Anyway good to get it sorted finally. 

    /* Message handler for all states. */
    static void on_all_states(struct opito_msg_data *msg)
    {
    	if (IS_EVENT(msg, util, UTIL_EVT_SHUTDOWN_REQUEST)) {
    		/* The module doesn't have anything to shut down and can
    		 * report back immediately.
    		 */
    		SEND_SHUTDOWN_ACK(opito, OPITO_EVT_SHUTDOWN_READY, self.id);
    		state_set(STATE_SHUTDOWN);
    	}
    
    
    	if (IS_EVENT(msg, modem, MODEM_EVT_INITIALIZED)){
    		opito_check_certificates();
    	}
    
    }
    

    Regards 
    Marshall

Children
No Data
Related