From a645015dee7792d6103c9ac4d9e6f401fb66c7c6 Mon Sep 17 00:00:00 2001 From: Cao Sen Miao Date: Mon, 28 Nov 2022 16:54:03 +0800 Subject: [PATCH] esp_flash: correct veriable 'size' description --- components/spi_flash/esp_flash_spi_init.c | 2 +- components/spi_flash/include/esp_flash.h | 6 +++--- components/spi_flash/spi_flash_chip_generic.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/spi_flash/esp_flash_spi_init.c b/components/spi_flash/esp_flash_spi_init.c index ffd19adf0b..6b69a0352d 100644 --- a/components/spi_flash/esp_flash_spi_init.c +++ b/components/spi_flash/esp_flash_spi_init.c @@ -322,7 +322,7 @@ esp_err_t esp_flash_init_default_chip(void) if (default_chip.size > legacy_chip->chip_size) { ESP_EARLY_LOGW(TAG, "Detected size(%dk) larger than the size in the binary image header(%dk). Using the size in the binary image header.", default_chip.size/1024, legacy_chip->chip_size/1024); } - // Set chip->size equal to ROM flash size(also equal to menuconfig flash size), which means the available size that can be used + // Set chip->size equal to ROM flash size(also equal to the size in binary image header), which means the available size that can be used default_chip.size = legacy_chip->chip_size; esp_flash_default_chip = &default_chip; diff --git a/components/spi_flash/include/esp_flash.h b/components/spi_flash/include/esp_flash.h index f803a24b12..bfb7e88c1e 100644 --- a/components/spi_flash/include/esp_flash.h +++ b/components/spi_flash/include/esp_flash.h @@ -100,7 +100,7 @@ struct esp_flash_t { void *os_func_data; ///< Pointer to argument for os-specific hooks. Left NULL and will be initialized with ``os_func``. esp_flash_io_mode_t read_mode; ///< Configured SPI flash read mode. Set before ``esp_flash_init`` is called. - uint32_t size; ///< Size of SPI flash in bytes. If 0, size will be detected during initialisation. Note: Only stands for the available size (`CONFIG_ESPTOOLPY_FLASHSIZE`), If you want to get the flash physical size, please call `esp_flash_get_physical_size`. + uint32_t size; ///< Size of SPI flash in bytes. If 0, size will be detected during initialisation. Note: this stands for the size in the binary image header. If you want to get the flash physical size, please call `esp_flash_get_physical_size`. uint32_t chip_id; ///< Detected chip id. uint32_t busy :1; ///< This flag is used to verify chip's status. uint32_t hpm_dummy_ena :1; ///< This flag is used to verify whether flash works under HPM status. @@ -148,11 +148,11 @@ esp_err_t esp_flash_read_id(esp_flash_t *chip, uint32_t *out_id); /** @brief Detect flash size based on flash ID. * * @param chip Pointer to identify flash chip. Must have been successfully initialised via esp_flash_init() - * @param[out] out_size Detected size in bytes, standing for the available size (`CONFIG_ESPTOOLPY_FLASHSIZE`). + * @param[out] out_size Detected size in bytes, standing for the size in the binary image header. * * @note 1. Most flash chips use a common format for flash ID, where the lower 4 bits specify the size as a power of 2. If * the manufacturer doesn't follow this convention, the size may be incorrectly detected. - * 2. The out_size returned only stands for the size selected in menuconfig. + * 2. The out_size returned only stands for The out_size stands for the size in the binary image header. * If you want to get the real size of the chip, please call `esp_flash_get_physical_size` instead. * * @return ESP_OK on success, or a flash error code if operation failed. diff --git a/components/spi_flash/spi_flash_chip_generic.c b/components/spi_flash/spi_flash_chip_generic.c index 81d5ddbd6a..6726c4feea 100644 --- a/components/spi_flash/spi_flash_chip_generic.c +++ b/components/spi_flash/spi_flash_chip_generic.c @@ -102,7 +102,7 @@ esp_err_t spi_flash_chip_generic_detect_size(esp_flash_t *chip, uint32_t *size) However, some other flash vendors also have their own rule, we will add them in chip specific files. */ uint32_t mem_density = (id & 0xFF); - if (mem_density > SPI_FLASH_LINEAR_DENSITY_LAST_VALUE ) { + if (mem_density > SPI_FLASH_LINEAR_DENSITY_LAST_VALUE) { mem_density -= SPI_FLASH_HEX_A_F_RANGE; }