Skip to content

Commit cfea71d

Browse files
fdlamottedpgeorge
authored andcommitted
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 <[email protected]>
1 parent 2f88c1e commit cfea71d

File tree

7 files changed

+39
-15
lines changed

7 files changed

+39
-15
lines changed

ports/esp32/boards/ESP32_GENERIC/mpconfigvariant_D2WD.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set(SDKCONFIG_DEFAULTS
22
${SDKCONFIG_DEFAULTS}
3+
boards/sdkconfig.flash_2MiB
34
boards/ESP32_GENERIC/sdkconfig.d2wd
45
)
56

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
# Optimise using -Os to reduce size
2-
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
3-
CONFIG_COMPILER_OPTIMIZATION_PERF=n
4-
CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y
5-
6-
# Change maximum log level to error, to reduce firmware size.
7-
CONFIG_LOG_MAXIMUM_LEVEL_ERROR=y
8-
CONFIG_LOG_MAXIMUM_LEVEL_INFO=n
9-
10-
# Disable SPI Ethernet driver to reduce firmware size.
11-
CONFIG_ETH_USE_SPI_ETHERNET=n
12-
1+
# Setting specific to d2wd
132
CONFIG_ESPTOOLPY_FLASHMODE_DIO=y
143
CONFIG_ESPTOOLPY_FLASHFREQ_40M=y
15-
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
16-
CONFIG_PARTITION_TABLE_CUSTOM=y
17-
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-2MiB.csv"

ports/esp32/boards/ESP32_GENERIC_C2/board.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
"product": "ESP32-C2",
1919
"thumbnail": "",
2020
"url": "https://www.espressif.com/en/products/modules",
21+
"variants": {
22+
"FLASH_2M": "2MiB flash"
23+
},
2124
"vendor": "Espressif"
2225
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
The following files are firmware images that should work on most ESP32-C2-based
22
boards with at least 4MiB of flash and 26MHz crystal frequency. This includes
33
ESP8684-WROOM and ESP8684-MINI modules.
4+
5+
If your board has only 2MiB of flash, you should try the FLASH\_2M variant

ports/esp32/boards/ESP32_GENERIC_C2/mpconfigboard.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
// This configuration is for a generic ESP32C2 board with 4MiB (or more) of flash.
22

3+
#ifndef MICROPY_HW_BOARD_NAME
34
#define MICROPY_HW_BOARD_NAME "ESP32C2 module"
5+
#endif
6+
7+
#ifndef MICROPY_HW_MCU_NAME
48
#define MICROPY_HW_MCU_NAME "ESP32C2"
9+
#endif
510

611
#define MICROPY_HW_ENABLE_SDCARD (0)
712
#define MICROPY_PY_MACHINE_I2S (0)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set(SDKCONFIG_DEFAULTS
2+
${SDKCONFIG_DEFAULTS}
3+
boards/sdkconfig.flash_2MiB
4+
)
5+
6+
list(APPEND MICROPY_DEF_BOARD
7+
MICROPY_HW_BOARD_NAME="Generic ESP32-C2 module with 2MiB Flash"
8+
MICROPY_OPT_COMPUTED_GOTO=0
9+
MICROPY_PY_NETWORK_LAN=0
10+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Set flash size to 2MiB.
2+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n
3+
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
4+
CONFIG_PARTITION_TABLE_CUSTOM=y
5+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-2MiB.csv"
6+
7+
# Disable SPI Ethernet driver to reduce firmware size.
8+
CONFIG_ETH_USE_SPI_ETHERNET=n
9+
10+
# Optimise using -Os to reduce size.
11+
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
12+
CONFIG_COMPILER_OPTIMIZATION_PERF=n
13+
CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y
14+
15+
# Change maximum log level to error, to reduce firmware size.
16+
CONFIG_LOG_MAXIMUM_LEVEL_ERROR=y
17+
CONFIG_LOG_MAXIMUM_LEVEL_INFO=n

0 commit comments

Comments
 (0)