From 8ba75a1e9f6fbbf962c4f95afa060dcf38dd7a58 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Fri, 9 Dec 2016 14:18:58 +1100 Subject: [PATCH] SPI flash: Block erase size 64KB not 32KB Reverts changes made in 9f9d92b2dfed7e8a2e1ecbcf0bd8e4139abd5372 --- components/esp32/include/rom/spi_flash.h | 11 +++-------- components/esp32/include/soc/spi_reg.h | 4 ++-- components/spi_flash/flash_ops.c | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/components/esp32/include/rom/spi_flash.h b/components/esp32/include/rom/spi_flash.h index 32f018477a..1e4dddeeb9 100644 --- a/components/esp32/include/rom/spi_flash.h +++ b/components/esp32/include/rom/spi_flash.h @@ -384,8 +384,8 @@ SpiFlashOpResult SPIParamCfg(uint32_t deviceId, uint32_t chip_size, uint32_t blo SpiFlashOpResult SPIEraseChip(void); /** - * @brief Erase a 32KB block of flash - * Uses SPI flash command 52h. + * @brief Erase a 64KB block of flash + * Uses SPI flash command D8H. * Please do not call this function in SDK. * * @param uint32_t block_num : Which block to erase. @@ -398,6 +398,7 @@ SpiFlashOpResult SPIEraseBlock(uint32_t block_num); /** * @brief Erase a sector of flash. + * Uses SPI flash command 20H. * Please do not call this function in SDK. * * @param uint32_t sector_num : Which sector to erase. @@ -412,12 +413,6 @@ SpiFlashOpResult SPIEraseSector(uint32_t sector_num); * @brief Erase some sectors. * Please do not call this function in SDK. * - * @note If calling this function, first set - * g_rom_flashchip.block_size = 32768; or call SPIParamCfg() - * with appropriate parameters. This is due to a ROM bug, the - * block erase command in use is a 32KB erase but after reset - * the block_size field is incorrectly set to 65536. - * * @param uint32_t start_addr : Start addr to erase, should be sector aligned. * * @param uint32_t area_len : Length to erase, should be sector aligned. diff --git a/components/esp32/include/soc/spi_reg.h b/components/esp32/include/soc/spi_reg.h index 34f2f24e1c..d1eeedb9f0 100644 --- a/components/esp32/include/soc/spi_reg.h +++ b/components/esp32/include/soc/spi_reg.h @@ -69,14 +69,14 @@ #define SPI_FLASH_PP_V 0x1 #define SPI_FLASH_PP_S 25 /* SPI_FLASH_SE : R/W ;bitpos:[24] ;default: 1'b0 ; */ -/*description: Sector erase enable(4KB). Sector erase operation will be triggered +/*description: Sector erase enable. A 4KB sector is erased via SPI command 20H. Sector erase operation will be triggered when the bit is set. The bit will be cleared once the operation done.1: enable 0: disable.*/ #define SPI_FLASH_SE (BIT(24)) #define SPI_FLASH_SE_M (BIT(24)) #define SPI_FLASH_SE_V 0x1 #define SPI_FLASH_SE_S 24 /* SPI_FLASH_BE : R/W ;bitpos:[23] ;default: 1'b0 ; */ -/*description: Block erase enable(32KB) . Block erase operation will be triggered +/*description: Block erase enable. A 64KB block is erased via SPI command D8H. Block erase operation will be triggered when the bit is set. The bit will be cleared once the operation done.1: enable 0: disable.*/ #define SPI_FLASH_BE (BIT(23)) #define SPI_FLASH_BE_M (BIT(23)) diff --git a/components/spi_flash/flash_ops.c b/components/spi_flash/flash_ops.c index db3ac042f0..7f6fd70db0 100644 --- a/components/spi_flash/flash_ops.c +++ b/components/spi_flash/flash_ops.c @@ -32,7 +32,7 @@ #include "cache_utils.h" /* bytes erased by SPIEraseBlock() ROM function */ -#define BLOCK_ERASE_SIZE 32768 +#define BLOCK_ERASE_SIZE 65536 #if CONFIG_SPI_FLASH_ENABLE_COUNTERS static const char* TAG = "spi_flash";