Erase size not set for external chip in esp_partition_register_external
Posted: Mon Jan 29, 2024 10:02 am
We are using a external chip spi flash chip on our board.
We can successfully init this chip with the following code:
We want to run the LFS filesytem on this chip. However, to use LFS, we need to know the erase_size. This property is never set in the esp_partition_register_external call and remains 0.
Is this intended behaviour?
I've got a workarround and that is by forcefully setting the variable after the register_external command.
This means i have to cast it to not be const, and then i can change it, which is not ideal.
is there a better way to solve this?
We can successfully init this chip with the following code:
Code: Select all
// Init External Flash
ESP_LOGI(Tag, "Init External Flash");
const esp_flash_spi_device_config_t config = {
.host_id = SPI2_HOST,
.cs_io_num = GPIO_NUM_10,
.io_mode = SPI_FLASH_DIO,
.speed = ESP_FLASH_5MHZ, // Deprecrated
.input_delay_ns = 0,
.cs_id = 0,
.freq_mhz = ESP_FLASH_5MHZ ///< The frequency of flash chip(MHZ)
};
esp_flash_t* chip = nullptr;
const esp_partition_t* partition = nullptr;
spi_bus_add_flash_device(&chip, &config);
esp_flash_init(chip);
err = esp_partition_register_external(chip, 0, chip->size, "ext_lfs", ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_UNDEFINED, &partition);
Is this intended behaviour?
I've got a workarround and that is by forcefully setting the variable after the register_external command.
Code: Select all
((esp_partition_t*)(partition))->erase_size = 4096;
is there a better way to solve this?