1- # Set location of base MicroPython directory.
21get_filename_component (MICROPY_DIR ${PROJECT_DIR} /components/micropython/micropython ABSOLUTE )
32get_filename_component (MICROPY_PORT_DIR ${PROJECT_DIR} /components/micropython/micropython/ports/esp32 ABSOLUTE )
3+ set (MICROPY_FROZEN_MANIFEST ${PROJECT_DIR} /manifests/${CONFIG_MICROPY_FROZEN_MANIFEST} )
4+
45# Include core source components.
56include (${MICROPY_DIR} /py/py.cmake)
67
7- #include(${MICROPY_DIR}/extmod/extmod.cmake)
8- # CMake fragment for MicroPython extmod component
9- #COPIED EXTMOD CMAKE file to here.
10-
11- set (MICROPY_EXTMOD_DIR "${MICROPY_DIR} /extmod" )
12- set (MICROPY_OOFATFS_DIR "${MICROPY_DIR} /lib/oofatfs" )
13-
14- set (MICROPY_SOURCE_EXTMOD
15- ${MICROPY_EXTMOD_DIR} /machine_i2c.c
16- ${MICROPY_EXTMOD_DIR} /machine_mem.c
17- ${MICROPY_EXTMOD_DIR} /machine_pulse.c
18- ${MICROPY_EXTMOD_DIR} /machine_signal.c
19- ${MICROPY_EXTMOD_DIR} /machine_spi.c
20- ${MICROPY_EXTMOD_DIR} /modbluetooth.c
21- ${MICROPY_EXTMOD_DIR} /modbtree.c
22- ${MICROPY_EXTMOD_DIR} /modframebuf.c
23- ${MICROPY_EXTMOD_DIR} /modonewire.c
24- ${MICROPY_EXTMOD_DIR} /moduasyncio.c
25- ${MICROPY_EXTMOD_DIR} /modubinascii.c
26- ${MICROPY_EXTMOD_DIR} /moducryptolib.c
27- ${MICROPY_EXTMOD_DIR} /moductypes.c
28- ${MICROPY_EXTMOD_DIR} /moduhashlib.c
29- ${MICROPY_EXTMOD_DIR} /moduheapq.c
30- ${MICROPY_EXTMOD_DIR} /modujson.c
31- ${MICROPY_EXTMOD_DIR} /modurandom.c
32- ${MICROPY_EXTMOD_DIR} /modure.c
33- ${MICROPY_EXTMOD_DIR} /moduselect.c
34- ${MICROPY_EXTMOD_DIR} /modussl_axtls.c
35- ${MICROPY_EXTMOD_DIR} /modussl_mbedtls.c
36- ${MICROPY_EXTMOD_DIR} /modutimeq.c
37- ${MICROPY_EXTMOD_DIR} /moduwebsocket.c
38- ${MICROPY_EXTMOD_DIR} /moduzlib.c
39- ${MICROPY_EXTMOD_DIR} /modwebrepl.c
40- ${MICROPY_EXTMOD_DIR} /uos_dupterm.c
41- ${MICROPY_EXTMOD_DIR} /utime_mphal.c
42- #${MICROPY_EXTMOD_DIR}/vfs.c
43- #${MICROPY_EXTMOD_DIR}/vfs_blockdev.c
44- #${MICROPY_EXTMOD_DIR}/vfs_fat.c
45- #${MICROPY_EXTMOD_DIR}/vfs_fat_diskio.c
46- #${MICROPY_EXTMOD_DIR}/vfs_fat_file.c
47- #${MICROPY_EXTMOD_DIR}/vfs_lfs.c
48- #${MICROPY_EXTMOD_DIR}/vfs_posix.c
49- #${MICROPY_EXTMOD_DIR}/vfs_posix_file.c
50- #${MICROPY_EXTMOD_DIR}/vfs_reader.c
51- ${MICROPY_EXTMOD_DIR} /virtpin.c
52- ${MICROPY_EXTMOD_DIR} /nimble/modbluetooth_nimble.c
53- ${COMPONENT_DIR} /vfs_fat/vfs_native_file.c
54- ${COMPONENT_DIR} /vfs_fat/vfs_native_misc.c
55- ${COMPONENT_DIR} /vfs_fat/vfs_native.c
56- ${COMPONENT_DIR} /vfs_fat/vfs_reader.c
57- ${COMPONENT_DIR} /vfs_fat/vfs.c
58- )
59-
60- set (MICROPY_FROZEN_MANIFEST ${PROJECT_DIR} /manifests/${CONFIG_MICROPY_FROZEN_MANIFEST} )
8+ if (NOT CMAKE_BUILD_EARLY_EXPANSION)
9+ include (${MICROPY_DIR} /py/usermod.cmake)
10+ include (${MICROPY_DIR} /extmod/extmod.cmake)
11+
12+ list (REMOVE_ITEM MICROPY_SOURCE_EXTMOD
13+ ${MICROPY_EXTMOD_DIR} /vfs.c
14+ ${MICROPY_EXTMOD_DIR} /vfs_blockdev.c
15+ ${MICROPY_EXTMOD_DIR} /vfs_fat.c
16+ ${MICROPY_EXTMOD_DIR} /vfs_fat_diskio.c
17+ ${MICROPY_EXTMOD_DIR} /vfs_fat_file.c
18+ ${MICROPY_EXTMOD_DIR} /vfs_lfs.c
19+ ${MICROPY_EXTMOD_DIR} /vfs_posix.c
20+ ${MICROPY_EXTMOD_DIR} /vfs_posix_file.c
21+ ${MICROPY_EXTMOD_DIR} /vfs_reader.c
22+ )
23+
24+ list (APPEND MICROPY_SOURCE_EXTMOD
25+ ${COMPONENT_DIR} /vfs_fat/vfs_native_file.c
26+ ${COMPONENT_DIR} /vfs_fat/vfs_native_misc.c
27+ ${COMPONENT_DIR} /vfs_fat/vfs_native.c
28+ ${COMPONENT_DIR} /vfs_fat/vfs_reader.c
29+ ${COMPONENT_DIR} /vfs_fat/vfs.c
30+ )
31+ endif ()
6132
6233set (MICROPY_QSTRDEFS_PORT
6334 ${MICROPY_PORT_DIR} /qstrdefsport.h
6435)
6536
37+ set (MICROPY_SOURCE_SHARED
38+ ${MICROPY_DIR} /shared/readline/readline.c
39+ ${MICROPY_DIR} /shared/netutils/netutils.c
40+ ${MICROPY_DIR} /shared/timeutils/timeutils.c
41+ ${MICROPY_DIR} /shared/runtime/interrupt_char.c
42+ ${MICROPY_DIR} /shared/runtime/stdout_helpers.c
43+ ${MICROPY_DIR} /shared/runtime/sys_stdio_mphal.c
44+ ${MICROPY_DIR} /shared/runtime/pyexec.c
45+ )
46+
6647set (MICROPY_SOURCE_LIB
67- # ${MICROPY_DIR}/lib/littlefs/lfs1.c
68- # ${MICROPY_DIR}/lib/littlefs/lfs1_util.c
69- # ${MICROPY_DIR}/lib/littlefs/lfs2.c
70- # ${MICROPY_DIR}/lib/littlefs/lfs2_util.c
48+ ${MICROPY_DIR} /lib/littlefs/lfs1.c
49+ ${MICROPY_DIR} /lib/littlefs/lfs1_util.c
50+ ${MICROPY_DIR} /lib/littlefs/lfs2.c
51+ ${MICROPY_DIR} /lib/littlefs/lfs2_util.c
7152 ${MICROPY_DIR} /lib/mbedtls_errors/mp_mbedtls_errors.c
72- ${MICROPY_DIR} /lib/mp-readline/readline.c
73- ${MICROPY_DIR} /lib/netutils/netutils.c
74- #${MICROPY_DIR}/lib/oofatfs/ff.c
75- #${MICROPY_DIR}/lib/oofatfs/ffunicode.c
76- ${MICROPY_DIR} /lib/timeutils/timeutils.c
77- ${MICROPY_DIR} /lib/utils/interrupt_char.c
78- #${MICROPY_DIR}/lib/utils/stdout_helpers.c
79- ${MICROPY_DIR} /lib/utils/sys_stdio_mphal.c
80- ${MICROPY_DIR} /lib/utils/pyexec.c
53+ # ${MICROPY_DIR}/lib/oofatfs/ff.c
54+ # ${MICROPY_DIR}/lib/oofatfs/ffunicode.c
8155)
56+ if (IDF_TARGET STREQUAL "esp32c3" )
57+ list (APPEND MICROPY_SOURCE_LIB ${MICROPY_DIR} /shared/runtime/gchelper_generic.c)
58+ endif ()
8259
8360set (MICROPY_SOURCE_DRIVERS
8461 ${MICROPY_DIR} /drivers/bus/softspi.c
@@ -87,27 +64,32 @@ set(MICROPY_SOURCE_DRIVERS
8764
8865set (MICROPY_SOURCE_PORT
8966 ${COMPONENT_DIR} /main.c
90- ${COMPONENT_DIR} /vfs_fat/moduos.c
9167 ${COMPONENT_DIR} /modconsts.c
68+ ${MICROPY_PORT_DIR} /main.c
9269 ${MICROPY_PORT_DIR} /uart.c
70+ ${MICROPY_PORT_DIR} /usb.c
71+ ${MICROPY_PORT_DIR} /usb_serial_jtag.c
9372 ${MICROPY_PORT_DIR} /gccollect.c
9473 ${MICROPY_PORT_DIR} /mphalport.c
9574 #${MICROPY_PORT_DIR}/fatfs_port.c
9675 ${MICROPY_PORT_DIR} /help.c
9776 ${MICROPY_PORT_DIR} /modutime.c
9877 #${MICROPY_PORT_DIR}/moduos.c
78+ ${COMPONENT_DIR} /vfs_fat/moduos.c
79+ ${MICROPY_PORT_DIR} /machine_bitstream.c
9980 ${MICROPY_PORT_DIR} /machine_timer.c
10081 ${MICROPY_PORT_DIR} /machine_pin.c
10182 ${MICROPY_PORT_DIR} /machine_touchpad.c
10283 ${MICROPY_PORT_DIR} /machine_adc.c
10384 ${MICROPY_PORT_DIR} /machine_dac.c
10485 ${MICROPY_PORT_DIR} /machine_i2c.c
105- ${MICROPY_PORT_DIR} /machine_pwm .c
86+ ${MICROPY_PORT_DIR} /machine_i2s .c
10687 ${MICROPY_PORT_DIR} /machine_uart.c
10788 ${MICROPY_PORT_DIR} /modmachine.c
10889 ${MICROPY_PORT_DIR} /modnetwork.c
10990 ${MICROPY_PORT_DIR} /network_lan.c
11091 ${MICROPY_PORT_DIR} /network_ppp.c
92+ ${MICROPY_PORT_DIR} /network_wlan.c
11193 ${MICROPY_PORT_DIR} /mpnimbleport.c
11294 ${MICROPY_PORT_DIR} /modsocket.c
11395 ${MICROPY_PORT_DIR} /modesp.c
@@ -116,7 +98,6 @@ set(MICROPY_SOURCE_PORT
11698 ${MICROPY_PORT_DIR} /esp32_rmt.c
11799 ${MICROPY_PORT_DIR} /esp32_ulp.c
118100 ${MICROPY_PORT_DIR} /modesp32.c
119- ${MICROPY_PORT_DIR} /espneopixel.c
120101 ${MICROPY_PORT_DIR} /machine_hw_spi.c
121102 ${MICROPY_PORT_DIR} /machine_wdt.c
122103 ${MICROPY_PORT_DIR} /mpthreadport.c
@@ -127,9 +108,11 @@ set(MICROPY_SOURCE_PORT
127108set (MICROPY_SOURCE_QSTR
128109 ${MICROPY_SOURCE_PY}
129110 ${MICROPY_SOURCE_EXTMOD}
111+ ${MICROPY_SOURCE_USERMOD}
112+ ${MICROPY_SOURCE_SHARED}
130113 ${MICROPY_SOURCE_LIB}
131114 ${MICROPY_SOURCE_PORT}
132- ${COMPONENT_DIR} /vfs_fat/
115+ ${MICROPY_SOURCE_BOARD}
133116 ${COMPONENT_DIR} /modconsts.c
134117 ${EXTMODS}
135118 ${COMPONENT_DIR} /mpconfigoverrides.h
@@ -140,7 +123,6 @@ set(IDF_COMPONENTS
140123 bootloader_support
141124 bt
142125 driver
143- esp32
144126 esp_common
145127 esp_eth
146128 esp_event
@@ -166,41 +148,53 @@ set(IDF_COMPONENTS
166148 wear_levelling
167149 spiffs
168150 driver_sdcard
169- driver_rtcmem
170- driver_touchbuttons
171151)
172152
173- if (IDF_VERSION_MINOR GREATER_EQUAL 1)
153+ if (IDF_VERSION_MINOR GREATER_EQUAL 1 OR IDF_VERSION_MAJOR GREATER_EQUAL 5 )
174154 list (APPEND IDF_COMPONENTS esp_netif)
175155endif ()
176156
177- if (IDF_VERSION_MINOR GREATER_EQUAL 2)
157+ if (IDF_VERSION_MINOR GREATER_EQUAL 2 OR IDF_VERSION_MAJOR GREATER_EQUAL 5 )
178158 list (APPEND IDF_COMPONENTS esp_system)
179159 list (APPEND IDF_COMPONENTS esp_timer)
180160endif ()
181161
182- if (IDF_VERSION_MINOR GREATER_EQUAL 3)
162+ if (IDF_VERSION_MINOR GREATER_EQUAL 3 OR IDF_VERSION_MAJOR GREATER_EQUAL 5 )
183163 list (APPEND IDF_COMPONENTS esp_hw_support)
184164 list (APPEND IDF_COMPONENTS esp_pm)
185165 list (APPEND IDF_COMPONENTS hal)
186166endif ()
187167
168+ if (IDF_TARGET STREQUAL "esp32" )
169+ list (APPEND IDF_COMPONENTS esp32)
170+ elseif (IDF_TARGET STREQUAL "esp32c3" )
171+ list (APPEND IDF_COMPONENTS esp32c3)
172+ list (APPEND IDF_COMPONENTS riscv)
173+ elseif (IDF_TARGET STREQUAL "esp32s2" )
174+ list (APPEND IDF_COMPONENTS esp32s2)
175+ list (APPEND IDF_COMPONENTS tinyusb)
176+ elseif (IDF_TARGET STREQUAL "esp32s3" )
177+ list (APPEND IDF_COMPONENTS esp32s3)
178+ list (APPEND IDF_COMPONENTS tinyusb)
179+ endif ()
180+
188181# Register the main IDF component.
189182idf_component_register(
190183 SRCS
191184 ${MICROPY_SOURCE_PY}
192185 ${MICROPY_SOURCE_EXTMOD}
186+ ${MICROPY_SOURCE_SHARED}
193187 ${MICROPY_SOURCE_LIB}
194188 ${MICROPY_SOURCE_DRIVERS}
195189 ${MICROPY_SOURCE_PORT}
196- ${COMPONENT_DIR} /mpconfigoverrides.h
190+ ${MICROPY_SOURCE_BOARD}
197191 INCLUDE_DIRS
198- ${MICROPY_DIR}
192+ ${MICROPY_INC_CORE}
193+ ${MICROPY_INC_USERMOD}
199194 ${MICROPY_PORT_DIR}
200195 ${MICROPY_BOARD_DIR}
201196 ${CMAKE_BINARY_DIR}
202- ${COMPONENT_DIR}
203- ${COMPONENT_DIR} /vfs_fat
197+ "./"
204198 REQUIRES
205199 ${IDF_COMPONENTS}
206200)
@@ -223,6 +217,7 @@ set(MICROPY_CROSS_FLAGS -march=xtensawin)
223217
224218# Set compile options for this port.
225219target_compile_definitions (${MICROPY_TARGET} PUBLIC
220+ ${MICROPY_DEF_CORE}
226221 MICROPY_ESP_IDF_4=1
227222)
228223
@@ -233,32 +228,26 @@ target_compile_options(${MICROPY_TARGET} PUBLIC
233228 -Wno-missing-field-initializers
234229)
235230
231+ # Add additional extmod and usermod components.
232+ target_link_libraries (${MICROPY_TARGET} micropy_extmod_btree)
233+ target_link_libraries (${MICROPY_TARGET} usermod)
234+
235+
236236# Collect all of the include directories and compile definitions for the IDF components.
237237foreach (comp ${IDF_COMPONENTS} )
238- get_target_property (type __idf_${comp} TYPE )
239- set (_inc OFF )
240- set (_def OFF )
241- if (${type} STREQUAL STATIC_LIBRARY)
242- get_target_property (_inc __idf_${comp} INCLUDE_DIRECTORIES )
243- get_target_property (_def __idf_${comp} COMPILE_DEFINITIONS )
244- elseif (${type} STREQUAL INTERFACE_LIBRARY)
245- get_target_property (_inc __idf_${comp} INTERFACE_INCLUDE_DIRECTORIES )
246- get_target_property (_def __idf_${comp} INTERFACE_COMPILE_DEFINITIONS )
247- endif ()
248- if (_inc)
249- list (APPEND MICROPY_CPP_INC_EXTRA ${_inc} )
250- endif ()
251- if (_def)
252- list (APPEND MICROPY_CPP_DEF_EXTRA ${_def} )
253- endif ()
238+ micropy_gather_target_properties(__idf_${comp} )
254239endforeach ()
255240
256- if (IDF_VERSION_MINOR GREATER_EQUAL 2)
241+ if (IDF_VERSION_MINOR GREATER_EQUAL 2 OR IDF_VERSION_MAJOR GREATER_EQUAL 5 )
257242 # These paths cannot currently be found by the IDF_COMPONENTS search loop above,
258243 # so add them explicitly.
259244 list (APPEND MICROPY_CPP_INC_EXTRA ${IDF_PATH} /components/soc/soc/${IDF_TARGET} /include )
260245 list (APPEND MICROPY_CPP_INC_EXTRA ${IDF_PATH} /components/soc/soc/include )
246+ if (IDF_VERSION_MINOR GREATER_EQUAL 3)
247+ list (APPEND MICROPY_CPP_INC_EXTRA ${IDF_PATH} /components/tinyusb/additions/include )
248+ list (APPEND MICROPY_CPP_INC_EXTRA ${IDF_PATH} /components/tinyusb/tinyusb/src)
249+ endif ()
261250endif ()
262251
263252# Include the main MicroPython cmake rules.
264- include (${MICROPY_DIR} /py/mkrules.cmake)
253+ include (${MICROPY_DIR} /py/mkrules.cmake)
0 commit comments