esp32/boards: Add new board variant for esp32c2 devices with 2MiB flash.

Factors out the space-saving config options from `sdkconfig.d2wd` to a new
`sdkconfig.flash_2MiB` file, and uses that in the new C2 FLASH_2M variant.

Signed-off-by: Florent <florent@frizoncorrea.fr>
This commit is contained in:
Florent 2025-09-28 13:52:22 +02:00 committed by Damien George
parent 2f88c1e795
commit cfea71da50
7 changed files with 39 additions and 15 deletions

View File

@ -1,5 +1,6 @@
set(SDKCONFIG_DEFAULTS
${SDKCONFIG_DEFAULTS}
boards/sdkconfig.flash_2MiB
boards/ESP32_GENERIC/sdkconfig.d2wd
)

View File

@ -1,17 +1,3 @@
# Optimise using -Os to reduce size
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_PERF=n
CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y
# Change maximum log level to error, to reduce firmware size.
CONFIG_LOG_MAXIMUM_LEVEL_ERROR=y
CONFIG_LOG_MAXIMUM_LEVEL_INFO=n
# Disable SPI Ethernet driver to reduce firmware size.
CONFIG_ETH_USE_SPI_ETHERNET=n
# Setting specific to d2wd
CONFIG_ESPTOOLPY_FLASHMODE_DIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_40M=y
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-2MiB.csv"

View File

@ -18,5 +18,8 @@
"product": "ESP32-C2",
"thumbnail": "",
"url": "https://www.espressif.com/en/products/modules",
"variants": {
"FLASH_2M": "2MiB flash"
},
"vendor": "Espressif"
}

View File

@ -1,3 +1,5 @@
The following files are firmware images that should work on most ESP32-C2-based
boards with at least 4MiB of flash and 26MHz crystal frequency. This includes
ESP8684-WROOM and ESP8684-MINI modules.
If your board has only 2MiB of flash, you should try the FLASH\_2M variant

View File

@ -1,7 +1,12 @@
// This configuration is for a generic ESP32C2 board with 4MiB (or more) of flash.
#ifndef MICROPY_HW_BOARD_NAME
#define MICROPY_HW_BOARD_NAME "ESP32C2 module"
#endif
#ifndef MICROPY_HW_MCU_NAME
#define MICROPY_HW_MCU_NAME "ESP32C2"
#endif
#define MICROPY_HW_ENABLE_SDCARD (0)
#define MICROPY_PY_MACHINE_I2S (0)

View File

@ -0,0 +1,10 @@
set(SDKCONFIG_DEFAULTS
${SDKCONFIG_DEFAULTS}
boards/sdkconfig.flash_2MiB
)
list(APPEND MICROPY_DEF_BOARD
MICROPY_HW_BOARD_NAME="Generic ESP32-C2 module with 2MiB Flash"
MICROPY_OPT_COMPUTED_GOTO=0
MICROPY_PY_NETWORK_LAN=0
)

View File

@ -0,0 +1,17 @@
# Set flash size to 2MiB.
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-2MiB.csv"
# Disable SPI Ethernet driver to reduce firmware size.
CONFIG_ETH_USE_SPI_ETHERNET=n
# Optimise using -Os to reduce size.
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_PERF=n
CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y
# Change maximum log level to error, to reduce firmware size.
CONFIG_LOG_MAXIMUM_LEVEL_ERROR=y
CONFIG_LOG_MAXIMUM_LEVEL_INFO=n