esp32: Add SDCard support for S3, and a GENERIC_S3_SPIRAM board.

Also add support for GPIO 47 and 48 on S3 boards.
This commit is contained in:
Seon Rozenblum 2021-11-12 11:23:49 +11:00 committed by Damien George
parent f72b49756d
commit 1904833e0c
10 changed files with 100 additions and 6 deletions

View File

@ -2,12 +2,11 @@
#define MICROPY_HW_MCU_NAME "ESP32S3"
#define MICROPY_PY_BLUETOOTH (0)
#define MICROPY_HW_ENABLE_SDCARD (0)
#define MICROPY_PY_MACHINE_DAC (0)
#define MICROPY_HW_I2C0_SCL (9)
#define MICROPY_HW_I2C0_SDA (8)
#define MICROPY_HW_SPI1_MOSI (35) // SDO
#define MICROPY_HW_SPI1_MISO (37) // SDI
#define MICROPY_HW_SPI1_SCK (36)
#define MICROPY_HW_SPI1_MOSI (35)
#define MICROPY_HW_SPI1_MISO (36)
#define MICROPY_HW_SPI1_SCK (37)

View File

@ -0,0 +1,16 @@
{
"deploy": [
"../deploy.md"
],
"docs": "",
"features": [
"BLE",
"WiFi"
],
"images": [],
"mcu": "esp32s3",
"product": "Generic ESP32-S3 (SPIRAM)",
"thumbnail": "",
"url": "https://www.espressif.com/en/products/modules",
"vendor": "Espressif"
}

View File

@ -0,0 +1,12 @@
set(IDF_TARGET esp32s3)
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
boards/sdkconfig.usb
boards/sdkconfig.spiram_sx
boards/GENERIC_S3_SPIRAM/sdkconfig.board
)
if(NOT MICROPY_FROZEN_MANIFEST)
set(MICROPY_FROZEN_MANIFEST ${MICROPY_PORT_DIR}/boards/manifest.py)
endif()

View File

@ -0,0 +1,12 @@
#define MICROPY_HW_BOARD_NAME "ESP32S3 module (spiram)"
#define MICROPY_HW_MCU_NAME "ESP32S3"
#define MICROPY_PY_BLUETOOTH (0)
#define MICROPY_PY_MACHINE_DAC (0)
#define MICROPY_HW_I2C0_SCL (9)
#define MICROPY_HW_I2C0_SDA (8)
#define MICROPY_HW_SPI1_MOSI (35)
#define MICROPY_HW_SPI1_MISO (36)
#define MICROPY_HW_SPI1_SCK (37)

View File

@ -0,0 +1,12 @@
CONFIG_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
CONFIG_ESPTOOLPY_AFTER_NORESET=y
CONFIG_SPIRAM_MEMTEST=
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"

View File

@ -1,5 +1,7 @@
# MicroPython on ESP32-S2 and ESP32-PAD1_subscript_3, ESP IDF configuration with SPIRAM support
CONFIG_ESP32S2_SPIRAM_SUPPORT=y
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
CONFIG_SPIRAM_MODE_QUAD=y
CONFIG_SPIRAM_TYPE_AUTO=y
CONFIG_DEFAULT_PSRAM_CLK_IO=30
CONFIG_DEFAULT_PSRAM_CS_IO=26
@ -9,3 +11,5 @@ CONFIG_SPIRAM_BOOT_INIT=y
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
CONFIG_SPIRAM_USE_MEMMAP=y
CONFIG_SPIRAM_MEMTEST=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768

View File

@ -200,6 +200,13 @@ STATIC const machine_pin_obj_t machine_pin_obj[] = {
{{&machine_pin_type}, GPIO_NUM_46},
#endif
#if CONFIG_IDF_TARGET_ESP32S3 && MICROPY_HW_ESP32S3_EXTENDED_IO
{{&machine_pin_type}, GPIO_NUM_47},
{{&machine_pin_type}, GPIO_NUM_48},
#endif
};
// forward declaration
@ -631,6 +638,14 @@ STATIC const machine_pin_irq_obj_t machine_pin_irq_object[] = {
{{&machine_pin_irq_type}, GPIO_NUM_43},
{{&machine_pin_irq_type}, GPIO_NUM_44},
{{&machine_pin_irq_type}, GPIO_NUM_45},
{{&machine_pin_irq_type}, GPIO_NUM_46},
#endif
#if CONFIG_IDF_TARGET_ESP32S3 && MICROPY_HW_ESP32S3_EXTENDED_IO
{{&machine_pin_irq_type}, GPIO_NUM_47},
{{&machine_pin_irq_type}, GPIO_NUM_48},
#endif
};

View File

@ -188,7 +188,11 @@ STATIC mp_obj_t machine_sdcard_make_new(const mp_obj_type_t *type, size_t n_args
}
if (is_spi) {
#if CONFIG_IDF_TARGET_ESP32S3
self->host.slot = slot_num ? SPI3_HOST : SPI2_HOST;
#else
self->host.slot = slot_num ? HSPI_HOST : VSPI_HOST;
#endif
}
DEBUG_printf(" Calling host.init()");
@ -198,6 +202,20 @@ STATIC mp_obj_t machine_sdcard_make_new(const mp_obj_type_t *type, size_t n_args
if (is_spi) {
// SPI interface
#if CONFIG_IDF_TARGET_ESP32S3
STATIC const sdspi_slot_config_t slot_defaults[2] = {
{
.gpio_miso = GPIO_NUM_36,
.gpio_mosi = GPIO_NUM_35,
.gpio_sck = GPIO_NUM_37,
.gpio_cs = GPIO_NUM_34,
.gpio_cd = SDSPI_SLOT_NO_CD,
.gpio_wp = SDSPI_SLOT_NO_WP,
.dma_channel = 2
},
SDSPI_SLOT_CONFIG_DEFAULT()
};
#else
STATIC const sdspi_slot_config_t slot_defaults[2] = {
{
.gpio_miso = GPIO_NUM_19,
@ -210,6 +228,7 @@ STATIC mp_obj_t machine_sdcard_make_new(const mp_obj_type_t *type, size_t n_args
},
SDSPI_SLOT_CONFIG_DEFAULT()
};
#endif
DEBUG_printf(" Setting up SPI slot configuration");
sdspi_slot_config_t slot_config = slot_defaults[slot_num];

View File

@ -101,7 +101,7 @@ void mp_task(void *pvParameter) {
#if CONFIG_ESP32_SPIRAM_SUPPORT || CONFIG_SPIRAM_SUPPORT
// Try to use the entire external SPIRAM directly for the heap
size_t mp_task_heap_size;
void *mp_task_heap = (void *)0x3f800000;
void *mp_task_heap = (void *)SOC_EXTRAM_DATA_LOW;
switch (esp_spiram_get_chip_size()) {
case ESP_SPIRAM_SIZE_16MBITS:
mp_task_heap_size = 2 * 1024 * 1024;
@ -120,7 +120,7 @@ void mp_task(void *pvParameter) {
// Try to use the entire external SPIRAM directly for the heap
size_t mp_task_heap_size;
size_t esp_spiram_size = esp_spiram_get_size();
void *mp_task_heap = (void *)0x3ff80000 - esp_spiram_size;
void *mp_task_heap = (void *)SOC_EXTRAM_DATA_HIGH - esp_spiram_size;
if (esp_spiram_size > 0) {
mp_task_heap_size = esp_spiram_size;
} else {

View File

@ -315,6 +315,11 @@ typedef long mp_off_t;
// board specifics
#define MICROPY_PY_SYS_PLATFORM "esp32"
// ESP32-S3 extended IO for 47 & 48
#ifndef MICROPY_HW_ESP32S3_EXTENDED_IO
#define MICROPY_HW_ESP32S3_EXTENDED_IO (1)
#endif
#ifndef MICROPY_HW_ENABLE_MDNS_QUERIES
#define MICROPY_HW_ENABLE_MDNS_QUERIES (1)
#endif