openocd firmware update #10

Closed
opened 2020-12-05 07:33:42 +08:00 by jbqubit · 13 comments

Would be nice if flashing was via openocd. Right now flashing requires using proprietary tool from st.com and a Windows machine. See Issue.

Would be nice if flashing was via openocd. Right now flashing requires using proprietary tool from st.com and a Windows machine. See [Issue](https://github.com/sinara-hw/Thermostat/issues/87/).

Same family of uP as Stabilizer which has openocd support.

Same family of uP as [Stabilizer](https://github.com/sinara-hw/stabilizer/wiki#overview) which has openocd [support](https://github.com/quartiq/stabilizer#using-gdbopenocd).

Right now flashing requires using proprietary tool from st.com and a Windows machine

No it doesn't, we developed with OpenOCD or Black Magic Probe.

> Right now flashing requires using proprietary tool from st.com and a Windows machine No it doesn't, we developed with OpenOCD or Black Magic Probe.

What are the steps to use OpenOCD for Thermostat?

What are the steps to use OpenOCD for Thermostat?

Added to README.md

Added to `README.md`

It would be most convenient to flash new firmware using microUSB port as done by st.com tool. Not all users may have the programmer ST-Link v2.1. And the corresponding pins are not easily accessible when the device is deployed in a lab. Is this supported by OpenOCD?

It would be most convenient to flash new firmware using microUSB port as done by st.com tool. Not all users may have the programmer ST-Link v2.1. And the corresponding pins are not easily accessible when the device is deployed in a lab. Is this supported by OpenOCD?

@jbqubit It may work with dfu-util as suggested on github, try it and let us know.

@jbqubit It may work with dfu-util as suggested on github, try it and let us know.

LOL. I've messed around enough with openocd to know that I will make zero progress doing it myself.

LOL. I've messed around enough with openocd to know that I will make zero progress doing it myself.

It's not easy for anyone. And we are talking about dfu-util here, not openocd.

It's not easy for anyone. And we are talking about dfu-util here, not openocd.

I have not yet looked into dfu-util. The device's microUSB port acts only as serial output.

I have not yet looked into dfu-util. The device's microUSB port acts only as serial output.

Not all users may have the programmer ST-Link v2.1.

That's the programmer I use. Any SWD programmer should work.

I acknowledge that the on-device connector is a bit cumbersome due to its half-width pin distance. There is a adapter just for that: Olimex ARM-JTAG-20-10.

> Not all users may have the programmer ST-Link v2.1. That's the programmer I use. Any SWD programmer should work. I acknowledge that the on-device connector is a bit cumbersome due to its half-width pin distance. There is a adapter just for that: [Olimex ARM-JTAG-20-10](https://www.olimex.com/Products/ARM/JTAG/ARM-JTAG-20-10/).

It may work with dfu-util as suggested on github

Is this the github reference you had in mind?

https://github.com/quartiq/stabilizer#using-usb-dfu

> It may work with dfu-util as suggested on github Is this the github reference you had in mind? https://github.com/quartiq/stabilizer#using-usb-dfu
  • Get rustup.
  • Get cargo-binutils.
  • Install the DFU USB tool (dfu-util).
  • Download firmware thermostat.hex
  • Convert firmware: arm-none-eabi-objcopy -O binary thermostat.elf thermostat.bin
  • Connect to the Micro USB connector below the RJ45.
  • Add jumper to Thermostat v2.0 across 2-pin jumper adjacent to JTAG connector.
  • Cycle board power to put it in DFU update mode
  • Push firmware to flash: dfu-util -a 0 -s 0x08000000:leave -D stabilizer.bin
  • Remove jumper
  • Cycle power to leave DFU update mode

Here's what success looks like.

$ dmesg
[1914872.585091] usb 1-4: new full-speed USB device number 9 using xhci_hcd
[1914872.733837] usb 1-4: New USB device found, idVendor=0483, idProduct=df11
[1914872.733838] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1914872.733839] usb 1-4: Product: STM32  BOOTLOADER
[1914872.733840] usb 1-4: Manufacturer: STMicroelectronics
[1914872.733840] usb 1-4: SerialNumber: 20673489524E
[1914879.508819] usb 1-4: USB disconnect, device number 9
[1914880.745050] usb 1-4: new full-speed USB device number 10 using xhci_hcd
[1914880.894735] usb 1-4: New USB device found, idVendor=16c0, idProduct=27dd
[1914880.894736] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[1914880.894738] usb 1-4: Product: thermostat
[1914880.894738] usb 1-4: Manufacturer: M-Labs
[1914880.906726] cdc_acm 1-4:1.0: ttyACM0: USB ACM device
[1914880.907020] usbcore: registered new interface driver cdc_acm
[1914880.907021] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[1914881.074235] usb 1-4: USB disconnect, device number 10
[1914891.660912] usb 1-4: new full-speed USB device number 11 using xhci_hcd
[1914891.810655] usb 1-4: New USB device found, idVendor=16c0, idProduct=27dd
[1914891.810657] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[1914891.810659] usb 1-4: Product: thermostat
[1914891.810660] usb 1-4: Manufacturer: M-Labs
[1914891.811442] cdc_acm 1-4:1.0: ttyACM0: USB ACM device
[1914988.557506] usb 1-4: USB disconnect, device number 11
[1914996.983634] usb 1-4: new full-speed USB device number 12 using xhci_hcd
[1914997.132620] usb 1-4: New USB device found, idVendor=0483, idProduct=df11
[1914997.132623] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1914997.132624] usb 1-4: Product: STM32  BOOTLOADER
[1914997.132626] usb 1-4: Manufacturer: STMicroelectronics
[1914997.132627] usb 1-4: SerialNumber: 20673489524E
[1915281.987219] usb 1-4: USB disconnect, device number 12
[1915283.084366] usb 1-4: new full-speed USB device number 13 using xhci_hcd
[1915283.233152] usb 1-4: New USB device found, idVendor=0483, idProduct=df11
[1915283.233155] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1915283.233156] usb 1-4: Product: STM32  BOOTLOADER
[1915283.233157] usb 1-4: Manufacturer: STMicroelectronics
[1915283.233158] usb 1-4: SerialNumber: 20673489524E
[1915332.364400] usb 1-4: USB disconnect, device number 13
[1915352.695571] usb 1-4: new full-speed USB device number 14 using xhci_hcd
[1915352.844314] usb 1-4: New USB device found, idVendor=0483, idProduct=df11
[1915352.844316] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1915352.844318] usb 1-4: Product: STM32  BOOTLOADER
[1915352.844319] usb 1-4: Manufacturer: STMicroelectronics
[1915352.844320] usb 1-4: SerialNumber: 20673489524E

$ sudo dfu-util --list
[sudo] password for britton: 
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [0483:df11] ver=2200, devnum=14, cfg=1, intf=0, path="1-4", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="20673489524E"
Found DFU: [0483:df11] ver=2200, devnum=14, cfg=1, intf=0, path="1-4", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="20673489524E"
Found DFU: [0483:df11] ver=2200, devnum=14, cfg=1, intf=0, path="1-4", alt=1, name="@Option Bytes  /0x1FFFC000/01*016 e/0x1FFEC000/01*016 e", serial="20673489524E"
Found DFU: [0483:df11] ver=2200, devnum=14, cfg=1, intf=0, path="1-4", alt=0, name="@Internal Flash  /0x08000000/04*016Kg,01*064Kg,07*128Kg,04*016Kg,01*064Kg,07*128Kg", serial="20673489524E"

$ arm-none-eabi-objcopy -O binary thermostat.elf thermostat.bin

$ sudo dfu-util -a 0 -s 0x08000000:leave -D thermostat.bin
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash  "
Downloading to address = 0x08000000, size = 151232
Download	[=========================] 100%       151232 bytes
Download done.
File downloaded successfully
Transitioning to dfuMANIFEST state
  • Confirm communication with the board using TCP on default IP address
$ nc -vv 192.168.1.26 23
Connection to 192.168.1.52 23 port [tcp/telnet] succeeded!
report
{"channel":0,"time":316450,"adc":null,"sens":null,"temperature":null,"pid_engaged":false,"i_set":1.982229040815131e-3,"vref":1.494e0,"dac_value":1.4939911145204077e0,"dac_feedback":1.496e0,"i_tec":1.514e0,"tec_i":5.0000000000000044e-2,"tec_u_meas":1.5030000000000001e0,"pid_output":null}
{"channel":1,"time":316390,"adc":null,"sens":null,"temperature":null,"pid_engaged":false,"i_set":-4.009127914148536e-3,"vref":1.491e0,"dac_value":1.4909954360429258e0,"dac_feedback":1.491e0,"i_tec":1.512e0,"tec_i":5.249999999999977e-2,"tec_u_meas":1.494e0,"pid_output":null}
* Get [rustup](https://rustup.rs/). * Get [cargo-binutils](https://github.com/rust-embedded/cargo-binutils/). * Install the DFU USB tool (dfu-util). * Download firmware [thermostat.hex](https://git.m-labs.hk/M-Labs) * Convert firmware: ```arm-none-eabi-objcopy -O binary thermostat.elf thermostat.bin``` * Connect to the Micro USB connector below the RJ45. * Add jumper to Thermostat v2.0 across 2-pin jumper adjacent to JTAG connector. * Cycle board power to put it in DFU update mode * Push firmware to flash: ```dfu-util -a 0 -s 0x08000000:leave -D stabilizer.bin``` * Remove jumper * Cycle power to leave DFU update mode ---------------- Here's what success looks like. ``` $ dmesg [1914872.585091] usb 1-4: new full-speed USB device number 9 using xhci_hcd [1914872.733837] usb 1-4: New USB device found, idVendor=0483, idProduct=df11 [1914872.733838] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [1914872.733839] usb 1-4: Product: STM32 BOOTLOADER [1914872.733840] usb 1-4: Manufacturer: STMicroelectronics [1914872.733840] usb 1-4: SerialNumber: 20673489524E [1914879.508819] usb 1-4: USB disconnect, device number 9 [1914880.745050] usb 1-4: new full-speed USB device number 10 using xhci_hcd [1914880.894735] usb 1-4: New USB device found, idVendor=16c0, idProduct=27dd [1914880.894736] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [1914880.894738] usb 1-4: Product: thermostat [1914880.894738] usb 1-4: Manufacturer: M-Labs [1914880.906726] cdc_acm 1-4:1.0: ttyACM0: USB ACM device [1914880.907020] usbcore: registered new interface driver cdc_acm [1914880.907021] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters [1914881.074235] usb 1-4: USB disconnect, device number 10 [1914891.660912] usb 1-4: new full-speed USB device number 11 using xhci_hcd [1914891.810655] usb 1-4: New USB device found, idVendor=16c0, idProduct=27dd [1914891.810657] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [1914891.810659] usb 1-4: Product: thermostat [1914891.810660] usb 1-4: Manufacturer: M-Labs [1914891.811442] cdc_acm 1-4:1.0: ttyACM0: USB ACM device [1914988.557506] usb 1-4: USB disconnect, device number 11 [1914996.983634] usb 1-4: new full-speed USB device number 12 using xhci_hcd [1914997.132620] usb 1-4: New USB device found, idVendor=0483, idProduct=df11 [1914997.132623] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [1914997.132624] usb 1-4: Product: STM32 BOOTLOADER [1914997.132626] usb 1-4: Manufacturer: STMicroelectronics [1914997.132627] usb 1-4: SerialNumber: 20673489524E [1915281.987219] usb 1-4: USB disconnect, device number 12 [1915283.084366] usb 1-4: new full-speed USB device number 13 using xhci_hcd [1915283.233152] usb 1-4: New USB device found, idVendor=0483, idProduct=df11 [1915283.233155] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [1915283.233156] usb 1-4: Product: STM32 BOOTLOADER [1915283.233157] usb 1-4: Manufacturer: STMicroelectronics [1915283.233158] usb 1-4: SerialNumber: 20673489524E [1915332.364400] usb 1-4: USB disconnect, device number 13 [1915352.695571] usb 1-4: new full-speed USB device number 14 using xhci_hcd [1915352.844314] usb 1-4: New USB device found, idVendor=0483, idProduct=df11 [1915352.844316] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [1915352.844318] usb 1-4: Product: STM32 BOOTLOADER [1915352.844319] usb 1-4: Manufacturer: STMicroelectronics [1915352.844320] usb 1-4: SerialNumber: 20673489524E ``` ``` $ sudo dfu-util --list [sudo] password for britton: dfu-util 0.9 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2016 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to http://sourceforge.net/p/dfu-util/tickets/ Found DFU: [0483:df11] ver=2200, devnum=14, cfg=1, intf=0, path="1-4", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="20673489524E" Found DFU: [0483:df11] ver=2200, devnum=14, cfg=1, intf=0, path="1-4", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="20673489524E" Found DFU: [0483:df11] ver=2200, devnum=14, cfg=1, intf=0, path="1-4", alt=1, name="@Option Bytes /0x1FFFC000/01*016 e/0x1FFEC000/01*016 e", serial="20673489524E" Found DFU: [0483:df11] ver=2200, devnum=14, cfg=1, intf=0, path="1-4", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg,04*016Kg,01*064Kg,07*128Kg", serial="20673489524E" ``` ``` $ arm-none-eabi-objcopy -O binary thermostat.elf thermostat.bin $ sudo dfu-util -a 0 -s 0x08000000:leave -D thermostat.bin dfu-util 0.9 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2016 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to http://sourceforge.net/p/dfu-util/tickets/ dfu-util: Invalid DFU suffix signature dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! Opening DFU capable USB device... ID 0483:df11 Run-time device DFU version 011a Claiming USB DFU Interface... Setting Alternate Setting #0 ... Determining device status: state = dfuERROR, status = 10 dfuERROR, clearing status Determining device status: state = dfuIDLE, status = 0 dfuIDLE, continuing DFU mode device DFU version 011a Device returned transfer size 2048 DfuSe interface name: "Internal Flash " Downloading to address = 0x08000000, size = 151232 Download [=========================] 100% 151232 bytes Download done. File downloaded successfully Transitioning to dfuMANIFEST state ``` * Confirm communication with the board using TCP on default IP address ``` $ nc -vv 192.168.1.26 23 Connection to 192.168.1.52 23 port [tcp/telnet] succeeded! report {"channel":0,"time":316450,"adc":null,"sens":null,"temperature":null,"pid_engaged":false,"i_set":1.982229040815131e-3,"vref":1.494e0,"dac_value":1.4939911145204077e0,"dac_feedback":1.496e0,"i_tec":1.514e0,"tec_i":5.0000000000000044e-2,"tec_u_meas":1.5030000000000001e0,"pid_output":null} {"channel":1,"time":316390,"adc":null,"sens":null,"temperature":null,"pid_engaged":false,"i_set":-4.009127914148536e-3,"vref":1.491e0,"dac_value":1.4909954360429258e0,"dac_feedback":1.491e0,"i_tec":1.512e0,"tec_i":5.249999999999977e-2,"tec_u_meas":1.494e0,"pid_output":null} ```

Is this the github reference you had in mind?

A comment on the issue you posted yourself...
https://github.com/sinara-hw/Thermostat/issues/87/#issuecomment-739081142

> Is this the github reference you had in mind? A comment on the issue you posted yourself... https://github.com/sinara-hw/Thermostat/issues/87/#issuecomment-739081142
sb10q closed this issue 2020-12-08 09:58:44 +08:00
Sign in to join this conversation.
No Label
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/thermostat#10
There is no content yet.