RS41-flashing

From wikipost
Revision as of 22:35, 15 September 2020 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

If you've just retrieved an RS41 radiosonde and wonder how to get started with flashing it with your own code then this page is for you.

stopping the transmitter

When an RS41 is launched it holds 2x AA batteries that will keep the radiosonde transmitting for about 6 hours. The simplest way to stop the RS41 from transmitting is to press the on/off button briefly. The button is located under the sticker with the serial number, but just press it until the LED turns off.

RS41-on-off-button.jpg

open the case

Pry open the two plastic tabs on the top and bottom to separate the two styrofoam halves that encapsulates the RS41 circuit board.


Connecting to the RS41 programming header

If you have a 2mm-pitch 2x5 IDC connector laying around you can use that, but most people will just have to solder four wires to the programming header.

____________________
____________________|   (circuit board)
    | 2 4 6 8 10 |
    | 1 3 5 7 9  |   (programming connector)
    +------------+

  pin   
------------
   1    GND
   2
   3
   4    Vcc  (3.3V !!)
   5
   6
   7
   8    SWCLK
   9    SWDIO
  10

Using a USB ST-Link programming dongle we connect the wires.


setting up the STM32 compiler environment

apt-get install


install the ST-Link software

Don't use the Debian apt version of stlink, but instead use the one on github or grab it with pip (python installer)

git clone https://github.com/stlink-org/stlink.git

pip

clear the write-protect flag of the flash memory

start stlink debugger

- batteries not required (power STM32 straight from STLink)
- button press not required


in one screen run:

---[openocd debugger]---
map@zhora:~/local/radiosonde-rs41$ openocd -f /usr/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/share/openocd/scripts/target/stm32f1x.cfg 
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v29 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.306883
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
---[]---





then run telnet on another screen

---[telnet localhost 4444]---
map@zhora:~/local/radiosonde-rs41$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> reset
> halt
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x41000003 pc: 0x0800d5fc msp: 0x200015c0
> flash info 0  
device id = 0x10016420
STM32 flash size failed, probe inaccurate - assuming 128k flash
flash size = 128kbytes
#0 : stm32f1x at 0x08000000, size 0x00020000, buswidth 0, chipwidth 0
        #  0: 0x00000000 (0x400 1kB) protected
        #  1: 0x00000400 (0x400 1kB) protected
        #  2: 0x00000800 (0x400 1kB) protected
        #  3: 0x00000c00 (0x400 1kB) protected
        #  4: 0x00001000 (0x400 1kB) protected
        #  5: 0x00001400 (0x400 1kB) protected
        #  6: 0x00001800 (0x400 1kB) protected
        #  7: 0x00001c00 (0x400 1kB) protected
        #  8: 0x00002000 (0x400 1kB) protected
        #  9: 0x00002400 (0x400 1kB) protected
        # 10: 0x00002800 (0x400 1kB) protected
        # 11: 0x00002c00 (0x400 1kB) protected
        # 12: 0x00003000 (0x400 1kB) protected
        # 13: 0x00003400 (0x400 1kB) protected
        # 14: 0x00003800 (0x400 1kB) protected
        # 15: 0x00003c00 (0x400 1kB) protected
        # 16: 0x00004000 (0x400 1kB) protected
        # 17: 0x00004400 (0x400 1kB) protected
        # 18: 0x00004800 (0x400 1kB) protected
        # 19: 0x00004c00 (0x400 1kB) protected
        # 20: 0x00005000 (0x400 1kB) protected
        # 21: 0x00005400 (0x400 1kB) protected
        # 22: 0x00005800 (0x400 1kB) protected
        # 23: 0x00005c00 (0x400 1kB) protected
        # 24: 0x00006000 (0x400 1kB) protected
        # 25: 0x00006400 (0x400 1kB) protected
        # 26: 0x00006800 (0x400 1kB) protected
        # 27: 0x00006c00 (0x400 1kB) protected
        # 28: 0x00007000 (0x400 1kB) protected
        # 29: 0x00007400 (0x400 1kB) protected
        # 30: 0x00007800 (0x400 1kB) protected
        # 31: 0x00007c00 (0x400 1kB) protected
        # 32: 0x00008000 (0x400 1kB) protected
        # 33: 0x00008400 (0x400 1kB) protected
        # 34: 0x00008800 (0x400 1kB) protected
        # 35: 0x00008c00 (0x400 1kB) protected
        # 36: 0x00009000 (0x400 1kB) protected
        # 37: 0x00009400 (0x400 1kB) protected
        # 38: 0x00009800 (0x400 1kB) protected
        # 39: 0x00009c00 (0x400 1kB) protected
        # 40: 0x0000a000 (0x400 1kB) protected
        # 41: 0x0000a400 (0x400 1kB) protected
        # 42: 0x0000a800 (0x400 1kB) protected
        # 43: 0x0000ac00 (0x400 1kB) protected
        # 44: 0x0000b000 (0x400 1kB) protected
        # 45: 0x0000b400 (0x400 1kB) protected
        # 46: 0x0000b800 (0x400 1kB) protected
        # 47: 0x0000bc00 (0x400 1kB) protected
        # 48: 0x0000c000 (0x400 1kB) protected
        # 49: 0x0000c400 (0x400 1kB) protected
        # 50: 0x0000c800 (0x400 1kB) protected
        # 51: 0x0000cc00 (0x400 1kB) protected
        # 52: 0x0000d000 (0x400 1kB) protected
        # 53: 0x0000d400 (0x400 1kB) protected
        # 54: 0x0000d800 (0x400 1kB) protected
        # 55: 0x0000dc00 (0x400 1kB) protected
        # 56: 0x0000e000 (0x400 1kB) protected
        # 57: 0x0000e400 (0x400 1kB) protected
        # 58: 0x0000e800 (0x400 1kB) protected
        # 59: 0x0000ec00 (0x400 1kB) protected
        # 60: 0x0000f000 (0x400 1kB) not protected
        # 61: 0x0000f400 (0x400 1kB) not protected
        # 62: 0x0000f800 (0x400 1kB) not protected
        # 63: 0x0000fc00 (0x400 1kB) not protected
        # 64: 0x00010000 (0x400 1kB) not protected
        # 65: 0x00010400 (0x400 1kB) not protected
        # 66: 0x00010800 (0x400 1kB) not protected
        # 67: 0x00010c00 (0x400 1kB) not protected
        # 68: 0x00011000 (0x400 1kB) not protected
        # 69: 0x00011400 (0x400 1kB) not protected
        # 70: 0x00011800 (0x400 1kB) not protected
        # 71: 0x00011c00 (0x400 1kB) not protected
        # 72: 0x00012000 (0x400 1kB) not protected
        # 73: 0x00012400 (0x400 1kB) not protected
        # 74: 0x00012800 (0x400 1kB) not protected
        # 75: 0x00012c00 (0x400 1kB) not protected
        # 76: 0x00013000 (0x400 1kB) not protected
        # 77: 0x00013400 (0x400 1kB) not protected
        # 78: 0x00013800 (0x400 1kB) not protected
        # 79: 0x00013c00 (0x400 1kB) not protected
        # 80: 0x00014000 (0x400 1kB) not protected
        # 81: 0x00014400 (0x400 1kB) not protected
        # 82: 0x00014800 (0x400 1kB) not protected
        # 83: 0x00014c00 (0x400 1kB) not protected
        # 84: 0x00015000 (0x400 1kB) not protected
        # 85: 0x00015400 (0x400 1kB) not protected
        # 86: 0x00015800 (0x400 1kB) not protected
        # 87: 0x00015c00 (0x400 1kB) not protected
        # 88: 0x00016000 (0x400 1kB) not protected
        # 89: 0x00016400 (0x400 1kB) not protected
        # 90: 0x00016800 (0x400 1kB) not protected
        # 91: 0x00016c00 (0x400 1kB) not protected
        # 92: 0x00017000 (0x400 1kB) not protected
        # 93: 0x00017400 (0x400 1kB) not protected
        # 94: 0x00017800 (0x400 1kB) not protected
        # 95: 0x00017c00 (0x400 1kB) not protected
        # 96: 0x00018000 (0x400 1kB) not protected
        # 97: 0x00018400 (0x400 1kB) not protected
        # 98: 0x00018800 (0x400 1kB) not protected
        # 99: 0x00018c00 (0x400 1kB) not protected
        #100: 0x00019000 (0x400 1kB) not protected
        #101: 0x00019400 (0x400 1kB) not protected
        #102: 0x00019800 (0x400 1kB) not protected
        #103: 0x00019c00 (0x400 1kB) not protected
        #104: 0x0001a000 (0x400 1kB) not protected
        #105: 0x0001a400 (0x400 1kB) not protected
        #106: 0x0001a800 (0x400 1kB) not protected
        #107: 0x0001ac00 (0x400 1kB) not protected
        #108: 0x0001b000 (0x400 1kB) not protected
        #109: 0x0001b400 (0x400 1kB) not protected
        #110: 0x0001b800 (0x400 1kB) not protected
        #111: 0x0001bc00 (0x400 1kB) not protected
        #112: 0x0001c000 (0x400 1kB) not protected
        #113: 0x0001c400 (0x400 1kB) not protected
        #114: 0x0001c800 (0x400 1kB) not protected
        #115: 0x0001cc00 (0x400 1kB) not protected
        #116: 0x0001d000 (0x400 1kB) not protected
        #117: 0x0001d400 (0x400 1kB) not protected
        #118: 0x0001d800 (0x400 1kB) not protected
        #119: 0x0001dc00 (0x400 1kB) not protected
        #120: 0x0001e000 (0x400 1kB) not protected
        #121: 0x0001e400 (0x400 1kB) not protected
        #122: 0x0001e800 (0x400 1kB) not protected
        #123: 0x0001ec00 (0x400 1kB) not protected
        #124: 0x0001f000 (0x400 1kB) not protected
        #125: 0x0001f400 (0x400 1kB) not protected
        #126: 0x0001f800 (0x400 1kB) not protected
        #127: 0x0001fc00 (0x400 1kB) not protected
STM32F100 (Low/Medium Density) - Rev: Z
> 
> reset
> halt
> flash protect 0 0 last off
Device Security Bit Set
target halted due to breakpoint, current mode: Handler HardFault
xPSR: 0x61000003 pc: 0x2000003a msp: 0x200015c0
cleared protection for sectors 0 through 127 on flash bank 0
> flash info 0
device id = 0x10016420
flash size = 64kbytes
#0 : stm32f1x at 0x08000000, size 0x00010000, buswidth 0, chipwidth 0
        #  0: 0x00000000 (0x400 1kB) not protected
        #  1: 0x00000400 (0x400 1kB) not protected
        #  2: 0x00000800 (0x400 1kB) not protected
        #  3: 0x00000c00 (0x400 1kB) not protected
        #  4: 0x00001000 (0x400 1kB) not protected
        #  5: 0x00001400 (0x400 1kB) not protected
        #  6: 0x00001800 (0x400 1kB) not protected
        #  7: 0x00001c00 (0x400 1kB) not protected
        #  8: 0x00002000 (0x400 1kB) not protected
        #  9: 0x00002400 (0x400 1kB) not protected
        # 10: 0x00002800 (0x400 1kB) not protected
        # 11: 0x00002c00 (0x400 1kB) not protected
        # 12: 0x00003000 (0x400 1kB) not protected
        # 13: 0x00003400 (0x400 1kB) not protected
        # 14: 0x00003800 (0x400 1kB) not protected
        # 15: 0x00003c00 (0x400 1kB) not protected
        # 16: 0x00004000 (0x400 1kB) not protected
        # 17: 0x00004400 (0x400 1kB) not protected
        # 18: 0x00004800 (0x400 1kB) not protected
        # 19: 0x00004c00 (0x400 1kB) not protected
        # 20: 0x00005000 (0x400 1kB) not protected
        # 21: 0x00005400 (0x400 1kB) not protected
        # 22: 0x00005800 (0x400 1kB) not protected
        # 23: 0x00005c00 (0x400 1kB) not protected
        # 24: 0x00006000 (0x400 1kB) not protected
        # 25: 0x00006400 (0x400 1kB) not protected
        # 26: 0x00006800 (0x400 1kB) not protected
        # 27: 0x00006c00 (0x400 1kB) not protected
        # 28: 0x00007000 (0x400 1kB) not protected
        # 29: 0x00007400 (0x400 1kB) not protected
        # 30: 0x00007800 (0x400 1kB) not protected
        # 31: 0x00007c00 (0x400 1kB) not protected
        # 32: 0x00008000 (0x400 1kB) not protected
        # 33: 0x00008400 (0x400 1kB) not protected
        # 34: 0x00008800 (0x400 1kB) not protected
        # 35: 0x00008c00 (0x400 1kB) not protected
        # 36: 0x00009000 (0x400 1kB) not protected
        # 37: 0x00009400 (0x400 1kB) not protected
        # 38: 0x00009800 (0x400 1kB) not protected
        # 39: 0x00009c00 (0x400 1kB) not protected
        # 40: 0x0000a000 (0x400 1kB) not protected
        # 41: 0x0000a400 (0x400 1kB) not protected
        # 42: 0x0000a800 (0x400 1kB) not protected
        # 43: 0x0000ac00 (0x400 1kB) not protected
        # 44: 0x0000b000 (0x400 1kB) not protected
        # 45: 0x0000b400 (0x400 1kB) not protected
        # 46: 0x0000b800 (0x400 1kB) not protected
        # 47: 0x0000bc00 (0x400 1kB) not protected
        # 48: 0x0000c000 (0x400 1kB) not protected
        # 49: 0x0000c400 (0x400 1kB) not protected
        # 50: 0x0000c800 (0x400 1kB) not protected
        # 51: 0x0000cc00 (0x400 1kB) not protected
        # 52: 0x0000d000 (0x400 1kB) not protected
        # 53: 0x0000d400 (0x400 1kB) not protected
        # 54: 0x0000d800 (0x400 1kB) not protected
        # 55: 0x0000dc00 (0x400 1kB) not protected
        # 56: 0x0000e000 (0x400 1kB) not protected
        # 57: 0x0000e400 (0x400 1kB) not protected
        # 58: 0x0000e800 (0x400 1kB) not protected
        # 59: 0x0000ec00 (0x400 1kB) not protected
        # 60: 0x0000f000 (0x400 1kB) not protected
        # 61: 0x0000f400 (0x400 1kB) not protected
        # 62: 0x0000f800 (0x400 1kB) not protected
        # 63: 0x0000fc00 (0x400 1kB) not protected
STM32F100 (Low/Medium Density) - Rev: Z
> 
---[]---


flasing firmware

once the flash has been set to unprotected, it is now possible to write the .bin file in one simple way:

st-flash --format binary write RS41HUP.bin 0x8000000


btw, you may need to time it right to start this command as it may only accept incoming resets/writing data at the very beginning of powering up the device.

=