|
31 | 31 |
|
32 | 32 | #include "mtd.h" |
33 | 33 |
|
34 | | -#include "esp_partition.h" |
35 | | - |
36 | 34 | #ifndef CPU_ESP8266 |
37 | 35 |
|
| 36 | +#include "esp_flash.h" |
| 37 | +#include "esp_flash_internal.h" |
38 | 38 | #include "esp_flash_partitions.h" |
39 | | -#include "esp_spi_flash.h" |
40 | 39 | #include "rom/cache.h" |
41 | | -#include "rom/spi_flash.h" |
| 40 | +#include "esp_rom_spiflash.h" |
42 | 41 | #include "soc/soc.h" |
43 | 42 |
|
44 | 43 | #else /* !CPU_ESP8266 */ |
45 | 44 |
|
| 45 | +#include "esp_partition.h" |
46 | 46 | #include "esp_flash_data_types.h" |
47 | 47 | #include "rom_functions.h" |
48 | 48 | #include "spi_flash.h" |
@@ -78,6 +78,35 @@ VFS_AUTO_MOUNT(littlefs2, { .dev = &_flash_dev }, VFS_DEFAULT_NVM(0), 0); |
78 | 78 | extern esp_spi_flash_chip_t flashchip; |
79 | 79 | extern uint32_t spi_flash_get_id(void); |
80 | 80 |
|
| 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 | + |
81 | 110 | #endif /* CPU_ESP8266 */ |
82 | 111 |
|
83 | 112 | /* forward declaration of mtd functions */ |
@@ -149,7 +178,7 @@ void spi_flash_drive_init(void) |
149 | 178 | esp_partition_info_t* part = (esp_partition_info_t*)(uintptr_t)part_buf; |
150 | 179 |
|
151 | 180 | 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); |
153 | 182 |
|
154 | 183 | if (part->magic == ESP_PART_ENTRY_MAGIC) { |
155 | 184 | DEBUG("%s partition @%08"PRIx32" size=%08"PRIx32" label=%s\n", __func__, |
|
0 commit comments