mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +08:00
arch/xtensa: update SPI Flash driver for ESP32-S2|S3
Updates the SPI Flash driver used for user storage MTD. Moves ESP32 and ESP32S3 to use common driver. Updates KConfig options to keep backwards compatibility. Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
This commit is contained in:
committed by
Matteo Golin
parent
4ccae59e69
commit
680766d304
@@ -33,7 +33,7 @@ config ESP32S3_SPEED_UP_ISR
|
||||
config ESP32S3_STORAGE_MTD_OFFSET
|
||||
hex "Storage MTD base address in SPI Flash"
|
||||
default 0x180000 if !ESP32S3_HAVE_OTA_PARTITION
|
||||
default 0x250000 if ESP32S3_HAVE_OTA_PARTITION
|
||||
default 0x260000 if ESP32S3_HAVE_OTA_PARTITION
|
||||
depends on ESP32S3_MTD
|
||||
---help---
|
||||
MTD base address in SPI Flash.
|
||||
|
||||
@@ -296,6 +296,20 @@ SECTIONS
|
||||
*libarch.a:*spi_flash_wrap.*(.text .text.* .literal .literal.*)
|
||||
*libarch.a:*spi_flash_oct_flash_init.*(.text .text.* .literal .literal.*)
|
||||
*libarch.a:*spi_flash_hpm_enable.*(.text .text.* .literal .literal.*)
|
||||
*libarch.a:esp_spiflash.*(.literal .text .literal.* .text.*)
|
||||
*libarch.a:esp_flash_api.*(.text .text.* .literal .literal.*)
|
||||
*libarch.a:esp_flash_spi_init.*(.text .text.* .literal .literal.*)
|
||||
*libarch.a:spi_flash_hal_iram.*(.literal .literal.* .text .text.*)
|
||||
*libarch.a:spi_flash_encrypt_hal_iram.*(.text .text.* .literal .literal.*)
|
||||
*libarch.a:spi_flash_hal_gpspi.*(.literal .literal.* .text .text.*)
|
||||
*libarch.a:spi_flash_chip*.*(.literal .literal.* .text .text.*)
|
||||
*libarch.a:spi_flash_wrap.*(.literal .literal.* .text .text.*)
|
||||
*libarch.a:spi_flash_os_func_noos.*(.literal .literal.* .text .text.*)
|
||||
*libarch.a:spi_flash_os_func_app.*(.literal .literal.* .text .text.*)
|
||||
*libarch.a:flash_brownout_hook.*(.literal .literal.* .text .text.*)
|
||||
*libarch.a:esp_cache.*(.literal .literal.* .text .text.*)
|
||||
*libarch.a:cache_utils.*(.literal .literal.* .text .text.*)
|
||||
*libarch.a:memspi_host_driver.*(.literal .literal.* .text .text.*)
|
||||
|
||||
*libc.a:*lib_instrument.*(.text .text.* .literal .literal.*)
|
||||
|
||||
@@ -433,6 +447,7 @@ SECTIONS
|
||||
*libsched.a:*sched_get_stackinfo.*(.rodata .rodata.*)
|
||||
*libarch.a:*esp_loader.*(.rodata .rodata.*)
|
||||
*libarch.a:esp32s3_spiflash.*(.rodata .rodata.*)
|
||||
*libarch.a:esp_spiflash.*(.rodata .rodata.*)
|
||||
*libarch.a:*brownout.*(.rodata .rodata.*)
|
||||
*libarch.a:*cpu.*(.rodata .rodata.*)
|
||||
*libarch.a:*gpio_hal.*(.rodata .rodata.*)
|
||||
@@ -495,6 +510,19 @@ SECTIONS
|
||||
*libarch.a:*spi_flash_wrap.*(.rodata .rodata.*)
|
||||
*libarch.a:*spi_flash_oct_flash_init.*(.rodata .rodata.*)
|
||||
*libarch.a:*spi_flash_hpm_enable.*(.rodata .rodata.*)
|
||||
*libarch.a:esp_flash_api.*(.rodata .rodata.*)
|
||||
*libarch.a:esp_flash_spi_init.*(.rodata .rodata.*)
|
||||
*libarch.a:spi_flash_hal_iram.*(.rodata .rodata.*)
|
||||
*libarch.a:spi_flash_encrypt_hal_iram.*(.rodata .rodata.*)
|
||||
*libarch.a:spi_flash_hal_gpspi.*(.rodata .rodata.*)
|
||||
*libarch.a:spi_flash_chip*.*(.rodata .rodata.*)
|
||||
*libarch.a:spi_flash_wrap.*(.rodata .rodata.*)
|
||||
*libarch.a:spi_flash_os_func_noos.*(.rodata .rodata.*)
|
||||
*libarch.a:spi_flash_os_func_app.*(.rodata .rodata.*)
|
||||
*libarch.a:flash_brownout_hook.*(.rodata .rodata.*)
|
||||
*libarch.a:esp_cache.*(.rodata .rodata.*)
|
||||
*libarch.a:cache_utils.*(.rodata .rodata.*)
|
||||
*libarch.a:memspi_host_driver.*(.rodata .rodata.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = ABSOLUTE(.);
|
||||
|
||||
@@ -43,8 +43,13 @@
|
||||
#include <nuttx/fs/nxffs.h>
|
||||
#include <nuttx/fs/partition.h>
|
||||
|
||||
#include "esp32s3_spiflash.h"
|
||||
#include "esp32s3_spiflash_mtd.h"
|
||||
#if defined(CONFIG_ESP32S3_SPIRAM) || defined(CONFIG_ESP32S3_PARTITION_TABLE)
|
||||
# include "esp32s3_spiflash.h"
|
||||
# include "esp32s3_spiflash_mtd.h"
|
||||
#else
|
||||
# include "espressif/esp_spiflash.h"
|
||||
# include "espressif/esp_spiflash_mtd.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@@ -123,8 +128,12 @@ static int init_ota_partitions(void)
|
||||
for (int i = 0; i < nitems(g_ota_partition_table); ++i)
|
||||
{
|
||||
const struct partition_s *part = &g_ota_partition_table[i];
|
||||
#if defined(CONFIG_ESP32S3_SPIRAM) || defined(CONFIG_ESP32S3_PARTITION_TABLE)
|
||||
mtd = esp32s3_spiflash_alloc_mtdpart(part->firstblock, part->blocksize,
|
||||
OTA_ENCRYPT);
|
||||
#else
|
||||
mtd = esp_spiflash_alloc_mtdpart(part->firstblock, part->blocksize);
|
||||
#endif
|
||||
|
||||
ret = register_mtddriver(part->name, mtd, 0755, NULL);
|
||||
if (ret < 0)
|
||||
@@ -358,9 +367,14 @@ static int init_storage_partition(void)
|
||||
int ret = OK;
|
||||
struct mtd_dev_s *mtd;
|
||||
|
||||
#if defined(CONFIG_ESP32S3_SPIRAM) || defined(CONFIG_ESP32S3_PARTITION_TABLE)
|
||||
mtd = esp32s3_spiflash_alloc_mtdpart(CONFIG_ESP32S3_STORAGE_MTD_OFFSET,
|
||||
CONFIG_ESP32S3_STORAGE_MTD_SIZE,
|
||||
false);
|
||||
OTA_ENCRYPT);
|
||||
#else
|
||||
mtd = esp_spiflash_alloc_mtdpart(CONFIG_ESP32S3_STORAGE_MTD_OFFSET,
|
||||
CONFIG_ESP32S3_STORAGE_MTD_SIZE);
|
||||
#endif
|
||||
if (!mtd)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to alloc MTD partition of SPI Flash\n");
|
||||
@@ -435,7 +449,11 @@ int board_spiflash_init(void)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
#if defined(CONFIG_ESP32S3_SPIRAM) || defined(CONFIG_ESP32S3_PARTITION_TABLE)
|
||||
ret = esp32s3_spiflash_init();
|
||||
#else
|
||||
ret = esp_spiflash_init();
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
|
||||
@@ -28,7 +28,6 @@ CONFIG_ESP32S3_UART0=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_HOST_MACOS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=3072
|
||||
@@ -44,6 +43,8 @@ CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_SMP_NCPUS=2
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
|
||||
Reference in New Issue
Block a user