boards/xtensa: fixes SPI Flash for MCUBoot usage
Fixes partitions for MCUBoot usage. Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
This commit is contained in:
parent
664277039e
commit
3f8cde728d
6 changed files with 410 additions and 81 deletions
|
|
@ -39,12 +39,10 @@
|
|||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/mtd/mtd.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/fs/partition.h>
|
||||
#ifdef CONFIG_ESP32_SPIFLASH_NXFFS
|
||||
#include <nuttx/fs/nxffs.h>
|
||||
#endif
|
||||
#ifdef CONFIG_BCH
|
||||
#include <nuttx/drivers/drivers.h>
|
||||
#endif
|
||||
|
||||
#include "esp32_spiflash.h"
|
||||
#include "esp32_board_spiflash.h"
|
||||
|
|
@ -69,15 +67,6 @@
|
|||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32_HAVE_OTA_PARTITION
|
||||
struct ota_partition_s
|
||||
{
|
||||
uint32_t offset; /* Partition offset from the beginning of MTD */
|
||||
uint32_t size; /* Partition size in bytes */
|
||||
const char *devpath; /* Partition device path */
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
|
@ -91,22 +80,25 @@ static int init_ota_partitions(void);
|
|||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32_HAVE_OTA_PARTITION
|
||||
static const struct ota_partition_s g_ota_partition_table[] =
|
||||
static const struct partition_s g_ota_partition_table[] =
|
||||
{
|
||||
{
|
||||
.offset = CONFIG_ESP32_OTA_PRIMARY_SLOT_OFFSET,
|
||||
.size = CONFIG_ESP32_OTA_SLOT_SIZE,
|
||||
.devpath = CONFIG_ESP32_OTA_PRIMARY_SLOT_DEVPATH
|
||||
.name = CONFIG_ESP32_OTA_PRIMARY_SLOT_DEVPATH,
|
||||
.index = 0,
|
||||
.firstblock = CONFIG_ESP32_OTA_PRIMARY_SLOT_OFFSET,
|
||||
.blocksize = CONFIG_ESP32_OTA_SLOT_SIZE,
|
||||
},
|
||||
{
|
||||
.offset = CONFIG_ESP32_OTA_SECONDARY_SLOT_OFFSET,
|
||||
.size = CONFIG_ESP32_OTA_SLOT_SIZE,
|
||||
.devpath = CONFIG_ESP32_OTA_SECONDARY_SLOT_DEVPATH
|
||||
.name = CONFIG_ESP32_OTA_SECONDARY_SLOT_DEVPATH,
|
||||
.index = 1,
|
||||
.firstblock = CONFIG_ESP32_OTA_SECONDARY_SLOT_OFFSET,
|
||||
.blocksize = CONFIG_ESP32_OTA_SLOT_SIZE,
|
||||
},
|
||||
{
|
||||
.offset = CONFIG_ESP32_OTA_SCRATCH_OFFSET,
|
||||
.size = CONFIG_ESP32_OTA_SCRATCH_SIZE,
|
||||
.devpath = CONFIG_ESP32_OTA_SCRATCH_DEVPATH
|
||||
.name = CONFIG_ESP32_OTA_SCRATCH_DEVPATH,
|
||||
.index = 2,
|
||||
.firstblock = CONFIG_ESP32_OTA_SCRATCH_OFFSET,
|
||||
.blocksize = CONFIG_ESP32_OTA_SCRATCH_SIZE,
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
|
@ -123,15 +115,15 @@ static int init_ota_partitions(void)
|
|||
|
||||
for (int i = 0; i < nitems(g_ota_partition_table); ++i)
|
||||
{
|
||||
const struct ota_partition_s *part = &g_ota_partition_table[i];
|
||||
mtd = esp32_spiflash_alloc_mtdpart(part->offset, part->size,
|
||||
const struct partition_s *part = &g_ota_partition_table[i];
|
||||
mtd = esp32_spiflash_alloc_mtdpart(part->firstblock, part->blocksize,
|
||||
OTA_ENCRYPT);
|
||||
|
||||
ret = register_mtddriver(part->devpath, mtd, 0755, NULL);
|
||||
ret = register_mtddriver(part->name, mtd, 0755, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "register_mtddriver %s failed: %d\n",
|
||||
part->devpath, ret);
|
||||
part->name, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
@ -406,8 +398,6 @@ static int init_storage_partition(void)
|
|||
}
|
||||
|
||||
#else
|
||||
int minor;
|
||||
char path[32];
|
||||
|
||||
ret = register_mtddriver("/dev/esp32flash", mtd, 0755, NULL);
|
||||
if (ret < 0)
|
||||
|
|
@ -416,19 +406,6 @@ static int init_storage_partition(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ESP32_HAVE_OTA_PARTITION
|
||||
minor = nitems(g_ota_partition_table);
|
||||
#else
|
||||
minor = 0;
|
||||
#endif
|
||||
snprintf(path, sizeof(path), "/dev/mtdblock%d", minor);
|
||||
ret = register_mtddriver(path, mtd, 0755, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to register the MTD driver %s, \
|
||||
ret %d\n", path, ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
# CONFIG_ARCH_LEDS is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ALLOW_BSD_COMPONENTS=y
|
||||
CONFIG_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32-devkitc"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
|
|
@ -15,23 +16,23 @@ CONFIG_ARCH_BOARD_ESP32_DEVKITC=y
|
|||
CONFIG_ARCH_CHIP="esp32"
|
||||
CONFIG_ARCH_CHIP_ESP32=y
|
||||
CONFIG_ARCH_CHIP_ESP32WROVER=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_ASSERTIONS=y
|
||||
CONFIG_DEBUG_FEATURES=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEFAULT_TASK_STACKSIZE=4096
|
||||
CONFIG_DEV_URANDOM=y
|
||||
CONFIG_DRIVERS_IEEE80211=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_ESP32_APP_FORMAT_MCUBOOT=y
|
||||
CONFIG_ESP32_SPIFLASH=y
|
||||
CONFIG_ESP32_SPIFLASH_SPIFFS=y
|
||||
CONFIG_ESP32_UART0=y
|
||||
CONFIG_ESPRESSIF_WIFI=y
|
||||
CONFIG_EXAMPLES_MCUBOOT_SLOT_CONFIRM=y
|
||||
CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT=y
|
||||
CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_BUFFER_SIZE=4096
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
|
|
@ -39,24 +40,34 @@ CONFIG_IDLETHREAD_STACKSIZE=3072
|
|||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LINE_MAX=300
|
||||
CONFIG_MM_REGIONS=3
|
||||
CONFIG_LINE_MAX=64
|
||||
CONFIG_MM_REGIONS=4
|
||||
CONFIG_NAME_MAX=48
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDB_DNSCLIENT_NAMESIZE=64
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NETDEV_WIRELESS_IOCTL=y
|
||||
CONFIG_NETUTILS_CJSON=y
|
||||
CONFIG_NETUTILS_IPERF=y
|
||||
CONFIG_NETUTILS_TELNETD=y
|
||||
CONFIG_NETUTILS_WEBCLIENT=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_ETH_PKTSIZE=1518
|
||||
CONFIG_NET_ICMP_SOCKET=y
|
||||
CONFIG_NET_PREALLOC_DEVIF_CALLBACKS=32
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCP_DELAYED_ACK=y
|
||||
CONFIG_NET_TCP_WRITE_BUFFERS=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_MOTD=y
|
||||
CONFIG_NSH_MOTD_STRING="Welcome to MCUboot support on NuttX!"
|
||||
CONFIG_NSH_MOTD_STRING="This is MCUBoot Update Agent image"
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=2048
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||
CONFIG_RAM_SIZE=114688
|
||||
|
|
@ -65,6 +76,10 @@ CONFIG_RR_INTERVAL=200
|
|||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SIG_DEFAULT=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_SMP_NCPUS=2
|
||||
CONFIG_SPI=y
|
||||
CONFIG_SPIFFS_NAME_MAX=48
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
|
|
@ -77,4 +92,4 @@ CONFIG_UART0_SERIAL_CONSOLE=y
|
|||
CONFIG_WIRELESS=y
|
||||
CONFIG_WIRELESS_WAPI=y
|
||||
CONFIG_WIRELESS_WAPI_CMDTOOL=y
|
||||
CONFIG_WIRELESS_WAPI_STACKSIZE=4096
|
||||
CONFIG_WIRELESS_WAPI_INITCONF=y
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "inttypes.h"
|
||||
#include <stdbool.h>
|
||||
|
|
@ -40,9 +41,7 @@
|
|||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/mtd/mtd.h>
|
||||
#include <nuttx/fs/nxffs.h>
|
||||
#ifdef CONFIG_BCH
|
||||
#include <nuttx/drivers/drivers.h>
|
||||
#endif
|
||||
#include <nuttx/fs/partition.h>
|
||||
|
||||
#include "espressif/esp_spiflash.h"
|
||||
#include "espressif/esp_spiflash_mtd.h"
|
||||
|
|
@ -60,10 +59,88 @@
|
|||
# define CONFIG_ESP32S2_STORAGE_MTD_SIZE 0x100000
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_HAVE_OTA_PARTITION
|
||||
static int init_ota_partitions(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_HAVE_OTA_PARTITION
|
||||
static const struct partition_s g_ota_partition_table[] =
|
||||
{
|
||||
{
|
||||
.name = CONFIG_ESPRESSIF_OTA_PRIMARY_SLOT_DEVPATH,
|
||||
.index = 0,
|
||||
.firstblock = CONFIG_ESPRESSIF_OTA_PRIMARY_SLOT_OFFSET,
|
||||
.blocksize = CONFIG_ESPRESSIF_OTA_SLOT_SIZE,
|
||||
},
|
||||
{
|
||||
.name = CONFIG_ESPRESSIF_OTA_SECONDARY_SLOT_DEVPATH,
|
||||
.index = 1,
|
||||
.firstblock = CONFIG_ESPRESSIF_OTA_SECONDARY_SLOT_OFFSET,
|
||||
.blocksize = CONFIG_ESPRESSIF_OTA_SLOT_SIZE,
|
||||
},
|
||||
{
|
||||
.name = CONFIG_ESPRESSIF_OTA_SCRATCH_DEVPATH,
|
||||
.index = 2,
|
||||
.firstblock = CONFIG_ESPRESSIF_OTA_SCRATCH_OFFSET,
|
||||
.blocksize = CONFIG_ESPRESSIF_OTA_SCRATCH_SIZE,
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: init_ota_partitions
|
||||
*
|
||||
* Description:
|
||||
* Initialize partitions that are dedicated to firmware OTA update.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_HAVE_OTA_PARTITION
|
||||
static int init_ota_partitions(void)
|
||||
{
|
||||
struct mtd_dev_s *mtd;
|
||||
int ret = OK;
|
||||
|
||||
for (int i = 0; i < nitems(g_ota_partition_table); ++i)
|
||||
{
|
||||
const struct partition_s *part = &g_ota_partition_table[i];
|
||||
mtd = esp_spiflash_alloc_mtdpart(part->firstblock, part->blocksize);
|
||||
|
||||
ret = register_mtddriver(part->name, mtd, 0755, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: register_mtddriver %s failed: %d\n",
|
||||
part->name, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: setup_smartfs
|
||||
*
|
||||
|
|
@ -339,12 +416,6 @@ static int init_storage_partition(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = register_mtddriver("/dev/mtdblock0", mtd, 0755, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to register MTD mtdblock0: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
|
@ -372,6 +443,14 @@ int board_spiflash_init(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_HAVE_OTA_PARTITION
|
||||
ret = init_ota_partitions();
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = init_storage_partition();
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_LEDS is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ALLOW_BSD_COMPONENTS=y
|
||||
CONFIG_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32s2-saola-1"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32S2_SAOLA_1=y
|
||||
CONFIG_ARCH_CHIP="esp32s2"
|
||||
CONFIG_ARCH_CHIP_ESP32S2=y
|
||||
CONFIG_ARCH_CHIP_ESP32S2WROVER=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEFAULT_TASK_STACKSIZE=4096
|
||||
CONFIG_DRIVERS_IEEE80211=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_ESP32S2_APP_FORMAT_MCUBOOT=y
|
||||
CONFIG_ESP32S2_RT_TIMER_TASK_STACK_SIZE=4096
|
||||
CONFIG_ESP32S2_UART0=y
|
||||
CONFIG_ESPRESSIF_SPIFLASH=y
|
||||
CONFIG_ESPRESSIF_WIFI=y
|
||||
CONFIG_EXAMPLES_MCUBOOT_SLOT_CONFIRM=y
|
||||
CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_IOB_NBUFFERS=124
|
||||
CONFIG_IOB_THROTTLE=24
|
||||
CONFIG_LINE_MAX=64
|
||||
CONFIG_NAME_MAX=48
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NETDEV_WIRELESS_IOCTL=y
|
||||
CONFIG_NETUTILS_CJSON=y
|
||||
CONFIG_NETUTILS_IPERF=y
|
||||
CONFIG_NETUTILS_WEBCLIENT=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_ETH_PKTSIZE=1514
|
||||
CONFIG_NET_ICMP_SOCKET=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCP_DELAYED_ACK=y
|
||||
CONFIG_NET_TCP_WRITE_BUFFERS=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_UDP_WRITE_BUFFERS=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_MOTD=y
|
||||
CONFIG_NSH_MOTD_STRING="This is MCUBoot Update Agent image"
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=2048
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SIG_DEFAULT=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSLOG_BUFFER=y
|
||||
CONFIG_SYSTEM_DHCPC_RENEW=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_TIMER=y
|
||||
CONFIG_TLS_TASK_NELEM=4
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_WIRELESS=y
|
||||
CONFIG_WIRELESS_WAPI=y
|
||||
CONFIG_WIRELESS_WAPI_CMDTOOL=y
|
||||
CONFIG_WIRELESS_WAPI_INITCONF=y
|
||||
CONFIG_WIRELESS_WAPI_STACKSIZE=8192
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "inttypes.h"
|
||||
#include <stdbool.h>
|
||||
|
|
@ -40,12 +41,7 @@
|
|||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/mtd/mtd.h>
|
||||
#include <nuttx/fs/nxffs.h>
|
||||
#ifdef CONFIG_MTD_PARTITION
|
||||
#include <nuttx/fs/partition.h>
|
||||
#endif
|
||||
#ifdef CONFIG_BCH
|
||||
#include <nuttx/drivers/drivers.h>
|
||||
#endif
|
||||
|
||||
#include "esp32s3_spiflash.h"
|
||||
#include "esp32s3_spiflash_mtd.h"
|
||||
|
|
@ -54,10 +50,95 @@
|
|||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32S3_OTA_PARTITION_ENCRYPT
|
||||
# define OTA_ENCRYPT true
|
||||
#else
|
||||
# define OTA_ENCRYPT false
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32S3_HAVE_OTA_PARTITION
|
||||
static int init_ota_partitions(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32S3_HAVE_OTA_PARTITION
|
||||
static const struct partition_s g_ota_partition_table[] =
|
||||
{
|
||||
{
|
||||
.name = CONFIG_ESP32S3_OTA_PRIMARY_SLOT_DEVPATH,
|
||||
.index = 0,
|
||||
.firstblock = CONFIG_ESP32S3_OTA_PRIMARY_SLOT_OFFSET,
|
||||
.blocksize = CONFIG_ESP32S3_OTA_SLOT_SIZE,
|
||||
},
|
||||
{
|
||||
.name = CONFIG_ESP32S3_OTA_SECONDARY_SLOT_DEVPATH,
|
||||
.index = 1,
|
||||
.firstblock = CONFIG_ESP32S3_OTA_SECONDARY_SLOT_OFFSET,
|
||||
.blocksize = CONFIG_ESP32S3_OTA_SLOT_SIZE,
|
||||
},
|
||||
{
|
||||
.name = CONFIG_ESP32S3_OTA_SCRATCH_DEVPATH,
|
||||
.index = 2,
|
||||
.firstblock = CONFIG_ESP32S3_OTA_SCRATCH_OFFSET,
|
||||
.blocksize = CONFIG_ESP32S3_OTA_SCRATCH_SIZE,
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: init_ota_partitions
|
||||
*
|
||||
* Description:
|
||||
* Initialize partitions that are dedicated to firmware OTA update.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32S3_HAVE_OTA_PARTITION
|
||||
static int init_ota_partitions(void)
|
||||
{
|
||||
struct mtd_dev_s *mtd;
|
||||
int ret = OK;
|
||||
|
||||
for (int i = 0; i < nitems(g_ota_partition_table); ++i)
|
||||
{
|
||||
const struct partition_s *part = &g_ota_partition_table[i];
|
||||
mtd = esp32s3_spiflash_alloc_mtdpart(part->firstblock, part->blocksize,
|
||||
OTA_ENCRYPT);
|
||||
|
||||
ret = register_mtddriver(part->name, mtd, 0755, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: register_mtddriver %s failed: %d\n",
|
||||
part->name, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: setup_smartfs
|
||||
*
|
||||
|
|
@ -334,22 +415,6 @@ static int init_storage_partition(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = register_mtddriver("/dev/mtdblock0", mtd, 0755, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to register MTD mtdblock0: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MTD_PARTITION
|
||||
ret = parse_mtd_partition(mtd, NULL, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to parse MTD partition: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_MTD_PARTITION */
|
||||
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
|
@ -377,6 +442,14 @@ int board_spiflash_init(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ESP32S3_HAVE_OTA_PARTITION
|
||||
ret = init_ota_partitions();
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = init_storage_partition();
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
@ -385,4 +458,3 @@ int board_spiflash_init(void)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,97 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_LEDS is not set
|
||||
# CONFIG_NDEBUG is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ALLOW_BSD_COMPONENTS=y
|
||||
CONFIG_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32s3-devkit"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32S3_DEVKIT=y
|
||||
CONFIG_ARCH_CHIP="esp32s3"
|
||||
CONFIG_ARCH_CHIP_ESP32S3=y
|
||||
CONFIG_ARCH_CHIP_ESP32S3WROOM1N4=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEFAULT_TASK_STACKSIZE=4096
|
||||
CONFIG_DRIVERS_IEEE80211=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_ESP32S3_APP_FORMAT_MCUBOOT=y
|
||||
CONFIG_ESP32S3_RT_TIMER_TASK_STACK_SIZE=4096
|
||||
CONFIG_ESP32S3_SPIFLASH=y
|
||||
CONFIG_ESP32S3_SPIFLASH_SPIFFS=y
|
||||
CONFIG_ESP32S3_STORAGE_MTD_OFFSET=0x180000
|
||||
CONFIG_ESP32S3_UART0=y
|
||||
CONFIG_ESPRESSIF_WIFI=y
|
||||
CONFIG_EXAMPLES_MCUBOOT_SLOT_CONFIRM=y
|
||||
CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT=y
|
||||
CONFIG_EXAMPLES_RANDOM=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_IOB_NBUFFERS=124
|
||||
CONFIG_IOB_THROTTLE=24
|
||||
CONFIG_LINE_MAX=64
|
||||
CONFIG_NAME_MAX=48
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NETDEV_WIRELESS_IOCTL=y
|
||||
CONFIG_NETUTILS_CJSON=y
|
||||
CONFIG_NETUTILS_IPERF=y
|
||||
CONFIG_NETUTILS_WEBCLIENT=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_ETH_PKTSIZE=1514
|
||||
CONFIG_NET_ICMP_SOCKET=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCP_DELAYED_ACK=y
|
||||
CONFIG_NET_TCP_WRITE_BUFFERS=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_UDP_WRITE_BUFFERS=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_MOTD=y
|
||||
CONFIG_NSH_MOTD_STRING="This is MCUBoot Update Agent image"
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=2048
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SIG_DEFAULT=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_SMP_NCPUS=2
|
||||
CONFIG_SPIFFS_NAME_MAX=128
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSLOG_BUFFER=y
|
||||
CONFIG_SYSTEM_DHCPC_RENEW=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_TIMER=y
|
||||
CONFIG_TLS_TASK_NELEM=4
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_WIRELESS=y
|
||||
CONFIG_WIRELESS_WAPI=y
|
||||
CONFIG_WIRELESS_WAPI_CMDTOOL=y
|
||||
CONFIG_WIRELESS_WAPI_INITCONF=y
|
||||
CONFIG_WIRELESS_WAPI_STACKSIZE=8192
|
||||
Loading…
Add table
Reference in a new issue