This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch releases/12.5 in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/releases/12.5 by this push: new 7d28420c0b xtensa/esp32s3: Fix one page program span over 2 pages 7d28420c0b is described below commit 7d28420c0b5408063f33d3c2c3986b7025cabe4c Author: Dong Heng <dongh...@espressif.com> AuthorDate: Tue Mar 19 14:35:53 2024 +0800 xtensa/esp32s3: Fix one page program span over 2 pages One page program can't span over 2 pages. --- arch/xtensa/src/esp32s3/esp32s3_spiflash.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/src/esp32s3/esp32s3_spiflash.c b/arch/xtensa/src/esp32s3/esp32s3_spiflash.c index 3054e60815..f17408631f 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_spiflash.c +++ b/arch/xtensa/src/esp32s3/esp32s3_spiflash.c @@ -99,6 +99,7 @@ /* SPI flash hardware definition */ +# define FLASH_PAGE_SIZE (256) # define FLASH_SECTOR_SIZE (4096) /* SPI flash command */ @@ -1181,10 +1182,11 @@ int spi_flash_write(uint32_t dest_addr, const void *buffer, uint32_t size) spiflash_start(); - for (int i = 0; i < size; i += SPI_BUFFER_BYTES) + while (tx_bytes) { uint32_t spi_buffer[SPI_BUFFER_WORDS]; - uint32_t n = MIN(tx_bytes, SPI_BUFFER_BYTES); + uint32_t n = FLASH_PAGE_SIZE - tx_addr % FLASH_PAGE_SIZE; + n = MIN(n, MIN(tx_bytes, SPI_BUFFER_BYTES)); #ifdef CONFIG_ESP32S3_SPIRAM