mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
spi_flash: Remove legacy spi_flash drivers
This commit is contained in:
@@ -6,7 +6,6 @@ SOURCE_FILES := \
|
||||
partition.c \
|
||||
../spi_flash/partition_target.c \
|
||||
flash_ops.c \
|
||||
esp32/flash_ops_esp32.c \
|
||||
) \
|
||||
|
||||
INCLUDE_DIRS := \
|
||||
@@ -16,6 +15,7 @@ INCLUDE_DIRS := \
|
||||
../private_include \
|
||||
$(addprefix stubs/, \
|
||||
app_update/include \
|
||||
bsd/include \
|
||||
driver/include \
|
||||
esp_timer/include \
|
||||
freertos/include \
|
||||
|
@@ -3,11 +3,13 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "esp_spi_flash.h"
|
||||
#include "spi_flash_mmap.h"
|
||||
#include "esp_partition.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
#include "esp_flash.h"
|
||||
#include "bsd_strings.h"
|
||||
|
||||
SpiFlash spiflash = SpiFlash();
|
||||
|
||||
@@ -85,6 +87,11 @@ esp_rom_spiflash_result_t esp_rom_spiflash_read(uint32_t target, uint32_t *dest,
|
||||
return spiflash.read(target, dest, len);
|
||||
}
|
||||
|
||||
extern "C" esp_err_t esp_flash_read(esp_flash_t *chip, void *buffer, uint32_t address, uint32_t length)
|
||||
{
|
||||
return spiflash.read(address, buffer, length);
|
||||
}
|
||||
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_erase_block(uint32_t block)
|
||||
{
|
||||
return spiflash.erase_block(block);
|
||||
@@ -100,11 +107,29 @@ esp_rom_spiflash_result_t esp_rom_spiflash_erase_page(uint32_t page)
|
||||
return spiflash.erase_page(page);
|
||||
}
|
||||
|
||||
extern "C" esp_err_t esp_flash_erase_region(esp_flash_t *chip, uint32_t start_addr, uint32_t size)
|
||||
{
|
||||
size_t start = start_addr / SPI_FLASH_SEC_SIZE;
|
||||
size_t end = start + size / SPI_FLASH_SEC_SIZE;
|
||||
const size_t sectors_per_block = 65536 / SPI_FLASH_SEC_SIZE;
|
||||
esp_rom_spiflash_result_t rc = ESP_ROM_SPIFLASH_RESULT_OK;
|
||||
for (size_t sector = start; sector != end && rc == ESP_ROM_SPIFLASH_RESULT_OK; ) {
|
||||
rc = spiflash.erase_sector(sector);
|
||||
++sector;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write(uint32_t target, const uint32_t *src, int32_t len)
|
||||
{
|
||||
return spiflash.write(target, src, len);
|
||||
}
|
||||
|
||||
extern "C" esp_err_t esp_flash_write(esp_flash_t *chip, const void *buffer, uint32_t address, uint32_t length)
|
||||
{
|
||||
return spiflash.write(address, buffer, length);
|
||||
}
|
||||
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write_encrypted(uint32_t flash_addr, uint32_t *data, uint32_t len)
|
||||
{
|
||||
return spiflash.write(flash_addr, data, len);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include "esp_spi_flash.h"
|
||||
#include "spi_flash_mmap.h"
|
||||
#include "esp_partition.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
|
@@ -5,12 +5,14 @@ SOURCE_FILES := \
|
||||
esp32/crc.cpp \
|
||||
esp32/esp_random.c \
|
||||
esp_timer/src/esp_timer.c \
|
||||
bsd/strlcpy.c\
|
||||
bootloader_support/src/bootloader_common.c
|
||||
|
||||
INCLUDE_DIRS := \
|
||||
../include \
|
||||
../private_include \
|
||||
app_update/include \
|
||||
bsd/include \
|
||||
driver/include \
|
||||
esp_timer/include \
|
||||
freertos/include \
|
||||
|
Reference in New Issue
Block a user