nrf9160 with P-GPS: SecureFault before LTE is connected

Hey,

Debugging an issue with my application at the moment, losely based on asset tracker. I'm using the Location API to gather GNSS/Cellular positioning on a custom board using an nrf9160.

I have been unable to debug an issue where the device will encounter a SecureFault (according to ozone) when a GNSS request is made, but LTE/nRF Cloud is not connected. I am initialising both the modem LC library, and the nRF Cloud library, and then the location api, but making a GNSS request before either LTE or nRF Cloud has had a chance to connect. I am simulating this by starting up the device with no antennas connected, and requesting location 20 seconds after boot. 

From debugging, it seems to fail somewhere inside reading the flash to look at the already downloaded P-GPS data, but I am unable to find exactly where for some reason. I get nothing printed to console, just a reboot or halt depending on CONFIG_RESET_ON_FATAL_ERROR. This only happens if the device has previously downloaded P-GPS predictions and have stored them in the system's flash using CONFIG_NRF_CLOUD_PGPS_STORAGE_PARTITION

Disabling CONFIG_NRF_CLOUD_PGPS makes this issue disappear, and letting LTE and nRF Cloud connect first before requesting will also make the issue disappear. I've increased all relevant stack sizes (that I could find) and cannot get a stacktrace to appear in ozone once it reaches a fault. Trying to log the fault with TFM exceptions, but I think uart0 is being pulled into a secure mode and can't log the fault.

Any guidance on this would be great, as it's a blocker for using P-GPS at the moment as we can't guarantee device stability if it's turned on in a no-signal environment.

My prj.conf file:

#### System ####
CONFIG_APP_EVENT_MANAGER=y
CONFIG_EVENTS=y
CONFIG_APP_EVENT_MANAGER_LOG_EVENT_TYPE=n
CONFIG_REBOOT=y
CONFIG_MULTITHREADING=y
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_RESET_ON_FATAL_ERROR=y
CONFIG_CJSON_LIB=y
CONFIG_FPU=y
CONFIG_THREAD_ANALYZER=y
CONFIG_THREAD_NAME=y
CONFIG_THREAD_MONITOR=y
CONFIG_SYS_HEAP_AUTO=y
CONFIG_CAF=y
CONFIG_SCHED_SCALABLE=y
CONFIG_WAITQ_SCALABLE=y

#### Tracing/Debugging ####
# CONFIG_TRACING=y
# CONFIG_INIT_STACKS=y
# CONFIG_SEGGER_SYSTEMVIEW=y
# CONFIG_SEGGER_SYSTEMVIEW_BOOT_ENABLE=y
# CONFIG_DEBUG_THREAD_INFO=y
# CONFIG_USE_SEGGER_RTT=y

#### General Debugging ####
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_OPTIMIZATIONS=y
CONFIG_ASSERT=y

#### Stacks & Heaps ####
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_LOCATION_WORKQUEUE_STACK_SIZE=6144
CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD_STACK_SIZE=5120
CONFIG_HEAP_MEM_POOL_SIZE=98304
CONFIG_AT_MONITOR_HEAP_SIZE=4096
CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
# CONFIG_LOG_BUFFER_SIZE=8192

#### Logging ####
CONFIG_LOG=y
CONFIG_LOG_TAG_MAX_LEN=5
CONFIG_LOG_TAG_DEFAULT="imove"
CONFIG_LOG_FUNC_NAME_PREFIX_ERR=y
CONFIG_UART_ASYNC_API=y
CONFIG_CBPRINTF_COMPLETE=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_LOG_TIMESTAMP_64BIT=y

### Instant Logging ###
# Don't use, calling synchronous logging from inside an IRQ (i2c error logging) kills the application through a HardFault
# CONFIG_LOG_MODE_DEFERRED=n
# CONFIG_LOG_MODE_IMMEDIATE=y

### Deferred Logging ###
CONFIG_LOG_MODE_DEFERRED=y
CONFIG_LOG_MODE_IMMEDIATE=n
CONFIG_LOG_PROCESS_THREAD_SLEEP_MS=500

### UART Logging ###
CONFIG_LOG_BACKEND_UART=y

### RTT Logging ###
# CONFIG_LOG_BACKEND_RTT=y
# CONFIG_USE_SEGGER_RTT=y

#### Networking ####
CONFIG_NRF_MODEM_LIB=y
CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y
CONFIG_MODEM_INFO=y
CONFIG_MODEM_ATTEST_TOKEN=y
CONFIG_MODEM_ATTEST_TOKEN_PARSING=y
CONFIG_MODEM_INFO_ADD_NETWORK=y

CONFIG_AT_CMD_PARSER=y
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_IPV6=y
CONFIG_NET_IPV4=y

CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y

#### Antenna Control ####
CONFIG_MODEM_ANTENNA=y
CONFIG_MODEM_ANTENNA_GNSS_EXTERNAL=y
CONFIG_MODEM_ANTENNA_AT_COEX0="AT%XCOEX0=1,1,1570,1580"

#### Date/Time ####
CONFIG_DATE_TIME=y
CONFIG_DATE_TIME_NTP=y
CONFIG_DATE_TIME_AUTO_UPDATE=y

#### Settings Subsystems ####
CONFIG_SETTINGS=y
CONFIG_FCB=y
CONFIG_SETTINGS_FCB=y

#### Power Management ####
CONFIG_PM=y
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_POWER_DOMAIN=y

#### PSM ####
### 1800 seconds (30 minutes) periodic TAU
CONFIG_LTE_PSM_REQ_RPTAU="10111110"
### 60 seconds active time
CONFIG_LTE_PSM_REQ_RAT="00011110"

#### eDRX ####
# Disable eDRX to use PSM instead
CONFIG_LTE_EDRX_REQ=y
# This is a very confusing number. See:
# https://infocenter.nordicsemi.com/index.jsp?topic=%2Fref_at_commands%2FREF%2Fat_commands%2Fnw_service%2Fcedrxrdp_set.html
CONFIG_LTE_EDRX_REQ_VALUE_LTE_M="0010" # 20.48 seconds
CONFIG_LTE_RAI_REQ_VALUE="4"

#### BME280 ####
CONFIG_BME280=y
CONFIG_BME280_MODE_FORCED=y
CONFIG_BME280_TEMP_OVER_4X=y
CONFIG_BME280_HUMIDITY_OVER_4X=y
CONFIG_BME280_PRESS_OVER_4X=y
# CONFIG_BME280_STANDBY_1000MS=y

#### LIS2DH ####
CONFIG_LIS2DH=y
CONFIG_LIS2DH_ODR_2=y
CONFIG_LIS2DH_ACCEL_RANGE_8G=y
CONFIG_LIS2DH_MEASURE_TEMPERATURE=n
CONFIG_LIS2DH_TRIGGER_OWN_THREAD=y

CONFIG_SENSOR=y
CONFIG_I2C=y

#### Battery ####
CONFIG_ADC=y

#### Flash Storage ####
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR=n
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_STREAM_FLASH=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

CONFIG_NANOPB=y
CONFIG_NANOPB_ENABLE_MALLOC=y

#### Location APIs ####
CONFIG_LOCATION=y
CONFIG_LOCATION_METHOD_GNSS=y
CONFIG_LOCATION_METHOD_CELLULAR=y
CONFIG_LOCATION_DATA_DETAILS=y
CONFIG_LOCATION_SERVICE_CLOUD_RECV_BUF_SIZE=1024
CONFIG_LOCATION_SERVICE_NRF_CLOUD=y
CONFIG_LOCATION_THREAD_STACK_SIZE=8192

#### nRF Cloud ####
CONFIG_NRF_CLOUD_MQTT=y
CONFIG_NRF_CLOUD_MQTT_KEEPALIVE=600
CONFIG_NRF_CLOUD_REST=y
CONFIG_NRF_CLOUD_LOCATION=y
CONFIG_NRF_CLOUD_AGPS=y
CONFIG_NRF_CLOUD_PGPS=y
CONFIG_NRF_CLOUD_PGPS_TRANSPORT_MQTT=y
CONFIG_NRF_CLOUD_PGPS_DOWNLOAD_TRANSPORT_HTTP=y
CONFIG_NRF_CLOUD_PGPS_STORAGE_PARTITION=y
CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS=y
CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS_NETWORK=y
CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS_SIM=y
CONFIG_NRF_CLOUD_DEVICE_STATUS_ENCODE_VOLTAGE=n

### Download Client ####
CONFIG_DOWNLOAD_CLIENT=y
CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=y
CONFIG_DOWNLOAD_CLIENT_BUF_SIZE=2300
CONFIG_DOWNLOAD_CLIENT_MAX_HOSTNAME_SIZE=128

CONFIG_NRF_CLOUD_FOTA=n
CONFIG_HW_ID_LIBRARY=y
CONFIG_MODEM_JWT=y
CONFIG_HW_ID_LIBRARY_SOURCE_UUID=y
CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID=y

Parents
  • We did a bunch of P-GPS experimentation today and I came across your post on accident.  I believe I know how to resolve your problem.  The SDK has a suboptimal sequence when requesting P-GPS injection data that could lead to a null pointer condition.

    In the file nrf_cloud_pgps.c at the end of the file there is a code snippet that looks like below:

    if (evt_handler) {
    			evt.type = PGPS_EVT_AVAILABLE;
    			evt.prediction = found_prediction;
    			evt_handler(&evt);
    		}

    Simply change it to the below and it has a high chance of solving your problem (trying to inject a null prediction pointer!!)

    if (evt_handler && found_prediction) {
    			evt.type = PGPS_EVT_AVAILABLE;
    			evt.prediction = found_prediction;
    			evt_handler(&evt);
    		}

    P-GPS is such a critical feature, I wished Nordic tested it more and made it more accessible.  Not cool that prediction data isn't available publicly like other GPS solutions providers.

  • Thank you for reporting that, I have checked that this is how the code looks in the main branch currently and I am forwarding this to the developers.

    Best regards,

    Michal

Reply Children
No Data
Related