Issues I was facing during radiosonde_auto_rx install

I was facing this error:

$ sudo python auto_rx.py
2021-07-26 08:50:15,471 INFO:Reading configuration file…
2021-07-26 08:50:15,472 WARNING:Config - Web Password not set, disabling web control
2021-07-26 08:50:15,949 INFO:RTLSDR - Attempting to reset: Bus: 1 Device: 9
2021-07-26 08:50:18,712 INFO:RTLSDR - Attempting to reset: Bus: 1 Device: 9
2021-07-26 08:50:21,457 INFO:RTLSDR - Attempting to reset: Bus: 1 Device: 9
2021-07-26 08:50:24,219 INFO:RTLSDR - Attempting to reset: Bus: 1 Device: 9
2021-07-26 08:50:26,993 INFO:RTLSDR - Attempting to reset: Bus: 1 Device: 9
2021-07-26 08:50:29,430 ERROR:RTLSDR - RTLSDR with serial #0 was not recovered after 5 reset attempts.
2021-07-26 08:50:29,430 WARNING:Config - SDR #0 invalid.
2021-07-26 08:50:29,430 ERROR:Config - No working SDRs! Cannot run…
2021-07-26 08:50:29,430 CRITICAL:Error in configuration file! Exiting…

Note I was using “sudo” to run the auto_rx.py command, because normal user was receiving permission error. Then searching in the Internet I didn’t find a solution, but started to suspect it could be related to the permission.

Then I downloaded the udev rule: https://raw.githubusercontent.com/osmocom/rtl-sdr/master/rtl-sdr.rules and copied it:

$ sudo mv rtl-sdr.rules /etc/udev/rules.d/70-rtl-sdr.rules

And restarted the udev:

$ sudo udevadm trigger

Then the reset error disappeared but other error happened:

$ python auto_rx.py
2021-07-26 09:01:51,636 INFO:Reading configuration file…
2021-07-26 09:01:51,637 WARNING:Config - Web Password not set, disabling web control
2021-07-26 09:01:54,536 INFO:Config - Tested SDR #0 OK
2021-07-26 09:01:54,537 CRITICAL:Binary mp3h1mod does not exist - did you run build.sh?

Then I moved to depmod and compiled the mp3h1mod:

$ cd ../demod/mod/
$ vi Makefile:

PROGRAMS := rs41mod dfm09mod rs92mod lms6mod lms6Xmod meisei100mod m10mod mXXmod imet54mod mp3h1mod

mp3h1mod: mp3h1mod.o demod_mod.o


$ cd ../..
$ make
$ cp demod/mod/mp3h1mod auto_rx/

Then everything worked as expected:

$ python auto_rx.py
2021-07-26 09:05:35,025 INFO:Reading configuration file…
2021-07-26 09:05:35,026 WARNING:Config - Web Password not set, disabling web control
2021-07-26 09:05:37,900 INFO:Config - Tested SDR #0 OK
2021-07-26 09:05:37,902 INFO:Started Flask server on http://0.0.0.0:5000
2021-07-26 09:05:37,902 INFO:Telemetry Logger - Started Telemetry Logger Thread.
2021-07-26 09:05:37,902 INFO:OziMux - Started OziMux / Payload Summary Exporter
2021-07-26 09:05:37,903 INFO:Sondehub Uploader - Started Sondehub Uploader Thread.
2021-07-26 09:05:38,710 INFO:Sondehub Uploader - Uploaded station information to Sondehub.
2021-07-26 09:05:43,675 INFO:Version - Local Version: 1.5.4 - Up to date!
2021-07-26 09:05:43,675 INFO:Task Manager - SDR #0 has been allocated to Scanner.
2021-07-26 09:05:46,593 INFO:Scanner #0 - Starting Scanner Thread
2021-07-26 09:05:46,600 INFO:Scanner #0 - Running frequency scan.
2021-07-26 09:06:07,174 INFO:Scanner #0 - Detected peaks on 2 frequencies (MHz): [400.79 402.26]

More info: https://github.com/projecthorus/radiosonde_auto_rx/wiki

[location]
station_lat = -27.543275
station_lon = -48.509017
station_alt = 0.0

ppm = 2

http://www.om3bc.com/docs/RS/autofile.tar.gz

When you want to find the division by zero

That was the crash:

esp32_rng_initialize: Initializing RNG                                                 
esp32_bt_controller_init: BT controller compile version [a4c513b]                         
btdm_controller_mem_init: .data initialise [0x3ffae6e0] <== [0x4000d890]                  
btdm_controller_mem_init: .bss initialise [0x3ffb0000] - [0x3ffb09a8]                     
btdm_controller_mem_init: .bss initialise [0x3ffb09a8] - [0x3ffb1ddc]                     
btdm_controller_mem_init: .bss initialise [0x3ffb1ddc] - [0x3ffb2730]                     
btdm_controller_mem_init: .bss initialise [0x3ffb2730] - [0x3ffb6388]                     
btdm_controller_mem_init: .bss initialise [0x3ffb8000] - [0x3ffb9a20]                     
btdm_controller_mem_init: .bss initialise [0x3ffbdb28] - [0x3ffbdb5c]                     
esp32_bt_controller_init: BT controller compile version [a4c513b]                         
esp_ble_set_isr: n=5 f=0x4008b66c arg=0 irq=9                                             
esp_ble_set_isr: n=8 f=0x4008b6ac arg=0 irq=12                                            
esp_ble_set_isr: n=7 f=0x4008b654 arg=0 irq=11                                            
xtensa_user_panic: User Exception: EXCCAUSE=0006 task: btController                       
xtensa_registerdump:    PC: 401395f5    PS: 00060830                                      
xtensa_registerdump:    A0: 80082724    A1: 3ffcf4d0    A2: 00000064    A3: 00000001      
xtensa_registerdump:    A4: 00000000    A5: 00000000    A6: 00000008    A7: 3ffcf500      
xtensa_registerdump:    A8: 00000002    A9: 00000000   A10: 00000000   A11: 00000003      
xtensa_registerdump:   A12: 00000064   A13: 00000000   A14: 401353dc   A15: 3ffcf470      
xtensa_registerdump:   SAR: 00000020 CAUSE: 00000006 VADDR: 00000000                      
xtensa_registerdump:  LBEG: 4000c2e0  LEND: 4000c2f6  LCNT: ffffffff                      
xtensa_registerdump:  TMP0: 400808d8  TMP1: 3ffcf2b0                                      
xtensa_btdump: Backtrace0: 400d75ca:3ffcf1f0                                              
xtensa_btdump: Backtrace1: 400d6a72:3ffcf220                                              
xtensa_btdump: Backtrace2: 400d6b91:3ffcf240                                              
xtensa_btdump: Backtrace3: 400d69f1:3ffcf280                                              
xtensa_btdump: Backtrace4: 400808f5:3ffcf2b0                                              
xtensa_btdump: Backtrace5: 40020:3ffcf310                                                 
xtensa_btdump: BACKTRACE Done                                                             
xtensa_dumpstate: sp:         3ffcf1d0                                                    
xtensa_dumpstate: stack base: 3ffca650                                                    
xtensa_dumpstate: stack size: 00000830                                                    
xtensa_dumpstate: ERROR: Stack pointer is not within allocated stack                      
xtensa_stackdump: 3ffca640: 3ffca648 00000000 74696e69 00000000 5ee9e106 37b32ee5 28740f1f
xtensa_stackdump: 3ffca660: 00249f00 0229e9f6 00001248 39e31955 024e9b23 3ffca760 00000008
xtensa_stackdump: 3ffca680: 97d9ef5b 6dd407fc b93f0ef9 a36e5f42 57d5eb86 7ee10181 3418aa79
xtensa_stackdump: 3ffca6a0: 00249f00 024e88f6 0000122d 5ae6c916 00000000 3ffca7a0 0000000d
xtensa_stackdump: 3ffca6c0: e5dccdf8 a46e4975 b4e1445e 2de35921 3597ef13 ee69dee2 87e50029
xtensa_stackdump: 3ffca6e0: 400d69f4 00000000 00000000 3c763775 00000000 3ffca7a0 4ac6d383
xtensa_stackdump: 3ffca700: 2bd71b13 b5b239b7 a9848d40 851cf774 00040023 3ffca760 0001804f
xtensa_stackdump: 3ffca720: 3ffca2a0 00000007 3ffc39f0 0db63a00 00000000 3ffca7a0 d5530f84
xtensa_stackdump: 3ffca740: deb0b36e 2aa265a8 86547725 240f53e1 00040023 3ffca7a0 0001804f
xtensa_stackdump: 3ffca760: 00000040 00000007 3ffc39f0 3ffca900 00000000 3ffca7a0 00000070
xtensa_stackdump: 3ffca780: 00000008 3ffca980 800d7982 3ffca950 00060520 3ffcab84 3ffcabcc
xtensa_stackdump: 3ffca7a0: 400d825e 00060530 800e6d95 3ffca9c0 00000000 00000109 3f407888
xtensa_stackdump: 3ffca7c0: 3ffbdb5c 3ffca9c0 800d825c 3ffca980 00000000 0000007f 00000070
xtensa_stackdump: 3ffca7e0: 00000008 3ffca980 00000006 27c52b29 3ffca2a0 4000c2e0 4000c2ff
xtensa_stackdump: 3ffca800: 40080740 3ffca7a0 93853250 100a3ffa 0df76fbe e56a121e 741236e8

The EXCCAUSE=0006 means division by zero

So, let to disassemble to return address (A0)

(gdb) disassemble /m 0x40082724
Dump of assembler code for function btdm_us_2_lpcycles:
warning: Source file is more recent than executable.
1462 {
0x400826d0 <+0>: entry a1, 64
0x400826d3 <+3>: mov.n a7, a1
0x400826d5 <+5>: s32i.n a2, a7, 16

1463 uint64_t cycles;
1464 cycles = ((uint64_t)(us) << g_btdm_lpcycle_us_frac) / g_btdm_lpcycle_us; 0x400826d7 <+7>: l32i.n a2, a7, 16
0x400826d9 <+9>: mov.n a8, a2
0x400826db <+11>: movi.n a9, 0
0x400826dd <+13>: l32r a2, 0x400806f4
0x400826e0 <+16>: l8ui a2, a2, 0
0x400826e3 <+19>: movi.n a3, 32
0x400826e5 <+21>: and a3, a2, a3
0x400826e8 <+24>: movi.n a6, 0
0x400826ea <+26>: srli a13, a8, 1
0x400826ed <+29>: movi.n a12, -1
0x400826ef <+31>: xor a12, a2, a12
0x400826f2 <+34>: ssr a12
0x400826f5 <+37>: srl a12, a13
---Type to continue, or q to quit---q
Quit

How to copy (dump) the content of STM32F103 Flash

A user called Sandeep asked me at the NuttX Channel how to copy the firmware already flashed in the stm32f103 MCU. Then I decided to document it here:

$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg -c init -c "reset halt" -c "flash read_bank 0 dump_flash.bin"

debug log of the ESP32-C3 BLE booting on NuttX

I (206) boot: Loaded app from partition at offset 0x10000
I (206) boot: Disabling RNG early entropy source…
ABesp32c3_bt_controller_init: BT controller compile version [501d88d]
interrupt_set_wrapper: cpu_no=0 , intr_source=8 , intr_num=5, intr_prio=1
queue_recv_wrapper: Failed to timedreceive from mqueue error=-116
queue_recv_wrapper: Failed to timedreceive from mqueue error=-116
bt_initialize: btdev 0x3fc862c0
bt_hci_cmd_create: opcode 0c03 param_len 0
bt_buf_alloc: buf 0x3fc8497c type 0 reserve 1
bt_hci_cmd_create: buf 0x3fc8497c
bt_buf_extend: buf 0x3fc8497c len 3
bt_hci_cmd_send_sync: opcode 0c03 len 3
hci_tx_kthread: started
bt_buf_addref: buf 0x3fc8497c (old) ref 1 type 0
hci_tx_kthread: Sending command 0c03 buf 0x3fc8497c to driver
bt_receive: data 0x3fc8f1b3 len 6
bt_buf_alloc: buf 0x3fc84964 type 1 reserve 0
bt_buf_extend: buf 0x3fc84964 len 6
priority_rx_work: list 0x3fc841ac
priority_rx_work: buf 0x3fc84964 type 1 len 6
bt_buf_consume: buf 0x3fc84964 len 2
hci_cmd_complete: opcode 0c03
bt_buf_consume: buf 0x3fc84964 len 3
hci_reset_complete: status 0
bt_buf_addref: buf 0x3fc84964 (old) ref 1 type 1
bt_buf_release: buf 0x3fc8497c ref 2 type 0
bt_buf_release: Remaining references: 1
bt_buf_release: buf 0x3fc84964 ref 2 type 1
bt_buf_release: Remaining references: 1
queue_recv_wrapper: Failed to timedreceive from mqueue error=-116
bt_buf_release: buf 0x3fc8497c ref 1 type 0
bt_buf_release: Buffer freed: 0x3fc8497c
bt_buf_release: buf 0x3fc8497c ref 0 type 0
bt_buf_release: Remaining references: 255
bt_buf_release: buf 0x3fc84964 ref 1 type 1
bt_buf_release: Buffer freed: 0x3fc84964
bt_hci_cmd_create: opcode 1003 param_len 0
bt_buf_alloc: buf 0x3fc84964 type 0 reserve 1
bt_hci_cmd_create: buf 0x3fc84964
bt_buf_extend: buf 0x3fc84964 len 3
bt_hci_cmd_send_sync: opcode 1003 len 3
bt_buf_addref: buf 0x3fc84964 (old) ref 1 type 0
hci_tx_kthread: Sending command 1003 buf 0x3fc84964 to driver
bt_receive: data 0x3fc8f1ab len 14
bt_buf_alloc: buf 0x3fc8497c type 1 reserve 0
bt_buf_extend: buf 0x3fc8497c len 14
priority_rx_work: list 0x3fc841ac
priority_rx_work: buf 0x3fc8497c type 1 len 14
bt_buf_consume: buf 0x3fc8497c len 2
hci_cmd_complete: opcode 1003
bt_buf_consume: buf 0x3fc8497c len 3
hci_cmd_complete: Unhandled opcode 1003
bt_buf_addref: buf 0x3fc8497c (old) ref 1 type 1
bt_buf_release: buf 0x3fc84964 ref 2 type 0
bt_buf_release: Remaining references: 1
bt_buf_release: buf 0x3fc8497c ref 2 type 1
bt_buf_release: Remaining references: 1
queue_recv_wrapper: Failed to timedreceive from mqueue error=-116
bt_buf_release: buf 0x3fc84964 ref 1 type 0
bt_buf_release: Buffer freed: 0x3fc84964
bt_buf_release: buf 0x3fc84964 ref 0 type 0
bt_buf_release: Remaining references: 255
read_local_features_complete: status 0
bt_buf_release: buf 0x3fc8497c ref 1 type 1
bt_buf_release: Buffer freed: 0x3fc8497c
bt_hci_cmd_create: opcode 1001 param_len 0
bt_buf_alloc: buf 0x3fc8497c type 0 reserve 1
bt_hci_cmd_create: buf 0x3fc8497c
bt_buf_extend: buf 0x3fc8497c len 3
bt_hci_cmd_send_sync: opcode 1001 len 3
bt_buf_addref: buf 0x3fc8497c (old) ref 1 type 0
hci_tx_kthread: Sending command 1001 buf 0x3fc8497c to driver
bt_receive: data 0x3fc8f1ab len 14
bt_buf_alloc: buf 0x3fc84964 type 1 reserve 0
bt_buf_extend: buf 0x3fc84964 len 14
priority_rx_work: list 0x3fc841ac
priority_rx_work: buf 0x3fc84964 type 1 len 14
bt_buf_consume: buf 0x3fc84964 len 2
hci_cmd_complete: opcode 1001
bt_buf_consume: buf 0x3fc84964 len 3
hci_cmd_complete: Unhandled opcode 1001
bt_buf_addref: buf 0x3fc84964 (old) ref 1 type 1
bt_buf_release: buf 0x3fc8497c ref 2 type 0
bt_buf_release: Remaining references: 1
bt_buf_release: buf 0x3fc84964 ref 2 type 1
bt_buf_release: Remaining references: 1
queue_recv_wrapper: Failed to timedreceive from mqueue error=-116
bt_buf_release: buf 0x3fc8497c ref 1 type 0
bt_buf_release: Buffer freed: 0x3fc8497c
bt_buf_release: buf 0x3fc8497c ref 0 type 0
bt_buf_release: Remaining references: 255
read_local_ver_complete: status 0
bt_buf_release: buf 0x3fc84964 ref 1 type 1
bt_buf_release: Buffer freed: 0x3fc84964
bt_hci_cmd_create: opcode 1009 param_len 0
bt_buf_alloc: buf 0x3fc84964 type 0 reserve 1
bt_hci_cmd_create: buf 0x3fc84964
bt_buf_extend: buf 0x3fc84964 len 3
bt_hci_cmd_send_sync: opcode 1009 len 3
bt_buf_addref: buf 0x3fc84964 (old) ref 1 type 0
hci_tx_kthread: Sending command 1009 buf 0x3fc84964 to driver
bt_receive: data 0x3fc8f1af len 12
bt_buf_alloc: buf 0x3fc8497c type 1 reserve 0
bt_buf_extend: buf 0x3fc8497c len 12
priority_rx_work: list 0x3fc841ac
priority_rx_work: buf 0x3fc8497c type 1 len 12
bt_buf_consume: buf 0x3fc8497c len 2
hci_cmd_complete: opcode 1009
bt_buf_consume: buf 0x3fc8497c len 3
hci_cmd_complete: Unhandled opcode 1009
bt_buf_addref: buf 0x3fc8497c (old) ref 1 type 1
bt_buf_release: buf 0x3fc84964 ref 2 type 0
bt_buf_release: Remaining references: 1
bt_buf_release: buf 0x3fc8497c ref 2 type 1
bt_buf_release: Remaining references: 1
queue_recv_wrapper: Failed to timedreceive from mqueue error=-116
bt_buf_release: buf 0x3fc84964 ref 1 type 0
bt_buf_release: Buffer freed: 0x3fc84964
bt_buf_release: buf 0x3fc84964 ref 0 type 0
bt_buf_release: Remaining references: 255
read_bdaddr_complete: status 0
bt_buf_release: buf 0x3fc8497c ref 1 type 1
bt_buf_release: Buffer freed: 0x3fc8497c
bt_hci_cmd_create: opcode 2003 param_len 0
bt_buf_alloc: buf 0x3fc8497c type 0 reserve 1
bt_hci_cmd_create: buf 0x3fc8497c
bt_buf_extend: buf 0x3fc8497c len 3
bt_hci_cmd_send_sync: opcode 2003 len 3
bt_buf_addref: buf 0x3fc8497c (old) ref 1 type 0
hci_tx_kthread: Sending command 2003 buf 0x3fc8497c to driver
bt_receive: data 0x3fc8f1ab len 14
bt_buf_alloc: buf 0x3fc84964 type 1 reserve 0
bt_buf_extend: buf 0x3fc84964 len 14
priority_rx_work: list 0x3fc841ac
priority_rx_work: buf 0x3fc84964 type 1 len 14
bt_buf_consume: buf 0x3fc84964 len 2
hci_cmd_complete: opcode 2003
bt_buf_consume: buf 0x3fc84964 len 3
hci_cmd_complete: Unhandled opcode 2003
bt_buf_addref: buf 0x3fc84964 (old) ref 1 type 1
bt_buf_release: buf 0x3fc8497c ref 2 type 0
bt_buf_release: Remaining references: 1
bt_buf_release: buf 0x3fc84964 ref 2 type 1
bt_buf_release: Remaining references: 1
queue_recv_wrapper: Failed to timedreceive from mqueue error=-116
bt_buf_release: buf 0x3fc8497c ref 1 type 0
bt_buf_release: Buffer freed: 0x3fc8497c
bt_buf_release: buf 0x3fc8497c ref 0 type 0
bt_buf_release: Remaining references: 255
read_le_features_complete: status 0
bt_buf_release: buf 0x3fc84964 ref 1 type 1
bt_buf_release: Buffer freed: 0x3fc84964
bt_hci_cmd_create: opcode 2002 param_len 0
bt_buf_alloc: buf 0x3fc84964 type 0 reserve 1
bt_hci_cmd_create: buf 0x3fc84964
bt_buf_extend: buf 0x3fc84964 len 3
bt_hci_cmd_send_sync: opcode 2002 len 3
bt_buf_addref: buf 0x3fc84964 (old) ref 1 type 0
hci_tx_kthread: Sending command 2002 buf 0x3fc84964 to driver
bt_receive: data 0x3fc8f1af len 9
bt_buf_alloc: buf 0x3fc8497c type 1 reserve 0
bt_buf_extend: buf 0x3fc8497c len 9
priority_rx_work: list 0x3fc841ac
priority_rx_work: buf 0x3fc8497c type 1 len 9
bt_buf_consume: buf 0x3fc8497c len 2
hci_cmd_complete: opcode 2002
bt_buf_consume: buf 0x3fc8497c len 3
hci_cmd_complete: Unhandled opcode 2002
bt_buf_addref: buf 0x3fc8497c (old) ref 1 type 1
bt_buf_release: buf 0x3fc84964 ref 2 type 0
bt_buf_release: Remaining references: 1
bt_buf_release: buf 0x3fc8497c ref 2 type 1
bt_buf_release: Remaining references: 1
queue_recv_wrapper: Failed to timedreceive from mqueue error=-116
bt_buf_release: buf 0x3fc84964 ref 1 type 0
bt_buf_release: Buffer freed: 0x3fc84964
bt_buf_release: buf 0x3fc84964 ref 0 type 0
bt_buf_release: Remaining references: 255
le_read_buffer_size_complete: status 0
bt_buf_release: buf 0x3fc8497c ref 1 type 1
bt_buf_release: Buffer freed: 0x3fc8497c
bt_hci_cmd_create: opcode 0c01 param_len 8
bt_buf_alloc: buf 0x3fc8497c type 0 reserve 1
bt_hci_cmd_create: buf 0x3fc8497c
bt_buf_extend: buf 0x3fc8497c len 3
bt_buf_extend: buf 0x3fc8497c len 8
bt_buf_addref: buf 0x3fc8497c (old) ref 1 type 0
bt_hci_cmd_send_sync: opcode 0c01 len 11
bt_buf_addref: buf 0x3fc8497c (old) ref 2 type 0
hci_tx_kthread: Sending command 0c01 buf 0x3fc8497c to driver
bt_receive: data 0x3fc8f1ab len 6
bt_buf_alloc: buf 0x3fc84964 type 1 reserve 0
bt_buf_extend: buf 0x3fc84964 len 6
priority_rx_work: list 0x3fc841ac
priority_rx_work: buf 0x3fc84964 type 1 len 6
bt_buf_consume: buf 0x3fc84964 len 2
hci_cmd_complete: opcode 0c01
bt_buf_consume: buf 0x3fc84964 len 3
hci_cmd_complete: Unhandled opcode 0c01
bt_buf_addref: buf 0x3fc84964 (old) ref 1 type 1
bt_buf_release: buf 0x3fc8497c ref 3 type 0
bt_buf_release: Remaining references: 2
bt_buf_release: buf 0x3fc84964 ref 2 type 1
bt_buf_release: Remaining references: 1
queue_recv_wrapper: Failed to timedreceive from mqueue error=-116
bt_buf_release: buf 0x3fc8497c ref 2 type 0
bt_buf_release: Remaining references: 1
bt_buf_release: buf 0x3fc84964 ref 1 type 1
bt_buf_release: Buffer freed: 0x3fc84964
bt_buf_release: buf 0x3fc8497c ref 1 type 0
bt_buf_release: Buffer freed: 0x3fc8497c
bt_hci_cmd_create: opcode 0c33 param_len 7
bt_buf_alloc: buf 0x3fc8497c type 0 reserve 1
bt_hci_cmd_create: buf 0x3fc8497c
bt_buf_extend: buf 0x3fc8497c len 3
bt_buf_extend: buf 0x3fc8497c len 7
bt_buf_addref: buf 0x3fc8497c (old) ref 1 type 0
bt_hci_cmd_send: opcode 0c33 len 10
bt_hci_cmd_create: opcode 0c31 param_len 1
bt_buf_alloc: buf 0x3fc84964 type 0 reserve 1
bt_hci_cmd_create: buf 0x3fc84964
bt_buf_extend: buf 0x3fc84964 len 3
bt_buf_extend: buf 0x3fc84964 len 1
bt_buf_addref: buf 0x3fc84964 (old) ref 1 type 0
bt_hci_cmd_send_sync: opcode 0c31 len 4
bt_buf_addref: buf 0x3fc8497c (old) ref 2 type 0
hci_tx_kthread: Sending command 0c33 buf 0x3fc8497c to driver
bt_receive: data 0x3fc8f1ab len 6
bt_buf_alloc: buf 0x3fc8494c type 1 reserve 0
bt_buf_extend: buf 0x3fc8494c len 6
priority_rx_work: list 0x3fc841ac
priority_rx_work: buf 0x3fc8494c type 1 len 6
bt_buf_consume: buf 0x3fc8494c len 2
hci_cmd_complete: opcode 0c33
bt_buf_consume: buf 0x3fc8494c len 3
hci_cmd_complete: Unhandled opcode 0c33
bt_buf_release: buf 0x3fc8497c ref 3 type 0
bt_buf_release: Remaining references: 2
bt_buf_release: buf 0x3fc8494c ref 1 type 1
bt_buf_release: Buffer freed: 0x3fc8494c
queue_recv_wrapper: Failed to timedreceive from mqueue error=-116
bt_buf_release: buf 0x3fc8497c ref 2 type 0
bt_buf_release: Remaining references: 1
bt_buf_addref: buf 0x3fc84964 (old) ref 2 type 0
hci_tx_kthread: Sending command 0c31 buf 0x3fc84964 to driver
bt_receive: data 0x3fc8f1af len 6
bt_buf_alloc: buf 0x3fc8494c type 1 reserve 0
bt_buf_extend: buf 0x3fc8494c len 6
priority_rx_work: list 0x3fc841ac
priority_rx_work: buf 0x3fc8494c type 1 len 6
bt_buf_consume: buf 0x3fc8494c len 2
hci_cmd_complete: opcode 0c31
bt_buf_consume: buf 0x3fc8494c len 3
hci_cmd_complete: Unhandled opcode 0c31
bt_buf_addref: buf 0x3fc8494c (old) ref 1 type 1
bt_buf_release: buf 0x3fc84964 ref 3 type 0
bt_buf_release: Remaining references: 2
bt_buf_release: buf 0x3fc8494c ref 2 type 1
bt_buf_release: Remaining references: 1
queue_recv_wrapper: Failed to timedreceive from mqueue error=-116
bt_buf_release: buf 0x3fc84964 ref 2 type 0
bt_buf_release: Remaining references: 1
bt_buf_release: buf 0x3fc8494c ref 1 type 1
bt_buf_release: Buffer freed: 0x3fc8494c
bt_buf_release: buf 0x3fc84964 ref 1 type 0
bt_buf_release: Buffer freed: 0x3fc84964
hci_initialize: HCI ver 9 rev 22, manufacturer 96
hci_initialize: ACL buffers: pkts 12 mtu 251
bt_l2cap_chan_register: CID 0x0004
bt_l2cap_chan_register: CID 0x0006
bt_l2cap_chan_register: CID 0x0005
NuttShell (NSH) NuttX-10.1.0-RC1
nsh>

Using Bluetooth Low Energy BLE in the ESP32-C3 on NuttX

These are the steps!

Compile NuttX ble example:

$ ./tools/configure.sh esp32c3-devkit:ble
$ make download ESPTOOL_PORT=/dev/ttyUSB0
$ minicom
NuttShell (NSH) NuttX-10.1.0-RC1
nsh> ifconfig
bnep0 Link encap:UNSPEC at DOWN
inet addr:0.0.0.0 DRaddr:0.0.0.0 Mask:0.0.0.0
nsh> ?
help usage: help [-v] []
. cat df help ls ps source unset
[ cd echo hexdump mkdir pwd test usleep
? cp exec ifconfig mkrd rm time xd
arp cmp exit ifdown mount rmdir true
basename dirname false ifup mv set uname
break dd free kill nslookup sleep umount
Builtin Apps:
bt sh nsh
nsh> bt
ERROR: Missing interface name
Usage:

  bt <ifname> <cmd> [option [option [option...]]]
Where [option [option [option…]]] is one of:

    help                                                                              
    info            [-h]                                                              
    features        [-h] [le]                                                         
    scan            [-h] <start [-d]|get|stop>                                        
    advertise       [-h] <start|stop>                                                 
    security        [-h] <addr> public|private <level>                                
    gatt            [-h] <cmd> [option [option [option...]]]
Use the -h option on any command to get more info.
nsh> bt bnep0 info
Device: bnep0
BDAddr: 01:23:45:67:89:ab
Flags: 0000
Free: 20
ACL: 20
SCO: 0
Max:
ACL: 24
SCO: 0
MTU:
ACL: 70
SCO: 70
Policy: 0
Type: 0
nsh> bt bnep0 scan
ERROR: Missing scan command
scan: Scan commands:
Usage:

  bt <ifname> scan [-h] <start [-d]|get|stop>
Where the options do the following:

    start   - Starts scanning.  The -d option enables duplicate                       
              filtering.                                                              
    get     - Shows new accumulated scan results                                      
    stop    - Stops scanning
nsh> bt bnep0 scan start
nsh> bt bnep0 scan stop
nsh> bt bnep0 scan get
Scan result:
  1. addr: f3:d5:9a:7f:79:54 type: 1
    rssi: -76
    response type: 4
    advertiser data: 2. addr: 68:72:67:2a:9b:bc type: 1
    rssi: -79
    response type: 3
    advertiser data: 1e ff 06 00 01 09 20 02 63 5f d2 79 cb a0 c7 3d
    bb e9 0f 0c e8 e3 56 59 82 82 d4 59 5a d2 97
  2. addr: 48:68:49:2f:b5:09 type: 1
    rssi: -87
    response type: 2
    advertiser data: 02 01 1a 0a ff c4 00 06 34 03 12 14 16 80 02 0a
    d4 03 03 b9 fe 08 1b 00 2d 97 67 12 dd 78
  3. addr: 48:68:49:2f:b5:09 type: 1
    rssi: -85
    response type: 4
    advertiser data: 18 09 5b 4c 47 5d 20 77 65 62 4f 53 20 54 56 20
    55 4d 37 32 37 30 50 53 41 02 0a d4
  4. addr: 7e:91:3c:ef:a4:37 type: 1
    rssi: -87
    response type: 3
    advertiser data: 1e ff 06 00 01 09 20 02 16 3c 09 4a 4e 1b 3f c0
    e3 d3 8b 92 0d 21 32 0a 67 30 9a 0b 7b 6d bb
    nsh>

Debugging ESP32 over JTAG using OpenOCD

Right, I already posted how to debug ESP32-S2 here and the process is pretty similar

I’ll not explain how to wire the ESP32_PROG (or any other FTDI FT232 OpenOCD compatible programmer) to ESP32, you can find it easily in the Internet.

Instead I will use the ESP-WROVER-KIT board that already come with JTAG programmer in the board.

You need to clone the Espressif OpenOCD ESP32 repository:

$ git clone https://github.com/espressif/openocd-esp32

Configure and compile it:

$ ./bootstrap
$ ./configure --program-prefix=esp32- --enable-dummy --enable-ftdi --enable-ftdi-oscan1 --enable-stlink --enable-ti-icdi --enable-ulink --enable-usb-blaster-2 --enable-ft232r --enable-vsllink --enable-xds110 --enable-osbdm --enable-opendous --enable-esp-usb-jtag --enable-aice --enable-usbprog --enable-rlink --enable-armjtagew --enable-cmsis-dap --enable-kitprog --enable-usb-blaster --enable-presto --enable-openjtag --enable-jlink

If you have all the necessary libraries in your system you should see a nice report line mine:

OpenOCD configuration summary
MPSSE mode of FTDI based devices yes
cJTAG OSCAN1 tunneled thru MPSSE yes
ST-Link Programmer yes
TI ICDI JTAG Programmer yes
Keil ULINK JTAG Programmer yes
Altera USB-Blaster II Compatible yes
Bitbang mode of FT232R based devices yes
Versaloon-Link JTAG Programmer yes
TI XDS110 Debug Probe yes
OSBDM (JTAG only) Programmer yes
eStick/opendous JTAG Programmer yes
Espressif JTAG Programmer yes
Andes JTAG Programmer yes
USBProg JTAG Programmer yes
Raisonance RLink JTAG Programmer yes
Olimex ARM-JTAG-EW Programmer yes
CMSIS-DAP Compliant Debugger yes
Cypress KitProg Programmer yes
Altera USB-Blaster Compatible yes
ASIX Presto Adapter yes
OpenJTAG Adapter yes
SEGGER J-Link Programmer yes

Sometimes you could have some missing library and it will report “no”, but most of the time you will not use that feature anyway…

Now just compile and install it:

$ make
$ sudo make install

Finally we can run OpenOCD to debug ESP32:

$ esp32-openocd -f board/esp32-wrover-kit-3.3v.cfg -c "set ESP_RTOS none"
Open On-Chip Debugger v0.10.0-esp32-20201202-6-gc0a2ec6e (2021-05-14-14:19)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : FreeRTOS creation
Info : FreeRTOS creation
none
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32.cpu0: Target halted, PC=0x400803C0, debug_reason=00000001
Info : Listening on port 3333 for gdb connections

Open another terminal and execute:

$ xtensa-esp32-elf-gdb nuttx
GNU gdb (crosstool-NG esp-2020r2) 8.1.0.20180627-git
Copyright (C) 2018 Free Software Foundation, Inc.
...
Reading symbols from nuttx…done.
(gdb) target extended-remote :3333
(gdb) mon reset halt
(gdb) flushregs
(gdb) b nx_start
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.
esp32.cpu0: Target halted, PC=0x400D1F69, debug_reason=00000001
Set GDB target to 'esp32.cpu0'

Breakpoint 1, nx_start () at init/nx_start.c:355
355 int cpu = 0;
(gdb)