Skip to content

Commit

Permalink
fix(flasher_stub): Correct boundaries for SPIWrite4B and SPIRead4B
Browse files Browse the repository at this point in the history
SPIWrite4B and SPIRead4B functions are required for flash sizes bigger
than 16MB. This fix corrects the boundaries so SPIWrite and SPIRead
would be used for the whole 16MB area.

The octal flash support for 32 MB chips
(espressif/esptool#795) will be added in a
follow-up commit.

Closes espressif/esptool#745
  • Loading branch information
dobairoland committed Dec 27, 2022
1 parent 389fc00 commit 040e28e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions flasher_stub/stub_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void handle_flash_read(uint32_t addr, uint32_t len, uint32_t block_size,
uint32_t n = len - num_sent;
if (n > block_size) n = block_size;
#if defined(ESP32S3)
if (addr + len > 0x00ffffff)
if (addr + n > 0x01000000)
res = SPIRead4B(1, SPI_FLASH_FASTRD_MODE, addr, buf, n);
else
res = SPIRead(addr, (uint32_t *)buf, n);
Expand Down Expand Up @@ -158,7 +158,7 @@ int handle_flash_get_md5sum(uint32_t addr, uint32_t len) {
n = FLASH_SECTOR_SIZE;
}
#if defined(ESP32S3)
if (addr + len > 0x00ffffff)
if (addr + n > 0x01000000)
res = SPIRead4B(1, SPI_FLASH_FASTRD_MODE, addr, buf, n);
else
res = SPIRead(addr, (uint32_t *)buf, n);
Expand Down
2 changes: 1 addition & 1 deletion flasher_stub/stub_write_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void handle_flash_data(void *data_buf, uint32_t length) {

/* do the actual write */
#if defined(ESP32S3)
if (fs.next_write + length > 0x00ffffff)
if (fs.next_write + length > 0x01000000)
res = SPIWrite4B(1, SPI_FLASH_FASTRD_MODE, fs.next_write, data_buf, length);
else
res = SPIWrite(fs.next_write, data_buf, length);
Expand Down

0 comments on commit 040e28e

Please sign in to comment.