Seeed BLE Micro (nrf51822) hangs on k_msleep


Matias N. <matias@...>
 

Hi,
I'm starting a project based on the BLE Micro module from Seeedstudio. Since this "board" was not supported but the RedBear BLE nano board is the most similar one, I created a custom board directory for it using this as a template. I managed to flash the blinky sample to the module (using openocd and a ST-Link v2 clone device) and can also connect with gdb to debug. I have this module soldered to a custom PCB which features a LED and thus I set the correct LED GPIO in the dts file. I managed to control the LED but from my debugging it seems to hang when calling k_msleep(). When it hangs, if I pause the execution it appears to be right after the "wfi" instruction (i'm assuming the debugger breaks the sleep).

I'm not sure why this could be happening. My guess it is something to do with the clock configuration. The module features a 32.768hz crystal (just like the BLE Nano) but also a 16 MHz crystal (which I'm not sure is used or not by zephyr). I tried disabling tickless, but the behavior does not change.

As I'm new to zephyr I'm not quite sure what else to check. Googling for this problem I found old issues in GitHub relating to tickless mode, low-power, rtc, etc. But all seem to be merged/closed. I would appreciate any help in this.

Best,
Matias


Vinayak Kariappa
 

Hi Matias,

From the schematics posted in seedstudio website, indeed a 32KHz crystal is said to be present. You may always use the internal 32 KHz RC oscillator in nRF51 to check if the system timer is not the problem.

Enable the following to use RC Oscillator:
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

16MHz clock is essential for 2.4 GHz radio peripheral.

Regards,
Vinayak


On Sat, Jun 6, 2020 at 5:31 AM Matias N. <matias@...> wrote:
Hi,
I'm starting a project based on the BLE Micro module from Seeedstudio. Since this "board" was not supported but the RedBear BLE nano board is the most similar one, I created a custom board directory for it using this as a template. I managed to flash the blinky sample to the module (using openocd and a ST-Link v2 clone device) and can also connect with gdb to debug. I have this module soldered to a custom PCB which features a LED and thus I set the correct LED GPIO in the dts file. I managed to control the LED but from my debugging it seems to hang when calling k_msleep(). When it hangs, if I pause the execution it appears to be right after the "wfi" instruction (i'm assuming the debugger breaks the sleep).

I'm not sure why this could be happening. My guess it is something to do with the clock configuration. The module features a 32.768hz crystal (just like the BLE Nano) but also a 16 MHz crystal (which I'm not sure is used or not by zephyr). I tried disabling tickless, but the behavior does not change.

As I'm new to zephyr I'm not quite sure what else to check. Googling for this problem I found old issues in GitHub relating to tickless mode, low-power, rtc, etc. But all seem to be merged/closed. I would appreciate any help in this.

Best,
Matias


Matias N.
 

Hi,
sorry for the delay. I just tried your suggestion and it does not seem to make a difference. As I mentioned, on debugging it seems to be halted at the WFI instruction. From my understanding, there should be an interrupt firing via the RTC but this is not happening and the MCU does not get out of the WFI (I placed a breakpoint at the rtc1_nfr_isr) and it never reaches there.

I also tried to simply modify the in-tree board definition for BLE nano, changing the LED gpio pin and setting the appropriate UART pins for my board and then flashing the blinky sample. I got the same result of the LED staying fixed.

Furthermore, the board came with nordic's UART/BLE demonstration firmware and this works (I can bind from my phone) so I would rule out defective hardware.

I can't really understand what could be happening. Any idea on what I should try?

Best,
Matias

On Wed, Jun 10, 2020, at 21:42, Vinayak Kariappa wrote:
Hi Matias,

From the schematics posted in seedstudio website, indeed a 32KHz crystal is said to be present. You may always use the internal 32 KHz RC oscillator in nRF51 to check if the system timer is not the problem.

Enable the following to use RC Oscillator:
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

16MHz clock is essential for 2.4 GHz radio peripheral.

Regards,
Vinayak

On Sat, Jun 6, 2020 at 5:31 AM Matias N. <matias@...> wrote:

Hi,
I'm starting a project based on the BLE Micro module from Seeedstudio. Since this "board" was not supported but the RedBear BLE nano board is the most similar one, I created a custom board directory for it using this as a template. I managed to flash the blinky sample to the module (using openocd and a ST-Link v2 clone device) and can also connect with gdb to debug. I have this module soldered to a custom PCB which features a LED and thus I set the correct LED GPIO in the dts file. I managed to control the LED but from my debugging it seems to hang when calling k_msleep(). When it hangs, if I pause the execution it appears to be right after the "wfi" instruction (i'm assuming the debugger breaks the sleep).

I'm not sure why this could be happening. My guess it is something to do with the clock configuration. The module features a 32.768hz crystal (just like the BLE Nano) but also a 16 MHz crystal (which I'm not sure is used or not by zephyr). I tried disabling tickless, but the behavior does not change.

As I'm new to zephyr I'm not quite sure what else to check. Googling for this problem I found old issues in GitHub relating to tickless mode, low-power, rtc, etc. But all seem to be merged/closed. I would appreciate any help in this.

Best,
Matias





Chettimada, Vinayak Kariappa
 

Hi Matias,

 

Please create a github issue detailing the steps to reproduce, please mention the diff/changes of the upstream master samples you are using. Also upload the “.config” file of your build.

You can assign it to me, for starters.’

 

That said, be stuck at sleep/WFI indicates stopped 32KHz clock due to missing/damaged external crystal and misconfigure LFCLOCK source.

 

Regards,

Vinayak

 

From: users@... <users@...> On Behalf Of Matias N. via lists.zephyrproject.org
Sent: 16 June 2020 23:29
To: Vinayak Kariappa <vinayak.kariappa@...>
Cc: users@...
Subject: Re: [Zephyr-users] Seeed BLE Micro (nrf51822) hangs on k_msleep

 

Hi,

sorry for the delay. I just tried your suggestion and it does not seem to make a difference. As I mentioned, on debugging it seems to be halted at the WFI instruction. From my understanding, there should be an interrupt firing via the RTC but this is not happening and the MCU does not get out of the WFI (I placed a breakpoint at the rtc1_nfr_isr) and it never reaches there.

 

I also tried to simply modify the in-tree board definition for BLE nano, changing the LED gpio pin and setting the appropriate UART pins for my board and then flashing the blinky sample. I got the same result of the LED staying fixed.

 

Furthermore, the board came with nordic's UART/BLE demonstration firmware and this works (I can bind from my phone) so I would rule out defective hardware.

 

I can't really understand what could be happening. Any idea on what I should try?

 

Best,

Matias

 

On Wed, Jun 10, 2020, at 21:42, Vinayak Kariappa wrote:

Hi Matias,

 

From the schematics posted in seedstudio website, indeed a 32KHz crystal is said to be present. You may always use the internal 32 KHz RC oscillator in nRF51 to check if the system timer is not the problem.

 

Enable the following to use RC Oscillator:

CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y

CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

 

16MHz clock is essential for 2.4 GHz radio peripheral.

 

Regards,

Vinayak

 

On Sat, Jun 6, 2020 at 5:31 AM Matias N. <matias@...> wrote:

 

Hi,

I'm starting a project based on the BLE Micro module from Seeedstudio. Since this "board" was not supported but the RedBear BLE nano board is the most similar one, I created a custom board directory for it using this as a template. I managed to flash the blinky sample to the module (using openocd and a ST-Link v2 clone device) and can also connect with gdb to debug. I have this module soldered to a custom PCB which features a LED and thus I set the correct LED GPIO in the dts file. I managed to control the LED but from my debugging it seems to hang when calling k_msleep(). When it hangs, if I pause the execution it appears to be right after the "wfi" instruction (i'm assuming the debugger breaks the sleep).

 

I'm not sure why this could be happening. My guess it is something to do with the clock configuration. The module features a 32.768hz crystal (just like the BLE Nano) but also a 16 MHz crystal (which I'm not sure is used or not by zephyr). I tried disabling tickless, but the behavior does not change.

 

As I'm new to zephyr I'm not quite sure what else to check. Googling for this problem I found old issues in GitHub relating to tickless mode, low-power, rtc, etc. But all seem to be merged/closed. I would appreciate any help in this.

 

Best,

Matias

 

 

 


Matias N.
 

Thanks, I opened the issue. Don't know how to assign the issue to you, though.

On Wed, Jun 17, 2020, at 02:01, Chettimada, Vinayak Kariappa wrote:

Hi Matias,

 

Please create a github issue detailing the steps to reproduce, please mention the diff/changes of the upstream master samples you are using. Also upload the “.config” file of your build.

You can assign it to me, for starters.’

 

That said, be stuck at sleep/WFI indicates stopped 32KHz clock due to missing/damaged external crystal and misconfigure LFCLOCK source.

 

Regards,

Vinayak

 

From: users@... <users@...> On Behalf Of Matias N. via lists.zephyrproject.org
Sent: 16 June 2020 23:29
To: Vinayak Kariappa <vinayak.kariappa@...>
Cc: users@...
Subject: Re: [Zephyr-users] Seeed BLE Micro (nrf51822) hangs on k_msleep

 

Hi,

sorry for the delay. I just tried your suggestion and it does not seem to make a difference. As I mentioned, on debugging it seems to be halted at the WFI instruction. From my understanding, there should be an interrupt firing via the RTC but this is not happening and the MCU does not get out of the WFI (I placed a breakpoint at the rtc1_nfr_isr) and it never reaches there.

 

I also tried to simply modify the in-tree board definition for BLE nano, changing the LED gpio pin and setting the appropriate UART pins for my board and then flashing the blinky sample. I got the same result of the LED staying fixed.

 

Furthermore, the board came with nordic's UART/BLE demonstration firmware and this works (I can bind from my phone) so I would rule out defective hardware.

 

I can't really understand what could be happening. Any idea on what I should try?

 

Best,

Matias

 

On Wed, Jun 10, 2020, at 21:42, Vinayak Kariappa wrote:

Hi Matias,

 

From the schematics posted in seedstudio website, indeed a 32KHz crystal is said to be present. You may always use the internal 32 KHz RC oscillator in nRF51 to check if the system timer is not the problem.

 

Enable the following to use RC Oscillator:

CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y

CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

 

16MHz clock is essential for 2.4 GHz radio peripheral.

 

Regards,

Vinayak

 

On Sat, Jun 6, 2020 at 5:31 AM Matias N. <matias@...> wrote:

 

Hi,

I'm starting a project based on the BLE Micro module from Seeedstudio. Since this "board" was not supported but the RedBear BLE nano board is the most similar one, I created a custom board directory for it using this as a template. I managed to flash the blinky sample to the module (using openocd and a ST-Link v2 clone device) and can also connect with gdb to debug. I have this module soldered to a custom PCB which features a LED and thus I set the correct LED GPIO in the dts file. I managed to control the LED but from my debugging it seems to hang when calling k_msleep(). When it hangs, if I pause the execution it appears to be right after the "wfi" instruction (i'm assuming the debugger breaks the sleep).

 

I'm not sure why this could be happening. My guess it is something to do with the clock configuration. The module features a 32.768hz crystal (just like the BLE Nano) but also a 16 MHz crystal (which I'm not sure is used or not by zephyr). I tried disabling tickless, but the behavior does not change.

 

As I'm new to zephyr I'm not quite sure what else to check. Googling for this problem I found old issues in GitHub relating to tickless mode, low-power, rtc, etc. But all seem to be merged/closed. I would appreciate any help in this.

 

Best,

Matias