boot loop and can't load

mokatronics
Posts: 2
Joined: Thu Oct 24, 2019 3:38 pm

boot loop and can't load

Postby mokatronics » Thu Oct 24, 2019 5:10 pm

hello,

I'm very beginner with ESP32 and to learn in deep I downloaded all the PDF datasheets + bought 3xTTGO (ESP32-WROOM+OLED+CP2102+BMS) on Aliexpress (https://www.aliexpress.com/item/3295686 ... 4c4dN31Vn3 (poor quality).

I started to play with one of them with "get-started/hello_world" project included in espressif git repo. All work fine, I just must remember to push "Boot" button when I start
idf.py flash
command, to enter un flash mode. I tested to flash another small projects 3/4 times without any problem until when I tried to flash this two codes :
  1. #include <stdio.h>
  2. #include "freertos/FreeRTOS.h"
  3. #include "freertos/task.h"
  4. #include "driver/gpio.h"
  5. #include "esp_system.h"
  6. #include "esp_spi_flash.h"
  7.  
  8. #define BLINK_GPIO CONFIG_BLINK_GPIO
  9. #define INTERNAL_LED GPIO_SEL_2
  10.  
  11. void app_main(void)
  12. {
  13.    gpio_config_t gpconfg;
  14.    gpconfg.pin_bit_mask = INTERNAL_LED;
  15.    gpconfg.mode = GPIO_MODE_OUTPUT;
  16.    gpio_config(&gpconfg);
  17.    gpio_set_level(INTERNAL_LED, 1);
  18.    for(;;){}
  19.  
  20. }
and
  1. #include <stdio.h>
  2. #include "freertos/FreeRTOS.h"
  3. #include "freertos/task.h"
  4. #include "driver/gpio.h"
  5. #include "esp_system.h"
  6. #include "esp_spi_flash.h"
  7.  
  8. #define BLINK_GPIO CONFIG_BLINK_GPIO
  9. #define INTERNAL_LED GPIO_SEL_1
  10.  
  11. void app_main(void)
  12. {
  13.    gpio_config_t gpconfg;
  14.    gpconfg.pin_bit_mask = INTERNAL_LED;
  15.    gpconfg.mode = GPIO_MODE_OUTPUT;
  16.    gpio_config(&gpconfg);
  17.    gpio_set_level(INTERNAL_LED, 1);
  18.    for(;;){}
  19.  
  20. }
ok I know it's a mistake, internal LED it isn't on GPIO 1 or 2 :oops:

I tried to flash these codes without any modification in sdkconfig file :
  • first try, load stopped at 40% with a communication error
  • second try, load stopped at 10%, also with a communication error
  • third try, no response :

Code: Select all

esptool.py v2.8-dev
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to Espressif device: Invalid head of packet (0x34)
esptool.py failed with exit code 2
I tried all possible combinaison with EN and BOOT button, like EN pushed then in same time BOOT, and release EN to select flash mode...

In serial monitor when I plug the board and turn on, I've this message in loop very quickly :

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x3 (SW_RESET),boot:0x17 (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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6992
ho 0 tail 12 room 4
load:0x40078000,len:14228
load:0x40080400,len:4296
entry 0x400806e4
I (119) boot: Chip Revision: 1
I (138) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (82) boot: ESP-IDF v4.1-dev-474-g2e6398aff 2nd stage bootloader
I (82) boot: compile time 23:28:58
I (82) boot: Enabling RNG early entropy source...
I (88) boot: SPI Speed      : 40MHz
I (93) boot: SPI Mode       : DIO
I (97) boot: SPI Flash Size : 2MB
I (101) boot: Partition Table:
I (104) boot: ## Label            Usage          Type ST Offset   Length
I (112) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (119) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (127) boot:  2 factory          factory app      00 00 00010000 00100000
I (134) boot: End of partition table
I (139) boot_comm: chip revision: 1, min. application chip revision: 0
I (146) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x06c44 ( 27716) map
I (165) esp_image: segment 1: paddr=0x00016c6c vaddr=0x3ffb0000 size=0x020cc (  8396) load
I (169) esp_image: segment 2: paddr=0x00018d40 vaddr=0x40080000 size=0x00400 (  1024) load
0x40080000: _WindowOverflow4 at /*MASKED*/esp32/esp-idf/components/freertos/xtensa_vectors.S:1778

I (173) esp_image: segment 3: paddr=0x00019148 vaddr=0x40080400 size=0x06ec8 ( 28360) load
E (194) esp_image: invalid segment length 0xffffffff
E (194) boot: Factory app partition is not bootable
E (195) boot: No bootable app partitions in the partition table

ets Jun  8 2016 00:22:57

rst:0x3 (SW_RESET),boot:0x17 (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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6992
ho 0 tail 12 room 4
load:0x40078000,len:14228
load:0x40080400,len:4296
entry 0x400806e4
I (119) boot: Chip Revision: 1
I (138) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (82) boot: ESP-IDF v4.1-dev-474-g2e6398aff 2nd stage bootloader
I (82) boot: compile time 23:28:58
I (82) boot: Enabling RNG early entropy source...
I (88) boot: SPI Speed      : 40MHz
I (93) boot: SPI Mode       : DIO
I (97) boot: SPI Flash Size : 2MB
I (101) boot: Partition Table:
I (104) boot: ## Label            Usage          Type ST Offset   Length
I (112) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (119) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (127) boot:  2 factory          factory app      00 00 00010000 00100000
I (134) boot: End of partition table
I (139) boot_comm: chip revision: 1, min. application chip revision: 0
I (146) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x06c44 ( 27716) map
I (165) esp_image: segment 1: paddr=0x00016c6c vaddr=0x3ffb0000 size=0x020cc (  8396) load
I (169) esp_image: segment 2: paddr=0x00018d40 vaddr=0x40080000 size=0x00400 (  1024) load
0x40080000: _WindowOverflow4 at /*MASKED*/esp32/esp-idf/components/freertos/xtensa_vectors.S:1778

I (173) esp_image: segment 3: paddr=0x00019148 vaddr=0x40080400 size=0x06ec8 ( 28360) load
E (194) esp_image: invalid segment length 0xffffffff
E (194) boot: Factory app partition is not bootable
E (195) boot: No bootable app partitions in the partition table

... ETC ...
Pushing EN+BOOT then release EN give (stopping loop) :

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x7 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
waiting for download
I tried to flash at this moment, with same result Failed to connect to Espressif device: Invalid head of packet (0x34)

  • To check my USB cable, I plugged another TTGO board (same model) which run/flash gracefully.
  • I tried to use another computer on Windows 10 (my main computer is on Ubuntu) with Espressif tool and Serial Sniffer : same result.
  • All commands with esptool.py doesn't works... failed to connect to Espressif device: Invalid head blabla....
  • checked the voltage, it is at 3.3V
I tried to use --trace option with esptool.py with a another TTGO board who work, and compare result with the one that doesn't work :
Image
left side: bad board - right side: normal behavior

I make a small UART reader with Arduino NANO, pluggeg on TX/RX (U0TX/U0RX) on TTGO board to observe what's happen when esp is waiting download and I try to flash :

Code: Select all

rst:0x1 (POWERON_RESET),boot:0x7 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
waiting for download

<--- START idf.py flash --->

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x17 (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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6992
ho 0 tail 12 room 4
load:0x40078000,len:14228
load:0x40080400,len:4296
entry 0x400806e4
I (75) boot: Chip Revision: 1
I (75) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (41) boot: ESP-IDF v4.1-dev-474-g2e6398aff 2nd stage bootloader
I (41) boot: compile time 23:28:58
I (41) boot: Enabling RNG early entropy source...
I (47) boot: SPI Speed      : 40MHz
I (52) boot: SPI Mode       : DIO
I (56) boot: SPI Flash Size : 2MB
I (60) boot: Partition Table:
I (63) boot: ## Label            Usage          Type ST Offset   Length
I (70) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (85) boot:  2 factory          factory app      00 00 00010000 00100000
I (93) boot: End of partition table
I (97) boot_comm: chip revision: 1, min. application chip revision: 0
I (104) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x06c44 ( 27716) map
I (123) esp_image: segment 1: paddr=0x00016c6c vaddr=0x3ffb0000 size=0x020cc (  8396) load
I (127) esp_image: segment 2: paddr=0x00018d40 vaddr=0x40080000 size=0x00400 (  1024) load
I (131) esp_image: segment 3: paddr=0x00019148 vaddr=0x40080400 size=0x06ec8 ( 28360) load
E (152) esp_image: invalid segment length 0xffffffff
E (152) boot: Factory app partition is not bootable
E (153) boot: No bootable app partitions in the partition table
ets Jun  8 2016 00:22:57

rst:0x3 (SW_RESET),boot:0x17 (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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6992
ho 0 tail 12 room 4
load:0x40078000,len:14228
load:0x40080400,len:4296
entry 0x400806e4
I (119) boot: Chip Revision: 1
I (138) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (82) boot: ESP-IDF v4.1-dev-474-g2e6398aff 2nd stage bootloader
I (82) boot: compile time 23:28:58
I (82) boot: Enabling RNG early entropy source...
I (88) boot: SPI Speed      : 40MHz
I (93) boot: SPI Mode       : DIO
I (97) boot: SPI Flash Size : 2MB
I (101) boot: Partition Table:
I (104) boot: ## Label            Usage          Type ST Offset   Length
I (112) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (119) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (127) boot:  2 factory          factory app      00 00 00010000 00100000
I (134) boot: End of partition table
I (139) boot_comm: chip revision: 1, min. application chip revision: 0
I (146) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x06c44 ( 27716) map
I (165) esp_image: segment 1: paddr=0x00016c6c vaddr=0x3ffb0000 size=0x020cc (  8396) load
I (169) esp_image: segment 2: paddr=0x00018d40 v�ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x17 (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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6992
ho 0 tail 12 room 4
load:0x40078000,len:14228
load:0x40080400,len:4296
entry 0x400806e4
I (75) boot: Chip Revision: 1
I (75) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (41) boot: ESP-IDF v4.1-dev-474-g2e6398aff 2nd stage bootloader
I (41) boot: compile time 23:28:58
I (42) boot: Enabling RNG early entropy source...
I (47) boot: SPI Speed      : 40MHz
I (52) boot: SPI Mode       : DIO
I (56) boot: SPI Flash Size : 2MB
I (60) boot: Partition Table:
I (63) boot: ## Label            Usage          Type ST Offset   Length
I (71) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (85) boot:  2 factory          factory app      00 00 00010000 00100000
I (93) boot: End of partition table
I (97) boot_comm: chip revision: 1, min. application chip revision: 0
I (104) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x06c44 ( 27716) map
I (123) esp_image: segment 1: paddr=0x00016c6c vaddr=0x3ffb0000 size=0x020cc (  8396) load
I (127) esp_image: segment 2: paddr=0x00018d40 vaddr=0x40080000 size=0x00400 (  1024) load
I (131) esp_image: segment 3: paddr=0x00019148 vaddr=0x40080400 size=0x06ec8 ( 28360) load
E (152) esp_image: invalid segment length 0xffffffff
E (152) boot: Factory app partition is not bootable
E (153) boot: No bootable app partitions in the partition table

... LOOPING WITH THIS SAME MESSAGE...

I don't know what to do now...
I suspect maybe the CP2102 who don't send anything ? How I can bypass this chip and test with my external UART-USB ? Can I flash without CP2120? I also buy a cheap logic analyze on ebay which will arrive in 1 week to try to understand what happen with my ESP32.

If someone have any idea, I gladly take it !

(my apologize for my horrible english)

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: boot loop and can't load

Postby ESP_Angus » Fri Oct 25, 2019 12:09 am

Hi Mokatronics,

Your English is absolutely great, no need to apologise.

Thanks for all the detail.

The output from your "Arduino Nano" trace of the serial exchange shows that esptool is not able to reset the board properly into bootloader mode - it's booting into "normal" mode which has the incomplete flash contents (due to previous issue where it failed part way through), then it keeps resetting either because of the fatal error or because esptool is triggering more resets (but always into the wrong boot mode).

Normally this indicates some problem with the auto-reset circuit, which it sounds like already doesn't work well on this board. I'd suggest to hold down the BOOT button and then press and quickly release the EN button every few seconds while holding BOOT. Keep doing this for the esptool "Connecting..." stage, if it succeeds in connecting then you can release both buttons for the rest of the flashing stage.

Given it sounds like you've already tried this, maybe the buttons aren't working - you can try pulling GPIO0 to GND permanently with an external wire (this should be equivalent to holding BOOT down). You'll need to remove the jumper once flashing is done, to get it to boot from the flash.

More about this here: https://github.com/espressif/esptool/wi ... -Selection

If you get the board to start responding and you still get the problem of flash failing part way through, check if you can lower the baud rate at all and re-try swapping the USB cable, USB port, etc.

If none of this works you probably have defective hardware.

mokatronics
Posts: 2
Joined: Thu Oct 24, 2019 3:38 pm

Re: boot loop and can't load

Postby mokatronics » Sat Oct 26, 2019 11:59 am

Hi ESP_Angus,

Thank you for your quick reply and your patience to read my post.

I think I fix this issue. I'm not really sure but it's seems that the CP2102 on board is little lazy. Today I try to load code with real external UART (FTDI) and bypass the CP2102. Five tries to flash, five success !!! I crossed my finger for my next testings.

In short this issue taught me lot of thing about ESP32 :D

Who is online

Users browsing this forum: No registered users and 79 guests