Skip to content

Commit

Permalink
feat(ports): add esp32 board ESP32_S3_BOX_3
Browse files Browse the repository at this point in the history
  • Loading branch information
Lzw655 committed Nov 10, 2024
1 parent bf32822 commit 7869082
Show file tree
Hide file tree
Showing 34 changed files with 2,602 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ user.props

# MacOS desktop metadata files
.DS_Store

# lvgl
**/**/lv_binding_micropython/*
lextab.py
yacctab.py
6 changes: 5 additions & 1 deletion ports/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ set(SDKCONFIG_DEFAULTS ${CMAKE_BINARY_DIR}/sdkconfig.combined)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

# Set the location of the main component for the project (one per target).
list(APPEND EXTRA_COMPONENT_DIRS main_${IDF_TARGET})
if (MAIN_VARIANT)
list(APPEND EXTRA_COMPONENT_DIRS main_${IDF_TARGET}_${MAIN_VARIANT})
else()
list(APPEND EXTRA_COMPONENT_DIRS main_${IDF_TARGET})
endif()

# Enable the panic handler wrapper
idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND)
Expand Down
9 changes: 9 additions & 0 deletions ports/esp32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ else
BUILD ?= build-$(BOARD)
endif

ifneq ($(MAIN_VARIANT),)
BUILD := $(BUILD)-$(MAIN_VARIANT)
endif

# Device serial settings.
PORT ?= /dev/ttyUSB0
BAUD ?= 460800
Expand All @@ -52,6 +56,10 @@ ifdef BOARD_VARIANT
IDFPY_FLAGS += -D MICROPY_BOARD_VARIANT=$(BOARD_VARIANT)
endif

ifdef MAIN_VARIANT
IDFPY_FLAGS += -D MAIN_VARIANT=$(MAIN_VARIANT)
endif

ifdef MICROPY_PREVIEW_VERSION_2
IDFPY_FLAGS += -D MICROPY_PREVIEW_VERSION_2=1
endif
Expand All @@ -63,6 +71,7 @@ define RUN_IDF_PY
endef

all:
echo $(IDFPY_FLAGS)
idf.py $(IDFPY_FLAGS) -B $(BUILD) build || (echo -e $(HELP_BUILD_ERROR); false)
@$(PYTHON) makeimg.py \
$(BUILD)/sdkconfig \
Expand Down
24 changes: 24 additions & 0 deletions ports/esp32/boards/ESP32_S3_BOX_3/board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"deploy": [
"../deploy_s3.md"
],
"docs": "",
"features": [
"BLE",
"External Flash",
"External RAM",
"WiFi"
],
"images": [
"generic_s3.jpg"
],
"mcu": "esp32s3",
"product": "ESP32-S3",
"thumbnail": "",
"url": "https://www.espressif.com/en/products/modules",
"vendor": "Espressif",
"variants": {
"SPIRAM_OCT": "Support for Octal-SPIRAM",
"FLASH_4M": "4MiB flash"
}
}
9 changes: 9 additions & 0 deletions ports/esp32/boards/ESP32_S3_BOX_3/board.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The following files are firmware that should work on most ESP32-S3-based
boards with 4/8MiB of flash, including WROOM and MINI modules.

This firmware supports configurations with and without SPIRAM (also known as
PSRAM) and will auto-detect a connected SPIRAM chip at startup and allocate
the MicroPython heap accordingly. However if your board has Octal SPIRAM, then
use the "spiram-oct" variant.

If your board has 4MiB flash (including ESP32-S3FH4R2 based ones with embedded flash), then use the "flash-4m" build.
9 changes: 9 additions & 0 deletions ports/esp32/boards/ESP32_S3_BOX_3/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(IDF_TARGET esp32s3)

set(SDKCONFIG_DEFAULTS
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.usb
boards/sdkconfig.ble
boards/ESP32_S3_BOX_3/sdkconfig.base
boards/ESP32_S3_BOX_3/sdkconfig.board
)
11 changes: 11 additions & 0 deletions ports/esp32/boards/ESP32_S3_BOX_3/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef MICROPY_HW_BOARD_NAME
// Can be set by mpconfigboard.cmake.
#define MICROPY_HW_BOARD_NAME "ESP32-S3-BOX-3"
#endif
#define MICROPY_HW_MCU_NAME "ESP32S3"

// Enable UART REPL for modules that have an external USB-UART and don't use native USB.
#define MICROPY_HW_ENABLE_UART_REPL (1)

#define MICROPY_HW_I2C0_SCL (9)
#define MICROPY_HW_I2C0_SDA (8)
7 changes: 7 additions & 0 deletions ports/esp32/boards/ESP32_S3_BOX_3/partitions-16MiB.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Notes: the offset of the partition table itself is set in
# $IDF_PATH/components/partition_table/Kconfig.projbuild.
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, , 0x1000,
factory, app, factory, , 9M,
vfs, data, fat, , 6M,
139 changes: 139 additions & 0 deletions ports/esp32/boards/ESP32_S3_BOX_3/sdkconfig.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# MicroPython on ESP32, ESP IDF configuration
# The following options override the defaults

CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000

# Compiler options: use -O2 and disable assertions to improve performance
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y

# Application manager
CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=y
CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR=y

# Bootloader config
CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y
CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y

# Change default log level to "ERROR" (instead of "INFO")
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y

# Set the maximum included log level higher than the default,
# so esp.osdebug() can enable more logging at runtime.
#
# To increase the max log verbosity to Debug or Verbose instead, comment
# CONFIG_LOG_MAXIMUM_LEVEL_INFO=y and uncomment one of the other settings.
#
# If not needed, the next line can be commented entirely to save binary size.
CONFIG_LOG_MAXIMUM_LEVEL_INFO=y
#CONFIG_LOG_MAXIMUM_LEVEL_DEBUG=y
#CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE=y

# Main XTAL Config
# Only on: ESP32
CONFIG_XTAL_FREQ_AUTO=y

# ESP System Settings
# Only on: ESP32, ESP32S3
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=n

# Power Management
CONFIG_PM_ENABLE=y

# Memory protection
# This is required to allow allocating IRAM
CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=n

# FreeRTOS
CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=2
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP=y

# UDP
CONFIG_LWIP_PPP_SUPPORT=y
CONFIG_LWIP_PPP_PAP_SUPPORT=y
CONFIG_LWIP_PPP_CHAP_SUPPORT=y

# SSL
# Use 4kiB output buffer instead of default 16kiB
CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y
CONFIG_MBEDTLS_HAVE_TIME_DATE=y
CONFIG_MBEDTLS_PLATFORM_TIME_ALT=y
CONFIG_MBEDTLS_HAVE_TIME=y

# Disable ALPN support as it's not implemented in MicroPython
CONFIG_MBEDTLS_SSL_ALPN=n

# Disable slow or unused EC curves
CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=n
CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=n
CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=n
CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=n

# Disable certificate bundle as it's not implemented in MicroPython
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n

# Allow mbedTLS to allocate from PSRAM or internal memory
#
# (The ESP-IDF default is internal-only, partly for physical security to prevent
# possible information leakage from unencrypted PSRAM contents on the original
# ESP32 - no PSRAM encryption on that chip. MicroPython doesn't support flash
# encryption and is already storing the Python heap in PSRAM so this isn't a
# significant factor in overall physical security.)
CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y

# ULP coprocessor support
# Only on: ESP32, ESP32S2, ESP32S3
CONFIG_ULP_COPROC_ENABLED=y
CONFIG_ULP_COPROC_TYPE_FSM=y
CONFIG_ULP_COPROC_RESERVE_MEM=2040

# For cmake build
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MiB.csv"

# To reduce iRAM usage
CONFIG_ESP32_WIFI_IRAM_OPT=n
CONFIG_ESP32_WIFI_RX_IRAM_OPT=n
CONFIG_SPI_MASTER_ISR_IN_IRAM=n
CONFIG_SPI_SLAVE_ISR_IN_IRAM=n
CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=n
CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=n

# Legacy ADC Calibration Configuration
# Only on: ESP32
CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y
CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y
CONFIG_ADC_CAL_LUT_ENABLE=y

# UART Configuration
CONFIG_UART_ISR_IN_IRAM=y

# IDF 5 deprecated
CONFIG_ADC_SUPPRESS_DEPRECATE_WARN=y
CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y

CONFIG_ETH_USE_SPI_ETHERNET=y
CONFIG_ETH_SPI_ETHERNET_W5500=y
CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL=y
CONFIG_ETH_SPI_ETHERNET_DM9051=y

# Using newlib "nano" formatting saves size on SoCs where "nano" formatting
# functions are in ROM. Note some newer chips (c2,c6) have "full" newlib
# formatting in ROM instead and should override this, check
# ESP_ROM_HAS_NEWLIB_NANO_FORMAT.
CONFIG_NEWLIB_NANO_FORMAT=y

# IRAM/DRAM split protection is a memory protection feature on some parts
# that support SOC_CPU_IDRAM_SPLIT_USING_PMP, eg. C2, C5, C6, H2
# Due to limitations in the PMP system this feature breaks native emitters
# so is disabled by default.
CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT=n

# Further limit total sockets in TIME-WAIT when there are many short-lived
# connections.
CONFIG_LWIP_MAX_ACTIVE_TCP=12
16 changes: 16 additions & 0 deletions ports/esp32/boards/ESP32_S3_BOX_3/sdkconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="boards/ESP32_S3_BOX_3/partitions-16MiB.csv"
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_RODATA=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESP_CONSOLE_UART_CUSTOM=y
CONFIG_ESP_CONSOLE_UART_BAUDRATE=2000000
CONFIG_FREERTOS_HZ=1000
CONFIG_ESP_BROOKESIA_MEMORY_USE_CUSTOM=y
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
5 changes: 5 additions & 0 deletions ports/esp32/esp32_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ if(NOT CMAKE_BUILD_EARLY_EXPANSION)

include(${MICROPY_DIR}/py/usermod.cmake)
include(${MICROPY_DIR}/extmod/extmod.cmake)

idf_build_get_property(component_targets __COMPONENT_TARGETS)
string(REPLACE "___idf_lvgl" "" component_targets "${component_targets}")
idf_build_set_property(__COMPONENT_TARGETS "${component_targets}")
message("Component targets: ${component_targets}")
endif()

list(APPEND MICROPY_QSTRDEFS_PORT
Expand Down
13 changes: 13 additions & 0 deletions ports/esp32/main_esp32s3_box3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Set location of base MicroPython directory.
if(NOT MICROPY_DIR)
get_filename_component(MICROPY_DIR ${CMAKE_CURRENT_LIST_DIR}/../../.. ABSOLUTE)
endif()

# Set location of the ESP32 port directory.
if(NOT MICROPY_PORT_DIR)
get_filename_component(MICROPY_PORT_DIR ${MICROPY_DIR}/ports/esp32 ABSOLUTE)
endif()

set(MICROPY_PY_TINYUSB ON)

include(${CMAKE_CURRENT_LIST_DIR}/esp32_common.cmake)
1 change: 1 addition & 0 deletions ports/esp32/main_esp32s3_box3/esp-box-3/.component_hash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9afc6dd09f779dfc9f7b1b15f129b5dbed6235a20c5991a4d30304c8705a48f4
13 changes: 13 additions & 0 deletions ports/esp32/main_esp32s3_box3/esp-box-3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#IDF version is less than IDF5.0
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_LESS "5.0")
set(SRC_VER "esp-box-3_idf4.c")
else()
set(SRC_VER "esp-box-3_idf5.c")
endif()

idf_component_register(
SRCS "esp-box-3.c" ${SRC_VER}
INCLUDE_DIRS "include"
PRIV_INCLUDE_DIRS "priv_include"
REQUIRES driver spiffs esp_lcd
)
Loading

0 comments on commit 7869082

Please sign in to comment.