Skip to content

Commit 1b9ef9e

Browse files
committed
third-party: Fix compilation errors.
Signed-off-by: lbuque <[email protected]>
1 parent 9ac0f5f commit 1b9ef9e

15 files changed

+117
-63
lines changed

third-party/CMakeLists.txt

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
# SPDX-License-Identifier: MIT
44

55
# Top-level cmake file for building MicroPython on ESP32.
6-
6+
#
7+
# Note for maintainers: Where possible, functionality should be put into
8+
# esp32_common.cmake not this file. This is because this CMakeLists.txt file
9+
# needs to be duplicated for out-of-tree builds, and can easily get out of date.
710
cmake_minimum_required(VERSION 3.12)
811

912
set(CMAKE_C_FLAGS "-Wno-unused-variable -Wno-unused-but-set-variable")
@@ -18,7 +21,7 @@ set(IDF_VERSION "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}"
1821

1922
# Set the board if it's not already set.
2023
if(NOT MICROPY_BOARD)
21-
set(MICROPY_BOARD M5STACK_4MB)
24+
set(MICROPY_BOARD ESPRESSIF_ESP32_S3_BOX_3)
2225
endif()
2326

2427
# Set the board directory and check that it exists.
@@ -42,12 +45,6 @@ set(SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig)
4245
# Save the manifest file set from the cmake command line.
4346
set(MICROPY_USER_FROZEN_MANIFEST ${MICROPY_FROZEN_MANIFEST})
4447

45-
# Specific options for IDF v5.2 and later
46-
set(SDKCONFIG_IDF_VERSION_SPECIFIC "")
47-
if (IDF_VERSION VERSION_GREATER_EQUAL "5.2.0")
48-
set(SDKCONFIG_IDF_VERSION_SPECIFIC boards/sdkconfig.idf52)
49-
endif()
50-
5148
# Include board config; this is expected to set (among other options):
5249
# - SDKCONFIG_DEFAULTS
5350
# - IDF_TARGET
@@ -77,34 +74,28 @@ set(SDKCONFIG_DEFAULTS ${CMAKE_BINARY_DIR}/sdkconfig.combined)
7774

7875
if(BUILD_WITH_LVGL)
7976
# Include LVGL component, ignore KCONFIG
80-
idf_build_set_property(LV_MICROPYTHON 1)
81-
idf_build_component(${CMAKE_SOURCE_DIR}/components/lv_bindings/lvgl)
82-
idf_build_set_property(COMPILE_DEFINITIONS "-DLV_KCONFIG_IGNORE" APPEND)
83-
separate_arguments(LV_CFLAGS_ENV UNIX_COMMAND $ENV{LV_CFLAGS})
84-
list(APPEND LV_CFLAGS ${LV_CFLAGS_ENV})
85-
idf_build_set_property(COMPILE_DEFINITIONS "${LV_CFLAGS}" APPEND)
77+
# idf_build_set_property(LV_MICROPYTHON 1)
78+
# idf_build_component(${CMAKE_SOURCE_DIR}/components/lv_bindings/lvgl)
79+
# idf_build_set_property(COMPILE_DEFINITIONS "-DLV_KCONFIG_IGNORE" APPEND)
80+
# separate_arguments(LV_CFLAGS_ENV UNIX_COMMAND $ENV{LV_CFLAGS})
81+
# list(APPEND LV_CFLAGS ${LV_CFLAGS_ENV})
82+
# idf_build_set_property(COMPILE_DEFINITIONS "${LV_CFLAGS}" APPEND)
8683
endif()
8784

8885
# Include main IDF cmake file.
8986
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
9087

9188
# Set the location of the main component for the project (one per target).
92-
list(APPEND EXTRA_COMPONENT_DIRS main_${IDF_TARGET})
89+
list(APPEND EXTRA_COMPONENT_DIRS main)
9390
list(APPEND EXTRA_COMPONENT_DIRS ../m5stack/components/esp32-camera)
9491
list(APPEND EXTRA_COMPONENT_DIRS ../m5stack/components/libffi)
9592
# list(APPEND EXTRA_COMPONENT_DIRS ../m5stack/components/lv_bindings)
9693
list(APPEND EXTRA_COMPONENT_DIRS ../m5stack/components/M5Unified/M5GFX)
9794
list(APPEND EXTRA_COMPONENT_DIRS ../m5stack/components/M5Unified/M5Unified)
9895
list(APPEND EXTRA_COMPONENT_DIRS ./components/BOX3GFX)
9996
list(APPEND EXTRA_COMPONENT_DIRS ../m5stack/components/uiflow_utility)
97+
list(APPEND EXTRA_COMPONENT_DIRS ../m5stack/components/esp_dmx)
10098
# list(APPEND EXTRA_COMPONENT_DIRS ./boards)
10199

102-
# Enable the panic handler wrapper
103-
idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND)
104-
105-
# Patch LWIP memory pool allocators (see lwip_patch.c)
106-
idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=memp_malloc" APPEND)
107-
idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=memp_free" APPEND)
108-
109100
# Define the project.
110101
project(micropython)

third-party/CMakeListsDefault.cmake

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ if(NOT MICROPY_PORT_DIR)
1212
get_filename_component(MICROPY_PORT_DIR ${MICROPY_DIR}/ports/esp32 ABSOLUTE)
1313
endif()
1414

15+
# RISC-V specific inclusions
16+
if(CONFIG_IDF_TARGET_ARCH_RISCV)
17+
list(APPEND MICROPY_SOURCE_LIB
18+
${MICROPY_DIR}/shared/runtime/gchelper_native.c
19+
${MICROPY_DIR}/shared/runtime/gchelper_rv32i.s
20+
)
21+
endif()
22+
23+
if(NOT DEFINED MICROPY_PY_TINYUSB)
24+
if(CONFIG_IDF_TARGET_ESP32S2 OR CONFIG_IDF_TARGET_ESP32S3)
25+
set(MICROPY_PY_TINYUSB ON)
26+
endif()
27+
endif()
28+
1529
# Include core source components.
1630
include(${MICROPY_DIR}/py/py.cmake)
1731

@@ -57,7 +71,7 @@ list(APPEND MICROPY_SOURCE_DRIVERS
5771
${MICROPY_DIR}/drivers/dht/dht.c
5872
)
5973

60-
string(CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/tinyusb)
74+
list(APPEND GIT_SUBMODULES lib/tinyusb)
6175
if(MICROPY_PY_TINYUSB)
6276
set(TINYUSB_SRC "${MICROPY_DIR}/lib/tinyusb/src")
6377
string(TOUPPER OPT_MCU_${IDF_TARGET} tusb_mcu)
@@ -76,6 +90,7 @@ if(MICROPY_PY_TINYUSB)
7690
${MICROPY_DIR}/shared/tinyusb/mp_usbd.c
7791
${MICROPY_DIR}/shared/tinyusb/mp_usbd_cdc.c
7892
${MICROPY_DIR}/shared/tinyusb/mp_usbd_descriptor.c
93+
${MICROPY_DIR}/shared/tinyusb/mp_usbd_runtime.c
7994
)
8095

8196
list(APPEND MICROPY_INC_TINYUSB
@@ -121,7 +136,7 @@ set(MICROPY_SOURCE_PORT
121136
${PROJECT_DIR}/../m5stack/modesp32.c
122137
${PROJECT_DIR}/../micropython/ports/esp32/machine_hw_spi.c
123138
${PROJECT_DIR}/../micropython/ports/esp32/mpthreadport.c
124-
${PROJECT_DIR}/../micropython/ports/esp32/machine_rtc.c
139+
${PROJECT_DIR}/../m5stack/machine_rtc.c
125140
${PROJECT_DIR}/../micropython/ports/esp32/machine_sdcard.c
126141
${PROJECT_DIR}/../micropython/ports/esp32/modespnow.c
127142
)
@@ -153,6 +168,7 @@ set(MICROPY_SOURCE_QSTR
153168
${MICROPY_SOURCE_LIB}
154169
${MICROPY_SOURCE_PORT}
155170
${MICROPY_SOURCE_BOARD}
171+
${MICROPY_SOURCE_TINYUSB}
156172
# ${MICROPY_SOURCE_M5UNIFIED}
157173
${MICROPY_SOURCE_M5CAMERA}
158174
)
@@ -191,7 +207,6 @@ set(IDF_COMPONENTS
191207
ulp
192208
usb
193209
vfs
194-
xtensa
195210
esp_http_client
196211
esp-tls
197212
libffi
@@ -200,8 +215,15 @@ set(IDF_COMPONENTS
200215
BOX3GFX
201216
esp32-camera
202217
uiflow_utility
218+
esp_dmx
219+
esp_mm
220+
esp_driver_ppa
203221
)
204222

223+
if(CONFIG_IDF_TARGET_ESP32 OR CONFIG_IDF_TARGET_ESP32S2 OR CONFIG_IDF_TARGET_ESP32S3)
224+
list(APPEND IDF_COMPONENTS xtensa)
225+
endif()
226+
205227
if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s3")
206228
list(APPEND IDF_COMPONENTS boards)
207229
list(APPEND IDF_COMPONENTS audio_pipeline)
@@ -211,6 +233,22 @@ if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s3")
211233
list(APPEND IDF_COMPONENTS esp_codec_dev)
212234
endif()
213235

236+
# Provide the default LD fragment if not set
237+
if (MICROPY_USER_LDFRAGMENTS)
238+
set(MICROPY_LDFRAGMENTS ${MICROPY_USER_LDFRAGMENTS})
239+
endif()
240+
241+
if (UPDATE_SUBMODULES)
242+
# ESP-IDF checks if some paths exist before CMake does. Some paths don't
243+
# yet exist if this is an UPDATE_SUBMODULES pass on a brand new checkout, so remove
244+
# any path which might not exist yet. A "real" build will not set UPDATE_SUBMODULES.
245+
unset(MICROPY_SOURCE_TINYUSB)
246+
unset(MICROPY_SOURCE_EXTMOD)
247+
unset(MICROPY_SOURCE_LIB)
248+
unset(MICROPY_INC_TINYUSB)
249+
unset(MICROPY_INC_CORE)
250+
endif()
251+
214252
# Register the main IDF component.
215253
idf_component_register(
216254
SRCS
@@ -230,7 +268,7 @@ idf_component_register(
230268
${MICROPY_BOARD_DIR}
231269
${CMAKE_BINARY_DIR}
232270
LDFRAGMENTS
233-
linker.lf
271+
${MICROPY_LDFRAGMENTS}
234272
REQUIRES
235273
${IDF_COMPONENTS}
236274
)
@@ -239,8 +277,10 @@ idf_component_register(
239277
set(MICROPY_TARGET ${COMPONENT_TARGET})
240278

241279
# Define mpy-cross flags, for use with frozen code.
242-
if(CONFIG_IDF_TARGET_ARCH STREQUAL "xtensa")
243-
set(MICROPY_CROSS_FLAGS -march=xtensawin)
280+
if(CONFIG_IDF_TARGET_ARCH_XTENSA)
281+
set(MICROPY_CROSS_FLAGS -march=xtensawin)
282+
elseif(CONFIG_IDF_TARGET_ARCH_RISCV)
283+
set(MICROPY_CROSS_FLAGS -march=rv32imc)
244284
endif()
245285

246286
# Set compile options for this port.
@@ -266,7 +306,7 @@ target_compile_options(${MICROPY_TARGET} PUBLIC
266306
)
267307

268308
target_link_options(${MICROPY_TARGET} PUBLIC
269-
${MICROPY_LINK_TINYUSB}
309+
${MICROPY_LINK_TINYUSB}
270310
)
271311

272312
# Additional include directories needed for private NimBLE headers.
@@ -278,6 +318,20 @@ target_include_directories(${MICROPY_TARGET} PUBLIC
278318
target_link_libraries(${MICROPY_TARGET} micropy_extmod_btree)
279319
target_link_libraries(${MICROPY_TARGET} usermod)
280320

321+
# Extra linker options
322+
# (when wrap symbols are in standalone files, --undefined ensures
323+
# the linker doesn't skip that file.)
324+
target_link_options(${MICROPY_TARGET} PUBLIC
325+
# Patch LWIP memory pool allocators (see lwip_patch.c)
326+
-Wl,--undefined=memp_malloc
327+
-Wl,--wrap=memp_malloc
328+
-Wl,--wrap=memp_free
329+
330+
# Enable the panic handler wrapper
331+
-Wl,--undefined=esp_panic_handler
332+
-Wl,--wrap=esp_panic_handler
333+
)
334+
281335
# Collect all of the include directories and compile definitions for the IDF components,
282336
# including those added by the IDF Component Manager via idf_components.yaml.
283337
foreach(comp ${__COMPONENT_NAMES_RESOLVED})
@@ -313,4 +367,4 @@ add_custom_command(
313367
${GEN_PINS_PREFIX}
314368
VERBATIM
315369
COMMAND_EXPAND_LISTS
316-
)
370+
)

third-party/boards/SEEED_STUDIO_XIAO_ESP32S3/mpconfigboard.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ set(BOARD_ID 136)
1111
set(M5_CAMERA_MODULE_ENABLE TRUE)
1212

1313
set(SDKCONFIG_DEFAULTS
14-
./boards/SEEED_STUDIO_XIAO_ESP32S3/sdkconfig.board
1514
./boards/sdkconfig.base
15+
${SDKCONFIG_IDF_VERSION_SPECIFIC}
1616
./boards/sdkconfig.240mhz
1717
./boards/sdkconfig.disable_iram
1818
./boards/sdkconfig.ble
1919
./boards/sdkconfig.usb
2020
./boards/sdkconfig.flash_8mb
2121
./boards/sdkconfig.spiram_sx
2222
./boards/sdkconfig.spiram_oct
23+
./boards/SEEED_STUDIO_XIAO_ESP32S3/sdkconfig.board
2324
)
2425

2526
# If not enable LVGL, ignore this...

third-party/boards/SEEED_STUDIO_XIAO_ESP32S3/sdkconfig.board

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ CONFIG_SPIRAM_MEMTEST=
1414
# M5STACK UiFlow USB description
1515
CONFIG_TINYUSB_DESC_CDC_STRING="Seeed XIAO-ESP32S3(UiFlow2)"
1616

17+
# SSL
18+
CONFIG_MBEDTLS_AES_USE_INTERRUPT=n
19+
1720
#
1821
# Audio HAL
1922
#
20-
CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y
23+
CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y

third-party/boards/sdkconfig.base

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ CONFIG_COMPILER_OPTIMIZATION_PERF=y
88
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y
99

1010
# Application manager
11-
CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=y
12-
CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR=y
11+
# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=y
12+
# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR=y
1313

1414
# Bootloader config
1515
CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y
1616
CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y
1717
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
1818

1919
# Change default log level to "ERROR" (instead of "INFO")
20-
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
20+
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
2121

2222
# Set the maximum included log level higher than the default,
2323
# so esp.osdebug() can enable more logging at runtime.
@@ -49,7 +49,8 @@ CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=n
4949
# FreeRTOS
5050
CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=2
5151
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
52-
CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP=y
52+
CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP=n
53+
CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK=y
5354

5455
# UDP
5556
CONFIG_LWIP_PPP_SUPPORT=y
@@ -63,6 +64,9 @@ CONFIG_MBEDTLS_HAVE_TIME_DATE=y
6364
CONFIG_MBEDTLS_PLATFORM_TIME_ALT=y
6465
CONFIG_MBEDTLS_HAVE_TIME=y
6566

67+
# Enable DTLS
68+
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y
69+
6670
# Disable ALPN support as it's not implemented in MicroPython
6771
CONFIG_MBEDTLS_SSL_ALPN=n
6872

@@ -126,7 +130,7 @@ CONFIG_ETH_SPI_ETHERNET_DM9051=y
126130
# functions are in ROM. Note some newer chips (c2,c6) have "full" newlib
127131
# formatting in ROM instead and should override this, check
128132
# ESP_ROM_HAS_NEWLIB_NANO_FORMAT.
129-
CONFIG_NEWLIB_NANO_FORMAT=y
133+
CONFIG_NEWLIB_NANO_FORMAT=n
130134

131135
# IRAM/DRAM split protection is a memory protection feature on some parts
132136
# that support SOC_CPU_IDRAM_SPLIT_USING_PMP, eg. C2, C5, C6, H2

third-party/boards/sdkconfig.flash_12mb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# For cmake build
66
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
77
CONFIG_PARTITION_TABLE_CUSTOM=y
8-
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_16mb.csv"
8+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_16mb.csv"

third-party/boards/sdkconfig.flash_16mb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# For cmake build
66
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
77
CONFIG_PARTITION_TABLE_CUSTOM=y
8-
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_16mb.csv"
8+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_16mb.csv"

third-party/boards/sdkconfig.flash_4mb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# For cmake build
66
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
77
CONFIG_PARTITION_TABLE_CUSTOM=y
8-
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_4mb.csv"
8+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_4mb.csv"

third-party/boards/sdkconfig.flash_8mb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# For cmake build
66
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
77
CONFIG_PARTITION_TABLE_CUSTOM=y
8-
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_8mb.csv"
8+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_8mb.csv"
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
2-
#
3-
# SPDX-License-Identifier: MIT
4-
51
# MicroPython on ESP32, ESP IDF configuration with SPIRAM support
62

7-
CONFIG_ESP32_SPIRAM_SUPPORT=y
3+
CONFIG_SPIRAM=y
84
CONFIG_SPIRAM_CACHE_WORKAROUND=y
95
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
10-
#CONFIG_SPIRAM_USE_MEMMAP=y
6+
CONFIG_SPIRAM_USE_MALLOC=y
7+
8+
# This is the threshold for preferring small allocations from internal memory
9+
# first, before failing over to PSRAM.
10+
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=8192
1111

12+
# SPIRAM increases the size of the firmware and overflows iram0_0_seg, due
13+
# to PSRAM bug workarounds. Apply some options to reduce the firmware size.
1214
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
1315
CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y
14-
CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y
16+
# CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y # Workaround required: see main_esp32/linker.lf
1517
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
16-
CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y
18+
CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y

0 commit comments

Comments
 (0)