ESP32 Firmware on AI-Thinker (esp32cam) board Failure

I have an AI-Thinker esp32cam board and I modified the firmware as suggested and recompiled and flashed the firmware onto my AI-Thinker board.

It appears the firmware works fine on my board, as verified via idf.py -p /dev/ttyUSB0 monitor:

entry 0x40080694
I (28) boot: ESP-IDF v4.4.1-dirty 2nd stage bootloader
I (28) boot: compile time 13:24:30
I (29) boot: chip revision: 1
I (32) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot.esp32: SPI Speed      : 80MHz
I (44) boot.esp32: SPI Mode       : DIO
I (48) boot.esp32: SPI Flash Size : 4MB
I (53) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (62) boot: ## Label            Usage          Type ST Offset   Length
I (69) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (76) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (84) boot:  2 factory          factory app      00 00 00010000 00300000
I (91) boot:  3 storage          Unknown data     01 82 00310000 000f0000
I (99) boot: End of partition table
I (103) boot_comm: chip revision: 1, min. application chip revision: 0
I (110) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=24350h (148304) map
I (164) esp_image: segment 1: paddr=00034378 vaddr=3ffb0000 size=03d94h ( 15764) load
I (169) esp_image: segment 2: paddr=00038114 vaddr=40080000 size=07f04h ( 32516) load
I (181) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=73500h (472320) map
I (324) esp_image: segment 4: paddr=000b3528 vaddr=40087f04 size=0a4d0h ( 42192) load
I (339) esp_image: segment 5: paddr=000bda00 vaddr=50000000 size=00010h (    16) load
I (348) boot: Loaded app from partition at offset 0x10000
I (348) boot: Disabling RNG early entropy source...
Hello from Edge Impulse Device SDK.
Compiled on Jun 30 2022 13:44:39
ERR: failed to connect to inertial sensor!
Inertial sensor initialization failed
Type AT+HELP to see a list of commands.
> 

I am able to verify the AT+HELP and AT+CONFIG? commands work just fine.

But when I try to run edge-impulse-daemon, I get the following error:

Edge Impulse serial daemon v1.15.1
Endpoints:
    Websocket: wss://remote-mgmt.edgeimpulse.com
    API:       https://studio.edgeimpulse.com/v1
    Ingestion: https://ingestion.edgeimpulse.com

[SER] Connecting to /dev/ttyUSB0
[SER] Serial is connected, trying to read config...
[SER] Failed to get info off device Timeout when waiting for >  (timeout: 5000) onConnected
[SER] Serial is connected, trying to read config...
[SER] Failed to get info off device Timeout when waiting for >  (timeout: 5000) onConnected

I then tried:
edge-impulse-run-impulse

Edge Impulse impulse runner v1.15.1
[SER] Connecting to /dev/ttyUSB0
[SER] Serial is connected, trying to read config...
[SER] Failed to get info off device:undefined. Is this device running a binary built through Edge Impulse? Reconnecting in 5 seconds...

Then I tried the following:
edge-impulse-run-impulse --raw

Edge Impulse impulse runner v1.15.1
[SER] Connecting to /dev/ttyUSB0
[SER] Connected to /dev/ttyUSB0
AT+HELP

I tried entering AT+HELP on the console, but there was no response. I am totally at a loss as to how to get this working… Any suggestions?

Hello @gururise,

:thinking: Not sure how to fix this…
Have you tried to flash again the firmware, reset the board or try with another USB cable ?

Regards,

Louis

I tried bypassing the edge-impulse-daemon by using WebUSB via the lastest Chrome Browser and when connecting to my AI-Thinker board on /dev/ttyUSB0 I get the following error:

image

I’ve also tried the pre-compiled firmware images that you offered in this post and after uploading it successfully to my AI-Thinker esp32cam board, I get the exact same results as in my original post.

I have also tried the following:

  1. Reboot computer
  2. New USB cable

Is there any way to get some type of verbose output from the edge-impulse-daemon to see what is going on?

So after a little more debugging, I compiled the edge-impulse-daemon to output verbose serial data and noticed that when connecting via SERIAL (/dev/ttyUSB0) I get a constant stream of 00h (garbage) across the port:

[SER] serial data <Buffer 00> 
[SER] serial data <Buffer 00 00> 
[SER] serial data <Buffer 00 00> 
[SER] serial data <Buffer 00>

I can confirm this when connecting via screen to /dev/ttyUSB0 (115200 8N1). Either i get a bunch of raw ‘00’ streaming across the screen, or I get nothing.

However, when I connect via idf.py -p /dev/ttyUSB0, it seems to work; however, the chip seems to be forced to reset:

Executing action: monitor
Running idf_monitor in directory /home/gene/Downloads/espressif/edge_impulse_firmware/firmware-espressif-esp32
Executing "/home/gene/.espressif/python_env/idf4.4_py3.10_env/bin/python /opt/esp-idf/tools/idf_monitor.py -p /dev/ttyUSB0 -b 115200 --toolchain-prefix xtensa-esp32-elf- --target esp32 --revision 0 /home/gene/Downloads/espressif/edge_impulse_firmware/firmware-espressif-esp32/build/ei_firmware_esp32.elf -m '/home/gene/.espressif/python_env/idf4.4_py3.10_env/bin/python' '/opt/esp-idf/tools/idf.py' '-p' '/dev/ttyUSB0'"...
--- idf_monitor on /dev/ttyUSB0 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Junets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:6612
load:0x40078000,len:14816
ho 0 tail 12 room 4
load:0x40080400,len:3792
0x40080400: _init at ??:?

entry 0x40080694
I (28) boot: ESP-IDF v4.4.1-dirty 2nd stage bootloader
I (28) boot: compile time 13:24:30
I (29) boot: chip revision: 1
I (32) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot.esp32: SPI Speed      : 80MHz
I (44) boot.esp32: SPI Mode       : DIO
I (48) boot.esp32: SPI Flash Size : 4MB
I (53) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (62) boot: ## Label            Usage          Type ST Offset   Length
I (69) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (76) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (84) boot:  2 factory          factory app      00 00 00010000 00300000
I (91) boot:  3 storage          Unknown data     01 82 00310000 000f0000
I (99) boot: End of partition table
I (103) boot_comm: chip revision: 1, min. application chip revision: 0
I (110) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=24350h (148304) map
I (164) esp_image: segment 1: paddr=00034378 vaddr=3ffb0000 size=03d94h ( 15764) load
I (169) esp_image: segment 2: paddr=00038114 vaddr=40080000 size=07f04h ( 32516) load
I (181) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=734ech (472300) map
I (324) esp_image: segment 4: paddr=000b3514 vaddr=40087f04 size=0a4d0h ( 42192) load
I (339) esp_image: segment 5: paddr=000bd9ec vaddr=50000000 size=00010h (    16) load
I (348) boot: Loaded app from partition at offset 0x10000
I (348) boot: Disabling RNG early entropy source...
Hello from Edge Impulse Device SDK.
Compiled on Jul  1 2022 09:17:09
ERR: failed to connect to inertial sensor!
Inertial sensor initialization failed
Type AT+HELP to see a list of commands.
> 

Could this be a bad esp32cam board?

EDIT: I just flashed another brand new AI-Thinker esp32cam board and had the exact same result.

I also had a problem this is due to a lack of power, it just reboots, try to connect usb ttl ft232

Hi @gururise,

This is really odd. I just tried my AI Thinker ESP32-CAM board, and I was able to connect with edge-impulse-daemon after uploading the new firmware. As @norik.badalyan suggests, you may want to check your power supply to the ESP32 board.

2 Likes

@gururise - were you ever able to figure this out. I’m getting identical results.

Feels like it isn’t a power issue if I can connect with the monitor and run commands manually, but :person_shrugging:

Hello,

Can you try with that firmware?
I have also an AI-Thinker ESP32-CAM and I was able to flash it properly.

Best,

Louis

Thanks for the quick reply, @louis !!

I tried the build you linked with the same result. The flash looks successful:

Wrote 776320 bytes (405346 compressed) at 0x00000000 in 9.5 seconds (effective 653.6 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Flashed your ESP32 development board.
To set up your development with Edge Impulse, run 'edge-impulse-daemon'
To run your impulse on your development board, run 'edge-impulse-run-impulse'

But edge-impulse-daemon still fails:

[SER] Connecting to /dev/ttyUSB0
[SER] Serial is connected, trying to read config...
[SER] Failed to get info off device Timeout when waiting for >  (timeout: 5000) onConnected
[SER] Serial is connected, trying to read config...
[SER] Failed to get info off device Timeout when waiting for >  (timeout: 5000) onConnected

As with @gururise though, I am able to connect over serial and run AT commands with idf.py -p /dev/ttyUSB0 monitor:

Hello from Edge Impulse Device SDK.
Compiled on May  5 2022 12:55:53
ERR: failed to connect to inertial sensor!
Inertial sensor initialization failed
Type AT+HELP to see a list of commands.
===== Device info =====
ID:         ##:##:##:##:##:##
Type:       ESPRESSIF_ESP32
AT Version: 1.7.0
Data Transfer Baudrate: 1500000
...

Oh I think I understand, there is no inertial sensor attached to that device, @AIWintermuteAI, do you think we can easily disable the inertial part in the code when recompiling the firmware?

Else you might just want to comment out the following lines before recompiling the firmware :slight_smile:

I don’t have my ESP32-CAM with me at the moment so I won’t be able to test but last time I tried, I successfully managed to use the firmware I sent you :confused:

Best,

Louis

I do not think that is inertial sensor issue - it checks if sensor is connected and if not prints out that message without interrupting normal boot sequence. Granted, it should be an INFO message and not ERR - I’ll fix it in the next upgrade.
My bet is on TTL-USB serial converter and driver issues, especially since stray 00 characters were mentioned on serial connection. We had multiple users successfully using ESP-CAM and it was tested internally too.
For testing I was using regular AI-Thinker esp32cam and Adafruit USB to TTL Serial Cable - Debug / Console Cable for Raspberry Pi USB to TTL Serial Cable - Debug / Console Cable for Raspberry Pi : ID 954 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits
Perhaps @shawn_edgeimpulse and @louis can share their hardware setups?

1 Like

Hello @AIWintermuteAI, @jamstooks

I am using the ESP32-CAM AI-Thinker, an ESP32-CAM-MB USB Programmer (CH340G Serial Chip) and the OV2640 Camera.

Best,

Louis

Thanks again for all the help @louis.

In the end, it looks like the connection baud rate was the issue. Adding -b 115200 to the flash command after building the firmware did the trick.

idf.py -p /dev/tty.usbserial-1430 -b 115200 flash
1 Like

@louis - once we’ve got all this working locally, what’s the next step for actually deploying?

It looks like edge-impulse-run-impulse requires a compiled binary for our board, but if we’re using the ESP32-CAM AI-Thinker as you are, there doesn’t seem to be a binary we can use. Only ESP-EYE appears to supported.

Do you happen to have a flow you’d recommend? Maybe creating a c++ library and running that?