Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programming ESP32-C3-MINI-1 module using JTAG (OCD-390) #168

Closed
Wasabinary opened this issue Aug 4, 2021 · 11 comments
Closed

Programming ESP32-C3-MINI-1 module using JTAG (OCD-390) #168

Wasabinary opened this issue Aug 4, 2021 · 11 comments

Comments

@Wasabinary
Copy link

Hi,

Continuing my journey trying to use JTAG on ESP32-C3, I am now trying to flash an ESP32-C3-MINI-1, which is connected following the reference design of this module.
After successfully burning the JTAG_SEL_ENABLE efuse, and pulling it to 3.3V in order to enable JTAG over GPIOs, I'm now trying to flash the "Hello World" ESP-IDF example using a JLINK and the latest openocd-esp32 version.

Unfortunately, I get stuck with error messages that I did not encountered using an ESP32-C3 devkit when running openocd -f interface\jlink.cfg -f target\esp32c3.cfg -c "program_esp hello-world.bin 0x10000 verify reset exit":

...
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
Error: Failed to get flash maps (4294967290)!
Warn : Failed to get flash mappings (-4)!
Info : Auto-detected flash bank 'esp32c3.flash' size 4096 KB
Info : Using flash bank 'esp32c3.flash' size 4096 KB
** Programming Started **
Info : PROF: Data transferred in 2375.62 ms @ 63.9832 KB/s
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
shutdown command invoked

Even if it seems like programming succeed, I'm confused by this error message:

Error: Failed to get flash maps (4294967290)!
Warn : Failed to get flash mappings (-4)!

Moreover, after connecting an FTDI cable to RXD and TXD pins, all I this error printing again and again:

invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff

Obviously, I did something wrong to my chip...
I thought using JTAG would be very straight forward after burning the efuse, but I'm really struggling to finally succeed at programming ESP32 modules for custom PCB...

Any help would be very welcomed...

@github-actions github-actions bot changed the title Programming ESP32-C3-MINI-1 module using JTAG Programming ESP32-C3-MINI-1 module using JTAG (OCD-390) Aug 4, 2021
@igrr
Copy link
Member

igrr commented Aug 4, 2021

@Wasabinary aside from programming the application binary, have you also programmed the 2nd stage bootloader and the partition table binaries? invalid header: 0xffffffff possibly indicates that the 2nd stage bootloader is not written into Flash.

@Wasabinary
Copy link
Author

Oh so I definitely missed a step somewhere... Indeed, I only compiled the hello-world example and tried to flash the binary into my ESP32-C3, and I'm completely unaware of the steps you are referring to... Where can I find the resources about these in order to properly prepare the chip to host my firmware ?

@Wasabinary
Copy link
Author

I think I got it, building the app also creates a bootloader folder and a partition_table folder into the build folder of my projet. Do I need to use JTAG the same way in order to upload bootloader.bin and partition-table.bin into my chip ?

@erhankur
Copy link
Collaborator

erhankur commented Aug 4, 2021

@Wasabinary yes you can with -c "program_esp_bins build flasher_args.json verify reset exit":

@Wasabinary
Copy link
Author

Yaaay it works now! The command given by @erhankur did the trick:

openocd -f interface\jlink.cfg -f target\esp32c3.cfg -c "program_esp_bins build flasher_args.json verify exit"

It uploaded partition-table.bin, bootloader.bin and hello-world.bin one after the other, and now my application is running fine: no more flash mapping error and no more invalid header error.

Once again, thanks a lot!

@Spatens
Copy link

Spatens commented Feb 7, 2022

I use a esp32dev and it works perfectly not using SPIFFS - the "Hello" project
When I try to embed SPIFFS - I get the same symptoms with not finding the flash maps.
I DID "Build Filesystem image" and selected "Upload Fielsystem image" in PlatformIO.
And then I get "Error: Failed to get flash maps (4294967290)!"
When I try to issue this one (I tried to enter my device...):
openocd -f interface\jlink.cfg -f target\esp32dev.cfg -c "program_esp_bins build flasher_args.json verify exit"
Then I get this one: Error: Can't find target\esp32dev.cfg
How do I proceed ? Please any help appreciated...
AAahh - I just realized that I perhaps is in the wrong forum - can you help anyway?

@Wasabinary
Copy link
Author

Hi,

I can't find the file "target\esp32dev.cfg" you are refering to in my own openocd-esp32 folder. But may be you should try with "target\esp32", that should be fine

@Spatens
Copy link

Spatens commented Feb 9, 2022

Hi - thanks for your reply. I have trying to get it to work - I ran into other problems and have not been able to get back yo you.
I had two versions of python, two Espressif IDF`s on top of VS-code with platformIO, my IDF installation is on E: - with numerous irritating references to my windows userID. I still have not solved how to set my path correct - but I keep trying. I WILL return to you. I deleted ALL old python references and installed all over.

Now I am simply not able to execute the command: "openocd" from my project directory but have to change to the tool-openocd-esp32" directory and then I execute this:
openocd -f interface\jlink.cfg -f target\esp32.cfg -c "program_esp_bins build flasher_args.json verify exit

The result is this:
E:/ESP/ESP_IDF/packages/tool-openocd-esp32/bin/../share/openocd/scripts/target/esp_common.cfg:191: Error: build/flasher_args.json: No such file or directory in procedure 'program_esp_bins'
at file "E:/ESP/ESP_IDF/packages/tool-openocd-esp32/bin/../share/openocd/scripts/target/esp_common.cfg", line 191

I am pretty sure that it could be my setup - wrong path - but I don't know how to fix it. Some os us needs more... :-)
Hope you will help...

@Wasabinary
Copy link
Author

Wasabinary commented Feb 10, 2022

I think the best way to make sure you don't have path related problems is to use absolute path for everything (including openocd.exe, which is in .espressif\tools\openocd-esp32\v0.10.0-esp32-20211111\openocd-esp32\bin fodler in my case. Same thing for .cfg files and flasher_args.json, use absolute paths so you will not have any problem linked to that.

On the other hand, I remember having problems with program_esp_bins command, and I managed to flash my ESP32 by flashing build/bootloader/bootloader.bin, build/partition_table/partition-table.bin and build/application.bin one by one with the corresponding offsets. These offsets can be found in build/flasher_args.json

@gerekon
Copy link
Collaborator

gerekon commented Feb 10, 2022

@Spatens

openocd -f interface\jlink.cfg -f target\esp32.cfg -c "program_esp_bins build flasher_args.json verify exit

To make this working you either need to invoke this command from your project dir (implying that build dir is there) or use @Wasabinary advice to use absolute path.

@Spatens
Copy link

Spatens commented Feb 10, 2022

Thanks Guys.... :-) I'm sure I can make this work for me. Else "I'll be back" as Sshwarzenegger says....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants