Skip to content

Commit 68fd1aa

Browse files
committed
ports/esp32: Add modesp32s3.
Signed-off-by: fvstory <fv1016898007@qq.com>
1 parent 92c7532 commit 68fd1aa

File tree

10 files changed

+991
-0
lines changed

10 files changed

+991
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"deploy": [
3+
"../deploy_s3.md"
4+
],
5+
"docs": "",
6+
"features": [
7+
"BLE",
8+
"WiFi"
9+
],
10+
"images": [
11+
"generic_s3.jpg"
12+
],
13+
"mcu": "esp32s3",
14+
"product": "Generic ESP32-S3 (SPIRAM Octal)",
15+
"thumbnail": "",
16+
"url": "https://www.espressif.com/en/products/modules",
17+
"vendor": "Espressif"
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set(IDF_TARGET esp32s3)
2+
3+
set(SDKCONFIG_DEFAULTS
4+
boards/sdkconfig.base
5+
boards/sdkconfig.usb
6+
boards/sdkconfig.ble
7+
boards/sdkconfig.240mhz
8+
boards/sdkconfig.gram_oct
9+
boards/GENERIC_S3_SPIRAM_OCT/sdkconfig.board
10+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#define MICROPY_HW_BOARD_NAME "ESP32S3 module (gram octal)"
2+
#define MICROPY_HW_MCU_NAME "ESP32S3"
3+
4+
#define MICROPY_PY_MACHINE_DAC (0)
5+
6+
// Enable UART REPL for modules that have an external USB-UART and don't use native USB.
7+
#define MICROPY_HW_ENABLE_UART_REPL (1)
8+
9+
// Enable psram for LCD GRAM.
10+
#define MICROPY_ESP_ENABLE_PSRAM_GRAM (1)
11+
12+
#define MICROPY_HW_I2C0_SCL (9)
13+
#define MICROPY_HW_I2C0_SDA (8)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
2+
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
3+
CONFIG_ESPTOOLPY_AFTER_NORESET=y
4+
5+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
6+
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=
7+
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=Y
8+
CONFIG_PARTITION_TABLE_CUSTOM=y
9+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-16MiB.csv"

ports/esp32/boards/sdkconfig.gram_oct

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# MicroPython on ESP32-S2 and ESP32-PAD1_subscript_3, ESP IDF configuration with SPIRAM support in Octal mode
2+
CONFIG_SPIRAM_MODE_QUAD=y
3+
CONFIG_SPIRAM_TYPE_AUTO=y
4+
CONFIG_SPIRAM_CLK_IO=30
5+
CONFIG_SPIRAM_CS_IO=26
6+
# In espidf5.1 the speed can be up to 120M, TODO
7+
CONFIG_SPIRAM_SPEED_80M=y
8+
CONFIG_SPIRAM=y
9+
CONFIG_SPIRAM_BOOT_INIT=y
10+
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
11+
CONFIG_SPIRAM_USE_CAPS_ALLOC=y
12+
CONFIG_SPIRAM_MODE_QUAD=
13+
CONFIG_SPIRAM_MODE_OCT=y

ports/esp32/main.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "esp_event.h"
3939
#include "esp_log.h"
4040
#include "esp_psram.h"
41+
#include "esp_heap_caps.h"
4142

4243
#include "py/stackctrl.h"
4344
#include "py/nlr.h"
@@ -64,6 +65,10 @@
6465
#include "modespnow.h"
6566
#endif
6667

68+
#if MICROPY_ESP32S3_LCDCAM
69+
#include "modesp32s3.h"
70+
#endif
71+
6772
// MicroPython runs as a task under FreeRTOS
6873
#define MP_TASK_PRIORITY (ESP_TASK_PRIO_MIN + 1)
6974
#define MP_TASK_STACK_SIZE (16 * 1024)
@@ -103,10 +108,24 @@ void mp_task(void *pvParameter) {
103108
// Allocate the uPy heap using malloc and get the largest available region,
104109
// limiting to 1/2 total available memory to leave memory for the OS.
105110
// When SPIRAM is enabled, this will allocate from SPIRAM.
111+
#if CONFIG_SPIRAM || CONFIG_SPIRAM_BOOT_INIT || CONFIG_SPIRAM_USE_CAPS_ALLOC
112+
uint32_t caps = MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT;
113+
size_t heap_total = esp_psram_get_size();
114+
#if CONFIG_SPIRAM_MODE_OCT || MICROPY_ESP_ENABLE_PSRAM_GRAM
115+
// Leave half of psam as gram using
116+
size_t mp_task_heap_size = heap_total / 2;
117+
void *mp_task_heap = heap_caps_aligned_calloc(64, 1, mp_task_heap_size, caps);
118+
#else
119+
// All psram for MP
120+
size_t mp_task_heap_size = heap_total;
121+
void *mp_task_heap = heap_caps_aligned_calloc(64, 1, mp_task_heap_size, caps);
122+
#endif
123+
#else
106124
uint32_t caps = MALLOC_CAP_8BIT;
107125
size_t heap_total = heap_caps_get_total_size(caps);
108126
size_t mp_task_heap_size = MIN(heap_caps_get_largest_free_block(caps), heap_total / 2);
109127
void *mp_task_heap = heap_caps_malloc(mp_task_heap_size, caps);
128+
#endif
110129

111130
soft_reset:
112131
// initialise the stack pointer for the main thread
@@ -159,6 +178,11 @@ void mp_task(void *pvParameter) {
159178
espnow_deinit(mp_const_none);
160179
MP_STATE_PORT(espnow_singleton) = NULL;
161180
#endif
181+
182+
#if MICROPY_ESP32S3_LCDCAM
183+
mp_esp32s3_lcd_cam_global_deinit();
184+
MP_STATE_PORT(esp32s3_lcd_cam_singleton) = NULL;
185+
#endif
162186

163187
machine_timer_deinit_all();
164188

ports/esp32/main_esp32s3/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,12 @@ if(NOT MICROPY_PORT_DIR)
88
get_filename_component(MICROPY_PORT_DIR ${MICROPY_DIR}/ports/esp32 ABSOLUTE)
99
endif()
1010

11+
list(APPEND MICROPY_SOURCE_PORT
12+
modesp32s3.c
13+
)
14+
15+
list(APPEND IDF_COMPONENTS
16+
esp_lcd
17+
)
18+
1119
include(${MICROPY_PORT_DIR}/esp32_common.cmake)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy