blob: 2223ecd031d4497c83cea90c52cd022eceaae602 [file] [log] [blame]
Damien George9b908822020-09-23 15:55:55 +10001# Set location of base MicroPython directory.
2get_filename_component(MICROPY_DIR ${PROJECT_DIR}/../.. ABSOLUTE)
3
4# Include core source components.
5include(${MICROPY_DIR}/py/py.cmake)
Damien George9b908822020-09-23 15:55:55 +10006
Michael O'Cleirigh0ccd9e02021-03-27 17:10:39 -04007if(NOT CMAKE_BUILD_EARLY_EXPANSION)
8 include(${MICROPY_DIR}/py/usermod.cmake)
Damien George212fe7f2021-04-08 23:45:28 +10009 include(${MICROPY_DIR}/extmod/extmod.cmake)
Michael O'Cleirigh0ccd9e02021-03-27 17:10:39 -040010endif()
11
Damien George75db0b92021-02-21 11:33:15 +110012set(MICROPY_QSTRDEFS_PORT
13 ${PROJECT_DIR}/qstrdefsport.h
14)
15
Damien George9b908822020-09-23 15:55:55 +100016set(MICROPY_SOURCE_LIB
17 ${MICROPY_DIR}/lib/littlefs/lfs1.c
18 ${MICROPY_DIR}/lib/littlefs/lfs1_util.c
19 ${MICROPY_DIR}/lib/littlefs/lfs2.c
20 ${MICROPY_DIR}/lib/littlefs/lfs2_util.c
21 ${MICROPY_DIR}/lib/mbedtls_errors/mp_mbedtls_errors.c
22 ${MICROPY_DIR}/lib/mp-readline/readline.c
23 ${MICROPY_DIR}/lib/netutils/netutils.c
24 ${MICROPY_DIR}/lib/oofatfs/ff.c
25 ${MICROPY_DIR}/lib/oofatfs/ffunicode.c
26 ${MICROPY_DIR}/lib/timeutils/timeutils.c
27 ${MICROPY_DIR}/lib/utils/interrupt_char.c
Damien George9b908822020-09-23 15:55:55 +100028 ${MICROPY_DIR}/lib/utils/sys_stdio_mphal.c
29 ${MICROPY_DIR}/lib/utils/pyexec.c
30)
31
32set(MICROPY_SOURCE_DRIVERS
33 ${MICROPY_DIR}/drivers/bus/softspi.c
34 ${MICROPY_DIR}/drivers/dht/dht.c
35)
36
37set(MICROPY_SOURCE_PORT
38 ${PROJECT_DIR}/main.c
39 ${PROJECT_DIR}/uart.c
40 ${PROJECT_DIR}/gccollect.c
41 ${PROJECT_DIR}/mphalport.c
42 ${PROJECT_DIR}/fatfs_port.c
43 ${PROJECT_DIR}/help.c
44 ${PROJECT_DIR}/modutime.c
45 ${PROJECT_DIR}/moduos.c
46 ${PROJECT_DIR}/machine_timer.c
47 ${PROJECT_DIR}/machine_pin.c
48 ${PROJECT_DIR}/machine_touchpad.c
49 ${PROJECT_DIR}/machine_adc.c
50 ${PROJECT_DIR}/machine_dac.c
51 ${PROJECT_DIR}/machine_i2c.c
52 ${PROJECT_DIR}/machine_pwm.c
53 ${PROJECT_DIR}/machine_uart.c
54 ${PROJECT_DIR}/modmachine.c
55 ${PROJECT_DIR}/modnetwork.c
56 ${PROJECT_DIR}/network_lan.c
57 ${PROJECT_DIR}/network_ppp.c
58 ${PROJECT_DIR}/mpnimbleport.c
59 ${PROJECT_DIR}/modsocket.c
60 ${PROJECT_DIR}/modesp.c
Thorsten von Eickenc10d4312021-01-18 01:06:12 -080061 ${PROJECT_DIR}/esp32_nvs.c
Damien George9b908822020-09-23 15:55:55 +100062 ${PROJECT_DIR}/esp32_partition.c
63 ${PROJECT_DIR}/esp32_rmt.c
64 ${PROJECT_DIR}/esp32_ulp.c
65 ${PROJECT_DIR}/modesp32.c
66 ${PROJECT_DIR}/espneopixel.c
67 ${PROJECT_DIR}/machine_hw_spi.c
68 ${PROJECT_DIR}/machine_wdt.c
69 ${PROJECT_DIR}/mpthreadport.c
70 ${PROJECT_DIR}/machine_rtc.c
71 ${PROJECT_DIR}/machine_sdcard.c
72)
73
74set(MICROPY_SOURCE_QSTR
75 ${MICROPY_SOURCE_PY}
76 ${MICROPY_SOURCE_EXTMOD}
Michael O'Cleirigh0ccd9e02021-03-27 17:10:39 -040077 ${MICROPY_SOURCE_USERMOD}
Damien George9b908822020-09-23 15:55:55 +100078 ${MICROPY_SOURCE_LIB}
79 ${MICROPY_SOURCE_PORT}
80)
81
82set(IDF_COMPONENTS
83 app_update
84 bootloader_support
Damien Georgeda2b5fa2021-02-14 01:36:30 +110085 bt
Damien George9b908822020-09-23 15:55:55 +100086 driver
87 esp32
88 esp_common
89 esp_eth
90 esp_event
91 esp_ringbuf
92 esp_rom
93 esp_wifi
94 freertos
95 heap
96 log
97 lwip
98 mbedtls
99 mdns
100 newlib
101 nvs_flash
102 sdmmc
103 soc
104 spi_flash
105 tcpip_adapter
106 ulp
107 vfs
108 xtensa
109)
110
Damien Georged191d882021-02-15 21:00:01 +1100111if(IDF_VERSION_MINOR GREATER_EQUAL 1)
112 list(APPEND IDF_COMPONENTS esp_netif)
113endif()
114
Damien Georgea9150022021-02-15 21:00:09 +1100115if(IDF_VERSION_MINOR GREATER_EQUAL 2)
116 list(APPEND IDF_COMPONENTS esp_system)
117 list(APPEND IDF_COMPONENTS esp_timer)
118endif()
119
Damien George143372a2021-02-19 10:38:01 +1100120if(IDF_VERSION_MINOR GREATER_EQUAL 3)
121 list(APPEND IDF_COMPONENTS esp_hw_support)
122 list(APPEND IDF_COMPONENTS esp_pm)
123 list(APPEND IDF_COMPONENTS hal)
124endif()
125
Damien George9b908822020-09-23 15:55:55 +1000126# Register the main IDF component.
127idf_component_register(
128 SRCS
129 ${MICROPY_SOURCE_PY}
130 ${MICROPY_SOURCE_EXTMOD}
Damien George9b908822020-09-23 15:55:55 +1000131 ${MICROPY_SOURCE_LIB}
132 ${MICROPY_SOURCE_DRIVERS}
133 ${MICROPY_SOURCE_PORT}
134 INCLUDE_DIRS
Damien George5dcc9b32021-04-09 00:59:16 +1000135 ${MICROPY_INC_CORE}
Michael O'Cleirigh0ccd9e02021-03-27 17:10:39 -0400136 ${MICROPY_INC_USERMOD}
Damien George9b908822020-09-23 15:55:55 +1000137 ${MICROPY_PORT_DIR}
138 ${MICROPY_BOARD_DIR}
139 ${CMAKE_BINARY_DIR}
140 REQUIRES
141 ${IDF_COMPONENTS}
142)
143
144# Set the MicroPython target as the current (main) IDF component target.
145set(MICROPY_TARGET ${COMPONENT_TARGET})
146
147# Define mpy-cross flags, for use with frozen code.
148set(MICROPY_CROSS_FLAGS -march=xtensawin)
149
150# Set compile options for this port.
151target_compile_definitions(${MICROPY_TARGET} PUBLIC
152 MICROPY_ESP_IDF_4=1
153 MICROPY_VFS_FAT=1
154 MICROPY_VFS_LFS2=1
155 FFCONF_H=\"${MICROPY_OOFATFS_DIR}/ffconf.h\"
156 LFS1_NO_MALLOC LFS1_NO_DEBUG LFS1_NO_WARN LFS1_NO_ERROR LFS1_NO_ASSERT
157 LFS2_NO_MALLOC LFS2_NO_DEBUG LFS2_NO_WARN LFS2_NO_ERROR LFS2_NO_ASSERT
158)
159
160# Disable some warnings to keep the build output clean.
161target_compile_options(${MICROPY_TARGET} PUBLIC
162 -Wno-clobbered
163 -Wno-deprecated-declarations
164 -Wno-missing-field-initializers
165)
166
Michael O'Cleirigh0ccd9e02021-03-27 17:10:39 -0400167# add usermod
168target_link_libraries(${MICROPY_TARGET} usermod)
169
170
Damien George9b908822020-09-23 15:55:55 +1000171# Collect all of the include directories and compile definitions for the IDF components.
172foreach(comp ${IDF_COMPONENTS})
Damien George0fabda32021-04-08 23:42:22 +1000173 micropy_gather_target_properties(__idf_${comp})
Damien George9b908822020-09-23 15:55:55 +1000174endforeach()
175
Damien Georgea9150022021-02-15 21:00:09 +1100176if(IDF_VERSION_MINOR GREATER_EQUAL 2)
177 # These paths cannot currently be found by the IDF_COMPONENTS search loop above,
178 # so add them explicitly.
179 list(APPEND MICROPY_CPP_INC_EXTRA ${IDF_PATH}/components/soc/soc/${IDF_TARGET}/include)
180 list(APPEND MICROPY_CPP_INC_EXTRA ${IDF_PATH}/components/soc/soc/include)
181endif()
182
Damien George9b908822020-09-23 15:55:55 +1000183# Include the main MicroPython cmake rules.
184include(${MICROPY_DIR}/py/mkrules.cmake)