Skip to content

Commit 740284f

Browse files
authored
add default spispeed init
add default spispeed initialization (issue #3) update readme.md
1 parent 5697e6e commit 740284f

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

README.md

+13-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
# esp32-serprog
2-
a minimal flashrom/serprog SPI programmer implementation for esp32 family, inspired by [pico-serprog](https://github.com/stacksmashing/pico-serprog) and [stm32-verprog](https://github.com/dword1511/stm32-vserprog)
2+
a minimal flashrom/serprog SPI programmer implementation for esp32 family, inspired by [pico-serprog](https://github.com/stacksmashing/pico-serprog) and [stm32-vserprog](https://github.com/dword1511/stm32-vserprog)
33

44
## Features
55

66
Use your ESP32 board as a [flashrom](https://flashrom.org/) compatible SPI flash programmer
77

88
* Should be compatible with all ESP32 family MCUs
99
* Uses ESP32 HW SPI peripheral capable of up to 80 MHz clock rate
10-
* Multiple connection options: HW UART, USB Serial/JTAG<sup>1</sup>, USB-CDC<sup>2</sup>, TCP (Wi-Fi)<sup>3</sup>
10+
* Multiple connection options: USB Serial/JTAG, HW UART, TCP (Wi-Fi)<sup>1</sup>
1111

12-
<sup>1</sup> - works unreliably, see USB Serial/JTAG section
13-
14-
<sup>2</sup> - not implemented yet
15-
16-
<sup>3</sup> - flashrom serprog TCP capability is working only on latest dev build
12+
<sup>1</sup> - flashrom serprog TCP capability is limited to non-windows OSes and requires flashrom version 1.4.0 or later
1713

1814
## Configuration
1915

@@ -28,17 +24,15 @@ serial interface to use options are (MCU dependent):
2824

2925
### USB Serial/JTAG
3026

31-
since i have only ESP32S3 i decided to target built-in serial/JTAG first, and it kind of works but there are issues most likely with the serial peripheral itself:
32-
33-
found [a similar issue on the esp32 forum](https://www.esp32.com/viewtopic.php?f=13&t=32209) and some other [ongoing development](https://github.com/espressif/esp-idf/pull/12291) regarding serial buffers
27+
older versions of esp-idf had issues with USB Serial/JTAG reliability,
28+
but as of esp-idf 5.4.0 everything appears to work as intended
3429

35-
* using flashrom MINGW build on windows: it works reliably for some speed combinations e.g. 1M baud rate 4M SPI rate, except i had to flush the bootloader junk before using the flashrom (e.g. open&close COM port using putty / idf.py monitor)
36-
* using same version flashrom ubuntu WSL2 build and usbipd to forward the usb device: there is no bootloader junk issue, but i always encounter data loss at random point when reading 4MByte flash (takes tens of seconds), so flashrom just hangs waiting for the data
37-
* haven't tested on real linux or macOS
30+
this is the default option for USB-capable chips (ESP32-S3, ESP32-C3, ESP32-C6 etc.)
3831

3932
### HW UART
4033

41-
after the serial/JTAG failure i decided to implement the real UART support, since i'm using a devkit board with CH343 USB-UART converter wired to UART0:
34+
if USB Serial/JTAG is not supported by your MCU or works unreliably,
35+
HW UART can be used:
4236

4337
* works perfectly as expected
4438
* bottlenecked by UART baud rate
@@ -48,13 +42,15 @@ after the serial/JTAG failure i decided to implement the real UART support, sinc
4842

4943
### USB-CDC
5044

51-
not implemented - haven't touched this one yet - enabling USB-CDC on esp32s3 requires burning an eFuse to disconnect the USB serial/JTAG PHY permanently
45+
in theory tinyUSB can be used instead of built-in USB Serial/JTAG peripheral,
46+
but it is supported only by a subset of USB Serial/JTAG-capable chips (e.g. ESP32-S3 but not ESP32-C3/C6)
47+
and since USB Serial/JTAG no longer misbehaves, i don't see any benefit in implementing USB-CDC
5248

5349
### TCP over Wi-Fi
5450

5551
*serprog TCP support is available only in non-windows builds e.g. linux, wsl2 etc.*
5652

57-
***warning**: flashrom serprog TCP support is working reliably only on latest dev build, please pull latest version and build from sources*
53+
***warning**: flashrom serprog TCP support is working reliably only on flashrom version >= 1.4.0*
5854

5955
to enable TCP over Wi-Fi, before building run `idf.py menuconfig` and go to `esp32-serprog`,
6056
select `Wi-Fi enabled` and set up your (existing) Wi-Fi credentials
@@ -79,7 +75,7 @@ even the cheapest BSS138-based one will do the job although the SPI speed will b
7975

8076
*i have successfully reflashed my Steam Deck 1.8V 16MByte BIOS chip using the cheapest aliexpress MOSFET levelshifter and 1.8V LDO at spispeed=250K, although it took like 20 minutes*
8177

82-
SPI speed selection is up to you, depends on the flash chip, wiring etc. - ESP32 should support up to 80MHz in theory
78+
SPI speed selection is up to you, depends on the flash chip, wiring etc. - ESP32 should support up to 80MHz in theory. If no spispeed parameter is provided default value of 8M is used
8379

8480
UART baud rate matters only when using HW UART, at least serial/JTAG will always transmit as fast as USB allows
8581

src/serprog/main/main.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#define PIN_NUM_CLK 6
3232
#define PIN_NUM_CS 10
3333

34-
#elif CONFIG_IDF_TARGET_ESP32S3
34+
#elif defined CONFIG_IDF_TARGET_ESP32S3
3535
#define EEPROM_HOST SPI2_HOST
3636
#define PIN_NUM_MISO 5
3737
#define PIN_NUM_MOSI 16
@@ -429,6 +429,8 @@ void app_main(void)
429429
#endif
430430
#endif
431431

432+
serprog_spi_init(8*1000*1000); //use 8M spispeed as initial value
433+
432434
for (;;)
433435
{
434436
int command = serprog_getchar();

0 commit comments

Comments
 (0)