-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
WIP: esp32: Add support to build using IDF cmake, with MicroPython as a cmake component #6473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
31dd25e
0ddce69
35f6c3d
6f5e026
5ea9433
9d61245
c38f627
bf2ee6c
b6b68a3
cf4a64b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# CMake fragment for MicroPython extmod component | ||
|
||
set(MPY_EXTMOD_DIR "${MPY_DIR}/extmod") | ||
set(OOFATFS_DIR "${MPY_DIR}/lib/oofatfs") | ||
|
||
set(SOURCE_EXTMOD | ||
${MPY_EXTMOD_DIR}/machine_i2c.c | ||
${MPY_EXTMOD_DIR}/machine_mem.c | ||
${MPY_EXTMOD_DIR}/machine_pulse.c | ||
${MPY_EXTMOD_DIR}/machine_signal.c | ||
${MPY_EXTMOD_DIR}/machine_spi.c | ||
${MPY_EXTMOD_DIR}/modbtree.c | ||
${MPY_EXTMOD_DIR}/modframebuf.c | ||
${MPY_EXTMOD_DIR}/moduasyncio.c | ||
${MPY_EXTMOD_DIR}/modubinascii.c | ||
${MPY_EXTMOD_DIR}/moducryptolib.c | ||
${MPY_EXTMOD_DIR}/moductypes.c | ||
${MPY_EXTMOD_DIR}/moduhashlib.c | ||
${MPY_EXTMOD_DIR}/moduheapq.c | ||
${MPY_EXTMOD_DIR}/modujson.c | ||
${MPY_EXTMOD_DIR}/modurandom.c | ||
${MPY_EXTMOD_DIR}/modure.c | ||
${MPY_EXTMOD_DIR}/moduselect.c | ||
${MPY_EXTMOD_DIR}/modussl_axtls.c | ||
${MPY_EXTMOD_DIR}/modussl_mbedtls.c | ||
${MPY_EXTMOD_DIR}/modutimeq.c | ||
${MPY_EXTMOD_DIR}/moduwebsocket.c | ||
${MPY_EXTMOD_DIR}/moduzlib.c | ||
${MPY_EXTMOD_DIR}/modwebrepl.c | ||
${MPY_EXTMOD_DIR}/uos_dupterm.c | ||
${MPY_EXTMOD_DIR}/utime_mphal.c | ||
${MPY_EXTMOD_DIR}/vfs.c | ||
${MPY_EXTMOD_DIR}/vfs_blockdev.c | ||
${MPY_EXTMOD_DIR}/vfs_fat.c | ||
${MPY_EXTMOD_DIR}/vfs_fat_diskio.c | ||
${MPY_EXTMOD_DIR}/vfs_fat_file.c | ||
${MPY_EXTMOD_DIR}/vfs_lfs.c | ||
${MPY_EXTMOD_DIR}/vfs_posix.c | ||
${MPY_EXTMOD_DIR}/vfs_posix_file.c | ||
${MPY_EXTMOD_DIR}/vfs_reader.c | ||
${MPY_EXTMOD_DIR}/virtpin.c | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
set(SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig) | ||
set(SDKCONFIG_DEFAULTS boards/sdkconfig.base) | ||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(micropython) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# Set location of base MicroPython directory, and this port's directory. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this file have to be in a subdirectory? (I know nothing about cmake) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Or at least I couldn't work out how to put it in |
||
get_filename_component(MPY_DIR ${PROJECT_DIR}/../.. ABSOLUTE) | ||
set(MPY_PORT_DIR ${PROJECT_DIR}) | ||
set(MPY_BOARD_DIR ${PROJECT_DIR}/boards/GENERIC) | ||
|
||
# Include core source components. | ||
include(${MPY_DIR}/py/py.cmake) | ||
include(${MPY_DIR}/extmod/extmod.cmake) | ||
|
||
set(SOURCE_EXTMOD_EXTRA | ||
${MPY_DIR}/extmod/modonewire.c | ||
) | ||
|
||
set(SOURCE_LIB | ||
${MPY_DIR}/lib/littlefs/lfs1.c | ||
${MPY_DIR}/lib/littlefs/lfs1_util.c | ||
${MPY_DIR}/lib/littlefs/lfs2.c | ||
${MPY_DIR}/lib/littlefs/lfs2_util.c | ||
${MPY_DIR}/lib/mbedtls_errors/mp_mbedtls_errors.c | ||
${MPY_DIR}/lib/mp-readline/readline.c | ||
${MPY_DIR}/lib/netutils/netutils.c | ||
${MPY_DIR}/lib/oofatfs/ff.c | ||
${MPY_DIR}/lib/oofatfs/ffunicode.c | ||
${MPY_DIR}/lib/timeutils/timeutils.c | ||
${MPY_DIR}/lib/utils/interrupt_char.c | ||
${MPY_DIR}/lib/utils/stdout_helpers.c | ||
${MPY_DIR}/lib/utils/sys_stdio_mphal.c | ||
${MPY_DIR}/lib/utils/pyexec.c | ||
) | ||
|
||
set(SOURCE_DRIVERS | ||
${MPY_DIR}/drivers/bus/softspi.c | ||
${MPY_DIR}/drivers/dht/dht.c | ||
) | ||
|
||
set(SOURCE_PORT | ||
${PROJECT_DIR}/main.c | ||
${PROJECT_DIR}/uart.c | ||
${PROJECT_DIR}/gccollect.c | ||
${PROJECT_DIR}/mphalport.c | ||
${PROJECT_DIR}/fatfs_port.c | ||
${PROJECT_DIR}/help.c | ||
${PROJECT_DIR}/modutime.c | ||
${PROJECT_DIR}/moduos.c | ||
${PROJECT_DIR}/machine_timer.c | ||
${PROJECT_DIR}/machine_pin.c | ||
${PROJECT_DIR}/machine_touchpad.c | ||
${PROJECT_DIR}/machine_adc.c | ||
${PROJECT_DIR}/machine_dac.c | ||
${PROJECT_DIR}/machine_i2c.c | ||
${PROJECT_DIR}/machine_pwm.c | ||
${PROJECT_DIR}/machine_uart.c | ||
${PROJECT_DIR}/modmachine.c | ||
${PROJECT_DIR}/modnetwork.c | ||
${PROJECT_DIR}/network_lan.c | ||
${PROJECT_DIR}/network_ppp.c | ||
${PROJECT_DIR}/mpnimbleport.c | ||
${PROJECT_DIR}/modsocket.c | ||
${PROJECT_DIR}/modesp.c | ||
${PROJECT_DIR}/esp32_partition.c | ||
${PROJECT_DIR}/esp32_rmt.c | ||
${PROJECT_DIR}/esp32_ulp.c | ||
${PROJECT_DIR}/modesp32.c | ||
${PROJECT_DIR}/espneopixel.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(SOURCE_QSTR | ||
${SOURCE_PY} | ||
${SOURCE_EXTMOD} | ||
${SOURCE_EXTMOD_EXTRA} | ||
${SOURCE_LIB} | ||
${SOURCE_PORT} | ||
) | ||
|
||
# Register the main IDF component. | ||
idf_component_register( | ||
SRCS | ||
${SOURCE_PY} | ||
${SOURCE_EXTMOD} | ||
${SOURCE_EXTMOD_EXTRA} | ||
${SOURCE_LIB} | ||
${SOURCE_DRIVERS} | ||
${SOURCE_PORT} | ||
INCLUDE_DIRS | ||
${MPY_DIR} | ||
${MPY_PORT_DIR} | ||
${MPY_BOARD_DIR} | ||
${CMAKE_BINARY_DIR} | ||
REQUIRES | ||
soc nvs_flash ulp sdmmc mdns app_update lwip | ||
) | ||
|
||
# Define mpy-cross flags and frozen manifest | ||
set(MPY_CROSS_FLAGS -march=xtensawin) | ||
set(FROZEN_MANIFEST ${PROJECT_DIR}/boards/manifest.py) | ||
|
||
# Include the main MicroPython cmake rules. | ||
set(MICROPYTHON_TARGET ${COMPONENT_TARGET}) | ||
include(${MPY_DIR}/py/mkrules.cmake) | ||
|
||
# Set compile options for this port. | ||
target_compile_options(${MICROPYTHON_TARGET} PUBLIC | ||
-DMICROPY_ESP_IDF_4=1 | ||
-DMICROPY_VFS_FAT=1 | ||
-DMICROPY_VFS_LFS2=1 | ||
-DFFCONF_H=\"${OOFATFS_DIR}/ffconf.h\" | ||
-DLFS1_NO_MALLOC -DLFS1_NO_DEBUG -DLFS1_NO_WARN -DLFS1_NO_ERROR -DLFS1_NO_ASSERT | ||
-DLFS2_NO_MALLOC -DLFS2_NO_DEBUG -DLFS2_NO_WARN -DLFS2_NO_ERROR -DLFS2_NO_ASSERT | ||
) | ||
|
||
# Disable some warnings to keep the build output clean. | ||
target_compile_options(${MICROPYTHON_TARGET} PUBLIC | ||
-Wno-clobbered | ||
-Wno-deprecated-declarations | ||
-Wno-implicit-fallthrough | ||
-Wno-missing-field-initializers | ||
-Wno-override-init | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,6 @@ | |
#include "esp_wifi.h" | ||
#include "esp_log.h" | ||
#include "lwip/dns.h" | ||
#include "tcpip_adapter.h" | ||
#include "mdns.h" | ||
|
||
#if !MICROPY_ESP_IDF_4 | ||
|
@@ -491,7 +490,7 @@ STATIC mp_obj_t esp_ifconfig(size_t n_args, const mp_obj_t *args) { | |
tcpip_adapter_ip_info_t info; | ||
tcpip_adapter_dns_info_t dns_info; | ||
tcpip_adapter_get_ip_info(self->if_id, &info); | ||
tcpip_adapter_get_dns_info(self->if_id, TCPIP_ADAPTER_DNS_MAIN, &dns_info); | ||
tcpip_adapter_get_dns_info(self->if_id, ESP_NETIF_DNS_MAIN, &dns_info); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compat with older esp-idf? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure, but easy to make it compat. |
||
if (n_args == 1) { | ||
// get | ||
mp_obj_t tuple[4] = { | ||
|
@@ -526,14 +525,14 @@ STATIC mp_obj_t esp_ifconfig(size_t n_args, const mp_obj_t *args) { | |
_esp_exceptions(e); | ||
} | ||
ESP_EXCEPTIONS(tcpip_adapter_set_ip_info(self->if_id, &info)); | ||
ESP_EXCEPTIONS(tcpip_adapter_set_dns_info(self->if_id, TCPIP_ADAPTER_DNS_MAIN, &dns_info)); | ||
ESP_EXCEPTIONS(tcpip_adapter_set_dns_info(self->if_id, ESP_NETIF_DNS_MAIN, &dns_info)); | ||
} else if (self->if_id == WIFI_IF_AP) { | ||
esp_err_t e = tcpip_adapter_dhcps_stop(WIFI_IF_AP); | ||
if (e != ESP_OK && e != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STOPPED) { | ||
_esp_exceptions(e); | ||
} | ||
ESP_EXCEPTIONS(tcpip_adapter_set_ip_info(WIFI_IF_AP, &info)); | ||
ESP_EXCEPTIONS(tcpip_adapter_set_dns_info(WIFI_IF_AP, TCPIP_ADAPTER_DNS_MAIN, &dns_info)); | ||
ESP_EXCEPTIONS(tcpip_adapter_set_dns_info(WIFI_IF_AP, ESP_NETIF_DNS_MAIN, &dns_info)); | ||
ESP_EXCEPTIONS(tcpip_adapter_dhcps_start(WIFI_IF_AP)); | ||
} | ||
} else { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work with esp-idf pre-4.1? Or is the idea to deprecate the use of older esp-idf versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get that far, I just wanted to get something working and get feedback (will add WIP to the PR title).
We can continue to support older IDF versions if it's not difficult, but I'd rather just support the latest (easier to test, etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP, I just wanted to flag it.