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

nrf52832 get stuck after SystemOFF or Flashing new firmware, only removing and applying power works

Hello, I'm using SDK 16.0, softdevice s132 v7.0.1, I'm sending the device to SystemOFF and configuring a pin to wake it up with

nrf_gpio_cfg_sense_set(IMU_INT2_PIN, NRF_GPIO_PIN_SENSE_HIGH);

IMU_INT2_PIN is an output from an IMU.

The device goes to SystemOFF however SOMETIMES the device won't wake up, I've checked with the oscilloscope, and the IMU_INT2_PIN is indeed going from LOW to HIGH, but the device simply wont wake up.

Similarly after flashing a new firmware, SOMETIMES the device just doesn't start. I've tried doing a mass erase but it didn't work.

I'm using a secure bootloader and it doesn't seem to be stuck in the bootloader code, because when I attached the debugger via gdb I can see that the PC is moving in a loop in the following directions:

0x0be04     ldr.w r0, [r4, ; 260] ; 0x104

0x0be08     cmp r0, ; 0

0x0be08     beq.n 0xbe00

0x0be00     bl 0x251b4

0x251b4    addw r0, pc, ; 12

0x251b8    add.w r0, r0, ; 0

0x251bc    mov r1, sp

0x251be    str.w r0, [r1, ; -8]

0x251c2    wfe

0x251c4    bx lr

and again from the 0x0be04

If I understand correctly this is the PC correspond to the SOFTDEVICE part, can someone identify what's happening here?

Is waiting for something? maybe in a loop waiting for the 32MHz crystal to stabilize?

How can I determine where the problem is?

  • Hi Nicolas, 

    the instruction at 0x251c2 indicates that the nRF52832 is waiting for an event, i.e. the __WFE() instruction.  Looking at the source code for the S132 v7.0.1, it waiting for the LFCLK to start up, i.e. the 32kHz clock source. While its waiting it will call __WFE().

    Is your application configured to use the internal RC Oscillator or an external crystal, i.e. is NRF_SDH_CLOCK_LF_SRC set to 0 or 1 in the applications sdk_config.h file?

    Does your board have an external 32kHz crystal?

    Best regards

    Bjørn

  • Hello Bjorn

    I'm using the internal RC oscillator, NRF_SDH_CLOCK_LF_SRC = 0, the board doesn't have an external 32kHz crystal

    I change something in the code and it hasn't happen again, I have forgotten to stop an app_timer that called an saadc conversion before calling the nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF)

    However, after what you've told me, this shouldn't explain why it got stuck waiting for the 32kHz crystal, and why it got stuck after flashing a new firmware. 

  • Another thing I changed was that the bootloader was using the board 10040 configuration, this configuration  used the pin 13 to enable the DFU mode, in my board that pin was not connected.

    Also I just discovered that the bootloader was using NRF_SDH_CLOCK_LF_SRC = 1 which is wrong

    My guess is that somehow the bootloader entered in DFU mode instead of jumping to the application and then it got stuck waiting for the 32KHz crystal to become available instead of using the internal RC oscillator.

    When I changed the pin to use a BUTTON, the bootloader doesn't enter the DFU mode and it jumps directly to the application.

    I'm going to do some more test but I believe this could be the answer.

    Thanks for your help

    Nicolas

  • Yes, if the bootloader was configured to use the LFXO and the NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN was floating, then this could promt the bootloader to always enter DFU mode and initialize the SoftDevice, which would then wait for the LFXO to start, which it cant since its not present. 

Related