SWD over ESP8266
SWD over ESP8266
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.
Potentially can flash bootloader using ESP8266 web interface without external debugger.
- johu
- Site Admin
- Posts: 6642
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 348 times
- Been thanked: 1502 times
- Contact:
Re: SWD over ESP8266
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
Re: SWD over ESP8266
Well this maybe a challenge, but looks promising.
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
Code: Select all
const int swd_clock_pin = 4;
const int swd_data_pin = 5;
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

- johu
- Site Admin
- Posts: 6642
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 348 times
- Been thanked: 1502 times
- Contact:
Re: SWD over ESP8266
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
Re: SWD over ESP8266
Added to ESP8266 firmware, this way you can flash your newly soldered board with blank STM32.
-
- Posts: 2
- Joined: Sun Apr 21, 2019 10:55 am
Re: SWD over ESP8266
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
The stm32duino community use this method to program the Arduino bootloader on a new STM32 chip.
ie. see https://medium.com/@paramaggarwal/progr ... 3cec0dbc86
- johu
- Site Admin
- Posts: 6642
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 348 times
- Been thanked: 1502 times
- Contact:
Re: SWD over ESP8266
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.
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
Re: SWD over ESP8266
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.
...code update coming soon to your web-interface

Need to connect GPIO4 and 5 from Olimex to CLK and DIO on SWD port.
- johu
- Site Admin
- Posts: 6642
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 348 times
- Been thanked: 1502 times
- Contact:
Re: SWD over ESP8266
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.

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.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
- johu
- Site Admin
- Posts: 6642
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 348 times
- Been thanked: 1502 times
- Contact:
Re: SWD over ESP8266
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
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
Re: SWD over ESP8266
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.
Use v2.7.4 for best results.
Re: SWD over ESP8266
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.
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 519 times
-
- flash-spiffs.bin
- (273.44 KiB) Downloaded 431 times