Skip to content

Commit 8348d88

Browse files
committed
Fix outdated comments and add missing ESP32-C5 support in CLI
- Update chip.go comments to include ESP32-S2 in magic value detection - Add ESP32-C5 to USB-JTAG/Serial reset comment in reset.go - Add missing esp32c5 to -chip flag and parseChipType() in main.go - Add missing auto to -reset flag and reset mode switch in main.go Signed-off-by: deadprogram <ron@hybridgroup.com>
1 parent 7659910 commit 8348d88

4 files changed

Lines changed: 13 additions & 6 deletions

File tree

main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ func main() {
2626
port := flag.String("port", "", "Serial port (e.g. /dev/ttyUSB0, COM3)")
2727
baud := flag.Int("baud", 460800, "Flash baud rate")
2828
offset := flag.String("offset", "0x0", "Flash offset for single binary mode")
29-
chip := flag.String("chip", "auto", "Chip type: auto, esp8266, esp32, esp32s2, esp32s3, esp32c2, esp32c3, esp32c6, esp32h2")
29+
chip := flag.String("chip", "auto", "Chip type: auto, esp8266, esp32, esp32s2, esp32s3, esp32c2, esp32c3, esp32c5, esp32c6, esp32h2")
3030
noCompress := flag.Bool("no-compress", false, "Disable compression")
3131
eraseAll := flag.Bool("erase-all", false, "Erase entire flash before writing")
3232
flashMode := flag.String("fm", "keep", "Flash mode: keep, qio, qout, dio, dout")
3333
flashFreq := flag.String("ff", "keep", "Flash frequency: keep, 80m, 40m, 26m, 20m (chip-specific)")
3434
flashSize := flag.String("fs", "keep", "Flash size: keep, 1MB, 2MB, 4MB, 8MB, 16MB")
35-
resetMode := flag.String("reset", "default", "Reset mode: default, no-reset, usb-jtag")
35+
resetMode := flag.String("reset", "default", "Reset mode: default, no-reset, usb-jtag, auto")
3636
version := flag.Bool("version", false, "Print version and exit")
3737

3838
// Multi-image mode
@@ -104,6 +104,8 @@ func main() {
104104
opts.ResetMode = espflasher.ResetNoReset
105105
case "usb-jtag":
106106
opts.ResetMode = espflasher.ResetUSBJTAG
107+
case "auto":
108+
opts.ResetMode = espflasher.ResetAuto
107109
default:
108110
log.Fatalf("Unknown reset mode: %s", *resetMode)
109111
}
@@ -224,6 +226,8 @@ func parseChipType(s string) espflasher.ChipType {
224226
return espflasher.ChipESP32C2
225227
case "esp32c3", "esp32-c3":
226228
return espflasher.ChipESP32C3
229+
case "esp32c5", "esp32-c5":
230+
return espflasher.ChipESP32C5
227231
case "esp32c6", "esp32-c6":
228232
return espflasher.ChipESP32C6
229233
case "esp32h2", "esp32-h2":

pkg/espflasher/chip.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ type chipDef struct {
5656
Name string
5757

5858
// MagicValue is read from CHIP_DETECT_MAGIC_REG_ADDR on older chips.
59-
// Only used for ESP8266 and ESP32 which don't support get_chip_id.
59+
// Only used for ESP8266, ESP32, and ESP32-S2 which don't support get_chip_id.
6060
MagicValue uint32
6161

6262
// ImageChipID is returned by the GET_SECURITY_INFO command on newer chips.
63-
// ESP8266 and ESP32 use magic value detection instead (ImageChipID = 0).
63+
// ESP8266, ESP32, and ESP32-S2 use magic value detection instead.
6464
ImageChipID uint32
6565

6666
// UsesMagicValue indicates this chip uses the magic register for detection

pkg/espflasher/doc.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
// - ESP32-S3
1010
// - ESP32-C2 (ESP8684)
1111
// - ESP32-C3
12+
// - ESP32-C5
1213
// - ESP32-C6
1314
// - ESP32-H2
1415
//
1516
// # Quick Start
1617
//
1718
// To flash a .bin file to a connected ESP device:
1819
//
19-
// flasher, err := espflasher.NewFlasher("/dev/ttyUSB0", nil)
20+
// flasher, err := espflasher.New("/dev/ttyUSB0", nil)
2021
// if err != nil {
2122
// log.Fatal(err)
2223
// }
@@ -36,6 +37,8 @@
3637
// - SLIP: Serial Line Internet Protocol framing (slip.go)
3738
// - Protocol: ROM bootloader command/response protocol (protocol.go)
3839
// - Chip: Per-target chip definitions and detection (chip.go, target_*.go)
40+
// - Image: Firmware image header parsing and patching (image.go)
41+
// - Stub: Stub loader for advanced operations like erase and read (stub.go)
3942
// - Flasher: High-level flash/verify/reset API (flasher.go)
4043
//
4144
// The protocol uses SLIP framing over serial UART. Commands are sent as

pkg/espflasher/reset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func tightReset(port serial.Port, delay time.Duration) {
8686
}
8787

8888
// usbJTAGSerialReset performs reset for USB-JTAG/Serial interfaces.
89-
// Used on ESP32-C3, ESP32-S3, ESP32-C6, ESP32-H2 when using the
89+
// Used on ESP32-C3, ESP32-S3, ESP32-C5, ESP32-C6, ESP32-H2 when using the
9090
// built-in USB-JTAG/Serial peripheral.
9191
//
9292
// The sequence matches esptool's USBJTAGSerialReset: assert DTR (IO0=LOW

0 commit comments

Comments
 (0)