mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
flashing: introduce flash method 'esp32jtag' for esp32c3/esp32s3 targets
This adds a new flash method 'esp32jtag' to explicitly define when this reset method is needed. When flashing esp32c3/esp32s3 boards on Windows this method of board reset is required, otherwise the reset does not take place and the board cannot be flashed. Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -386,7 +386,7 @@ func Flash(pkgName, port, outpath string, options *compileopts.Options) error {
|
||||
fileExt = ".hex"
|
||||
case "bmp":
|
||||
fileExt = ".elf"
|
||||
case "esp32flash":
|
||||
case "esp32flash", "esp32jtag":
|
||||
fileExt = ".bin"
|
||||
case "native":
|
||||
return errors.New("unknown flash method \"native\" - did you miss a -target flag?")
|
||||
@@ -528,7 +528,16 @@ func Flash(pkgName, port, outpath string, options *compileopts.Options) error {
|
||||
return &commandError{"failed to find port", port, err}
|
||||
}
|
||||
|
||||
if err := flashBinUsingEsp32(port, result.Binary, config.Options); err != nil {
|
||||
if err := flashBinUsingEsp32(port, classicReset, result.Binary, config.Options); err != nil {
|
||||
return &commandError{"failed to flash", result.Binary, err}
|
||||
}
|
||||
case "esp32jtag":
|
||||
port, err := getDefaultPort(port, config.Target.SerialPort)
|
||||
if err != nil {
|
||||
return &commandError{"failed to find port", port, err}
|
||||
}
|
||||
|
||||
if err := flashBinUsingEsp32(port, jtagReset, result.Binary, config.Options); err != nil {
|
||||
return &commandError{"failed to flash", result.Binary, err}
|
||||
}
|
||||
default:
|
||||
@@ -1031,8 +1040,20 @@ func flashHexUsingMSD(volumes []string, tmppath string, options *compileopts.Opt
|
||||
return errors.New("unable to locate any volume: [" + strings.Join(volumes, ",") + "]")
|
||||
}
|
||||
|
||||
func flashBinUsingEsp32(port, tmppath string, options *compileopts.Options) error {
|
||||
flasher, err := espflash.NewFlasher(port, nil)
|
||||
const (
|
||||
classicReset = "classic"
|
||||
jtagReset = "jtag"
|
||||
)
|
||||
|
||||
func flashBinUsingEsp32(port, resetMode, tmppath string, options *compileopts.Options) error {
|
||||
var opts *espflash.FlasherOptions
|
||||
// On Windows, we have to explicitly specify the reset mode to use USB JTAG.
|
||||
if runtime.GOOS == "windows" && resetMode == jtagReset {
|
||||
opts = espflash.DefaultOptions()
|
||||
opts.ResetMode = espflash.ResetUSBJTAG
|
||||
}
|
||||
|
||||
flasher, err := espflash.NewFlasher(port, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"src/device/esp/esp32c3.S"
|
||||
],
|
||||
"binary-format": "esp32c3",
|
||||
"flash-method": "esp32flash",
|
||||
"flash-method": "esp32jtag",
|
||||
"serial-port": ["303a:1001"],
|
||||
"openocd-interface": "esp_usb_jtag",
|
||||
"openocd-target": "esp32c3",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"src/internal/task/task_stack_esp32.S"
|
||||
],
|
||||
"binary-format": "esp32s3",
|
||||
"flash-method": "esp32flash",
|
||||
"flash-method": "esp32jtag",
|
||||
"emulator": "qemu-system-xtensa -machine esp32 -nographic -drive file={img},if=mtd,format=raw",
|
||||
"gdb": ["xtensa-esp32-elf-gdb"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user