2020-09-23 01:55:55 -04:00
|
|
|
# Set location of base MicroPython directory.
|
2021-06-24 02:03:25 -04:00
|
|
|
if(NOT MICROPY_DIR)
|
|
|
|
get_filename_component(MICROPY_DIR ${PROJECT_DIR}/../.. ABSOLUTE)
|
|
|
|
endif()
|
2020-09-23 01:55:55 -04:00
|
|
|
|
|
|
|
# Include core source components.
|
|
|
|
include(${MICROPY_DIR}/py/py.cmake)
|
|
|
|
|
2021-03-27 17:10:39 -04:00
|
|
|
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
|
|
|
|
include(${MICROPY_DIR}/py/usermod.cmake)
|
2021-04-08 09:45:28 -04:00
|
|
|
include(${MICROPY_DIR}/extmod/extmod.cmake)
|
2021-03-27 17:10:39 -04:00
|
|
|
endif()
|
|
|
|
|
2021-02-20 19:33:15 -05:00
|
|
|
set(MICROPY_QSTRDEFS_PORT
|
|
|
|
${PROJECT_DIR}/qstrdefsport.h
|
|
|
|
)
|
|
|
|
|
2021-07-09 00:19:15 -04:00
|
|
|
set(MICROPY_SOURCE_SHARED
|
|
|
|
${MICROPY_DIR}/shared/readline/readline.c
|
|
|
|
${MICROPY_DIR}/shared/netutils/netutils.c
|
|
|
|
${MICROPY_DIR}/shared/timeutils/timeutils.c
|
|
|
|
${MICROPY_DIR}/shared/runtime/interrupt_char.c
|
|
|
|
${MICROPY_DIR}/shared/runtime/stdout_helpers.c
|
|
|
|
${MICROPY_DIR}/shared/runtime/sys_stdio_mphal.c
|
|
|
|
${MICROPY_DIR}/shared/runtime/pyexec.c
|
|
|
|
)
|
|
|
|
|
2020-09-23 01:55:55 -04:00
|
|
|
set(MICROPY_SOURCE_LIB
|
|
|
|
${MICROPY_DIR}/lib/littlefs/lfs1.c
|
|
|
|
${MICROPY_DIR}/lib/littlefs/lfs1_util.c
|
|
|
|
${MICROPY_DIR}/lib/littlefs/lfs2.c
|
|
|
|
${MICROPY_DIR}/lib/littlefs/lfs2_util.c
|
|
|
|
${MICROPY_DIR}/lib/mbedtls_errors/mp_mbedtls_errors.c
|
|
|
|
${MICROPY_DIR}/lib/oofatfs/ff.c
|
|
|
|
${MICROPY_DIR}/lib/oofatfs/ffunicode.c
|
|
|
|
)
|
esp32: Add initial support for ESP32C3 SoCs.
Supported features for this SoC are:
- UART REPL, filesystem
- Pin, ADC, PWM, SoftI2C, SoftSPI, Timer, RTC
- OneWire, DHT, NeoPixel
- RMT
- WiFi, Bluetooth
Signed-off-by: Damien George <damien@micropython.org>
2021-07-17 22:11:21 -04:00
|
|
|
if(IDF_TARGET STREQUAL "esp32c3")
|
|
|
|
list(APPEND MICROPY_SOURCE_LIB ${MICROPY_DIR}/shared/runtime/gchelper_generic.c)
|
|
|
|
endif()
|
2020-09-23 01:55:55 -04:00
|
|
|
|
|
|
|
set(MICROPY_SOURCE_DRIVERS
|
|
|
|
${MICROPY_DIR}/drivers/bus/softspi.c
|
|
|
|
${MICROPY_DIR}/drivers/dht/dht.c
|
|
|
|
)
|
|
|
|
|
|
|
|
set(MICROPY_SOURCE_PORT
|
|
|
|
${PROJECT_DIR}/main.c
|
|
|
|
${PROJECT_DIR}/uart.c
|
2021-02-18 20:08:11 -05:00
|
|
|
${PROJECT_DIR}/usb.c
|
2021-08-26 14:19:46 -04:00
|
|
|
${PROJECT_DIR}/usb_serial_jtag.c
|
2020-09-23 01:55:55 -04:00
|
|
|
${PROJECT_DIR}/gccollect.c
|
|
|
|
${PROJECT_DIR}/mphalport.c
|
|
|
|
${PROJECT_DIR}/fatfs_port.c
|
|
|
|
${PROJECT_DIR}/help.c
|
|
|
|
${PROJECT_DIR}/modutime.c
|
2021-08-11 00:26:23 -04:00
|
|
|
${PROJECT_DIR}/machine_bitstream.c
|
2020-09-23 01:55:55 -04:00
|
|
|
${PROJECT_DIR}/machine_timer.c
|
|
|
|
${PROJECT_DIR}/machine_pin.c
|
|
|
|
${PROJECT_DIR}/machine_touchpad.c
|
|
|
|
${PROJECT_DIR}/machine_adc.c
|
2021-12-21 10:15:24 -05:00
|
|
|
${PROJECT_DIR}/machine_adcblock.c
|
2020-09-23 01:55:55 -04:00
|
|
|
${PROJECT_DIR}/machine_dac.c
|
|
|
|
${PROJECT_DIR}/machine_i2c.c
|
2021-04-17 00:27:40 -04:00
|
|
|
${PROJECT_DIR}/machine_i2s.c
|
2020-09-23 01:55:55 -04:00
|
|
|
${PROJECT_DIR}/machine_uart.c
|
|
|
|
${PROJECT_DIR}/modmachine.c
|
|
|
|
${PROJECT_DIR}/modnetwork.c
|
|
|
|
${PROJECT_DIR}/network_lan.c
|
|
|
|
${PROJECT_DIR}/network_ppp.c
|
2021-09-21 10:35:46 -04:00
|
|
|
${PROJECT_DIR}/network_wlan.c
|
2020-09-23 01:55:55 -04:00
|
|
|
${PROJECT_DIR}/mpnimbleport.c
|
|
|
|
${PROJECT_DIR}/modsocket.c
|
|
|
|
${PROJECT_DIR}/modesp.c
|
2021-01-18 04:06:12 -05:00
|
|
|
${PROJECT_DIR}/esp32_nvs.c
|
2020-09-23 01:55:55 -04:00
|
|
|
${PROJECT_DIR}/esp32_partition.c
|
|
|
|
${PROJECT_DIR}/esp32_rmt.c
|
|
|
|
${PROJECT_DIR}/esp32_ulp.c
|
|
|
|
${PROJECT_DIR}/modesp32.c
|
|
|
|
${PROJECT_DIR}/machine_hw_spi.c
|
|
|
|
${PROJECT_DIR}/machine_wdt.c
|
|
|
|
${PROJECT_DIR}/mpthreadport.c
|
|
|
|
${PROJECT_DIR}/machine_rtc.c
|
|
|
|
${PROJECT_DIR}/machine_sdcard.c
|
|
|
|
)
|
|
|
|
|
|
|
|
set(MICROPY_SOURCE_QSTR
|
|
|
|
${MICROPY_SOURCE_PY}
|
|
|
|
${MICROPY_SOURCE_EXTMOD}
|
2021-03-27 17:10:39 -04:00
|
|
|
${MICROPY_SOURCE_USERMOD}
|
2021-07-09 00:19:15 -04:00
|
|
|
${MICROPY_SOURCE_SHARED}
|
2020-09-23 01:55:55 -04:00
|
|
|
${MICROPY_SOURCE_LIB}
|
|
|
|
${MICROPY_SOURCE_PORT}
|
2021-09-21 10:00:26 -04:00
|
|
|
${MICROPY_SOURCE_BOARD}
|
2020-09-23 01:55:55 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
set(IDF_COMPONENTS
|
|
|
|
app_update
|
|
|
|
bootloader_support
|
2021-02-13 09:36:30 -05:00
|
|
|
bt
|
2020-09-23 01:55:55 -04:00
|
|
|
driver
|
2021-12-21 10:15:24 -05:00
|
|
|
esp_adc_cal
|
2020-09-23 01:55:55 -04:00
|
|
|
esp_common
|
|
|
|
esp_eth
|
|
|
|
esp_event
|
|
|
|
esp_ringbuf
|
|
|
|
esp_rom
|
|
|
|
esp_wifi
|
|
|
|
freertos
|
|
|
|
heap
|
|
|
|
log
|
|
|
|
lwip
|
|
|
|
mbedtls
|
|
|
|
mdns
|
|
|
|
newlib
|
|
|
|
nvs_flash
|
|
|
|
sdmmc
|
|
|
|
soc
|
|
|
|
spi_flash
|
|
|
|
tcpip_adapter
|
|
|
|
ulp
|
|
|
|
vfs
|
|
|
|
xtensa
|
|
|
|
)
|
|
|
|
|
2021-11-04 09:50:39 -04:00
|
|
|
if(IDF_VERSION_MINOR GREATER_EQUAL 1 OR IDF_VERSION_MAJOR GREATER_EQUAL 5)
|
2021-02-15 05:00:01 -05:00
|
|
|
list(APPEND IDF_COMPONENTS esp_netif)
|
|
|
|
endif()
|
|
|
|
|
2021-11-04 09:50:39 -04:00
|
|
|
if(IDF_VERSION_MINOR GREATER_EQUAL 2 OR IDF_VERSION_MAJOR GREATER_EQUAL 5)
|
2021-02-15 05:00:09 -05:00
|
|
|
list(APPEND IDF_COMPONENTS esp_system)
|
|
|
|
list(APPEND IDF_COMPONENTS esp_timer)
|
|
|
|
endif()
|
|
|
|
|
2021-11-04 09:50:39 -04:00
|
|
|
if(IDF_VERSION_MINOR GREATER_EQUAL 3 OR IDF_VERSION_MAJOR GREATER_EQUAL 5)
|
2021-02-18 18:38:01 -05:00
|
|
|
list(APPEND IDF_COMPONENTS esp_hw_support)
|
|
|
|
list(APPEND IDF_COMPONENTS esp_pm)
|
|
|
|
list(APPEND IDF_COMPONENTS hal)
|
|
|
|
endif()
|
|
|
|
|
2021-02-18 05:24:34 -05:00
|
|
|
if(IDF_TARGET STREQUAL "esp32")
|
|
|
|
list(APPEND IDF_COMPONENTS esp32)
|
esp32: Add initial support for ESP32C3 SoCs.
Supported features for this SoC are:
- UART REPL, filesystem
- Pin, ADC, PWM, SoftI2C, SoftSPI, Timer, RTC
- OneWire, DHT, NeoPixel
- RMT
- WiFi, Bluetooth
Signed-off-by: Damien George <damien@micropython.org>
2021-07-17 22:11:21 -04:00
|
|
|
elseif(IDF_TARGET STREQUAL "esp32c3")
|
|
|
|
list(APPEND IDF_COMPONENTS esp32c3)
|
|
|
|
list(APPEND IDF_COMPONENTS riscv)
|
2021-02-18 05:24:34 -05:00
|
|
|
elseif(IDF_TARGET STREQUAL "esp32s2")
|
|
|
|
list(APPEND IDF_COMPONENTS esp32s2)
|
2021-02-18 20:08:11 -05:00
|
|
|
list(APPEND IDF_COMPONENTS tinyusb)
|
2021-05-05 20:58:12 -04:00
|
|
|
elseif(IDF_TARGET STREQUAL "esp32s3")
|
|
|
|
list(APPEND IDF_COMPONENTS esp32s3)
|
|
|
|
list(APPEND IDF_COMPONENTS tinyusb)
|
2021-02-18 05:24:34 -05:00
|
|
|
endif()
|
|
|
|
|
2020-09-23 01:55:55 -04:00
|
|
|
# Register the main IDF component.
|
|
|
|
idf_component_register(
|
|
|
|
SRCS
|
|
|
|
${MICROPY_SOURCE_PY}
|
|
|
|
${MICROPY_SOURCE_EXTMOD}
|
2021-07-09 00:19:15 -04:00
|
|
|
${MICROPY_SOURCE_SHARED}
|
2020-09-23 01:55:55 -04:00
|
|
|
${MICROPY_SOURCE_LIB}
|
|
|
|
${MICROPY_SOURCE_DRIVERS}
|
|
|
|
${MICROPY_SOURCE_PORT}
|
2021-09-21 10:00:26 -04:00
|
|
|
${MICROPY_SOURCE_BOARD}
|
2020-09-23 01:55:55 -04:00
|
|
|
INCLUDE_DIRS
|
2021-04-08 10:59:16 -04:00
|
|
|
${MICROPY_INC_CORE}
|
2021-03-27 17:10:39 -04:00
|
|
|
${MICROPY_INC_USERMOD}
|
2020-09-23 01:55:55 -04:00
|
|
|
${MICROPY_PORT_DIR}
|
|
|
|
${MICROPY_BOARD_DIR}
|
|
|
|
${CMAKE_BINARY_DIR}
|
|
|
|
REQUIRES
|
|
|
|
${IDF_COMPONENTS}
|
|
|
|
)
|
|
|
|
|
|
|
|
# Set the MicroPython target as the current (main) IDF component target.
|
|
|
|
set(MICROPY_TARGET ${COMPONENT_TARGET})
|
|
|
|
|
|
|
|
# Define mpy-cross flags, for use with frozen code.
|
|
|
|
set(MICROPY_CROSS_FLAGS -march=xtensawin)
|
|
|
|
|
|
|
|
# Set compile options for this port.
|
|
|
|
target_compile_definitions(${MICROPY_TARGET} PUBLIC
|
2021-04-08 09:56:28 -04:00
|
|
|
${MICROPY_DEF_CORE}
|
2020-09-23 01:55:55 -04:00
|
|
|
MICROPY_ESP_IDF_4=1
|
|
|
|
MICROPY_VFS_FAT=1
|
|
|
|
MICROPY_VFS_LFS2=1
|
|
|
|
FFCONF_H=\"${MICROPY_OOFATFS_DIR}/ffconf.h\"
|
|
|
|
LFS1_NO_MALLOC LFS1_NO_DEBUG LFS1_NO_WARN LFS1_NO_ERROR LFS1_NO_ASSERT
|
|
|
|
LFS2_NO_MALLOC LFS2_NO_DEBUG LFS2_NO_WARN LFS2_NO_ERROR LFS2_NO_ASSERT
|
|
|
|
)
|
|
|
|
|
|
|
|
# Disable some warnings to keep the build output clean.
|
|
|
|
target_compile_options(${MICROPY_TARGET} PUBLIC
|
|
|
|
-Wno-clobbered
|
|
|
|
-Wno-deprecated-declarations
|
|
|
|
-Wno-missing-field-initializers
|
|
|
|
)
|
|
|
|
|
2021-04-08 09:56:28 -04:00
|
|
|
# Add additional extmod and usermod components.
|
|
|
|
target_link_libraries(${MICROPY_TARGET} micropy_extmod_btree)
|
2021-03-27 17:10:39 -04:00
|
|
|
target_link_libraries(${MICROPY_TARGET} usermod)
|
|
|
|
|
|
|
|
|
2020-09-23 01:55:55 -04:00
|
|
|
# Collect all of the include directories and compile definitions for the IDF components.
|
|
|
|
foreach(comp ${IDF_COMPONENTS})
|
2021-04-08 09:42:22 -04:00
|
|
|
micropy_gather_target_properties(__idf_${comp})
|
2020-09-23 01:55:55 -04:00
|
|
|
endforeach()
|
|
|
|
|
2021-11-04 09:50:39 -04:00
|
|
|
if(IDF_VERSION_MINOR GREATER_EQUAL 2 OR IDF_VERSION_MAJOR GREATER_EQUAL 5)
|
2021-02-15 05:00:09 -05:00
|
|
|
# These paths cannot currently be found by the IDF_COMPONENTS search loop above,
|
|
|
|
# so add them explicitly.
|
|
|
|
list(APPEND MICROPY_CPP_INC_EXTRA ${IDF_PATH}/components/soc/soc/${IDF_TARGET}/include)
|
|
|
|
list(APPEND MICROPY_CPP_INC_EXTRA ${IDF_PATH}/components/soc/soc/include)
|
2021-02-18 20:08:11 -05:00
|
|
|
if(IDF_VERSION_MINOR GREATER_EQUAL 3)
|
|
|
|
list(APPEND MICROPY_CPP_INC_EXTRA ${IDF_PATH}/components/tinyusb/additions/include)
|
|
|
|
list(APPEND MICROPY_CPP_INC_EXTRA ${IDF_PATH}/components/tinyusb/tinyusb/src)
|
|
|
|
endif()
|
2021-02-15 05:00:09 -05:00
|
|
|
endif()
|
|
|
|
|
2020-09-23 01:55:55 -04:00
|
|
|
# Include the main MicroPython cmake rules.
|
|
|
|
include(${MICROPY_DIR}/py/mkrules.cmake)
|