How to reinitialize ble stack

Kalpesh Lakum
Posts: 2
Joined: Thu Sep 26, 2024 8:19 am

How to reinitialize ble stack

Postby Kalpesh Lakum » Thu Oct 24, 2024 12:38 pm

<r>Aim: I want to initialize BLE stack and send some data and again de-initialize BLE stack. This i want to do in a loop forever.<br/>
<br/>
Problem: after Re-initializing BLE stack it is getting reboot<br/>
<br/>
Terminal Output:
<CODEBOX codebox="text" file="Untitled.txt"><s>
  1. </s>Guru Meditation Error: Core  0 panic'ed (Load access fault). Exception was unhandled.<br/>
  2. <br/>
  3. Core  0 register dump:<br/>
  4. Stack dump detected<br/>
  5. MEPC    : 0x42009624  RA      : 0x4200965e  SP      : 0x3fca9670  GP      : 0x3fc91e00  <br/>
  6. 0x42009624: ble_npl_mutex_pend at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/include/nimble/nimble_npl_os.h:234<br/>
  7.  (inlined by) ble_hs_lock_nested at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_hs.c:174<br/>
  8. 0x4200965e: ble_hs_lock at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_hs.c:220<br/>
  9. <br/>
  10. TP      : 0x3fc913c0  T0      : 0x4005890e  T1      : 0x0000000f  T2      : 0x42015e36  <br/>
  11. 0x4005890e: memset in ROM<br/>
  12. 0x42015e36: npl_freertos_callout_deinit at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c:795<br/>
  13. <br/>
  14. S0/FP   : 0x3fca3254  S1      : 0x00000001  A0      : 0x00000001  A1      : 0x00000009  <br/>
  15. A2      : 0x3fca3254  A3      : 0x00000012  A4      : 0x00000001  A5      : 0x00000000  <br/>
  16. A6      : 0x4200624e  A7      : 0x3fc92958  S2      : 0x00000009  S3      : 0x00000001  <br/>
  17. 0x4200624e: console_write at /home/kalpesh/esp/esp-idf/components/vfs/vfs_console.c:71<br/>
  18. <br/>
  19. S4      : 0x00000001  S5      : 0x0000001d  S6      : 0x00000012  S7      : 0x00000000  <br/>
  20. S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  <br/>
  21. T3      : 0x42014c94  T4      : 0x42015f62  T5      : 0x42014c90  T6      : 0x42015f4c  <br/>
  22. 0x42014c94: npl_freertos_callout_set_arg at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c:956<br/>
  23. 0x42015f62: npl_freertos_callout_remaining_ticks at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c:915<br/>
  24. 0x42014c90: npl_freertos_callout_get_ticks at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c:910<br/>
  25. 0x42015f4c: npl_freertos_callout_is_active at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c:884<br/>
  26. <br/>
  27. MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000005  MTVAL   : 0x00000044  <br/>
  28. 0x40380001: _vector_table at ??:?<br/>
  29. <br/>
  30. MHARTID : 0x00000000  <br/>
  31. <br/>
  32. <br/>
  33. Backtrace:<br/>
  34. <br/>
  35. <br/>
  36. 0x42009624 in ble_npl_mutex_pend (timeout=4294967295, mu=0x3fc95ae0 <ble_hs_mutex>) at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/include/nimble/nimble_npl_os.h:234<br/>
  37. 234         return npl_funcs->p_ble_npl_mutex_pend(mu, timeout);<br/>
  38. #0  0x42009624 in ble_npl_mutex_pend (timeout=4294967295, mu=0x3fc95ae0 <ble_hs_mutex>) at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/include/nimble/nimble_npl_os.h:234<br/>
  39. #1  ble_hs_lock_nested () at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_hs.c:174<br/>
  40. #2  0x4200965e in ble_hs_lock () at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_hs.c:219<br/>
  41. #3  0x4201ba0e in ble_att_svr_tx_rsp (conn_handle=conn_handle@entry=1, hs_status=9, om=0x3fca3254, att_op=att_op@entry=18 '\022', err_status=1 '\001', err_handle=err_handle@entry=29) at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_att_svr.c:680<br/>
  42. #4  0x4201bffc in ble_att_svr_rx_write (conn_handle=1, rxom=0x3fc95f60 <ble_l2cap_chan_mem+16>) at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_att_svr.c:2303<br/>
  43. #5  0x4200a890 in ble_att_rx (chan=0x3fc95f50 <ble_l2cap_chan_mem>) at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_att.c:517<br/>
  44. #6  0x4200a6c0 in ble_hs_hci_evt_acl_process (om=0x0) at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_hs_hci_evt.c:1145<br/>
  45. #7  0x4200967c in ble_hs_process_rx_data_queue () at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_hs.c:243<br/>
  46. #8  0x42009698 in ble_hs_event_rx_data (ev=<optimized out>) at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_hs.c:540<br/>
  47. #9  0x42014c4c in npl_freertos_event_run (ev=<optimized out>) at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c:451<br/>
  48. #10 0x40381d86 in ble_npl_event_run (ev=0x3fc95ccc <ble_hs_rx_q+8>) at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/include/nimble/nimble_npl_os.h:185<br/>
  49. #11 nimble_port_run () at /home/kalpesh/esp/esp-idf/components/bt/host/nimble/nimble/porting/nimble/src/nimble_port.c:279<br/>
  50. #12 0x42008ef2 in host_task (param=<error reading variable: value has been optimized out>) at /home/kalpesh/esp/ds18b20_temp_sens/GitHub/LoRaWAN-Sensor-Node/4. Firmware/Final_Firmware/LoRaWAN_SensorNode/main/LoraWaN_BLE/CapufGap.c:107<br/>
  51. #13 0x4038ab06 in vPortTaskWrapper (pxCode=<optimized out>, pvParameters=<optimized out>) at /home/kalpesh/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:255<br/>
  52. ELF file SHA256: 7c504abdb<br/>
  53. <br/>
  54. Rebooting...<e>
</e></CODEBOX></r>

irahul
Posts: 46
Joined: Fri Jun 18, 2021 10:07 am

Re: How to reinitialize ble stack

Postby irahul » Fri Oct 25, 2024 4:29 am

Blecent example has a code to show how to do stack init / deinit in a loop. https://github.com/espressif/esp-idf/bl ... ain.c#L910 . You can check it for reference.

Who is online

Users browsing this forum: MicroController and 222 guests