[esp32c3] Issues with Flash Memory on esp32c3 Modules (ESPTOOL-789)

ivand58
Posts: 10
Joined: Tue May 10, 2022 7:10 am

[esp32c3] Issues with Flash Memory on esp32c3 Modules (ESPTOOL-789)

Postby ivand58 » Fri Dec 22, 2023 8:17 pm

Hi,
I recently bought few new boards with esp32c3, and I'm facing with flash memory issues just with downloading the code that comes with the modules (flashing led):
1. the communication stops in case of `flash_read` , the whole command was:

Code: Select all

esptool.py  read_flash 0 ALL file.bin
2. with ` --no-stub` works, but only up to 1st half of the memory

Code: Select all

 esptool.py --no-stub read_flash 0 0x200000 flash_dump.bin
in case of reading the whole memory it crashes exactly on the middle:

Code: Select all

esptool.py --no-stub  --chip esp32c3  read_flash  0 ALL file.bin
esptool.py v4.7.dev3
Found 1 serial ports
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-C3 (QFN32) (revision v0.4)
Features: WiFi, BLE, Embedded Flash 4MB (XMC)
Crystal is 40MHz
MAC: 40:4c:ca:fa:de:80
Enabling default SPI flash mode...
Detected flash size: 4MB
2097152 (50 %)
A fatal error occurred: Failed to read flash block (result was 01090000: CRC or checksum was invalid)
The same is observed also after a full erase and uploading few example projects. The "Hello world" works, but still with `--no-stub` and half memory.

I am concerned that these issues might be related to either hardware defects or the possibility of non-genuine chips. I would appreciate any guidance on how to diagnose and address these problems.

Furthermore, I am interested in verifying the authenticity of the chips. Is there a recommended method or tool provided by Espressif to confirm whether the modules/chips are genuine or potentially altered?

Additionally, is there a way to check if the advertised memory size matches the actual available memory? I want to ensure that the modules have not been misrepresented, intentionally or unintentionally.

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: [esp32c3] Issues with Flash Memory on esp32c3 Modules

Postby ESP_Sprite » Sat Dec 23, 2023 11:13 am

Can you try to force the ESP32-C3 into download mode (hold BOOT button or pull down GPIO9 and reset or power on the board) and retry?

In general, we're not aware of any fake chips; ESP32 chips seem to be too complicated to be replicated and we have not seen any third shift shenanigans yet, so I'd lean towards your chip being genuine and the issue simply being something software-related.

You can get the flash id and manufacturer using 'esptool.py flash_id'; that also tells you the size of the flash.

ivand58
Posts: 10
Joined: Tue May 10, 2022 7:10 am

Re: [esp32c3] Issues with Flash Memory on esp32c3 Modules

Postby ivand58 » Sat Dec 23, 2023 8:37 pm

the flash id reports 4M but still only the first half is reachable and only with '--no-stub',
the bootload mode doesn't change the picture

Code: Select all

esptool.py  --chip esp32c3 flash_id
esptool.py v4.7.dev3
Found 1 serial ports
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-C3 (QFN32) (revision v0.4)
Features: WiFi, BLE, Embedded Flash 4MB (XMC)
Crystal is 40MHz
MAC: 40:4c:ca:fa:de:80
Uploading stub...
Running stub...
Stub running...
Manufacturer: 20
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...
READ: CAN READ HALF MEMORY ONLY (with boot mode):

Code: Select all

esptool.py --no-stub  --chip esp32c3  read_flash  0 ALL /tmp/ESP32c3_small_orig.bin
esptool.py v4.7.dev3
Found 1 serial ports
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-C3 (QFN32) (revision v0.4)
Features: WiFi, BLE, Embedded Flash 4MB (XMC)
Crystal is 40MHz
MAC: 40:4c:ca:fa:de:80
Enabling default SPI flash mode...
Detected flash size: 4MB
2097152 (50 %)
A fatal error occurred: Failed to read flash block (result was 01090000: CRC or checksum was invalid)
with stub it stops immediately

Code: Select all

 esptool.py  --chip esp32c3  read_flash  0 ALL /tmp/file.bin
esptool.py v4.7.dev3
Found 1 serial ports
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-C3 (QFN32) (revision v0.4)
Features: WiFi, BLE, Embedded Flash 4MB (XMC)
Crystal is 40MHz
MAC: 40:4c:ca:fa:de:80
Uploading stub...
Running stub...
Stub running...
Detected flash size: 4MB
4096 (0 %)
A fatal error occurred: Corrupt data, expected 0x1000 bytes but received 0xb11 bytes
Also if the demo is configured with stub and 4M the uploading crashes:

Code: Select all

...
esptool.py --chip esp32c3 -p /dev/ttyACM0 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 4MB 0x0 bootloader/bootloader.bin 0x10000 fast_scan.bin 0x8000 partition_table/partition-table.bin
esptool.py v4.7.dev3
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-C3 (QFN32) (revision v0.4)
Features: WiFi, BLE, Embedded Flash 4MB (XMC)
Crystal is 40MHz
MAC: 40:4c:ca:fa:de:80
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00005fff...
Flash will be erased from 0x00010000 to 0x000cefff...
Flash will be erased from 0x00008000 to 0x00008fff...
Compressed 20576 bytes to 12630...
Writing at 0x00000000... (100 %)
Wrote 20576 bytes (12630 compressed) at 0x00000000 in 0.3 seconds (effective 498.7 kbit/s)...

A fatal error occurred: Packet content transfer stopped (received 25 bytes)
CMake Error at run_serial_tool.cmake:66 (message):
...
What could be wrong with the stub functions ?

User avatar
ESP_Roland
Posts: 265
Joined: Tue Oct 09, 2018 10:28 am

Re: [esp32c3] Issues with Flash Memory on esp32c3 Modules

Postby ESP_Roland » Wed Dec 27, 2023 1:20 pm

I've tried this with an older revision of the chip and it can read the whole flash:

Code: Select all

`--> esptool.py  --chip esp32c3  read_flash  0 ALL /tmp/file.bin
esptool.py v4.7.0
Found 2 serial ports
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32-C3 (QFN32) (revision v0.3)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 
Uploading stub...
Running stub...
Stub running...
Detected flash size: 4MB
4194304 (100 %)
4194304 (100 %)
Read 4194304 bytes at 0x00000000 in 379.3 seconds (88.5 kbit/s)...
Hard resetting via RTS pin...
Without the flasher stub it fails as you reported:

Code: Select all

`--> esptool.py --no-stub --chip esp32c3 read_flash 0 ALL /tmp/file2.bin
esptool.py v4.7.0
Found 2 serial ports
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32-C3 (QFN32) (revision v0.3)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 
Enabling default SPI flash mode...
Detected flash size: 4MB
2097152 (50 %)
A fatal error occurred: Failed to read flash block (result was 01090000: CRC or checksum was invalid)
Please try to check the board's datasheet. What is the flash size promised there?

Esptool prints the flash size based on an eFuse field. It is possible that you have the 2MB version and the eFuse was burnt incorrectly (for some reason).

ivand58
Posts: 10
Joined: Tue May 10, 2022 7:10 am

Re: [esp32c3] Issues with Flash Memory on esp32c3 Modules

Postby ivand58 » Thu Dec 28, 2023 12:35 am

is there a way to set eFuse back to 2M ?,

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: [esp32c3] Issues with Flash Memory on esp32c3 Modules

Postby ESP_Sprite » Thu Dec 28, 2023 7:12 am

Actually, 0x4016 generally is for an 32MBit (=4MByte) part, so you should be able to read out the full 4MByte here...

User avatar
ESP_Roland
Posts: 265
Joined: Tue Oct 09, 2018 10:28 am

Re: [esp32c3] Issues with Flash Memory on esp32c3 Modules (ESPTOOL-789)

Postby ESP_Roland » Thu Dec 28, 2023 10:36 am

I will try to find a v0.4 revision chip and check the issue there.

User avatar
ESP_Roland
Posts: 265
Joined: Tue Oct 09, 2018 10:28 am

Re: [esp32c3] Issues with Flash Memory on esp32c3 Modules (ESPTOOL-789)

Postby ESP_Roland » Wed Jan 03, 2024 12:51 pm

Update: I've achieved the same result with a v1.0 and a v1.1. I've tried v4.7.dev1, v4.7 and v4.8.dev1 esptool versions. All the same results, i.e. flasher stub works. In my experiments I've used Espressif boards all through UART.

We will investigate the issue with --no-stub and USB.

User avatar
ESP_Roland
Posts: 265
Joined: Tue Oct 09, 2018 10:28 am

Re: [esp32c3] Issues with Flash Memory on esp32c3 Modules (ESPTOOL-789)

Postby ESP_Roland » Fri Jan 05, 2024 10:38 am

I've found a board with rev. 0.4 chip and Serial/JTAG USB. The results are same. Esptool with flasher stub is able to read the full 4MB flash.

Who is online

Users browsing this forum: Michaelboeding and 111 guests