Skip to content

Commit 141174d

Browse files
committed
boards: Add CUSTOM_ESP32 board.
Signed-off-by: Damien George <[email protected]>
1 parent 6082da0 commit 141174d

File tree

7 files changed

+72
-0
lines changed

7 files changed

+72
-0
lines changed

boards/CUSTOM_ESP32/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Top-level cmake file for building MicroPython on ESP32.
2+
# Nothing in here needs to be customised, it will work for any board.
3+
4+
cmake_minimum_required(VERSION 3.12)
5+
6+
# Set the location of MicroPython, the esp32 port, and the board directory.
7+
get_filename_component(PROJECT_DIR "../.." ABSOLUTE)
8+
#get_filename_component(MICROPY_TOP "../../lib/micropython" ABSOLUTE)
9+
#set(MICROPY_PORT_DIR ${MICROPY_TOP}/ports/esp32)
10+
set(MICROPY_PORT_DIR ${PROJECT_DIR}/lib/micropython/ports/esp32)
11+
get_filename_component(MICROPY_BOARD_DIR "." ABSOLUTE)
12+
13+
# Define the output sdkconfig so it goes in the build directory.
14+
set(SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig)
15+
16+
# Include board config; this is expected to set SDKCONFIG_DEFAULTS (among other options).
17+
include(${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
18+
19+
# Concatenate all sdkconfig files into a combined one for the IDF to use.
20+
file(WRITE ${CMAKE_BINARY_DIR}/sdkconfig.combined.in "")
21+
foreach(SDKCONFIG_DEFAULT ${SDKCONFIG_DEFAULTS})
22+
file(READ ${SDKCONFIG_DEFAULT} CONTENTS)
23+
file(APPEND ${CMAKE_BINARY_DIR}/sdkconfig.combined.in "${CONTENTS}")
24+
endforeach()
25+
configure_file(${CMAKE_BINARY_DIR}/sdkconfig.combined.in ${CMAKE_BINARY_DIR}/sdkconfig.combined COPYONLY)
26+
set(SDKCONFIG_DEFAULTS ${CMAKE_BINARY_DIR}/sdkconfig.combined)
27+
28+
# Include main IDF cmake file and define the project.
29+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
30+
project(micropython)

boards/CUSTOM_ESP32/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
This directory contains board definition files for an esp32-based board.
2+
3+
To build it make sure the IDF has been installed and the environment set up,
4+
for example using `export $IDF_PATH/export.sh`. Then build with:
5+
6+
$ idf.py build
7+
8+
To deploy the firmware to the board:
9+
10+
$ idf.py -p /dev/ttyUSB0 flash
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Include MicroPython ESP32 component.
2+
get_filename_component(MICROPY_DIR "../../../lib/micropython" ABSOLUTE)
3+
set(PROJECT_DIR ${MICROPY_DIR}/ports/esp32)
4+
include(${PROJECT_DIR}/main/CMakeLists.txt)

boards/CUSTOM_ESP32/manifest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
freeze("$(PORT_DIR)/modules")
2+
freeze("$(BOARD_DIR)/../../src/utils", "xxd.py")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Define the chip variant.
2+
set(IDF_TARGET esp32)
3+
4+
# Set the sdkconfig fragments.
5+
set(SDKCONFIG_DEFAULTS
6+
${MICROPY_PORT_DIR}/boards/sdkconfig.base
7+
${MICROPY_PORT_DIR}/boards/sdkconfig.ble
8+
)
9+
10+
# Set the user C modules to include in the build.
11+
set(USER_C_MODULES
12+
${PROJECT_DIR}/src/cmodules/cexample/micropython.cmake
13+
${PROJECT_DIR}/src/cmodules/cexample2/micropython.cmake
14+
)
15+
16+
# Set the manifest file for frozen Python code.
17+
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)

boards/CUSTOM_ESP32/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define MICROPY_HW_BOARD_NAME "Custom ESP32 board"
2+
#define MICROPY_HW_MCU_NAME "ESP32"

boards/CUSTOM_ESP32/partitions.csv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Notes: the offset of the partition table itself is set in
2+
# $IDF_PATH/components/partition_table/Kconfig.projbuild.
3+
# Name, Type, SubType, Offset, Size, Flags
4+
nvs, data, nvs, 0x9000, 0x6000,
5+
phy_init, data, phy, 0xf000, 0x1000,
6+
factory, app, factory, 0x10000, 0x180000,
7+
vfs, data, fat, 0x200000, 0x200000,

0 commit comments

Comments
 (0)