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

Flashing S3 via CDC does not work reliable #96

Closed
Jason2866 opened this issue May 29, 2023 · 19 comments
Closed

Flashing S3 via CDC does not work reliable #96

Jason2866 opened this issue May 29, 2023 · 19 comments

Comments

@Jason2866
Copy link
Contributor

Most of the time a timeout happens. See issue in esp-web-tools where esptool.js is used.
There is an another unsolved issue in Arduino Github.

@igrr Can you help?

@igrr
Copy link
Member

igrr commented May 29, 2023

@Jason2866 Do you have a binary which we can flash to reproduce this issue?

@igrr
Copy link
Member

igrr commented May 29, 2023

Interesting, I am not yet able to reproduce the issue with this binary... Do you meet the issue with a board which doesn't yet have anything flashed to it, or with a board which is flashed with some specific application?

From the logs in the linked issue (timeout well into the upload process) I think that this recent fix to the flasher stub might help: espressif/esptool@80dc210.
I'll try some more to reproduce the issue and then see if updating the stubs makes any difference.

@sblantipodi
Copy link

@igrr I have the same problem with a "clean board" and with a board pre-flashed with a CDC firmware.

@igrr
Copy link
Member

igrr commented May 29, 2023

After flashing the board with GlowWormLuciferinFULL_ESP32_S3_firmware-factory.bin and resetting the board, esptool.js can't put it into download mode:

esptool.js
Serial port WebSerial VendorID 0x303a ProductID 0x8167
Connecting.........._______......._______......._______......._______......._______......._______......._______Error: Failed to connect with the device

I have also tried esptool.py, which can't connect either. Opening the serial terminal and toggling DTR/RTS signals I also couldn't make the board reset into the download mode, so I assume the issue here is that the application doesn't handle DTR/RTS to reset into download mode. This looks like the topic of the other issue you just opened (#97) so I'm not going to address it here.


If I manually place the board into ROM download mode, it can be flashed. Also I haven't managed to reproduce the issue with flashing a board when flash is erased. I have erased flash using esptool.py first, then flashed the same application. I have also tried flashing a large (4 MB) binary. On 4 attempts, it got to the end of the flashing process without an issue:

Writing at 0x3ffafe... (100%)
Wrote 4194304 bytes (4195590 compressed) at 0x0 in 26.028 seconds.
Hash of data verified.
Leaving...

I am thinking that perhaps I'm not able to reproduce the issue due to a somewhat different eFuse configuration. Could you please run espefuse.py --port YOUR_PORT summary and attach the output you get as a file?

@sblantipodi
Copy link

if I put the board in CDC mode by pressing Boot, RST, leave RST, this is the output:

PS C:\dev\dpsoftware\ArduinoRaspberry\PUBLIC\glow_worm_luciferin> espefuse.exe --port //./COM11 summary
Connecting...
Device PID identification is only supported on COM and /dev/ serial ports.

Detecting chip type... ESP32-S3
espefuse.py v3.3.1

=== Run "summary" command ===
EFUSE_NAME (Block) Description  = [Meaningful Value] [Readable/Writeable] (Hex Value)
----------------------------------------------------------------------------------------
Config fuses:
DIS_ICACHE (BLOCK0)                                Disables ICache                                    = False R/W (0b0)
DIS_DCACHE (BLOCK0)                                Disables DCache                                    = False R/W (0b0)
DIS_DOWNLOAD_ICACHE (BLOCK0)                       Disables Icache when SoC is in Download mode       = False R/W (0b0)
DIS_DOWNLOAD_DCACHE (BLOCK0)                       Disables Dcache when SoC is in Download mode       = False R/W (0b0)
DIS_FORCE_DOWNLOAD (BLOCK0)                        Disables forcing chip into Download mode           = False R/W (0b0)
DIS_CAN (BLOCK0)                                   Disables the TWAI Controller hardware              = False R/W (0b0)
DIS_APP_CPU (BLOCK0)                               Disables APP CPU                                   = False R/W (0b0)
FLASH_TPUW (BLOCK0)                                Configures flash startup delay after SoC power-up, = 0 R/W (0x0)
                                                    unit is (ms/2). When the value is 15, delay is 7.
                                                   5 ms
DIS_LEGACY_SPI_BOOT (BLOCK0)                       Disables Legacy SPI boot mode                      = False R/W (0b0)
UART_PRINT_CHANNEL (BLOCK0)                        Selects the default UART for printing boot msg     = UART0 R/W (0b0)
FLASH_ECC_MODE (BLOCK0)                            Configures the ECC mode for SPI flash
   = 16-byte to 18-byte mode R/W (0b0)
DIS_USB_DOWNLOAD_MODE (BLOCK0)                     Disables USB OTG download feature in UART download = False R/W (0b0)
                                                    boot mode
UART_PRINT_CONTROL (BLOCK0)                        Sets the default UART boot message output mode     = Enabled R/W (0b00)
FLASH_TYPE (BLOCK0)                                Selects SPI flash type                             = 4 data lines R/W (0b0)
FLASH_PAGE_SIZE (BLOCK0)                           Sets the size of flash page                        = 0 R/W (0b00)
FLASH_ECC_EN (BLOCK0)                              Enables ECC in Flash boot mode                     = False R/W (0b0)
FORCE_SEND_RESUME (BLOCK0)                         Forces ROM code to send an SPI flash resume comman = False R/W (0b0)
                                                   d during SPI boot
BLOCK_USR_DATA (BLOCK3)                            User data
   = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 R/W

Efuse fuses:
WR_DIS (BLOCK0)                                    Disables programming of individual eFuses          = 0 R/W (0x00000000)
RD_DIS (BLOCK0)                                    Disables software reading from BLOCK4-10           = 0 R/W (0b0000000)

Identity fuses:
SECURE_VERSION (BLOCK0)                            Secure version (used by ESP-IDF anti-rollback feat = 0 R/W (0x0000)
                                                   ure)
MAC (BLOCK1)                                       Factory MAC Address
   = f4:12:fa:a8:d5:b8 (OK) R/W
WAFER_VERSION (BLOCK1)                             WAFER version                                      = 1 R/W (0b001)
PKG_VERSION (BLOCK1)                               ??? Package version                                = ESP32-S3 R/W (0x0)
BLOCK1_VERSION (BLOCK1)                            ??? BLOCK1 efuse version                           = 1 R/W (0b001)
OPTIONAL_UNIQUE_ID (BLOCK2)                        ??? Optional unique 128-bit ID
   = 16 63 52 48 9e f1 42 d5 42 7b 76 cf b8 84 90 05 R/W
BLOCK2_VERSION (BLOCK2)                            ??? Version of BLOCK2                              = 5 R/W (0b101)
CUSTOM_MAC (BLOCK3)                                Custom MAC Address
   = 00:00:00:00:00:00 (OK) R/W

Security fuses:
SOFT_DIS_JTAG (BLOCK0)                             Software disables JTAG by programming odd number o = 0 R/W (0b000)
                                                   f 1 bit(s). JTAG can be re-enabled via HMAC periph
                                                   eral
HARD_DIS_JTAG (BLOCK0)                             Hardware disables JTAG permanently                 = False R/W (0b0)
DIS_DOWNLOAD_MANUAL_ENCRYPT (BLOCK0)               Disables flash encryption when in download boot mo = False R/W (0b0)
                                                   des
SPI_BOOT_CRYPT_CNT (BLOCK0)                        Enables encryption and decryption, when an SPI boo = Disable R/W (0b000)
                                                   t mode is set. Enabled when 1 or 3 bits are set,di
                                                   sabled otherwise
SECURE_BOOT_KEY_REVOKE0 (BLOCK0)                   Revokes use of secure boot key digest 0            = False R/W (0b0)
SECURE_BOOT_KEY_REVOKE1 (BLOCK0)                   Revokes use of secure boot key digest 1            = False R/W (0b0)
SECURE_BOOT_KEY_REVOKE2 (BLOCK0)                   Revokes use of secure boot key digest 2            = False R/W (0b0)
KEY_PURPOSE_0 (BLOCK0)                             KEY0 purpose                                       = USER R/W (0x0)
KEY_PURPOSE_1 (BLOCK0)                             KEY1 purpose                                       = USER R/W (0x0)
KEY_PURPOSE_2 (BLOCK0)                             KEY2 purpose                                       = USER R/W (0x0)
KEY_PURPOSE_3 (BLOCK0)                             KEY3 purpose                                       = USER R/W (0x0)
KEY_PURPOSE_4 (BLOCK0)                             KEY4 purpose                                       = USER R/W (0x0)
KEY_PURPOSE_5 (BLOCK0)                             KEY5 purpose                                       = USER R/W (0x0)
SECURE_BOOT_EN (BLOCK0)                            Enables secure boot                                = False R/W (0b0)
SECURE_BOOT_AGGRESSIVE_REVOKE (BLOCK0)             Enables aggressive secure boot key revocation mode = False R/W (0b0)
STRAP_JTAG_SEL (BLOCK0)                            Enable selection between usb_to_jtagor pad_to_jtag = False R/W (0b0)
                                                    through GPIO3
DIS_DOWNLOAD_MODE (BLOCK0)                         Disables all Download boot modes                   = False R/W (0b0)
ENABLE_SECURITY_DOWNLOAD (BLOCK0)                  Enables secure UART download mode (read/write flas = False R/W (0b0)
                                                   h only)
BLOCK_KEY0 (BLOCK4)
  Purpose: USER
               Encryption key0 or user data
   = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 R/W
BLOCK_KEY1 (BLOCK5)
SPI_PAD_CONFIG_D5 (BLOCK1)                         SPI D5 pad                                         = 0 R/W (0b000000)
SPI_PAD_CONFIG_D6 (BLOCK1)                         SPI D6 pad                                         = 0 R/W (0b000000)
SPI_PAD_CONFIG_D7 (BLOCK1)                         SPI D7 pad                                         = 0 R/W (0b000000)

Usb Config fuses:
DIS_USB (BLOCK0)                                   Disables the USB OTG hardware                      = False R/W (0b0)
USB_EXCHG_PINS (BLOCK0)                            Exchanges USB D+ and D- pins                       = False R/W (0b0)
EXT_PHY_ENABLE (BLOCK0)                            Enables external USB PHY                           = False R/W (0b0)
BTLC_GPIO_ENABLE (BLOCK0)                          Enables BTLC GPIO                                  = 0 R/W (0b00)
DIS_USB_JTAG (BLOCK0)                              Disable usb_serial_jtag-to-jtag function           = False R/W (0b0)
DIS_USB_SERIAL_JTAG (BLOCK0)                       Disable usb_serial_jtag module                     = False R/W (0b0)
USB_PHY_SEL (BLOCK0)                               Select internal/external PHY for USB OTGand usb_se = False R/W (0b0)
                                                   rial_jtag

Vdd_Spi Config fuses:
VDD_SPI_XPD (BLOCK0)                               The VDD_SPI regulator is powered on                = True R/W (0b1)
VDD_SPI_TIEH (BLOCK0)                              The VDD_SPI power supply voltage at reset
   = Connect to VDD_RTC_IO R/W (0b1)
VDD_SPI_FORCE (BLOCK0)                             Force using VDD_SPI_XPD and VDD_SPI_TIEH to config = True R/W (0b1)
                                                   ure VDD_SPI LDO
PIN_POWER_SELECTION (BLOCK0)                       Sets default power supply for GPIO33..37           = VDD3P3_CPU R/W (0b0)

Wdt Config fuses:
WDT_DELAY_SEL (BLOCK0)                             Selects RTC WDT timeout threshold at startup       = 0 R/W (0b00)

Flash voltage (VDD_SPI) set to 3.3V by efuse.
PS C:\dev\dpsoftware\ArduinoRaspberry\PUBLIC\glow_worm_luciferin>

@igrr
Copy link
Member

igrr commented May 29, 2023

Thanks for trying this! The output does look pretty much the same as on the board I have here.

One other thing to try, could you flash the same binary on your end using https://igrr.github.io/esptool-js/?

I have just pushed a commit to that fork, updating esptool stubs to the latest v4.6 release which includes the fix for Super WDT triggering during the upload process.

@Jason2866
Copy link
Contributor Author

@igrr on an erased S3 this one fails to flash via CDC

http://ota.tasmota.com/tasmota32/tasmota32s3cdc.bin

@igrr
Copy link
Member

igrr commented May 29, 2023

@Jason2866 I'm not sure if it fails for you with https://igrr.github.io/esptool-js/, as suggested in the last comment, or with https://espressif.github.io/esptool-js/, or with another flasher?

I have just tried flashing this binary to an erased S3 (esptool.py --port /dev/tty.usbmodem4401 erase_flash) using https://igrr.github.io/esptool-js/ and that worked fine:

Writing at 0x1660cd... (100%)
Wrote 1477376 bytes (1039405 compressed) at 0x0 in 12.194 seconds.
Hash of data verified.
Leaving...

Could you please clarify which tool it fails for you with, and post a log? (Was it a connection timeout, or failure when flashing was already underway?)

@Jason2866
Copy link
Contributor Author

@igrr esptool.py does work well. It fails when using https://github.com/esphome/esp-web-tools
I have removed the CDC builds currently from my webflasher

@igrr
Copy link
Member

igrr commented May 29, 2023

@Jason2866 Just to clarify my previous comment, I have successfully flashed the binary using https://igrr.github.io/esptool-js/, not esptool.py. I only mentioned esptool.py in relation to erasing the contents of flash prior to flashing with esptool-js.

Could you please try flashing http://ota.tasmota.com/tasmota32/tasmota32s3cdc.bin using https://igrr.github.io/esptool-js/ and https://espressif.github.io/esptool-js/ ?
If it fails on your end, please attach the log output you get. Thank you.

@Jason2866
Copy link
Contributor Author

@igrr your https://igrr.github.io/esptool-js/ is working!! :-)

@igrr
Copy link
Member

igrr commented May 29, 2023

What about https://espressif.github.io/esptool-js/? If it didn't work, could you please attach the log output?

@Jason2866
Copy link
Contributor Author

Well, it works too. But when used with https://github.com/esphome/esp-web-tools it fails :-(

@sblantipodi
Copy link

@igrr I tried flashing my firmware with that tool,
it flashes the firmware without problems but once finished the ESP goes in boot-loop.

I see the devices continously connecting and disconnecting from Windows... weird. if I flash the same file with the web installer I linked previously it works ok.

@sblantipodi
Copy link

I tried flashing the tasmota firmware and same boot loop issues when using this tool:
https://igrr.github.io/esptool-js/

@Jason2866
Copy link
Contributor Author

@sblantipodi You have to use the factory image and flash at address 0x0

@sblantipodi
Copy link

oops, sorry, flashing at address 0x0 works with both firmware.

@igrr
Copy link
Member

igrr commented Jun 15, 2023

Since https://espressif.github.io/esptool-js/ works I'm going to close this issue. The upload issue with https://github.com/esphome/esp-web-tools can be tracked in esp-web-tools repository.

@igrr igrr closed this as not planned Won't fix, can't repro, duplicate, stale Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants