SWD over ESP8266

Discussion about various user interfaces such as web interface, displays and apps
Post Reply
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

SWD over ESP8266

Post by dima »

This is an interesting proof-of-concept https://github.com/scanlime/esp8266-arm-swd

Potentially can flash bootloader using ESP8266 web interface without external debugger.
User avatar
johu
Site Admin
Posts: 5683
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: SWD over ESP8266

Post by johu »

So you just need to hook up rx/tx to SWD pins somehow?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: SWD over ESP8266

Post by dima »

Well this maybe a challenge, but looks promising.

Code: Select all

const int swd_clock_pin = 4;
const int swd_data_pin = 5;
Olimex ESP8266 has free GPIOs:

GPIO4 -> Clock - Pin4 (SWD)
GPIO5 -> Data In/Out - Pin2 (SWD)

UPDATE: Success !!! I can connect (send magic sequence to change JTAG to SWD) and do basic commands like "halt" and read registers :D
User avatar
johu
Site Admin
Posts: 5683
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: SWD over ESP8266

Post by johu »

Thats an awesome extension! So it could be added to the normal firmware without getting in the way of normal functionality?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: SWD over ESP8266

Post by dima »

Added to ESP8266 firmware, this way you can flash your newly soldered board with blank STM32.
ultimate1112
Posts: 2
Joined: Sun Apr 21, 2019 10:55 am

Re: SWD over ESP8266

Post by ultimate1112 »

Forgive me, but if you're just trying to program the STM32 over the ESP8266, wouldn't you have the option to simply flash it using the UART pins it's already connected to? You just need the two UART pins, and the BOOT pins.

The stm32duino community use this method to program the Arduino bootloader on a new STM32 chip.
ie. see https://medium.com/@paramaggarwal/progr ... 3cec0dbc86
User avatar
johu
Site Admin
Posts: 5683
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: SWD over ESP8266

Post by johu »

Hi,
the integrated boot loader uses UART1 but the ESP module is connected to UART3 because UART1 shares it pins with timer that generates the PWM ;)

That said, before I had a JTAG/SWD adapter I used the integrated boot loader as well. On the Rev3 board it is not possible because BOOT0 is tied to GND.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: SWD over ESP8266

Post by dima »

Exciting news! SWD (Serial-Wire-Debugger) works now.

...code update coming soon to your web-interface ;)

Need to connect GPIO4 and 5 from Olimex to CLK and DIO on SWD port.
esp8266.png
User avatar
johu
Site Admin
Posts: 5683
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: SWD over ESP8266

Post by johu »

Very nice addition, when it finally works people don't need an STLink anymore to program fresh boards :)

Here is how I patched it to a V3 mainboard, just routed SWDIO and SWDCLK to the unused pins 9 and 10 of the ESP socket. This could be done by default in new designs. Then on the ESP module I also bridged GPIO4 and 5 to those pins. GPIO4=CLK=Pin 9 Esp=Pin 2 SWD and GPIO5=DATA=Pin 10 Esp=Pin 4 SWD
Gpio4 is bridged on the back side.
Attachments
IMG_20201119_190106.jpg
IMG_20201119_190051.jpg
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5683
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: SWD over ESP8266

Post by johu »

I think it would make sense to jumper UART RX/TX to SWCLK and SWIO. So during SWD programming UART on ESP8266 would be disabled.
Then no modification would need to be made to the ESP module
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: SWD over ESP8266

Post by dima »

FYI, Latest Arduino ESP8266 Core Library v3.x does not work with SWD (Single Wire Debug) web interface flashing. They changed a lot how memory is handled, it crashes the esp and the web-server.

Use v2.7.4 for best results.
esp-core-2-7-4.png
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: SWD over ESP8266

Post by dima »

All fixed for ESP8266 Core v3.0.2 and hopefully anything later.

Some cool tests you can do http://192.168.4.1/swd/hex?bootloader

Go to http://192.168.4.1/update and flash attached two files. See above posts two wire hardware mod required - both esp module and main board.
Attachments
FSBrowser.ino.modwifi.bin
(380.08 KiB) Downloaded 159 times
flash-spiffs.bin
(273.44 KiB) Downloaded 164 times
Post Reply