Month: July 2021

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"