Hello,
I'm trying on the ESB examples in nRF Connect SDK v1.3.1, but it seems the Zephyr is crashing during the call k_sleep (l. 54). The following code I isolate the "k_sleep" in a thread to pinpoint the source.
I'm using the PCA10040 board.
#include <drivers/clock_control.h> #include <drivers/clock_control/nrf_clock_control.h> #include <drivers/gpio.h> #include <irq.h> #include <logging/log.h> #include <nrf.h> #include <zephyr.h> #include <zephyr/types.h> LOG_MODULE_REGISTER(main_unit); #define DT_DRV_COMPAT nordic_nrf_clock int clocks_start(void) { int err; struct device *clk; clk = device_get_binding(DT_INST_LABEL(0)); if (!clk) { LOG_ERR("Clock device not found!"); return -EIO; } err = clock_control_on(clk, CLOCK_CONTROL_NRF_SUBSYS_HF); if (err && (err != -EINPROGRESS)) { LOG_ERR("HF clock start fail: %d", err); return err; } /* Block until clock is started. */ while (clock_control_get_status(clk, CLOCK_CONTROL_NRF_SUBSYS_HF) != CLOCK_CONTROL_STATUS_ON) { } LOG_DBG("HF clock started"); return 0; } #define NEW_THREAD_PRIO K_PRIO_PREEMPT(10) #define NEW_THREAD_OPT (0) //(K_FP_REGS) K_THREAD_STACK_DEFINE(new_thread_stack, 2000); struct k_thread new_thread_tcb; static void new_thread_entry(void *p1, void *p2, void *p3) { (void)p1; (void)p2; (void)p3; while (1) { k_sleep(K_MSEC(100)); } } void main(void) { int err; err = clocks_start(); if (err) { return; } if (!k_thread_create(&new_thread_tcb, new_thread_stack, K_THREAD_STACK_SIZEOF(new_thread_stack), new_thread_entry, NULL, NULL, NULL, NEW_THREAD_PRIO, NEW_THREAD_OPT, K_NO_WAIT)) { LOG_ERR("NEW THR FAILED"); return; } }
During debug the firmware is trapped in "z_arm_exc_spurious" handler. The log shows:
I tried several stack sizes and priorities for the new thread, but the crash persisted.
Did someone experiment this behaviour before?
---
Best Regards.
Christofer