This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

AWS IoT example getting RSRP results in HARD FAULT

In the AWS IoT example I have been trying to add RSRP support (i.e. getting RSRP when sending my data packet).

I registered the handler/callback function in main after modem_info_init() like modem_info_rsrp_register(rsrp_handler); where

uint16_t rsrp_value = 255;
void rsrp_handler(char rsrp_val)
{
    //printk("RSRP Subscription: %d\n", rsrp_val);
    if (rsrp_val != 255)
    {
        rsrp_value = (uint16_t)rsrp_val;
    }
}

And I just use the JSON function to add a number in the shadow_update() function.

However, once in a while:

Next data publication in 30 seconds
D: +CSCON notification
RRC mode: Connected
D: +CSCON notification
RRC mode: Idle
+CEREG: 5,1,"5DCC","0278120C",7,,,"00000000","00000110"
Publishing: {
        "state":        {
                "reported":     {
                        "device":       "xyz",
                        "batv": 4445,
                        "rsrp": 60,
                        "mode": 1,
                        "datim":        "20/09/29,07:54:44+08",
                        "timestamp":    1601366084484
                }
        }
} to AWS IoT broker
E: Exception occurred in Secure State
E: ***** HARD FAULT *****
E:   Fault escalation (see below)
E: ***** BUS FAULT *****
E:   Precise data bus error
E:   BFAR Address: 0x50015504
E: r0/a1:  0x00000018  r1/a2:  0x00000090  r2/a3:  0x00000247
E: r3/a4:  0x0002f22b r12/ip:  0x200214d0 r14/lr:  0x000000aa
E:  xpsr:  0x20020400
E: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0x00000000  s[ 3]:  0x00000000
E: s[ 4]:  0x00000000  s[ 5]:  0x00000000  s[ 6]:  0x00000000  s[ 7]:  0x00000000
E: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
E: s[12]:  0x00000000  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x00000000
E: fpscr:  0x00000000
E: Faulting instruction address (r15/pc): 0x20020ac8
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Current thread: 0x20020ac8 (unknown)
E: Resetting system

What's happening?

I also tried using modem_info_short_get(MODEM_INFO_RSRP, &rsrp_value); inside shadow_update(), however it only yields a valid number the first time. Afterwards it just gives 255. I have PSM enabled, so I figured this was why this approach did not work. I also tried triggering the AT command/modem_info_short_get from the lte event handler, but it becomes circular and resets (should be this way according to docs as far as I can tell), so just to let you know what I tried.

Parents
  • I noticed that it might also happen when not using RSRP. I updated to the latest origin/master earlier today - perhaps an unintended introduction of a bug?

    I get the following when compiling:

    C:/ncs/nrf/subsys/net/lib/aws_iot/src/aws_iot.c: In function 'mqtt_evt_handler':
    C:/ncs/nrf/subsys/net/lib/aws_iot/src/aws_iot.c:586:26: warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized]
      586 |     aws_iot_evt.data.err = err;

    I changed the err to just int err1 = 1; (and then changing the err to err1). Just in case, however it is not it.

    I can provoke the error by unplugging the SIM card and plugging it back in (with some changes to the example such that it does not delete the thread on disconnect. It also happens sometimes when the cell tower changes.

    It seems to be a problem in aws_iot_send(), as this is where it crashes (perhaps it is linked with the RSRP problem):

    +CEREG: 5,1,"5DCC","0278120C",7,,,"00000000","00000110"
    Publishing: {
            "state":        {
                    "reported":     {
                            "device":       "nrf-074626",
                            "batv": 4445,
                            "rsrp": 255,
                            "mode": 1,
                            "datim":        "20/09/29,12:48:02+08",
                            "timestamp":    1601383681346
                    }
            }
    } to AWS IoT broker
    *** Booting Zephyr OS build v2.3.0-rc1-ncs1-2410-g7d20f2ebf259  ***
    Flash regions           Domain          Permissions
    00 02 0x00000 0x18000   Secure          rwxl
    03 31 0x18000 0x100000  Non-Secure      rwxl
    
    Non-secure callable region 0 placed in flash region 2 with size 32.
    
    SRAM region             Domain          Permissions
    00 07 0x00000 0x10000   Secure          rwxl
    08 31 0x10000 0x40000   Non-Secure      rwxl
    
    Peripheral              Domain          Status
    00 NRF_P0               Non-Secure      OK
    01 NRF_CLOCK            Non-Secure      OK
    02 NRF_RTC0             Non-Secure      OK
    03 NRF_RTC1             Non-Secure      OK
    04 NRF_NVMC             Non-Secure      OK
    05 NRF_UARTE1           Non-Secure      OK
    06 NRF_UARTE2           Secure          SKIP
    07 NRF_TWIM2            Non-Secure      OK
    08 NRF_SPIM3            Non-Secure      OK
    09 NRF_TIMER0           Non-Secure      OK
    10 NRF_TIMER1           Non-Secure      OK
    11 NRF_TIMER2           Non-Secure      OK
    12 NRF_SAADC            Non-Secure      OK
    13 NRF_PWM0             Non-Secure      OK
    14 NRF_PWM1             Non-Secure      OK
    15 NRF_PWM2             Non-Secure      OK
    16 NRF_PWM3             Non-Secure      OK
    17 NRF_WDT              Non-Secure      OK
    18 NRF_IPC              Non-Secure      OK
    19 NRF_VMC              Non-Secure      OK
    20 NRF_FPU              Non-Secure      OK
    21 NRF_EGU1             Non-Secure      OK
    22 NRF_EGU2             Non-Secure      OK
    23 NRF_DPPIC            Non-Secure      OK
    24 NRF_GPIOTE1          Non-Secure      OK
    25 NRF_REGULATORS       Non-Secure      OK
    
    SPM: NS image at 0x18200
    SPM: NS MSP at 0x2002ac48
    SPM: NS reset vector at 0x1b989
    SPM: prepare to jump to Non-Secure image.
    *** Booting Zephyr OS build v2.3.0-rc1-ncs1-2410-g7d20f2ebf259  ***
    The AWS IoT sample started, version: v1.0.0

    It seems that the aws_iot_send() bugs out when the connection is lost or changed or some state change related to the LTE and/or AWS iot connection occurs.

Reply
  • I noticed that it might also happen when not using RSRP. I updated to the latest origin/master earlier today - perhaps an unintended introduction of a bug?

    I get the following when compiling:

    C:/ncs/nrf/subsys/net/lib/aws_iot/src/aws_iot.c: In function 'mqtt_evt_handler':
    C:/ncs/nrf/subsys/net/lib/aws_iot/src/aws_iot.c:586:26: warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized]
      586 |     aws_iot_evt.data.err = err;

    I changed the err to just int err1 = 1; (and then changing the err to err1). Just in case, however it is not it.

    I can provoke the error by unplugging the SIM card and plugging it back in (with some changes to the example such that it does not delete the thread on disconnect. It also happens sometimes when the cell tower changes.

    It seems to be a problem in aws_iot_send(), as this is where it crashes (perhaps it is linked with the RSRP problem):

    +CEREG: 5,1,"5DCC","0278120C",7,,,"00000000","00000110"
    Publishing: {
            "state":        {
                    "reported":     {
                            "device":       "nrf-074626",
                            "batv": 4445,
                            "rsrp": 255,
                            "mode": 1,
                            "datim":        "20/09/29,12:48:02+08",
                            "timestamp":    1601383681346
                    }
            }
    } to AWS IoT broker
    *** Booting Zephyr OS build v2.3.0-rc1-ncs1-2410-g7d20f2ebf259  ***
    Flash regions           Domain          Permissions
    00 02 0x00000 0x18000   Secure          rwxl
    03 31 0x18000 0x100000  Non-Secure      rwxl
    
    Non-secure callable region 0 placed in flash region 2 with size 32.
    
    SRAM region             Domain          Permissions
    00 07 0x00000 0x10000   Secure          rwxl
    08 31 0x10000 0x40000   Non-Secure      rwxl
    
    Peripheral              Domain          Status
    00 NRF_P0               Non-Secure      OK
    01 NRF_CLOCK            Non-Secure      OK
    02 NRF_RTC0             Non-Secure      OK
    03 NRF_RTC1             Non-Secure      OK
    04 NRF_NVMC             Non-Secure      OK
    05 NRF_UARTE1           Non-Secure      OK
    06 NRF_UARTE2           Secure          SKIP
    07 NRF_TWIM2            Non-Secure      OK
    08 NRF_SPIM3            Non-Secure      OK
    09 NRF_TIMER0           Non-Secure      OK
    10 NRF_TIMER1           Non-Secure      OK
    11 NRF_TIMER2           Non-Secure      OK
    12 NRF_SAADC            Non-Secure      OK
    13 NRF_PWM0             Non-Secure      OK
    14 NRF_PWM1             Non-Secure      OK
    15 NRF_PWM2             Non-Secure      OK
    16 NRF_PWM3             Non-Secure      OK
    17 NRF_WDT              Non-Secure      OK
    18 NRF_IPC              Non-Secure      OK
    19 NRF_VMC              Non-Secure      OK
    20 NRF_FPU              Non-Secure      OK
    21 NRF_EGU1             Non-Secure      OK
    22 NRF_EGU2             Non-Secure      OK
    23 NRF_DPPIC            Non-Secure      OK
    24 NRF_GPIOTE1          Non-Secure      OK
    25 NRF_REGULATORS       Non-Secure      OK
    
    SPM: NS image at 0x18200
    SPM: NS MSP at 0x2002ac48
    SPM: NS reset vector at 0x1b989
    SPM: prepare to jump to Non-Secure image.
    *** Booting Zephyr OS build v2.3.0-rc1-ncs1-2410-g7d20f2ebf259  ***
    The AWS IoT sample started, version: v1.0.0

    It seems that the aws_iot_send() bugs out when the connection is lost or changed or some state change related to the LTE and/or AWS iot connection occurs.

Children
No Data
Related