One question for using external flash?

markevens
Posts: 38
Joined: Sat Aug 01, 2020 6:31 am

One question for using external flash?

Postby markevens » Thu Nov 30, 2023 7:20 am

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?

MicroController
Posts: 1692
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: One question for using external flash?

Postby MicroController » Thu Nov 30, 2023 9:20 am

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.

Who is online

Users browsing this forum: No registered users and 254 guests