Skip to content

erase-region should check the provided length #753

@SergioGasquez

Description

@SergioGasquez

erase-region should check that the provided length is multiple of the SPI flash erase sector size. In esptool docs:

The address and length must both be multiples of the SPI flash erase sector size. This is 0x1000 (4096) bytes for supported flash chips.

❯ esptool.py --chip esp32c6 erase_region 0x1000 0x50
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-C6 (QFN40) (revision v0.0)
Features: WiFi 6, BT 5, IEEE802.15.4
Crystal is 40MHz
MAC: 60:55:f9:00:00:f7:1b:6c
BASE MAC: 60:55:f9:f7:1b:6c
MAC_EXT: 00:00
Uploading stub...
Running stub...
Stub running...
Erasing region (may be slow depending on size)...

A fatal error occurred: Size of data to erase must be a multiple of 4096
Status Ok(ExitStatus(unix_wait_status(512)))

While in espflash:

❯ espflash erase-region 0x1000 0x5
[2025-02-07T10:48:49Z INFO ] Serial port: '/dev/ttyACM0'
[2025-02-07T10:48:49Z INFO ] Connecting...
[2025-02-07T10:48:49Z INFO ] Using flash stub
[2025-02-07T10:48:49Z WARN ] Setting baud rate higher than 115,200 can cause issues
[2025-02-07T10:48:49Z INFO ] Erasing region at 0x00001000 (5 bytes)

We dont throw any error and we delete the next multiple of 4096 of the provided length, in the case of my example, 4096 (0x1000)

  • Once this is resolved we should create a test for it on HIL

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions