Page 1 of 1

SWD over ESP8266

Posted: Sun Dec 16, 2018 9:15 pm
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.

Re: SWD over ESP8266

Posted: Mon Dec 17, 2018 7:40 am
by johu
So you just need to hook up rx/tx to SWD pins somehow?

Re: SWD over ESP8266

Posted: Mon Dec 17, 2018 5:41 pm
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

Re: SWD over ESP8266

Posted: Sat Dec 22, 2018 10:57 am
by johu
Thats an awesome extension! So it could be added to the normal firmware without getting in the way of normal functionality?

Re: SWD over ESP8266

Posted: Sat Dec 22, 2018 6:50 pm
by dima
Added to ESP8266 firmware, this way you can flash your newly soldered board with blank STM32.

Re: SWD over ESP8266

Posted: Wed Jun 05, 2019 7:16 am
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

Re: SWD over ESP8266

Posted: Wed Jun 05, 2019 9:24 am
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.

Re: SWD over ESP8266

Posted: Sun Nov 22, 2020 8:51 pm
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

Re: SWD over ESP8266

Posted: Thu Nov 26, 2020 10:48 am
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.

Re: SWD over ESP8266

Posted: Tue May 11, 2021 7:55 pm
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

Re: SWD over ESP8266

Posted: Wed Dec 08, 2021 8:05 pm
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

Re: SWD over ESP8266

Posted: Mon Dec 13, 2021 7:44 pm
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.