Skip to content

Commit a4e7227

Browse files
committed
cpu/esp32/periph/flash: migration to ESP-IDF v5.4
1 parent f0d9c39 commit a4e7227

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

cpu/esp_common/periph/flash.c

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@
3131

3232
#include "mtd.h"
3333

34-
#include "esp_partition.h"
35-
3634
#ifndef CPU_ESP8266
3735

36+
#include "esp_flash.h"
37+
#include "esp_flash_internal.h"
3838
#include "esp_flash_partitions.h"
39-
#include "esp_spi_flash.h"
4039
#include "rom/cache.h"
41-
#include "rom/spi_flash.h"
40+
#include "esp_rom_spiflash.h"
4241
#include "soc/soc.h"
4342

4443
#else /* !CPU_ESP8266 */
4544

45+
#include "esp_partition.h"
4646
#include "esp_flash_data_types.h"
4747
#include "rom_functions.h"
4848
#include "spi_flash.h"
@@ -78,6 +78,35 @@ VFS_AUTO_MOUNT(littlefs2, { .dev = &_flash_dev }, VFS_DEFAULT_NVM(0), 0);
7878
extern esp_spi_flash_chip_t flashchip;
7979
extern uint32_t spi_flash_get_id(void);
8080

81+
#else
82+
83+
static inline esp_err_t spi_flash_erase_range(size_t start_address, size_t size)
84+
{
85+
esp_err_t res;
86+
uint32_t state = irq_disable();
87+
res = esp_flash_erase_region(esp_flash_default_chip, start_address, size);
88+
irq_restore(state);
89+
return res;
90+
}
91+
92+
static inline esp_err_t spi_flash_write(size_t dest_addr, const void *src, size_t size)
93+
{
94+
esp_err_t res;
95+
uint32_t state = irq_disable();
96+
res = esp_flash_write(esp_flash_default_chip, src, dest_addr, size);
97+
irq_restore(state);
98+
return res;
99+
}
100+
101+
static inline esp_err_t spi_flash_read(size_t src_addr, void *dest, size_t size)
102+
{
103+
esp_err_t res;
104+
uint32_t state = irq_disable();
105+
res = esp_flash_read(esp_flash_default_chip, dest, src_addr, size);
106+
irq_restore(state);
107+
return res;
108+
}
109+
81110
#endif /* CPU_ESP8266 */
82111

83112
/* forward declaration of mtd functions */
@@ -149,7 +178,7 @@ void spi_flash_drive_init(void)
149178
esp_partition_info_t* part = (esp_partition_info_t*)(uintptr_t)part_buf;
150179

151180
while (part_read && part_addr < ESP_PART_TABLE_ADDR + ESP_PART_TABLE_SIZE) {
152-
spi_flash_read (part_addr, (void*)part_buf, ESP_PART_ENTRY_SIZE);
181+
spi_flash_read(part_addr, (void*)part_buf, ESP_PART_ENTRY_SIZE);
153182

154183
if (part->magic == ESP_PART_ENTRY_MAGIC) {
155184
DEBUG("%s partition @%08"PRIx32" size=%08"PRIx32" label=%s\n", __func__,

0 commit comments

Comments
 (0)