I need some help here because I don't understand what I'm missing.
Ok I have the next hardware:
- ESP32
- ESP-PROG connected to ESP32 through JTAG
- USB-to-UART converter connected from my PC to the ESP32 (UART0)
- I can successfully flash my program (the hello-world example from Espressif) through the UART (by putting the ESP32 into boot mode first)
- I can successfully DEBUG my program after flashing
- I am unable to flash my program through JTAG directly, I mean just by selecting JTAG and flash, BUT it works if I first put the ESP32 into boot mode the same way I have to do when flashing trough the UART
Let me show you some logs, I am using ESP-IDF 5.2.1 but I tried newer versions with same results.
Flash through UART correct:
Code: Select all
* Executing task: C:\Users\dosiper2\.espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe C:\Users\dosiper2\esp\v5.2.1\esp-idf\components\esptool_py\esptool\esptool.py -p COM20 -b 460800 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_freq 40m --flash_size 2MB 0x1000 bootloader/bootloader.bin 0x10000 hello-world.bin 0x8000 partition_table/partition-table.bin
esptool.py v4.7.0
Serial port COM20
Connecting.........
Chip is ESP32-D0WD-V3 (revision v3.1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d0:ef:76:16:a3:dc
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00007fff...
Flash will be erased from 0x00010000 to 0x0003bfff...
Flash will be erased from 0x00008000 to 0x00008fff...
Compressed 26720 bytes to 16356...
Wrote 26720 bytes (16356 compressed) at 0x00001000 in 0.7 seconds (effective 303.4 kbit/s)...
Hash of data verified.
Compressed 177568 bytes to 95105...
Wrote 177568 bytes (95105 compressed) at 0x00010000 in 2.5 seconds (effective 558.3 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 539.3 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
Flash through JTAG correct If I first put the module into boot mode:
Code: Select all
Open On-Chip Debugger v0.12.0-esp32-20230921 (2023-09-21-13:40)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
adapter speed: 20000
kHz
Info : auto-selecting
first available session transport "jtag". To override use 'transport select <transport>'.
Info : Listening on p
ort 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
C:\Users\dosiper2\.espressif\tools\openocd-esp32\v0.12.0-esp32-20230921\openocd-esp32\bin\openocd.exe
Info : ftdi: if you experience problems at hi
gher adapter clocks, try the command "ftdi tdo_sample_edge falling"
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.
cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Warn : [esp32.cpu1] Unexpecte
d OCD_ID = 00000000
Warn : target esp32.cpu1 examination failed
Info : starting gdb server for esp32.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Info : [esp32.cpu0] Debug controlle
r was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x400
093F1, debug_reason=00000000
Info : [esp32.cpu0] Reset cause (1) - (Power on reset)
Warn : [esp32.cpu1] Unexpected OCD_ID = 00000000
Warn : [esp32.cpu1] Unexpected OCD_I
D = 00000000
Warn : [esp32.cpu1] Unex
pected OCD_ID = 00000000
Warn : [esp32.cpu1] Unexpected OCD_ID
= 00000000
Warn : [esp32.cpu1] Unexpected OCD_ID =
00000000
espefuse.py v4.7.0
Connecting...
.
.
.
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Detecting chip type...
ESP32
=== Run "summary" command ===
Saving efuse values to C:\Users\dosiper2\AppData\Local\Temp\espefusejsondump.tmp
Open On-Chip Debugger v0.12.0-esp32-20230921 (2023-09-21-13:40)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
C:\Users\dosiper2\.espressif\tools\openocd-esp32\v0.12.0-esp32-20230921\openocd-esp32\bin\openocd.exe
Info : accepting 'tcl' connection on tcp/6666
Info : dropped 'tcl' connection
Info : accepting 'tcl' connection on tcp/666
6
Flashing "d:/data/development/esp/hello-world/build/bootloader/bootloader.bin" at 0x1000
** program_esp input args <0x1000 verify> **
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp
32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Warn : [esp32.cpu1] Unexpected OCD_ID = 00000000
Info : [esp32.cpu0] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Tar
get halted, PC=0x40009394, debug_reason=00000000
Info : Set GDB target to 'esp32.cpu0'
Info : [esp32.cpu0] Debug controller was re
set.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halt
ed, PC=0x500000CF, debug_reason=00000000
Info : [esp32.cpu0] Reset cau
❌ se (3) - (Software core reset)
Info : [esp32.cpu1] requesting target halt and executing a soft reset
Error: Target not examined yet
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x40000400, debug_reason=00000
000
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu1] Target halted, PC=
0x40000400, debug_reason=00000000
Info : [esp32.cpu1] Reset cause (14) - (CPU1 reset by CPU0)
Info : [esp32.cpu0] Reset cause (3) - (S
oftware core reset)
Info : [esp32.cpu0] Target halted, PC=0x400BE636, debug_reason=00000001
Info : Flash mapping 0: 0x10020 ->
0x3f400020, 37 KB
Info : Flash mapping 1: 0x20020 -> 0x400d0020, 77 KB
Info : [esp32.cpu0] Target halted, PC
=0x400BE636, debug_reason=00000001
Info : Auto-detected flash bank 'esp32.cpu0.flash' size 16384 KB
Info : Using flash bank 'esp32.cpu0.flash' size 16384 KB
Info : [esp32.cpu0] Target halted, PC=0
x400BE636, debug_reason=00000001
Info : Flash mapping 0
: 0x10020 -> 0x3f400020, 37 KB
Info : Flash mapping 1: 0x20020 -> 0x400d0020, 77 KB
Info : [esp32.cpu0] Target halted, PC=0x400B
E636, debug_reason=00000001
Info : Auto-detected flash bank 'esp32.cpu1.flash' size 16384 KB
Info : Using flash bank 'esp32.cpu1.flash' size 16384 KB
** Programming Started
**
Info : [esp32.cpu0] Target halted, PC=0
x400BE636, debug_reason=00000001
Info : [esp32.cpu0] Target halted, PC=0x40
0BE636, debug_reason=00000001
Info : PROF: Erased 28672 bytes in 265.603 ms
Info : PROF: Data transferred in 84.
695 ms @ 330.598 KB/s
Info : [esp32.cpu0] Target halted, PC=0x400BE636, de
bug_reason=00000001
Info : PROF: Wrote 28672 bytes in 382.898 ms (data transfer time included)
** Programming Finished
in 1217 ms **
** Verify Started **
Info : [esp32.cpu0] Target halted, P
C=0x400BE636, debug_reason=00000001
Info : PROF: Flash verified in 113.2
23 ms
** Ver
ify OK **
** Flashing done for bootloader/bootloader.bin in 1331 ms **
Flashing "d:/data/development/esp/hello-world/build/hello-world.bin" at 0x10000
** program_esp input args <0x10000 verify> **
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32.cpu0] requesting targ
et halt and executing a soft reset
Info : [esp32.cpu0] Debug controller was reset
.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x
500000CF, debug_reason=00000000
Info : [esp32.cpu0] Reset cause (3) - (Software
core reset)
Info : [esp32.cpu1] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted,
PC=0x40000400, debug_reason=00000000
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu1] Target h
alted, PC=0x40000400, debug_reason=00000000
Info : [esp32.cpu1] Reset cause (14) - (CPU1 reset by CPU0)
Info : [esp32.cpu0] Reset cause (
3) - (Software core reset)
** Programming Started **
Info : [esp32.cpu0] Target halted, PC=0x40
0BE636, debug_reason=00000001
Info : [esp32.cpu0] Target halted, PC=0
x400BE636, debug_reason=00000001
Info : PROF: Erased 180224 bytes in 1033.18 ms
Info : PROF: Data transferred in 775.107 ms @ 227
.065 KB/s
Info : [esp32.cpu0] Target halted, PC
=0x400BE636, debug_reason=00000001
Info : PROF: Wrote 18
0224 bytes in 1133.78 ms (data transfer time included)
** Programming Finished in 2587 ms **
** Verify Started **
Info : [esp32.cpu0] Target halted, PC=0x4
00BE636, debug_reason=00000001
Info : PROF: Flash ve
rified in 114.447 ms
** Verify OK **
** Flashing done for hello-world.bin in 2701 ms **
Flashing "d:/data/development/esp/hello-world/build/partition_table/partition-table.bin" at 0x8000
** program_esp input args <0x8000 verify> **
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32.cpu0] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Debug controller
was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=
0x500000CF, debug_reason=00000000
Info : [esp32.cpu0] Reset cause (3)
- (Software core reset)
Info : [esp32.cpu1] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Core was r
eset.
Info : [esp32.cpu0] Target halted, PC=0x40
000400, debug_reason=00000000
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu1] Target halted, PC=0x40000400, debug_reason=00000000
Info : [esp32.cpu1] Reset cause (14
) - (CPU1 reset by CPU0)
Info : [esp32.cpu0] Reset cause (3) - (Software core
reset)
** Programming Started **
Info : [esp32.cpu0] Target halted, PC
=0x400BE636, debug_reason=00000001
Info : [esp32.cpu0] Target halted, PC=0x
400BE636, debug_reason=00000001
Info : PROF: Erased 4096 bytes in 48.441 ms
Info : PROF: Data transferred in 3
3.431 ms @ 119.649 KB/s
Info : [esp32.cpu0] Target halted, PC=0x400BE636, debug_reason=00000001
Info : PROF: Wrote 4096 b
ytes in 333.005 ms (data transfer time included)
** Programming Finished
in 771 ms **
** Verify Started **
Info : [esp32.cpu0] Target halted, PC=
0x400BE636, debug_reason=00000001
Info : PROF: Flash ver
ified in 69.859 ms
** Verify OK **
** Flashing done for partition_table/partition-table.bin in 857 ms **
** Total programming time 4889 ms **
** Resetting Target **
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32.cpu0] requesting target halt and executing a soft reset
Info : [esp32.cpu0] De
bug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Ta
rget halted, PC=0x500000CF, debug_reason=00000000
Info : [esp32.cpu0] Reset cause (
3) - (Software core reset)
Info : [esp32.cpu1] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
0
[/OpenOCD]
Flashed Successfully (JTag)
Flash has finished. You can monitor your device with 'ESP-IDF: Monitor command'
[OpenOCD]
Info : [esp32.cpu0] Target halted, PC=0x
400093C8, debug_reason=00000000
Info : [esp32.cpu0] Reset cause (3) - (Software core reset)
Info : [esp32.cpu1] Tar
get halted, PC=0x400076E2, debug_reason=00000000
Info : [esp32.cpu1] Reset
cause (14) - (CPU1 reset by CPU0)
And finally this is what I get if I try to JTAG flash without putting the module in boot mode:
Code: Select all
espefuse.py v4.7.0
Connecting...
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
.
Info : [esp32.cpu0] Target halted, PC=0x
4007A5B3, debug_reason=00000000
Info : [esp32.cpu0] Reset cause (12) - (Software CPU0 reset)
.
Info : [esp32.cpu1] Target halted, PC=0x40
0076E0, debug_reason=00000000
Info : [esp32.cpu1] Reset cause (12) - (Software CPU1 reset)
.
.
.
.
.
.
.
.
.
.
.
.
A fatal error occurred: Failed to connect to Espressif device: Invalid head of packet (0x52): Possible serial noise or corruption.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
Please make sure that you have specified the right port with the --port argument
I have Espressif IDF extension 1.9.0.
Thank you very much.