Page 1 of 1

One question for using external flash?

Posted: Thu Nov 30, 2023 7:20 am
by markevens
I am using external nor flash with ESP32 using spi communication and have only 1 mosi and 1 miso pin so
Which mode to used for reading from SPI flash
SPI_FLASH_DIO or
SPI_FLASH_FASTRD?

And I have two functions in my code which are

Code: Select all

static const esp_partition_t *add_partition(esp_flash_t *flash, const char *partition_label)
{
  ESP_LOGI(SYNC, "Adding external Flash as a partition, label=\"%s\", size=%d KB", partition_label, flash->size / 1024);
  const esp_partition_t *littlefs_partition;
  ESP_ERROR_CHECK(esp_partition_register_external(flash, 0, flash->size, partition_label, ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, &littlefs_partition));
  return littlefs_partition;
}

static void list_data_partitions(void)
{
  ESP_LOGI(SYNC, "Listing data partitions:");
  esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, NULL);

  for (; it != NULL; it = esp_partition_next(it))
  {
    const esp_partition_t *part = esp_partition_get(it);
    ESP_LOGI(SYNC, "- partition '%s', subtype %d, offset 0x%x, size %d kB",
             part->label, part->subtype, part->address, part->size / 1024);
  }

  esp_partition_iterator_release(it);
}
So If I am calling the list_data_partition function before add_partition it does not show the partition that I added in the last boot. list I need to add it using add_partition on every boot why?

And so what on every start-up I have to call this add_partition function? and it is okay?

Re: One question for using external flash?

Posted: Thu Nov 30, 2023 9:20 am
by MicroController
I need to add it using add_partition on every boot why?
Because right after boot only 1) the main flash and 2) partitions from the partition table are known to the system.