NRF51822 hanging


Scott Nelson <scott@...>
 

I’m running the Zephyr RTOS on an NRF51822 board. Occasionally I notice that the code execution is hung up for some reason (I have a status LED that stops flashing and I can no longer connect via BLE). I’m assuming there’s some kind of fault and I’ve tried debugging this by capturing the serial output (Zephyr logs faults, etc.). Oddly though, the issue never seems to arise when I have a little USB-to-serial board plugged in. How do you recommend I get to the bottom of this?

Thanks!

-Scott


Carles Cufi
 

Hi Scott,

Can you tell us a bit more about the board itself and whether you can debug post-mortem by plugging it and attaching to the executing code? Are you using a Nordic development kit and if not, are you using a Segger debugger chip?

Thanks,

Carles

On 14/08/2017, 19:46, "zephyr-users-bounces@lists.zephyrproject.org on behalf of Scott Nelson" <zephyr-users-bounces@lists.zephyrproject.org on behalf of scott@scottnelson.co> wrote:

I’m running the Zephyr RTOS on an NRF51822 board. Occasionally I notice that the code execution is hung up for some reason (I have a status LED that stops flashing and I can no longer connect via BLE). I’m assuming there’s some kind of fault and I’ve tried debugging this by capturing the serial output (Zephyr logs faults, etc.). Oddly though, the issue never seems to arise when I have a little USB-to-serial board plugged in. How do you recommend I get to the bottom of this?

Thanks!

-Scott
_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users


Scott Nelson <scott@...>
 

The board is one of these: http://www.waveshare.com/nrf51822-eval-kit.htm I have been flashing it with STLink + OpenOCD and I’m trying to figure out how I can debug the chip with that setup + GDB. I am not using the Nordic dev kit. Let me know if there’s any additional info I can provide and thanks for you help!

Is there a way I can override the Zephyr fault hander so that I could, for example, flash an LED or repeatedly log something to the serial output?

-Scott

On Aug 14, 2017, at 1:51 PM, Cufi, Carles <Carles.Cufi@nordicsemi.no> wrote:

Hi Scott,

Can you tell us a bit more about the board itself and whether you can debug post-mortem by plugging it and attaching to the executing code? Are you using a Nordic development kit and if not, are you using a Segger debugger chip?

Thanks,

Carles

On 14/08/2017, 19:46, "zephyr-users-bounces@lists.zephyrproject.org on behalf of Scott Nelson" <zephyr-users-bounces@lists.zephyrproject.org on behalf of scott@scottnelson.co> wrote:

I’m running the Zephyr RTOS on an NRF51822 board. Occasionally I notice that the code execution is hung up for some reason (I have a status LED that stops flashing and I can no longer connect via BLE). I’m assuming there’s some kind of fault and I’ve tried debugging this by capturing the serial output (Zephyr logs faults, etc.). Oddly though, the issue never seems to arise when I have a little USB-to-serial board plugged in. How do you recommend I get to the bottom of this?

Thanks!

-Scott
_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users


Carles Cufi
 

Hi Scott,

-----Original Message-----
From: Scott Nelson [mailto:scott@scottnelson.co]
Sent: 14 August 2017 20:06
To: Cufi, Carles <Carles.Cufi@nordicsemi.no>
Cc: zephyr-users@lists.zephyrproject.org
Subject: Re: [Zephyr-users] NRF51822 hanging

The board is one of these: http://www.waveshare.com/nrf51822-eval-
kit.htm I have been flashing it with STLink + OpenOCD and I’m trying to
figure out how I can debug the chip with that setup + GDB. I am not
using the Nordic dev kit. Let me know if there’s any additional info I
can provide and thanks for you help!

Is there a way I can override the Zephyr fault hander so that I could,
for example, flash an LED or repeatedly log something to the serial
output?
Yes, since you are using the BLE controller this could be a controller assert (which leads to panic). Assuming you are using the latest master (and you should if you are not, since there have been many fixes to the BLE controller recently) then you can override it here:

https://github.com/zephyrproject-rtos/zephyr/blob/master/arch/arm/core/fatal.c#L45

A CPU fault and a BLE controller assert should all end up there.

Regards,

Carles


Scott Nelson <scott@...>
 

Just upgraded to the latest master version and overrode the _SysFatalErrorHandler. Thanks! Very helpful info.

-Scott

On Aug 14, 2017, at 2:30 PM, Cufi, Carles <Carles.Cufi@nordicsemi.no> wrote:

Hi Scott,

-----Original Message-----
From: Scott Nelson [mailto:scott@scottnelson.co]
Sent: 14 August 2017 20:06
To: Cufi, Carles <Carles.Cufi@nordicsemi.no>
Cc: zephyr-users@lists.zephyrproject.org
Subject: Re: [Zephyr-users] NRF51822 hanging

The board is one of these: http://www.waveshare.com/nrf51822-eval-
kit.htm I have been flashing it with STLink + OpenOCD and I’m trying to
figure out how I can debug the chip with that setup + GDB. I am not
using the Nordic dev kit. Let me know if there’s any additional info I
can provide and thanks for you help!

Is there a way I can override the Zephyr fault hander so that I could,
for example, flash an LED or repeatedly log something to the serial
output?
Yes, since you are using the BLE controller this could be a controller assert (which leads to panic). Assuming you are using the latest master (and you should if you are not, since there have been many fixes to the BLE controller recently) then you can override it here:

https://github.com/zephyrproject-rtos/zephyr/blob/master/arch/arm/core/fatal.c#L45

A CPU fault and a BLE controller assert should all end up there.

Regards,

Carles


Boie, Andrew P
 

-----Original Message-----
From: zephyr-users-bounces@lists.zephyrproject.org [mailto:zephyr-users-
bounces@lists.zephyrproject.org] On Behalf Of Scott Nelson
Sent: Monday, August 14, 2017 11:06 AM

The board is one of these: http://www.waveshare.com/nrf51822-eval-kit.htm I
have been flashing it with STLink + OpenOCD and I’m trying to figure out how I
can debug the chip with that setup + GDB. I am not using the Nordic dev kit. Let
me know if there’s any additional info I can provide and thanks for you help!

Is there a way I can override the Zephyr fault hander so that I could, for
example, flash an LED or repeatedly log something to the serial output?
Yes. _SysFatalErrorHandler is declared __weak just for this purpose.

In your application, implement:

void _SysFatalErrorHandler(unsigned int reason, const NANO_ESF *pEsf)

And implement whatever policy you would like for fatal errors.
The default implementation for ARM is in arch/arm/core/sys_fatal_error_handler.c

Andrew


Carles Cufi
 

-----Original Message-----
From: Boie, Andrew P [mailto:andrew.p.boie@intel.com]
Sent: 14 August 2017 21:03
To: Scott Nelson <scott@scottnelson.co>; Cufi, Carles
<Carles.Cufi@nordicsemi.no>
Cc: zephyr-users@lists.zephyrproject.org

-----Original Message-----
From: zephyr-users-bounces@lists.zephyrproject.org
[mailto:zephyr-users- bounces@lists.zephyrproject.org] On Behalf Of
Scott Nelson
Sent: Monday, August 14, 2017 11:06 AM

The board is one of these:
http://www.waveshare.com/nrf51822-eval-kit.htm I have been flashing
it with STLink + OpenOCD and I’m trying to figure out how I can debug
the chip with that setup + GDB. I am not using the Nordic dev kit.
Let me know if there’s any additional info I can provide and thanks for
you help!

Is there a way I can override the Zephyr fault hander so that I could,
for example, flash an LED or repeatedly log something to the serial
output?

Yes. _SysFatalErrorHandler is declared __weak just for this purpose.

In your application, implement:

void _SysFatalErrorHandler(unsigned int reason, const NANO_ESF *pEsf)

And implement whatever policy you would like for fatal errors.
The default implementation for ARM is in
arch/arm/core/sys_fatal_error_handler.c
Thanks for the clarification Andrew, I actually always set the breakpoint in _NanoFatalErrorHandler() but it's really good to know that there's the user version declared weak.

Carles