[SOLVED] OpenOCD failed to flash the NINA

Discussions about the AI-deck
raven
Member
Posts: 32
Joined: Thu Sep 24, 2020 1:57 pm
Contact:

[SOLVED] OpenOCD failed to flash the NINA

Post by raven »

Hi~

I'm using Olimex OpenOCD JTAG ARM-USB-TINY-H to flash the NINA module on the AI-deck.
I run the basic command to test the connectivity just like

Code: Select all

openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f board/esp-wroom-32.cfg -c "adapter_khz 1000"


But the result is
Image

I have tried it on the Bitcraze Ubuntu Virtual Machine, MacOS and Windows, but got the same failing result.
I have 2 debuggers, 2 adapters and 3 AI decks. So, I think it's not the basic problem of the hardware or the OS environment.
Maybe the configuration file? or the version of esp-idf? or any other possible causes.

Thanks!
Last edited by raven on Sat Nov 21, 2020 5:18 am, edited 2 times in total.
Make positive impact.
kimberly
Bitcraze
Posts: 749
Joined: Fri Jul 06, 2018 11:13 am

Re: OpenOCD failed to flash the NINA

Post by kimberly »

It seems that it actually does what it supposed to do and is now waiting for the rest of the commands. It now needs to receive instructions.

I tried openocd myself with this command that is in the documentation:

Code: Select all

~/esp/openocd-esp32/bin/openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f board/esp-wroom-32.cfg -c "program_esp32 build/partitions_singleapp.bin 0x8000 verify" -c "program_esp32 build/bootloader/bootloader.bin 0x1000 verify" -c "program_esp32 build/ai-deck-jpeg-streamer-demo.bin 0x10000 verify reset exit"
Open On-Chip Debugger  v0.10.0-esp32-20190313 (2019-03-13-09:52)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 20000 kHz
Info : Configured 2 cores
esp32 interrupt mask on
Info : ftdi: if you experience problems at higher 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)
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Detected debug stubs @ 3ffb38b4 on core0 of target 'esp32'
Info : Listening on port 3333 for gdb connections
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 : Target halted. PRO_CPU: PC=0x4008D2E3 (active)    APP_CPU: PC=0x40139DA6 
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x5F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x5F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active)    APP_CPU: PC=0x00000000 
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400 
** Programming Started **
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x4009171A (active)    APP_CPU: PC=0x40000400 
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 111 KB
Info : Flash mapping 1: 0x30018 -> 0x400d0018, 427 KB
Info : Target halted. PRO_CPU: PC=0x4009171A (active)    APP_CPU: PC=0x40000400 
Info : Auto-detected flash size 2048 KB
Info : Using flash size 2048 KB
Info : Target halted. PRO_CPU: PC=0x4009171A (active)    APP_CPU: PC=0x40000400 
Info : Target halted. PRO_CPU: PC=0x4009171A (active)    APP_CPU: PC=0x40000400 
wrote 4096 bytes from file build/partitions_singleapp.bin in 0.875627s (4.568 KiB/s)
** Programming Finished **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x4009171A (active)    APP_CPU: PC=0x40000400 
read 3072 bytes from file build/partitions_singleapp.bin and flash bank 0 at offset 0x00008000 in 0.256456s (11.698 KiB/s)
contents match
** Verified OK **
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: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x5F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x5F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active)    APP_CPU: PC=0x00000000 
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400 
** Programming Started **
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x4009171A (active)    APP_CPU: PC=0x40000400 
Info : Target halted. PRO_CPU: PC=0x4009171A (active)    APP_CPU: PC=0x40000400 
wrote 28672 bytes from file build/bootloader/bootloader.bin in 1.099227s (25.472 KiB/s)
** Programming Finished **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x4009171A (active)    APP_CPU: PC=0x40000400 
read 25568 bytes from file build/bootloader/bootloader.bin and flash bank 0 at offset 0x00001000 in 0.335803s (74.355 KiB/s)
contents match
** Verified OK **
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: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x5F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x5F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active)    APP_CPU: PC=0x00000000 
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400 
** Programming Started **
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x4009171A (active)    APP_CPU: PC=0x40000400 
Info : Target halted. PRO_CPU: PC=0x4009171A (active)    APP_CPU: PC=0x40000400 
wrote 634880 bytes from file build/ai-deck-jpeg-streamer-demo.bin in 10.549781s (58.769 KiB/s)
** Programming Finished **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x4009171A (active)    APP_CPU: PC=0x40000400 
read 631920 bytes from file build/ai-deck-jpeg-streamer-demo.bin and flash bank 0 at offset 0x00010000 in 2.526620s (244.243 KiB/s)
contents match
** Verified OK **
** 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: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x5F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x5F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active)    APP_CPU: PC=0x00000000 
shutdown command invoked
Warn : Flash driver of esp32.flash does not support free_driver_priv()
That worked for me with flashing, so maybe openocd needs a bit more information.

What you can also try is using the ESP-idf docker we made: https://github.com/bitcraze/AIdeck_exam ... er-nina.md. I use that all the time now.
raven
Member
Posts: 32
Joined: Thu Sep 24, 2020 1:57 pm
Contact:

Re: OpenOCD failed to flash the NINA

Post by raven »

Thanks!
I have been using MacOS to do that, and the docker command in the documentation cannot apply on the MacOS,
because there is not a file called /dev/ttyUSB*

Maybe I should find some other usage to indicate the device location file for docker.
Make positive impact.
kimberly
Bitcraze
Posts: 749
Joined: Fri Jul 06, 2018 11:13 am

Re: OpenOCD failed to flash the NINA

Post by kimberly »

Good one, I will ask our Mac user here.

But your initial problem, is that solved now if you add the rest of the line to the terminal command?
raven
Member
Posts: 32
Joined: Thu Sep 24, 2020 1:57 pm
Contact:

Re: OpenOCD failed to flash the NINA

Post by raven »

Hi!

I bought a new Olimex debugger, traveling for 10 days (:
And now, it worked successfully!

Running basic command:

Code: Select all

openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f board/esp-wroom-32.cfg -c "adapter_khz 1000"
Image

But I met a new error about the software while running the "flash" command

Code: Select all

openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f board/esp-wroom-32.cfg  -c "adapter_khz 1000" -c "program_esp32 build/partitions_singleapp.bin 0x8000 verify" -c "program_esp32 build/bootloader/bootloader.bin 0x1000 verify" -c "program_esp32 build/ai-deck-jpeg-streamer-demo.bin 0x10000 verify reset exit"
I post this question in the Issue #126(https://github.com/espressif/openocd-esp32/issues/126) of the repository of the espressif/openocd-esp32. I think it's their problem.

In a word,
1) I can use OpenOCD to access the AI-deck after buying a new Olimex debugger.
2) The difference between these two debuggers is that the bad one will turn off the AI-deck LED and the LED of debugger won't blink when I start the GDB server.
3) I hope it's better if there is a docker way supporting the macOS. (how to change the "/ttyUSB0" under mac)
4) The user who used the newest esp32-openocd might meet the problem "'flash write_image' failed", I'm asking the developers of espressif, I will sync the solutions once I solved it.

Thanks!
Make positive impact.
raven
Member
Posts: 32
Joined: Thu Sep 24, 2020 1:57 pm
Contact:

Re: OpenOCD failed to flash the NINA

Post by raven »

Appendix:

I also use the docker way at first, it's really convenient and elegant!
But when I met some problems, I have to finish the work step-by-step to locate the problem.
Make positive impact.
kimberly
Bitcraze
Posts: 749
Joined: Fri Jul 06, 2018 11:13 am

Re: OpenOCD failed to flash the NINA

Post by kimberly »

1- good!
2- That the LED turns off is not something to be worried about I think. It also happens with my AIdeck
3- Apparently Mac also uses /dev/ttyUSB0-1-2 or something like that. I heard that from our Mac user here and Mac is also linux based. We havent tried the docker on Mac though yet.
4- Seems that you already got an answer from expressif. It would be handy to double check this indeed. Did you make clean and make in the NINA/firmware folder of the NINA ? You also need to run the OCD command in the same folder as well.
raven
Member
Posts: 32
Joined: Thu Sep 24, 2020 1:57 pm
Contact:

Re: OpenOCD failed to flash the NINA

Post by raven »

Thanks!
I succeeded finally!

The failing reason is a little silly~~
I forgot to execute the command under the project folder "/NINA/firmware"
And it's a little hard to find this problem according to the output log

I'm happy to see the hotpot "Bitcraze AI-deck Example"
I want to cry (灬ꈍ ꈍ灬)

~Be familiar with the embedding development
~Bought a broken debugger at first
~Buy the official debugger and transport for 10 days

Thanks again~
Make positive impact.
kimberly
Bitcraze
Posts: 749
Joined: Fri Jul 06, 2018 11:13 am

Re: OpenOCD failed to flash the NINA

Post by kimberly »

Ah yes! Success! That was me also while ago too when I was trying to get this to work.

I will add a line to the documentation in the NINA flash instructions that it needs to be made in the firmware folder. It was notified in the wifi example, but can imagine that this can be missed if you go directly to the NINA page.
raven
Member
Posts: 32
Joined: Thu Sep 24, 2020 1:57 pm
Contact:

Re: OpenOCD failed to flash the NINA

Post by raven »

Hi!

I have successfully flashed NINA and GAP8.
But I can't see the image stream when I execute the viewer.py
I want to ask that
1. what's the meaning of
"Also make sure that you force the AIdeck driver in your config.mk, as it will reset the AI-deck properly upon startup.
#CFLAGS += -DDECK_FORCE=bcAIDeck"
in https://github.com/bitcraze/AIdeck_exam ... /tryout.md
2. Is there a way to prove I have flashed GAP8? (We can know the NINA has been flashed according to the hotpot name.)
Make positive impact.
Post Reply