mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 23:54:33 +02:00
spi_flash: move patch files to common rom patch folder
This commit is contained in:
@@ -63,6 +63,7 @@ SECTIONS
|
||||
*libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
|
||||
*libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
|
||||
*libefuse.a:*.*(.literal .text .literal.* .text.*)
|
||||
*libesp_rom.a:*.*(.literal .text .literal.* .text.*)
|
||||
*(.fini.literal)
|
||||
*(.fini)
|
||||
*(.gnu.version)
|
||||
|
@@ -115,26 +115,20 @@ esp_err_t bootloader_flash_erase_range(uint32_t start_addr, uint32_t size)
|
||||
#else //BOOTLOADER_BUILD
|
||||
/* Bootloader version, uses ROM functions only */
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "esp32/rom/cache.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#include "esp32s2/rom/cache.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#include "esp32c3/rom/cache.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32H2
|
||||
#include "esp32h2/rom/spi_flash.h"
|
||||
#include "esp32h2/rom/cache.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP8684
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
#include "esp8684/rom/cache.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#endif
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#include "esp_log.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "esp_rom_efuse.h"
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/spi_reg.h"
|
||||
|
@@ -10,7 +10,6 @@
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp32c3/rom/gpio.h"
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#include "esp32c3/rom/efuse.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
|
@@ -10,7 +10,6 @@
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp32h2/rom/gpio.h"
|
||||
#include "esp32h2/rom/spi_flash.h"
|
||||
#include "esp32h2/rom/efuse.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/spi_reg.h"
|
||||
#include "soc/spi_mem_reg.h"
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/spi_reg.h"
|
||||
#include "soc/spi_mem_reg.h"
|
||||
|
@@ -10,8 +10,8 @@
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp8684/rom/gpio.h"
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
#include "esp8684/rom/efuse.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/spi_reg.h"
|
||||
|
@@ -52,7 +52,6 @@
|
||||
#include "esp8684/rom/cache.h"
|
||||
#include "esp8684/rom/efuse.h"
|
||||
#include "esp8684/rom/ets_sys.h"
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
#include "esp8684/rom/crc.h"
|
||||
#include "esp8684/rom/rtc.h"
|
||||
#include "esp8684/rom/uart.h"
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "esp_rom_efuse.h"
|
||||
#include "esp_rom_uart.h"
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
@@ -24,10 +25,8 @@
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "esp8684/rom/efuse.h"
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
#include "esp8684/rom/cache.h"
|
||||
#include "esp8684/rom/ets_sys.h"
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
#include "esp8684/rom/rtc.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "bootloader_init.h"
|
||||
|
@@ -17,7 +17,6 @@
|
||||
#include "esp_log.h"
|
||||
#include "esp_efuse.h"
|
||||
#include "spiram_psram.h"
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "esp32/rom/cache.h"
|
||||
#include "esp32/rom/efuse.h"
|
||||
#include "esp_rom_efuse.h"
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#include "esp_types.h"
|
||||
#include "esp_log.h"
|
||||
#include "spiram_psram.h"
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#include "esp32s2/rom/opi_flash.h"
|
||||
#include "esp32s2/rom/cache.h"
|
||||
#include "esp32s2/rom/efuse.h"
|
||||
|
@@ -12,7 +12,6 @@
|
||||
#include "esp_log.h"
|
||||
#include "spiram_psram.h"
|
||||
#include "esp32s3/rom/ets_sys.h"
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#include "esp32s3/rom/opi_flash.h"
|
||||
#include "esp32s3/rom/gpio.h"
|
||||
#include "esp32s3/rom/cache.h"
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#include "esp_types.h"
|
||||
#include "esp_log.h"
|
||||
#include "spiram_psram.h"
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#include "esp32s3/rom/opi_flash.h"
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#include "esp32s3/rom/efuse.h"
|
||||
|
@@ -16,6 +16,7 @@ else()
|
||||
list(APPEND sources "patches/esp_rom_crc.c"
|
||||
"patches/esp_rom_sys.c"
|
||||
"patches/esp_rom_uart.c"
|
||||
"patches/esp_rom_spiflash.c"
|
||||
"patches/esp_rom_tjpgd.c")
|
||||
list(APPEND private_required_comp soc hal)
|
||||
endif()
|
||||
@@ -26,7 +27,8 @@ endif()
|
||||
|
||||
idf_component_register(SRCS ${sources}
|
||||
INCLUDE_DIRS ${include_dirs}
|
||||
PRIV_REQUIRES ${private_required_comp})
|
||||
PRIV_REQUIRES ${private_required_comp}
|
||||
LDFRAGMENTS linker.lf)
|
||||
|
||||
if(target STREQUAL "esp32h2")
|
||||
if(CONFIG_IDF_TARGET_ESP32H2_BETA_VERSION_1)
|
||||
|
@@ -115,6 +115,12 @@ extern "C" {
|
||||
|
||||
#define FLASH_ID_GD25LQ32C 0xC86016
|
||||
|
||||
typedef enum {
|
||||
ESP_ROM_SPIFLASH_RESULT_OK,
|
||||
ESP_ROM_SPIFLASH_RESULT_ERR,
|
||||
ESP_ROM_SPIFLASH_RESULT_TIMEOUT
|
||||
} esp_rom_spiflash_result_t;
|
||||
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
|
||||
/**
|
||||
|
@@ -71,18 +71,18 @@ extern "C" {
|
||||
#define FLASH_ID_GD25LQ32C 0xC86016
|
||||
|
||||
typedef enum {
|
||||
SPI_FLASH_RESULT_OK,
|
||||
SPI_FLASH_RESULT_ERR,
|
||||
SPI_FLASH_RESULT_TIMEOUT
|
||||
} SpiFlashOpResult;
|
||||
ESP_ROM_SPIFLASH_RESULT_OK,
|
||||
ESP_ROM_SPIFLASH_RESULT_ERR,
|
||||
ESP_ROM_SPIFLASH_RESULT_TIMEOUT
|
||||
} esp_rom_spiflash_result_t;
|
||||
|
||||
typedef void (* spi_flash_func_t)(void);
|
||||
typedef SpiFlashOpResult (* spi_flash_op_t)(void);
|
||||
typedef SpiFlashOpResult (* spi_flash_erase_t)(uint32_t);
|
||||
typedef SpiFlashOpResult (* spi_flash_rd_t)(uint32_t, uint32_t*, int);
|
||||
typedef SpiFlashOpResult (* spi_flash_wr_t)(uint32_t, const uint32_t*, int);
|
||||
typedef SpiFlashOpResult (* spi_flash_ewr_t)(uint32_t, const void*, uint32_t);
|
||||
typedef SpiFlashOpResult (* spi_flash_wren_t)(void*);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_op_t)(void);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_erase_t)(uint32_t);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_rd_t)(uint32_t, uint32_t*, int);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_wr_t)(uint32_t, const uint32_t*, int);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_ewr_t)(uint32_t, const void*, uint32_t);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_wren_t)(void*);
|
||||
|
||||
typedef struct {
|
||||
uint32_t read_sub_len;
|
||||
|
@@ -71,18 +71,18 @@ extern "C" {
|
||||
#define FLASH_ID_GD25LQ32C 0xC86016
|
||||
|
||||
typedef enum {
|
||||
SPI_FLASH_RESULT_OK,
|
||||
SPI_FLASH_RESULT_ERR,
|
||||
SPI_FLASH_RESULT_TIMEOUT
|
||||
} SpiFlashOpResult;
|
||||
ESP_ROM_SPIFLASH_RESULT_OK,
|
||||
ESP_ROM_SPIFLASH_RESULT_ERR,
|
||||
ESP_ROM_SPIFLASH_RESULT_TIMEOUT
|
||||
} esp_rom_spiflash_result_t;
|
||||
|
||||
typedef void (* spi_flash_func_t)(void);
|
||||
typedef SpiFlashOpResult (* spi_flash_op_t)(void);
|
||||
typedef SpiFlashOpResult (* spi_flash_erase_t)(uint32_t);
|
||||
typedef SpiFlashOpResult (* spi_flash_rd_t)(uint32_t, uint32_t*, int);
|
||||
typedef SpiFlashOpResult (* spi_flash_wr_t)(uint32_t, const uint32_t*, int);
|
||||
typedef SpiFlashOpResult (* spi_flash_ewr_t)(uint32_t, const void*, uint32_t);
|
||||
typedef SpiFlashOpResult (* spi_flash_wren_t)(void*);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_op_t)(void);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_erase_t)(uint32_t);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_rd_t)(uint32_t, uint32_t*, int);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_wr_t)(uint32_t, const uint32_t*, int);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_ewr_t)(uint32_t, const void*, uint32_t);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_wren_t)(void*);
|
||||
|
||||
typedef struct {
|
||||
uint32_t read_sub_len;
|
||||
|
@@ -8,7 +8,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "spi_flash.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -107,10 +107,10 @@ extern "C" {
|
||||
#define FLASH_ID_GD25LQ32C 0xC86016
|
||||
|
||||
typedef enum {
|
||||
SPI_FLASH_RESULT_OK,
|
||||
SPI_FLASH_RESULT_ERR,
|
||||
SPI_FLASH_RESULT_TIMEOUT
|
||||
} SpiFlashOpResult;
|
||||
ESP_ROM_SPIFLASH_RESULT_OK,
|
||||
ESP_ROM_SPIFLASH_RESULT_ERR,
|
||||
ESP_ROM_SPIFLASH_RESULT_TIMEOUT
|
||||
} esp_rom_spiflash_result_t;
|
||||
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "spi_flash.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -100,19 +100,19 @@ extern "C" {
|
||||
|
||||
|
||||
typedef enum {
|
||||
SPI_FLASH_RESULT_OK,
|
||||
SPI_FLASH_RESULT_ERR,
|
||||
SPI_FLASH_RESULT_TIMEOUT
|
||||
} SpiFlashOpResult;
|
||||
ESP_ROM_SPIFLASH_RESULT_OK,
|
||||
ESP_ROM_SPIFLASH_RESULT_ERR,
|
||||
ESP_ROM_SPIFLASH_RESULT_TIMEOUT
|
||||
} esp_rom_spiflash_result_t;
|
||||
|
||||
typedef void (*spi_flash_func_t)(void);
|
||||
typedef SpiFlashOpResult (*spi_flash_op_t)(void);
|
||||
typedef SpiFlashOpResult (*spi_flash_erase_t)(uint32_t);
|
||||
typedef SpiFlashOpResult (*spi_flash_rd_t)(uint32_t, void*, int);
|
||||
typedef SpiFlashOpResult (*spi_flash_wr_t)(uint32_t, const uint32_t*, int);
|
||||
typedef SpiFlashOpResult (*spi_flash_ewr_t)(uint32_t, const void*, uint32_t);
|
||||
typedef SpiFlashOpResult (*spi_flash_wren_t)(void*);
|
||||
typedef SpiFlashOpResult (* spi_flash_erase_area_t)(uint32_t, uint32_t);
|
||||
typedef esp_rom_spiflash_result_t (*spi_flash_op_t)(void);
|
||||
typedef esp_rom_spiflash_result_t (*spi_flash_erase_t)(uint32_t);
|
||||
typedef esp_rom_spiflash_result_t (*spi_flash_rd_t)(uint32_t, void*, int);
|
||||
typedef esp_rom_spiflash_result_t (*spi_flash_wr_t)(uint32_t, const uint32_t*, int);
|
||||
typedef esp_rom_spiflash_result_t (*spi_flash_ewr_t)(uint32_t, const void*, uint32_t);
|
||||
typedef esp_rom_spiflash_result_t (*spi_flash_wren_t)(void*);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_erase_area_t)(uint32_t, uint32_t);
|
||||
|
||||
typedef struct {
|
||||
uint8_t pp_addr_bit_len;
|
||||
|
@@ -16,14 +16,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup spi_flash_apis, spi flash operation related apis
|
||||
* @brief spi_flash apis
|
||||
*/
|
||||
|
||||
/** @addtogroup spi_flash_apis
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define PERIPHS_SPI_FLASH_CMD SPI_MEM_CMD_REG(1)
|
||||
#define PERIPHS_SPI_FLASH_ADDR SPI_MEM_ADDR_REG(1)
|
||||
#define PERIPHS_SPI_FLASH_CTRL SPI_MEM_CTRL_REG(1)
|
||||
@@ -78,445 +70,21 @@ extern "C" {
|
||||
|
||||
#define FLASH_ID_GD25LQ32C 0xC86016
|
||||
|
||||
typedef enum {
|
||||
ESP_ROM_SPIFLASH_QIO_MODE = 0,
|
||||
ESP_ROM_SPIFLASH_QOUT_MODE,
|
||||
ESP_ROM_SPIFLASH_DIO_MODE,
|
||||
ESP_ROM_SPIFLASH_DOUT_MODE,
|
||||
ESP_ROM_SPIFLASH_FASTRD_MODE,
|
||||
ESP_ROM_SPIFLASH_SLOWRD_MODE
|
||||
} esp_rom_spiflash_read_mode_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_ROM_SPIFLASH_RESULT_OK,
|
||||
ESP_ROM_SPIFLASH_RESULT_ERR,
|
||||
ESP_ROM_SPIFLASH_RESULT_TIMEOUT
|
||||
} esp_rom_spiflash_result_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t device_id;
|
||||
uint32_t chip_size; // chip size in bytes
|
||||
uint32_t block_size;
|
||||
uint32_t sector_size;
|
||||
uint32_t page_size;
|
||||
uint32_t status_mask;
|
||||
} esp_rom_spiflash_chip_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t data_length;
|
||||
uint8_t read_cmd0;
|
||||
uint8_t read_cmd1;
|
||||
uint8_t write_cmd;
|
||||
uint16_t data_mask;
|
||||
uint16_t data;
|
||||
} esp_rom_spiflash_common_cmd_t;
|
||||
|
||||
/**
|
||||
* @brief Fix the bug in SPI hardware communication with Flash/Ext-SRAM in High Speed.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint8_t spi: 0 for SPI0(Cache Access), 1 for SPI1(Flash read/write).
|
||||
*
|
||||
* @param uint8_t freqdiv: Pll is 80M, 4 for 20M, 3 for 26.7M, 2 for 40M, 1 for 80M.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void esp_rom_spiflash_fix_dummylen(uint8_t spi, uint8_t freqdiv);
|
||||
|
||||
/**
|
||||
* @brief Select SPI Flash to QIO mode when WP pad is read from Flash.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint8_t wp_gpio_num: WP gpio number.
|
||||
*
|
||||
* @param uint32_t ishspi: 0 for spi, 1 for hspi, flash pad decided by strapping
|
||||
* else, bit[5:0] spiclk, bit[11:6] spiq, bit[17:12] spid, bit[23:18] spics0, bit[29:24] spihd
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void esp_rom_spiflash_select_qiomode(uint8_t wp_gpio_num, uint32_t ishspi);
|
||||
|
||||
/**
|
||||
* @brief Set SPI Flash pad drivers.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint8_t wp_gpio_num: WP gpio number.
|
||||
*
|
||||
* @param uint32_t ishspi: 0 for spi, 1 for hspi, flash pad decided by strapping
|
||||
* else, bit[5:0] spiclk, bit[11:6] spiq, bit[17:12] spid, bit[23:18] spics0, bit[29:24] spihd
|
||||
*
|
||||
* @param uint8_t *drvs: drvs[0]-bit[3:0] for cpiclk, bit[7:4] for spiq, drvs[1]-bit[3:0] for spid, drvs[1]-bit[7:4] for spid
|
||||
* drvs[2]-bit[3:0] for spihd, drvs[2]-bit[7:4] for spiwp.
|
||||
* Values usually read from falsh by rom code, function usually callde by rom code.
|
||||
* if value with bit(3) set, the value is valid, bit[2:0] is the real value.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void esp_rom_spiflash_set_drvs(uint8_t wp_gpio_num, uint32_t ishspi, uint8_t *drvs);
|
||||
|
||||
/**
|
||||
* @brief Select SPI Flash function for pads.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint32_t ishspi: 0 for spi, 1 for hspi, flash pad decided by strapping
|
||||
* else, bit[5:0] spiclk, bit[11:6] spiq, bit[17:12] spid, bit[23:18] spics0, bit[29:24] spihd
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void esp_rom_spiflash_select_padsfunc(uint32_t ishspi);
|
||||
|
||||
/**
|
||||
* @brief SPI Flash init, clock divisor is 4, use 1 line Slow read mode.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint32_t ishspi: 0 for spi, 1 for hspi, flash pad decided by strapping
|
||||
* else, bit[5:0] spiclk, bit[11:6] spiq, bit[17:12] spid, bit[23:18] spics0, bit[29:24] spihd
|
||||
*
|
||||
* @param uint8_t legacy: In legacy mode, more SPI command is used in line.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void esp_rom_spiflash_attach(uint32_t ishspi, bool legacy);
|
||||
|
||||
/**
|
||||
* @brief SPI Read Flash status register. We use CMD 0x05 (RDSR).
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param esp_rom_spiflash_chip_t *spi : The information for Flash, which is exported from ld file.
|
||||
*
|
||||
* @param uint32_t *status : The pointer to which to return the Flash status value.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : read OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : read error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : read timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_read_status(esp_rom_spiflash_chip_t *spi, uint32_t *status);
|
||||
|
||||
/**
|
||||
* @brief SPI Read Flash status register bits 8-15. We use CMD 0x35 (RDSR2).
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param esp_rom_spiflash_chip_t *spi : The information for Flash, which is exported from ld file.
|
||||
*
|
||||
* @param uint32_t *status : The pointer to which to return the Flash status value.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : read OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : read error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : read timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_read_statushigh(esp_rom_spiflash_chip_t *spi, uint32_t *status);
|
||||
|
||||
/**
|
||||
* @brief Write status to Falsh status register.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param esp_rom_spiflash_chip_t *spi : The information for Flash, which is exported from ld file.
|
||||
*
|
||||
* @param uint32_t status_value : Value to .
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : write OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : write error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : write timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write_status(esp_rom_spiflash_chip_t *spi, uint32_t status_value);
|
||||
|
||||
/**
|
||||
* @brief Use a command to Read Flash status register.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param esp_rom_spiflash_chip_t *spi : The information for Flash, which is exported from ld file.
|
||||
*
|
||||
* @param uint32_t*status : The pointer to which to return the Flash status value.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : read OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : read error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : read timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_read_user_cmd(uint32_t *status, uint8_t cmd);
|
||||
|
||||
/**
|
||||
* @brief Config SPI Flash read mode when init.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param esp_rom_spiflash_read_mode_t mode : QIO/QOUT/DIO/DOUT/FastRD/SlowRD.
|
||||
*
|
||||
* This function does not try to set the QIO Enable bit in the status register, caller is responsible for this.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : config OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : config error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : config timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_config_readmode(esp_rom_spiflash_read_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Config SPI Flash clock divisor.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint8_t freqdiv: clock divisor.
|
||||
*
|
||||
* @param uint8_t spi: 0 for SPI0, 1 for SPI1.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : config OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : config error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : config timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_config_clk(uint8_t freqdiv, uint8_t spi);
|
||||
|
||||
/**
|
||||
* @brief Send CommonCmd to Flash so that is can go into QIO mode, some Flash use different CMD.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param esp_rom_spiflash_common_cmd_t *cmd : A struct to show the action of a command.
|
||||
*
|
||||
* @return uint16_t 0 : do not send command any more.
|
||||
* 1 : go to the next command.
|
||||
* n > 1 : skip (n - 1) commands.
|
||||
*/
|
||||
uint16_t esp_rom_spiflash_common_cmd(esp_rom_spiflash_common_cmd_t *cmd);
|
||||
|
||||
/**
|
||||
* @brief Unlock SPI write protect.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : Unlock OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : Unlock error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Unlock timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_unlock(void);
|
||||
|
||||
/**
|
||||
* @brief SPI write protect.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : Lock OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : Lock error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Lock timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_lock(void);
|
||||
|
||||
/**
|
||||
* @brief Update SPI Flash parameter.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint32_t deviceId : Device ID read from SPI, the low 32 bit.
|
||||
*
|
||||
* @param uint32_t chip_size : The Flash size.
|
||||
*
|
||||
* @param uint32_t block_size : The Flash block size.
|
||||
*
|
||||
* @param uint32_t sector_size : The Flash sector size.
|
||||
*
|
||||
* @param uint32_t page_size : The Flash page size.
|
||||
*
|
||||
* @param uint32_t status_mask : The Mask used when read status from Flash(use single CMD).
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : Update OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : Update error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Update timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_config_param(uint32_t deviceId, uint32_t chip_size, uint32_t block_size,
|
||||
uint32_t sector_size, uint32_t page_size, uint32_t status_mask);
|
||||
|
||||
/**
|
||||
* @brief Erase whole flash chip.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : Erase OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : Erase error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Erase timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_erase_chip(void);
|
||||
|
||||
/**
|
||||
* @brief Erase a 64KB block of flash
|
||||
* Uses SPI flash command D8H.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint32_t block_num : Which block to erase.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : Erase OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : Erase error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Erase timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_erase_block(uint32_t block_num);
|
||||
|
||||
/**
|
||||
* @brief Erase a sector of flash.
|
||||
* Uses SPI flash command 20H.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint32_t sector_num : Which sector to erase.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : Erase OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : Erase error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Erase timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_erase_sector(uint32_t sector_num);
|
||||
|
||||
/**
|
||||
* @brief Erase some sectors.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint32_t start_addr : Start addr to erase, should be sector aligned.
|
||||
*
|
||||
* @param uint32_t area_len : Length to erase, should be sector aligned.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : Erase OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : Erase error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Erase timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_erase_area(uint32_t start_addr, uint32_t area_len);
|
||||
|
||||
/**
|
||||
* @brief Write Data to Flash, you should Erase it yourself if need.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint32_t dest_addr : Address to write, should be 4 bytes aligned.
|
||||
*
|
||||
* @param const uint32_t *src : The pointer to data which is to write.
|
||||
*
|
||||
* @param uint32_t len : Length to write, should be 4 bytes aligned.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : Write OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : Write error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Write timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write(uint32_t dest_addr, const uint32_t *src, int32_t len);
|
||||
|
||||
/**
|
||||
* @brief Read Data from Flash, you should Erase it yourself if need.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint32_t src_addr : Address to read, should be 4 bytes aligned.
|
||||
*
|
||||
* @param uint32_t *dest : The buf to read the data.
|
||||
*
|
||||
* @param uint32_t len : Length to read, should be 4 bytes aligned.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : Read OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : Read error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Read timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_read(uint32_t src_addr, uint32_t *dest, int32_t len);
|
||||
|
||||
/**
|
||||
* @brief SPI1 go into encrypto mode.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void esp_rom_spiflash_write_encrypted_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Prepare 32 Bytes data to encrpto writing, you should Erase it yourself if need.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint32_t flash_addr : Address to write, should be 32 bytes aligned.
|
||||
*
|
||||
* @param uint32_t *data : The pointer to data which is to write.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : Prepare OK.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : Prepare error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Prepare timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_prepare_encrypted_data(uint32_t flash_addr, uint32_t *data);
|
||||
|
||||
/**
|
||||
* @brief SPI1 go out of encrypto mode.
|
||||
* Please do not call this function in SDK.
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void esp_rom_spiflash_write_encrypted_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Write data to flash with transparent encryption.
|
||||
* @note Sectors to be written should already be erased.
|
||||
*
|
||||
* @note Please do not call this function in SDK.
|
||||
*
|
||||
* @param uint32_t flash_addr : Address to write, should be 32 byte aligned.
|
||||
*
|
||||
* @param uint32_t *data : The pointer to data to write. Note, this pointer must
|
||||
* be 32 bit aligned and the content of the data will be
|
||||
* modified by the encryption function.
|
||||
*
|
||||
* @param uint32_t len : Length to write, should be 32 bytes aligned.
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : Data written successfully.
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : Encryption write error.
|
||||
* ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Encrypto write timeout.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write_encrypted(uint32_t flash_addr, uint32_t *data, uint32_t len);
|
||||
|
||||
|
||||
/* TODO: figure out how to map these to their new names */
|
||||
typedef enum {
|
||||
SPI_ENCRYPT_DESTINATION_FLASH,
|
||||
} SpiEncryptDest;
|
||||
|
||||
typedef esp_rom_spiflash_result_t SpiFlashOpResult;
|
||||
|
||||
SpiFlashOpResult SPI_Encrypt_Write(uint32_t flash_addr, const void *data, uint32_t len);
|
||||
SpiFlashOpResult SPI_Encrypt_Write_Dest(SpiEncryptDest dest, uint32_t flash_addr, const void *data, uint32_t len);
|
||||
void SPI_Write_Encrypt_Enable(void);
|
||||
void SPI_Write_Encrypt_Disable(void);
|
||||
|
||||
/** @brief Wait until SPI flash write operation is complete
|
||||
*
|
||||
* @note Please do not call this function in SDK.
|
||||
*
|
||||
* Reads the Write In Progress bit of the SPI flash status register,
|
||||
* repeats until this bit is zero (indicating write complete).
|
||||
*
|
||||
* @return ESP_ROM_SPIFLASH_RESULT_OK : Write is complete
|
||||
* ESP_ROM_SPIFLASH_RESULT_ERR : Error while reading status.
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_wait_idle(esp_rom_spiflash_chip_t *spi);
|
||||
|
||||
|
||||
/** @brief Enable Quad I/O pin functions
|
||||
*
|
||||
* @note Please do not call this function in SDK.
|
||||
*
|
||||
* Sets the HD & WP pin functions for Quad I/O modes, based on the
|
||||
* efuse SPI pin configuration.
|
||||
*
|
||||
* @param wp_gpio_num - Number of the WP pin to reconfigure for quad I/O.
|
||||
*
|
||||
* @param spiconfig - Pin configuration, as returned from ets_efuse_get_spiconfig().
|
||||
* - If this parameter is 0, default SPI pins are used and wp_gpio_num parameter is ignored.
|
||||
* - If this parameter is 1, default HSPI pins are used and wp_gpio_num parameter is ignored.
|
||||
* - For other values, this parameter encodes the HD pin number and also the CLK pin number. CLK pin selection is used
|
||||
* to determine if HSPI or SPI peripheral will be used (use HSPI if CLK pin is the HSPI clock pin, otherwise use SPI).
|
||||
* Both HD & WP pins are configured via GPIO matrix to map to the selected peripheral.
|
||||
*/
|
||||
void esp_rom_spiflash_select_qio_pins(uint8_t wp_gpio_num, uint32_t spiconfig);
|
||||
|
||||
|
||||
typedef void (* spi_flash_func_t)(void);
|
||||
typedef SpiFlashOpResult (* spi_flash_op_t)(void);
|
||||
typedef SpiFlashOpResult (* spi_flash_erase_t)(uint32_t);
|
||||
typedef SpiFlashOpResult (* spi_flash_rd_t)(uint32_t, uint32_t*, int);
|
||||
typedef SpiFlashOpResult (* spi_flash_wr_t)(uint32_t, const uint32_t*, int);
|
||||
typedef SpiFlashOpResult (* spi_flash_ewr_t)(uint32_t, const void*, uint32_t);
|
||||
typedef SpiFlashOpResult (* spi_flash_wren_t)(void*);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_op_t)(void);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_erase_t)(uint32_t);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_rd_t)(uint32_t, uint32_t*, int);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_wr_t)(uint32_t, const uint32_t*, int);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_ewr_t)(uint32_t, const void*, uint32_t);
|
||||
typedef esp_rom_spiflash_result_t (* spi_flash_wren_t)(void*);
|
||||
|
||||
typedef struct {
|
||||
uint8_t pp_addr_bit_len;
|
||||
uint8_t se_addr_bit_len;
|
||||
uint8_t be_addr_bit_len;
|
||||
uint8_t rd_addr_bit_len;
|
||||
uint32_t read_sub_len;
|
||||
uint32_t write_sub_len;
|
||||
spi_flash_op_t unlock;
|
||||
@@ -530,35 +98,6 @@ typedef struct {
|
||||
spi_flash_op_t wait_idle;
|
||||
} spiflash_legacy_funcs_t;
|
||||
|
||||
|
||||
extern const spiflash_legacy_funcs_t *rom_spiflash_legacy_funcs;
|
||||
|
||||
/** @brief Global ROM spiflash data, as used by legacy
|
||||
SPI flash functions
|
||||
*/
|
||||
typedef struct {
|
||||
esp_rom_spiflash_chip_t chip;
|
||||
uint8_t dummy_len_plus[3];
|
||||
uint8_t sig_matrix;
|
||||
} spiflash_legacy_data_t;
|
||||
|
||||
extern spiflash_legacy_data_t *rom_spiflash_legacy_data;
|
||||
|
||||
/* Defines to make the C3 ROM legacvy data access compatible with previous chips */
|
||||
#define g_rom_flashchip (rom_spiflash_legacy_data->chip)
|
||||
#define g_rom_spiflash_dummy_len_plus (rom_spiflash_legacy_data->dummy_len_plus)
|
||||
|
||||
/**
|
||||
* @brief Clear WEL bit unconditionally.
|
||||
*
|
||||
* @return always ESP_ROM_SPIFLASH_RESULT_OK
|
||||
*/
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write_disable(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -11,9 +11,24 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32H2
|
||||
#include "esp32h2/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP8684
|
||||
#include "esp32h2/rom/spi_flash.h"
|
||||
#endif
|
||||
|
||||
/** \defgroup spi_flash_apis, spi flash operation related apis
|
||||
* @brief spi_flash apis
|
||||
*/
|
||||
@@ -36,12 +51,6 @@ typedef enum {
|
||||
ESP_ROM_SPIFLASH_OIO_DTR_MODE,
|
||||
} esp_rom_spiflash_read_mode_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_ROM_SPIFLASH_RESULT_OK,
|
||||
ESP_ROM_SPIFLASH_RESULT_ERR,
|
||||
ESP_ROM_SPIFLASH_RESULT_TIMEOUT
|
||||
} esp_rom_spiflash_result_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t device_id;
|
||||
uint32_t chip_size; // chip size in bytes
|
||||
|
4
components/esp_rom/linker.lf
Normal file
4
components/esp_rom/linker.lf
Normal file
@@ -0,0 +1,4 @@
|
||||
[mapping:esp_rom]
|
||||
archive: libesp_rom.a
|
||||
entries:
|
||||
esp_rom_spiflash (noflash)
|
@@ -3,19 +3,20 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
#include "soc/spi_periph.h"
|
||||
#include "spi_flash_defs.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
|
||||
|
||||
#define SPI_IDX 1
|
||||
#define OTH_IDX 0
|
||||
|
||||
|
||||
extern esp_rom_spiflash_chip_t g_rom_spiflash_chip;
|
||||
|
||||
#if CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
static inline bool is_issi_chip(const esp_rom_spiflash_chip_t* chip)
|
||||
{
|
||||
return (((chip->device_id >> 16)&0xff) == 0x9D);
|
||||
@@ -24,18 +25,11 @@ static inline bool is_issi_chip(const esp_rom_spiflash_chip_t* chip)
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_wait_idle(esp_rom_spiflash_chip_t *spi)
|
||||
{
|
||||
uint32_t status;
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
//wait for spi control ready
|
||||
while ((REG_READ(SPI_EXT2_REG(1)) & SPI_ST)) {
|
||||
}
|
||||
while ((REG_READ(SPI_EXT2_REG(0)) & SPI_ST)) {
|
||||
}
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
while ((REG_READ(SPI_MEM_FSM_REG(1)) & SPI_MEM_ST)) {
|
||||
}
|
||||
while ((REG_READ(SPI_MEM_FSM_REG(0)) & SPI_MEM_ST)) {
|
||||
}
|
||||
#endif
|
||||
//wait for flash status ready
|
||||
if ( ESP_ROM_SPIFLASH_RESULT_OK != esp_rom_spiflash_read_status(spi, &status)) {
|
||||
return ESP_ROM_SPIFLASH_RESULT_ERR;
|
||||
@@ -43,7 +37,6 @@ esp_rom_spiflash_result_t esp_rom_spiflash_wait_idle(esp_rom_spiflash_chip_t *sp
|
||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
/* Modified version of esp_rom_spiflash_unlock() that replaces version in ROM.
|
||||
|
||||
This works around a bug where esp_rom_spiflash_unlock sometimes reads the wrong
|
||||
@@ -104,10 +97,6 @@ __attribute__((__unused__)) esp_rom_spiflash_result_t esp_rom_spiflash_unlock(vo
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
|
||||
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
|
||||
|
||||
static esp_rom_spiflash_result_t esp_rom_spiflash_enable_write(esp_rom_spiflash_chip_t *spi);
|
||||
|
||||
@@ -118,7 +107,8 @@ static esp_rom_spiflash_result_t esp_rom_spiflash_erase_chip_internal(esp_rom_sp
|
||||
|
||||
// Chip erase.
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_CMD, SPI_FLASH_CE);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0) {
|
||||
}
|
||||
|
||||
// check erase is finished.
|
||||
esp_rom_spiflash_wait_idle(spi);
|
||||
@@ -139,7 +129,8 @@ static esp_rom_spiflash_result_t esp_rom_spiflash_erase_sector_internal(esp_rom_
|
||||
// sector erase 4Kbytes erase is sector erase.
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_ADDR, addr & 0xffffff);
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_CMD, SPI_FLASH_SE);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0) {
|
||||
}
|
||||
|
||||
esp_rom_spiflash_wait_idle(spi);
|
||||
|
||||
@@ -154,7 +145,8 @@ static esp_rom_spiflash_result_t esp_rom_spiflash_erase_block_internal(esp_rom_s
|
||||
// sector erase 4Kbytes erase is sector erase.
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_ADDR, addr & 0xffffff);
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_CMD, SPI_FLASH_BE);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0) {
|
||||
}
|
||||
|
||||
esp_rom_spiflash_wait_idle(spi);
|
||||
|
||||
@@ -208,7 +200,8 @@ static esp_rom_spiflash_result_t esp_rom_spiflash_program_page_internal(esp_rom_
|
||||
temp_bl = 0;
|
||||
}
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_CMD, SPI_FLASH_PP);
|
||||
while ( READ_PERI_REG(PERIPHS_SPI_FLASH_CMD ) != 0 );
|
||||
while ( READ_PERI_REG(PERIPHS_SPI_FLASH_CMD ) != 0 ) {
|
||||
}
|
||||
|
||||
esp_rom_spiflash_wait_idle(spi);
|
||||
}
|
||||
@@ -224,7 +217,8 @@ esp_rom_spiflash_result_t esp_rom_spiflash_read_status(esp_rom_spiflash_chip_t *
|
||||
while (ESP_ROM_SPIFLASH_BUSY_FLAG == (status_value & ESP_ROM_SPIFLASH_BUSY_FLAG)) {
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_STATUS, 0); // clear regisrter
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_CMD, SPI_FLASH_RDSR);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0) {
|
||||
}
|
||||
|
||||
status_value = READ_PERI_REG(PERIPHS_SPI_FLASH_STATUS) & (spi->status_mask);
|
||||
}
|
||||
@@ -254,7 +248,8 @@ esp_rom_spiflash_result_t esp_rom_spiflash_write_status(esp_rom_spiflash_chip_t
|
||||
// update status value by status_value
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_STATUS, status_value); // write status regisrter
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_CMD, SPI_FLASH_WRSR);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0) {
|
||||
}
|
||||
esp_rom_spiflash_wait_idle(spi);
|
||||
|
||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
||||
@@ -285,7 +280,8 @@ static esp_rom_spiflash_result_t esp_rom_spiflash_read_data(esp_rom_spiflash_chi
|
||||
REG_WRITE(SPI_MISO_DLEN_REG(1), ((ESP_ROM_SPIFLASH_BUFF_BYTE_READ_NUM << 3) - 1) << SPI_USR_MISO_DBITLEN_S);
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_ADDR, temp_addr << 8);
|
||||
REG_WRITE(PERIPHS_SPI_FLASH_CMD, SPI_USR);
|
||||
while (REG_READ(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
while (REG_READ(PERIPHS_SPI_FLASH_CMD) != 0) {
|
||||
}
|
||||
|
||||
for (i = 0; i < (ESP_ROM_SPIFLASH_BUFF_BYTE_READ_NUM >> 2); i++) {
|
||||
*addr_dest++ = READ_PERI_REG(PERIPHS_SPI_FLASH_C0 + i * 4);
|
||||
@@ -297,7 +293,8 @@ static esp_rom_spiflash_result_t esp_rom_spiflash_read_data(esp_rom_spiflash_chi
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_ADDR, temp_addr << 8);
|
||||
REG_WRITE(SPI_MISO_DLEN_REG(1), ((ESP_ROM_SPIFLASH_BUFF_BYTE_READ_NUM << 3) - 1) << SPI_USR_MISO_DBITLEN_S);
|
||||
REG_WRITE(PERIPHS_SPI_FLASH_CMD, SPI_USR);
|
||||
while (REG_READ(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
while (REG_READ(PERIPHS_SPI_FLASH_CMD) != 0) {
|
||||
};
|
||||
|
||||
remain_word_num = (0 == (temp_length & 0x3)) ? (temp_length >> 2) : (temp_length >> 2) + 1;
|
||||
for (i = 0; i < remain_word_num; i++) {
|
||||
@@ -318,7 +315,8 @@ static esp_rom_spiflash_result_t esp_rom_spiflash_enable_write(esp_rom_spiflash_
|
||||
|
||||
//enable write
|
||||
WRITE_PERI_REG(PERIPHS_SPI_FLASH_CMD, SPI_FLASH_WREN); // enable write operation
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0) {
|
||||
}
|
||||
|
||||
// make sure the flash is ready for writing
|
||||
while (ESP_ROM_SPIFLASH_WRENABLE_FLAG != (flash_status & ESP_ROM_SPIFLASH_WRENABLE_FLAG)) {
|
||||
@@ -476,8 +474,9 @@ esp_rom_spiflash_result_t esp_rom_spiflash_erase_sector(uint32_t sector_num)
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write(uint32_t target, const uint32_t *src_addr, int32_t len)
|
||||
{
|
||||
uint32_t page_size;
|
||||
uint32_t pgm_len, pgm_num;
|
||||
uint8_t i;
|
||||
uint32_t pgm_len;
|
||||
uint32_t pgm_num;
|
||||
uint32_t i;
|
||||
|
||||
// flash write is always 1 line currently
|
||||
REG_CLR_BIT(PERIPHS_SPI_FLASH_USRREG, SPI_USR_DUMMY);
|
||||
@@ -679,8 +678,21 @@ esp_rom_spiflash_result_t esp_rom_spiflash_erase_area(uint32_t start_addr, uint3
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write_disable(void)
|
||||
{
|
||||
REG_WRITE(SPI_CMD_REG(SPI_IDX), SPI_FLASH_WRDI);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0) {
|
||||
}
|
||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write_disable(void)
|
||||
{
|
||||
REG_WRITE(SPI_MEM_CMD_REG(SPI_IDX), SPI_MEM_FLASH_WRDI);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0) {
|
||||
}
|
||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
||||
}
|
||||
|
||||
#endif // IDF_TARGET
|
||||
|
||||
#endif // CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
|
@@ -86,8 +86,6 @@
|
||||
|
||||
#if CONFIG_APP_BUILD_TYPE_ELF_RAM
|
||||
#include "esp_rom_spiflash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP8684
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
#endif // CONFIG_APP_BUILD_TYPE_ELF_RAM
|
||||
|
||||
// Set efuse ROM_LOG_MODE on first boot
|
||||
|
@@ -1,6 +1,5 @@
|
||||
idf_build_get_property(target IDF_TARGET)
|
||||
if(BOOTLOADER_BUILD)
|
||||
set(srcs "${target}/spi_flash_rom_patch.c")
|
||||
set(cache_srcs "")
|
||||
set(priv_requires bootloader_support soc)
|
||||
else()
|
||||
@@ -12,7 +11,6 @@ else()
|
||||
)
|
||||
set(srcs
|
||||
"partition.c"
|
||||
"${target}/spi_flash_rom_patch.c"
|
||||
)
|
||||
|
||||
if(CONFIG_ESPTOOLPY_OCT_FLASH)
|
||||
|
@@ -32,7 +32,6 @@
|
||||
#include "soc/extmem_reg.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP8684
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
#include "esp8684/rom/cache.h"
|
||||
#include "soc/extmem_reg.h"
|
||||
#include "soc/cache_memory.h"
|
||||
|
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "esp_spi_flash.h"
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "esp32/rom/cache.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
|
||||
|
@@ -10,7 +10,6 @@
|
||||
#include "esp_spi_flash.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#include "esp32c3/rom/cache.h"
|
||||
#include "hal/spi_flash_hal.h"
|
||||
#include "esp_flash.h"
|
||||
|
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#include "soc/spi_periph.h"
|
||||
#include "spi_flash_defs.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
|
||||
#define SPI_IDX 1
|
||||
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write_disable(void)
|
||||
{
|
||||
REG_WRITE(SPI_MEM_CMD_REG(SPI_IDX), SPI_MEM_FLASH_WRDI);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
||||
}
|
@@ -10,7 +10,6 @@
|
||||
#include "esp_spi_flash.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "esp32h2/rom/spi_flash.h"
|
||||
#include "esp32h2/rom/cache.h"
|
||||
#include "hal/spi_flash_hal.h"
|
||||
#include "esp_flash.h"
|
||||
|
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#include "esp32h2/rom/spi_flash.h"
|
||||
#include "soc/spi_periph.h"
|
||||
#include "spi_flash_defs.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
|
||||
#define SPI_IDX 1
|
||||
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write_disable(void)
|
||||
{
|
||||
REG_WRITE(SPI_MEM_CMD_REG(SPI_IDX), SPI_MEM_FLASH_WRDI);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
||||
}
|
@@ -10,7 +10,6 @@
|
||||
#include "esp_spi_flash.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#include "esp32s2/rom/cache.h"
|
||||
#include "bootloader_flash.h"
|
||||
#include "hal/spi_flash_hal.h"
|
||||
|
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#include "soc/spi_periph.h"
|
||||
#include "spi_flash_defs.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
|
||||
|
||||
#define SPI_IDX 1
|
||||
extern esp_rom_spiflash_chip_t g_rom_spiflash_chip;
|
||||
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write_disable(void)
|
||||
{
|
||||
REG_WRITE(SPI_MEM_CMD_REG(SPI_IDX), SPI_MEM_FLASH_WRDI);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
||||
}
|
@@ -10,7 +10,6 @@
|
||||
#include "esp_spi_flash.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#include "bootloader_flash.h"
|
||||
#include "hal/spi_flash_hal.h"
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include "esp_err.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "esp32s3/rom/gpio.h"
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
#include "esp32s3/rom/opi_flash.h"
|
||||
#include "esp_private/spi_flash_os.h"
|
||||
|
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
// We keep this file here only for future use
|
@@ -7,7 +7,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
#include "esp32s3/rom/opi_flash.h"
|
||||
#include "mspi_timing_tuning_configs.h"
|
||||
|
@@ -10,14 +10,14 @@
|
||||
#include "esp_spi_flash.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
#include "esp8684/rom/cache.h"
|
||||
#include "hal/spi_flash_hal.h"
|
||||
#include "esp_flash.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
|
||||
static const char *TAG = "spiflash_c3";
|
||||
static const char *TAG = "spiflash_8684";
|
||||
|
||||
#define SPICACHE SPIMEM0
|
||||
#define SPIFLASH SPIMEM1
|
||||
|
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
#include "soc/spi_periph.h"
|
||||
#include "spi_flash_defs.h"
|
||||
|
||||
#define SPI_IDX 1
|
||||
|
||||
esp_rom_spiflash_result_t esp_rom_spiflash_write_disable(void)
|
||||
{
|
||||
REG_WRITE(SPI_MEM_CMD_REG(SPI_IDX), SPI_MEM_FLASH_WRDI);
|
||||
while (READ_PERI_REG(PERIPHS_SPI_FLASH_CMD) != 0);
|
||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
||||
}
|
@@ -20,8 +20,6 @@
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp_crypto_lock.h" // for locking flash encryption peripheral
|
||||
#endif //CONFIG_IDF_TARGET_ESP32S2
|
||||
#elif CONFIG_IDF_TARGET_ESP8684
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
|
||||
static const char TAG[] = "spi_flash";
|
||||
|
||||
|
@@ -21,7 +21,6 @@
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "esp_private/spi_flash_os.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
#include "esp32c3/rom/efuse.h"
|
||||
|
||||
__attribute__((unused)) static const char TAG[] = "spi_flash";
|
||||
|
||||
|
@@ -52,7 +52,6 @@
|
||||
#include "soc/mmu.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP8684
|
||||
#include "esp8684/rom/cache.h"
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#include "soc/mmu.h"
|
||||
#endif
|
||||
|
@@ -24,7 +24,6 @@
|
||||
#include "esp_private/esp_clk.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/cache.h"
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/cache.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
@@ -38,7 +37,6 @@
|
||||
#include "esp32h2/rom/cache.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP8684
|
||||
#include "esp8684/rom/cache.h"
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
#endif
|
||||
#include "esp_rom_spiflash.h"
|
||||
#include "esp_flash_partitions.h"
|
||||
|
@@ -1,7 +1,6 @@
|
||||
[mapping:spi_flash]
|
||||
archive: libspi_flash.a
|
||||
entries:
|
||||
spi_flash_rom_patch (noflash)
|
||||
spi_flash_chip_generic (noflash)
|
||||
spi_flash_chip_issi (noflash)
|
||||
spi_flash_chip_mxic (noflash)
|
||||
|
@@ -2,7 +2,6 @@
|
||||
#include "esp_partition.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
|
||||
bool spi_flash_check_and_flush_cache(size_t start_addr, size_t length)
|
||||
|
@@ -18,10 +18,6 @@
|
||||
#include "../cache_utils.h"
|
||||
#include "soc/timer_periph.h"
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#endif
|
||||
#include "esp_rom_spiflash.h"
|
||||
|
||||
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP8684)
|
||||
|
@@ -22,8 +22,6 @@
|
||||
#include "esp_vfs.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_rom_spiflash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP8684
|
||||
#include "esp8684/rom/spi_flash.h"
|
||||
|
||||
#include "spiffs_api.h"
|
||||
|
||||
|
Reference in New Issue
Block a user