2023-04-04 01:36:02 +01:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
2021-01-20 13:34:08 +00:00
|
|
|
|
|
|
|
# Set build type to reduce firmware size
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE MinSizeRel)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Set main target and component locations
|
2021-03-14 04:52:33 +00:00
|
|
|
set(MICROPY_TARGET firmware)
|
|
|
|
get_filename_component(MICROPY_DIR "../.." ABSOLUTE)
|
2021-01-20 13:34:08 +00:00
|
|
|
if (PICO_SDK_PATH_OVERRIDE)
|
|
|
|
set(PICO_SDK_PATH ${PICO_SDK_PATH_OVERRIDE})
|
|
|
|
else()
|
|
|
|
set(PICO_SDK_PATH ../../lib/pico-sdk)
|
|
|
|
endif()
|
|
|
|
|
2021-02-03 05:33:55 +00:00
|
|
|
# Use the local tinyusb instead of the one in pico-sdk
|
2021-03-14 04:52:33 +00:00
|
|
|
set(PICO_TINYUSB_PATH ${MICROPY_DIR}/lib/tinyusb)
|
2022-06-30 07:01:02 +01:00
|
|
|
# Use the local lwip instead of the one in pico-sdk
|
|
|
|
set(PICO_LWIP_PATH ${MICROPY_DIR}/lib/lwip)
|
2022-07-13 13:08:09 +01:00
|
|
|
# Use the local btstack instead of the one in pico-sdk
|
|
|
|
set(PICO_BTSTACK_PATH ${MICROPY_DIR}/lib/btstack)
|
2021-02-03 05:33:55 +00:00
|
|
|
|
2021-04-05 21:57:18 +01:00
|
|
|
# Set the location of this port's directory.
|
2023-06-12 21:15:56 +01:00
|
|
|
set(MICROPY_PORT_DIR ${CMAKE_CURRENT_LIST_DIR})
|
2021-04-05 21:57:18 +01:00
|
|
|
|
|
|
|
# Set the board if it's not already set.
|
|
|
|
if(NOT MICROPY_BOARD)
|
2023-08-16 04:13:01 +01:00
|
|
|
set(MICROPY_BOARD RPI_PICO)
|
2021-04-05 21:57:18 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Set the board directory and check that it exists.
|
|
|
|
if(NOT MICROPY_BOARD_DIR)
|
|
|
|
set(MICROPY_BOARD_DIR ${MICROPY_PORT_DIR}/boards/${MICROPY_BOARD})
|
|
|
|
endif()
|
2023-05-04 21:25:52 +01:00
|
|
|
get_filename_component(MICROPY_BOARD_DIR ${MICROPY_BOARD_DIR} ABSOLUTE)
|
2021-04-05 21:57:18 +01:00
|
|
|
if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
|
|
|
|
message(FATAL_ERROR "Invalid MICROPY_BOARD specified: ${MICROPY_BOARD}")
|
|
|
|
endif()
|
|
|
|
|
2022-03-09 21:28:52 +00:00
|
|
|
set(MICROPY_USER_FROZEN_MANIFEST ${MICROPY_FROZEN_MANIFEST})
|
|
|
|
|
|
|
|
# Include board config, it may override MICROPY_FROZEN_MANIFEST
|
2021-04-05 21:57:18 +01:00
|
|
|
include(${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
|
|
|
|
|
2022-01-06 05:49:57 +00:00
|
|
|
# Set the PICO_BOARD if it's not already set (allow a board to override it).
|
|
|
|
if(NOT PICO_BOARD)
|
|
|
|
string(TOLOWER ${MICROPY_BOARD} PICO_BOARD)
|
|
|
|
endif()
|
|
|
|
|
2023-04-04 01:36:02 +01:00
|
|
|
# Set the amount of C heap, if it's not already set.
|
|
|
|
# If a board uses malloc then it must set this to at least 4096.
|
|
|
|
if(NOT MICROPY_C_HEAP_SIZE)
|
|
|
|
set(MICROPY_C_HEAP_SIZE 0)
|
|
|
|
endif()
|
|
|
|
|
2022-06-08 03:21:51 +01:00
|
|
|
# Enable extmod components that will be configured by extmod.cmake.
|
|
|
|
# A board may also have enabled additional components.
|
|
|
|
set(MICROPY_SSL_MBEDTLS ON)
|
|
|
|
|
2022-07-04 02:21:58 +01:00
|
|
|
# Use the local cyw43_driver instead of the one in pico-sdk
|
|
|
|
if (MICROPY_PY_NETWORK_CYW43)
|
|
|
|
set(PICO_CYW43_DRIVER_PATH ${MICROPY_DIR}/lib/cyw43-driver)
|
|
|
|
endif()
|
|
|
|
|
2022-07-08 06:26:06 +01:00
|
|
|
# Necessary submodules for all boards.
|
|
|
|
string(CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/mbedtls)
|
|
|
|
string(CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/tinyusb)
|
|
|
|
|
2021-01-20 13:34:08 +00:00
|
|
|
# Include component cmake fragments
|
2021-03-14 04:52:33 +00:00
|
|
|
include(${MICROPY_DIR}/py/py.cmake)
|
|
|
|
include(${MICROPY_DIR}/extmod/extmod.cmake)
|
2021-01-20 13:34:08 +00:00
|
|
|
include(${PICO_SDK_PATH}/pico_sdk_init.cmake)
|
|
|
|
|
|
|
|
# Define the top-level project
|
2021-03-14 04:52:33 +00:00
|
|
|
project(${MICROPY_TARGET})
|
2021-01-20 13:34:08 +00:00
|
|
|
|
|
|
|
pico_sdk_init()
|
|
|
|
|
2021-02-23 22:57:14 +00:00
|
|
|
include(${MICROPY_DIR}/py/usermod.cmake)
|
|
|
|
|
2021-03-14 04:52:33 +00:00
|
|
|
add_executable(${MICROPY_TARGET})
|
|
|
|
|
|
|
|
set(MICROPY_QSTRDEFS_PORT
|
2023-06-12 21:15:56 +01:00
|
|
|
${MICROPY_PORT_DIR}/qstrdefsport.h
|
2021-03-14 04:52:33 +00: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/oofatfs/ff.c
|
|
|
|
${MICROPY_DIR}/lib/oofatfs/ffunicode.c
|
2022-06-30 07:01:02 +01:00
|
|
|
${MICROPY_DIR}/shared/netutils/dhcpserver.c
|
2021-08-15 17:30:18 +01:00
|
|
|
${MICROPY_DIR}/shared/netutils/netutils.c
|
2022-05-05 03:32:22 +01:00
|
|
|
${MICROPY_DIR}/shared/netutils/trace.c
|
2021-07-09 05:19:15 +01:00
|
|
|
${MICROPY_DIR}/shared/readline/readline.c
|
2023-01-23 20:53:39 +00:00
|
|
|
${MICROPY_DIR}/shared/runtime/gchelper_thumb1.s
|
2021-07-09 05:19:15 +01:00
|
|
|
${MICROPY_DIR}/shared/runtime/gchelper_native.c
|
2022-03-30 22:00:46 +01:00
|
|
|
${MICROPY_DIR}/shared/runtime/interrupt_char.c
|
2021-07-09 05:19:15 +01:00
|
|
|
${MICROPY_DIR}/shared/runtime/mpirq.c
|
|
|
|
${MICROPY_DIR}/shared/runtime/pyexec.c
|
|
|
|
${MICROPY_DIR}/shared/runtime/stdout_helpers.c
|
2023-11-14 02:21:13 +00:00
|
|
|
${MICROPY_DIR}/shared/runtime/softtimer.c
|
2021-07-09 05:19:15 +01:00
|
|
|
${MICROPY_DIR}/shared/runtime/sys_stdio_mphal.c
|
|
|
|
${MICROPY_DIR}/shared/timeutils/timeutils.c
|
2022-10-04 00:25:56 +01:00
|
|
|
${MICROPY_DIR}/shared/tinyusb/mp_cdc_common.c
|
|
|
|
${MICROPY_DIR}/shared/tinyusb/mp_usbd.c
|
|
|
|
${MICROPY_DIR}/shared/tinyusb/mp_usbd_descriptor.c
|
2021-01-20 13:34:08 +00:00
|
|
|
)
|
|
|
|
|
2021-03-14 04:52:33 +00:00
|
|
|
set(MICROPY_SOURCE_DRIVERS
|
|
|
|
${MICROPY_DIR}/drivers/bus/softspi.c
|
2022-01-02 13:07:33 +00:00
|
|
|
${MICROPY_DIR}/drivers/dht/dht.c
|
2021-01-20 13:34:08 +00:00
|
|
|
)
|
|
|
|
|
2021-03-14 04:52:33 +00:00
|
|
|
set(MICROPY_SOURCE_PORT
|
2021-02-03 22:59:36 +00:00
|
|
|
fatfs_port.c
|
2023-05-31 07:37:23 +01:00
|
|
|
help.c
|
2021-09-15 17:16:05 +01:00
|
|
|
machine_bitstream.c
|
2021-01-20 13:34:08 +00:00
|
|
|
machine_i2c.c
|
|
|
|
machine_pin.c
|
2021-02-18 18:45:23 +00:00
|
|
|
machine_rtc.c
|
2021-01-20 13:34:08 +00:00
|
|
|
machine_spi.c
|
|
|
|
machine_timer.c
|
|
|
|
main.c
|
|
|
|
modrp2.c
|
|
|
|
mphalport.c
|
2022-06-07 05:33:09 +01:00
|
|
|
mpnetworkport.c
|
2021-01-20 13:34:08 +00:00
|
|
|
mpthreadport.c
|
2024-01-02 03:45:44 +00:00
|
|
|
mutex_extra.c
|
2022-06-30 05:53:05 +01:00
|
|
|
pendsv.c
|
2021-01-20 13:34:08 +00:00
|
|
|
rp2_flash.c
|
|
|
|
rp2_pio.c
|
rp2/rp2_dma: Introduce a new rp2.DMA class for control over DMA xfers.
This commit implements fairly complete support for the DMA controller in
the rp2 series of microcontrollers. It provides a class for accessing the
DMA channels through a high-level, Pythonic interface, and functions for
setting and manipulating the DMA channel configurations.
Creating an instance of the rp2.DMA class claims one of the processor's DMA
channels. A sensible, per-channel default value for the ctrl register can
be fetched from the DMA.pack_ctrl() function, and the components of this
register can be set via keyword arguments to pack_ctrl().
The read, write, count and ctrl attributes of the DMA class provide
read/write access to the respective registers of the DMA controller. The
config() method allows any or all of these values to be set simultaneously
and adds a trigger keyword argument to allow the setup to immediately be
triggered. The read and write attributes (or keywords in config()) accept
either actual addresses or any object that supports the buffer interface.
The active() method provides read/write control of the channel's activity,
allowing the user to start and stop the channel and test if it is running.
Standard MicroPython interrupt handlers are supported through the irq()
method and the channel can be released either by deleting it and allowing
it to be garbage-collected or with the explicit close() method.
Direct, unfettered access to the DMA controllers registers is provided
through a proxy memoryview() object returned by the DMA.registers attribute
that maps directly onto the memory-mapped registers. This is necessary for
more fine-grained control and is helpful for allowing chaining of DMA
channels.
As a simple example, using DMA to do a fast memory copy just needs:
src = bytearray(32*1024)
dest = bytearray(32*1024)
dma = rp2.DMA()
dma.config(read=src, write=dest, count=len(src) // 4,
ctrl=dma.pack_ctrl(), trigger=True)
# Wait for completion
while dma.active():
pass
This API aims to strike a balance between simplicity and comprehensiveness.
Signed-off-by: Nicko van Someren <nicko@nicko.org>
Signed-off-by: Damien George <damien@micropython.org>
2023-09-30 23:54:47 +01:00
|
|
|
rp2_dma.c
|
2021-01-20 13:34:08 +00:00
|
|
|
uart.c
|
2022-09-18 03:34:09 +01:00
|
|
|
usbd.c
|
2021-06-15 23:55:09 +01:00
|
|
|
msc_disk.c
|
2022-05-05 03:50:15 +01:00
|
|
|
mbedtls/mbedtls_port.c
|
2022-10-25 19:45:00 +01:00
|
|
|
${CMAKE_BINARY_DIR}/pins_${MICROPY_BOARD}.c
|
2021-01-20 13:34:08 +00:00
|
|
|
)
|
|
|
|
|
2021-03-14 04:52:33 +00:00
|
|
|
set(MICROPY_SOURCE_QSTR
|
|
|
|
${MICROPY_SOURCE_PY}
|
2022-07-01 20:06:10 +01:00
|
|
|
${MICROPY_DIR}/shared/readline/readline.c
|
2021-07-09 05:19:15 +01:00
|
|
|
${MICROPY_DIR}/shared/runtime/mpirq.c
|
|
|
|
${MICROPY_DIR}/shared/runtime/sys_stdio_mphal.c
|
2023-06-12 21:15:56 +01:00
|
|
|
${MICROPY_PORT_DIR}/machine_adc.c
|
|
|
|
${MICROPY_PORT_DIR}/machine_i2c.c
|
|
|
|
${MICROPY_PORT_DIR}/machine_pin.c
|
|
|
|
${MICROPY_PORT_DIR}/machine_rtc.c
|
|
|
|
${MICROPY_PORT_DIR}/machine_spi.c
|
|
|
|
${MICROPY_PORT_DIR}/machine_timer.c
|
|
|
|
${MICROPY_PORT_DIR}/machine_uart.c
|
|
|
|
${MICROPY_PORT_DIR}/machine_wdt.c
|
|
|
|
${MICROPY_PORT_DIR}/modrp2.c
|
|
|
|
${MICROPY_PORT_DIR}/modos.c
|
|
|
|
${MICROPY_PORT_DIR}/rp2_flash.c
|
|
|
|
${MICROPY_PORT_DIR}/rp2_pio.c
|
rp2/rp2_dma: Introduce a new rp2.DMA class for control over DMA xfers.
This commit implements fairly complete support for the DMA controller in
the rp2 series of microcontrollers. It provides a class for accessing the
DMA channels through a high-level, Pythonic interface, and functions for
setting and manipulating the DMA channel configurations.
Creating an instance of the rp2.DMA class claims one of the processor's DMA
channels. A sensible, per-channel default value for the ctrl register can
be fetched from the DMA.pack_ctrl() function, and the components of this
register can be set via keyword arguments to pack_ctrl().
The read, write, count and ctrl attributes of the DMA class provide
read/write access to the respective registers of the DMA controller. The
config() method allows any or all of these values to be set simultaneously
and adds a trigger keyword argument to allow the setup to immediately be
triggered. The read and write attributes (or keywords in config()) accept
either actual addresses or any object that supports the buffer interface.
The active() method provides read/write control of the channel's activity,
allowing the user to start and stop the channel and test if it is running.
Standard MicroPython interrupt handlers are supported through the irq()
method and the channel can be released either by deleting it and allowing
it to be garbage-collected or with the explicit close() method.
Direct, unfettered access to the DMA controllers registers is provided
through a proxy memoryview() object returned by the DMA.registers attribute
that maps directly onto the memory-mapped registers. This is necessary for
more fine-grained control and is helpful for allowing chaining of DMA
channels.
As a simple example, using DMA to do a fast memory copy just needs:
src = bytearray(32*1024)
dest = bytearray(32*1024)
dma = rp2.DMA()
dma.config(read=src, write=dest, count=len(src) // 4,
ctrl=dma.pack_ctrl(), trigger=True)
# Wait for completion
while dma.active():
pass
This API aims to strike a balance between simplicity and comprehensiveness.
Signed-off-by: Nicko van Someren <nicko@nicko.org>
Signed-off-by: Damien George <damien@micropython.org>
2023-09-30 23:54:47 +01:00
|
|
|
${MICROPY_PORT_DIR}/rp2_dma.c
|
2022-10-25 19:45:00 +01:00
|
|
|
${CMAKE_BINARY_DIR}/pins_${MICROPY_BOARD}.c
|
2021-01-20 13:34:08 +00:00
|
|
|
)
|
|
|
|
|
2021-03-14 04:52:33 +00:00
|
|
|
set(PICO_SDK_COMPONENTS
|
2022-06-30 05:53:05 +01:00
|
|
|
cmsis_core
|
2021-03-14 04:52:33 +00:00
|
|
|
hardware_adc
|
|
|
|
hardware_base
|
|
|
|
hardware_clocks
|
|
|
|
hardware_dma
|
|
|
|
hardware_flash
|
|
|
|
hardware_gpio
|
|
|
|
hardware_i2c
|
|
|
|
hardware_irq
|
|
|
|
hardware_pio
|
2022-06-28 15:22:49 +01:00
|
|
|
hardware_pll
|
2021-03-14 04:52:33 +00:00
|
|
|
hardware_pwm
|
|
|
|
hardware_regs
|
|
|
|
hardware_rtc
|
|
|
|
hardware_spi
|
|
|
|
hardware_structs
|
|
|
|
hardware_sync
|
|
|
|
hardware_timer
|
|
|
|
hardware_uart
|
|
|
|
hardware_watchdog
|
2022-06-28 15:22:49 +01:00
|
|
|
hardware_xosc
|
2021-03-14 04:52:33 +00:00
|
|
|
pico_base_headers
|
|
|
|
pico_binary_info
|
|
|
|
pico_bootrom
|
|
|
|
pico_multicore
|
|
|
|
pico_platform
|
|
|
|
pico_stdio
|
|
|
|
pico_stdlib
|
|
|
|
pico_sync
|
|
|
|
pico_time
|
|
|
|
pico_unique_id
|
2021-02-18 18:45:23 +00:00
|
|
|
pico_util
|
2021-05-11 03:46:18 +01:00
|
|
|
tinyusb_common
|
2021-03-14 04:52:33 +00:00
|
|
|
tinyusb_device
|
|
|
|
)
|
2021-01-20 13:34:08 +00:00
|
|
|
|
2023-12-05 05:38:44 +00:00
|
|
|
# Use our custom pico_float_micropython float implementation. This is needed for two reasons:
|
|
|
|
# - to fix inf handling in pico-sdk's __wrap___aeabi_fadd();
|
|
|
|
# - so we can use our own libm functions, to fix inaccuracies in the pico-sdk versions.
|
|
|
|
pico_set_float_implementation(${MICROPY_TARGET} micropython)
|
|
|
|
|
|
|
|
# Define our custom pico_float_micropython component.
|
|
|
|
pico_add_library(pico_float_micropython)
|
|
|
|
|
|
|
|
# pico_float_micropython: add pico-sdk float and our libm source files.
|
|
|
|
target_sources(pico_float_micropython INTERFACE
|
|
|
|
${PICO_SDK_PATH}/src/rp2_common/pico_float/float_aeabi.S
|
|
|
|
${PICO_SDK_PATH}/src/rp2_common/pico_float/float_init_rom.c
|
|
|
|
${PICO_SDK_PATH}/src/rp2_common/pico_float/float_v1_rom_shim.S
|
2023-12-08 04:42:41 +00:00
|
|
|
${MICROPY_SOURCE_LIB_LIBM}
|
|
|
|
${MICROPY_SOURCE_LIB_LIBM_SQRT_SW}
|
2023-12-05 05:38:44 +00:00
|
|
|
${MICROPY_PORT_DIR}/libm_extra.c
|
|
|
|
)
|
|
|
|
|
|
|
|
# pico_float_micropython: wrap low-level floating-point ops, to call the pico-sdk versions.
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_fdiv)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_fmul)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_frsub)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_fsub)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_cfcmpeq)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_cfrcmple)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_cfcmple)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_fcmpeq)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_fcmplt)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_fcmple)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_fcmpge)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_fcmpgt)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_fcmpun)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_i2f)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_l2f)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_ui2f)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_ul2f)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_f2iz)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_f2lz)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_f2uiz)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_f2ulz)
|
|
|
|
pico_wrap_function(pico_float_micropython __aeabi_f2d)
|
|
|
|
|
2022-05-05 03:32:22 +01:00
|
|
|
if (MICROPY_PY_LWIP)
|
|
|
|
target_link_libraries(${MICROPY_TARGET} micropy_lib_lwip)
|
|
|
|
|
|
|
|
target_include_directories(${MICROPY_TARGET} PRIVATE
|
|
|
|
lwip_inc
|
|
|
|
)
|
|
|
|
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
|
|
|
MICROPY_PY_LWIP=1
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-07-22 13:42:52 +01:00
|
|
|
if(MICROPY_PY_BLUETOOTH)
|
|
|
|
list(APPEND MICROPY_SOURCE_PORT mpbthciport.c)
|
|
|
|
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
|
|
|
MICROPY_PY_BLUETOOTH=1
|
2021-09-14 21:22:17 +01:00
|
|
|
MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS=1
|
2021-07-22 13:42:52 +01:00
|
|
|
MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE=1
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2022-07-13 13:08:09 +01:00
|
|
|
if (MICROPY_PY_BLUETOOTH_CYW43)
|
|
|
|
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
|
|
|
CYW43_ENABLE_BLUETOOTH=1
|
|
|
|
MICROPY_PY_BLUETOOTH_CYW43=1
|
|
|
|
)
|
|
|
|
|
|
|
|
if (MICROPY_BLUETOOTH_BTSTACK)
|
|
|
|
target_link_libraries(${MICROPY_TARGET}
|
|
|
|
pico_btstack_hci_transport_cyw43
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (MICROPY_BLUETOOTH_BTSTACK)
|
|
|
|
string(CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/btstack)
|
|
|
|
|
|
|
|
list(APPEND MICROPY_SOURCE_PORT mpbtstackport.c)
|
|
|
|
|
|
|
|
include(${MICROPY_DIR}/extmod/btstack/btstack.cmake)
|
|
|
|
target_link_libraries(${MICROPY_TARGET} micropy_extmod_btstack)
|
|
|
|
|
|
|
|
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
|
|
|
MICROPY_BLUETOOTH_BTSTACK=1
|
|
|
|
MICROPY_BLUETOOTH_BTSTACK_CONFIG_FILE=\"btstack_inc/btstack_config.h\"
|
|
|
|
)
|
|
|
|
|
|
|
|
# For modbluetooth_btstack.c includes
|
|
|
|
get_target_property(BTSTACK_INCLUDE micropy_extmod_btstack INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
list(APPEND MICROPY_INC_CORE ${BTSTACK_INCLUDE})
|
|
|
|
endif()
|
|
|
|
|
2021-07-22 13:42:52 +01:00
|
|
|
if(MICROPY_BLUETOOTH_NIMBLE)
|
2022-07-04 02:16:20 +01:00
|
|
|
string(CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/mynewt-nimble)
|
|
|
|
if(NOT (${ECHO_SUBMODULES}) AND NOT EXISTS ${MICROPY_DIR}/lib/mynewt-nimble/nimble/host/include/host/ble_hs.h)
|
|
|
|
message(FATAL_ERROR " mynewt-nimble not initialized.\n Run 'make BOARD=${MICROPY_BOARD} submodules'")
|
|
|
|
endif()
|
|
|
|
|
2021-07-22 13:42:52 +01:00
|
|
|
list(APPEND MICROPY_SOURCE_PORT mpnimbleport.c)
|
|
|
|
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
|
|
|
MICROPY_BLUETOOTH_NIMBLE=1
|
|
|
|
MICROPY_BLUETOOTH_NIMBLE_BINDINGS_ONLY=0
|
2022-07-13 13:08:09 +01:00
|
|
|
MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING=1
|
|
|
|
MICROPY_PY_BLUETOOTH_ENABLE_L2CAP_CHANNELS=1
|
2021-07-22 13:42:52 +01:00
|
|
|
)
|
|
|
|
target_compile_options(${MICROPY_TARGET} PRIVATE
|
|
|
|
# TODO: This flag is currently needed to make nimble build.
|
|
|
|
-Wno-unused-but-set-variable
|
|
|
|
)
|
|
|
|
include(${MICROPY_DIR}/extmod/nimble/nimble.cmake)
|
|
|
|
target_link_libraries(${MICROPY_TARGET} micropy_extmod_nimble)
|
|
|
|
get_target_property(NIMBLE_INCLUDE micropy_extmod_nimble INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
list(APPEND MICROPY_INC_CORE ${NIMBLE_INCLUDE})
|
|
|
|
endif()
|
|
|
|
|
2022-09-18 03:34:09 +01:00
|
|
|
# tinyusb helper
|
|
|
|
target_include_directories(${MICROPY_TARGET} PRIVATE
|
|
|
|
${MICROPY_DIR}/shared/tinyusb/
|
|
|
|
)
|
|
|
|
|
2022-06-30 07:01:02 +01:00
|
|
|
if (MICROPY_PY_NETWORK_CYW43)
|
|
|
|
string(CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/cyw43-driver)
|
2022-07-04 02:16:20 +01:00
|
|
|
if((NOT (${ECHO_SUBMODULES})) AND NOT EXISTS ${MICROPY_DIR}/lib/cyw43-driver/src/cyw43.h)
|
|
|
|
message(FATAL_ERROR " cyw43-driver not initialized.\n Run 'make BOARD=${MICROPY_BOARD} submodules'")
|
|
|
|
endif()
|
2022-06-30 07:01:02 +01:00
|
|
|
|
|
|
|
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
|
|
|
MICROPY_PY_NETWORK_CYW43=1
|
|
|
|
MICROPY_PY_SOCKET_DEFAULT_TIMEOUT_MS=30000 # default socket timeout
|
|
|
|
)
|
|
|
|
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
|
|
|
CYW43_USE_STATS=1
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2022-10-25 17:43:38 +01:00
|
|
|
list(APPEND MICROPY_SOURCE_PORT
|
|
|
|
machine_pin_cyw43.c
|
|
|
|
)
|
|
|
|
|
2022-06-30 07:01:02 +01:00
|
|
|
target_link_libraries(${MICROPY_TARGET}
|
|
|
|
cyw43_driver_picow
|
|
|
|
cmsis_core
|
|
|
|
)
|
2022-07-13 13:08:09 +01:00
|
|
|
target_include_directories(${MICROPY_TARGET} PRIVATE
|
|
|
|
${MICROPY_DIR}/lib/cyw43-driver/
|
|
|
|
)
|
|
|
|
|
2022-06-30 07:01:02 +01:00
|
|
|
endif()
|
|
|
|
|
2021-09-14 21:22:17 +01:00
|
|
|
if (MICROPY_PY_NETWORK_NINAW10)
|
|
|
|
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
|
|
|
MICROPY_PY_NETWORK_NINAW10=1
|
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(${MICROPY_TARGET} PRIVATE
|
|
|
|
${MICROPY_DIR}/drivers/ninaw10/
|
|
|
|
)
|
|
|
|
|
|
|
|
# Enable NINA-W10 WiFi and Bluetooth drivers.
|
|
|
|
list(APPEND MICROPY_SOURCE_DRIVERS
|
|
|
|
${MICROPY_DIR}/drivers/ninaw10/nina_bt_hci.c
|
|
|
|
${MICROPY_DIR}/drivers/ninaw10/nina_wifi_drv.c
|
|
|
|
${MICROPY_DIR}/drivers/ninaw10/nina_wifi_bsp.c
|
2022-10-25 21:35:30 +01:00
|
|
|
${MICROPY_DIR}/drivers/ninaw10/machine_pin_nina.c
|
2021-09-14 21:22:17 +01:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2022-06-07 05:41:25 +01:00
|
|
|
if (MICROPY_PY_NETWORK_WIZNET5K)
|
2022-07-08 06:26:06 +01:00
|
|
|
string(CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/wiznet5k)
|
|
|
|
if((NOT (${ECHO_SUBMODULES})) AND NOT EXISTS ${MICROPY_DIR}/lib/wiznet5k/README.md)
|
|
|
|
message(FATAL_ERROR " wiznet5k not initialized.\n Run 'make BOARD=${MICROPY_BOARD} submodules'")
|
|
|
|
endif()
|
|
|
|
|
2022-05-05 08:26:16 +01:00
|
|
|
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
2022-06-07 05:41:25 +01:00
|
|
|
MICROPY_PY_NETWORK_WIZNET5K=1
|
2022-05-05 08:26:16 +01:00
|
|
|
WIZCHIP_PREFIXED_EXPORTS=1
|
2022-06-07 05:41:25 +01:00
|
|
|
_WIZCHIP_=${MICROPY_PY_NETWORK_WIZNET5K}
|
2022-05-05 08:26:16 +01:00
|
|
|
WIZCHIP_YIELD=mpy_wiznet_yield
|
|
|
|
)
|
|
|
|
|
|
|
|
if (MICROPY_PY_LWIP)
|
|
|
|
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
|
|
|
# When using MACRAW mode (with lwIP), maximum buffer space must be used for the raw socket
|
|
|
|
WIZCHIP_USE_MAX_BUFFER=1
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_include_directories(${MICROPY_TARGET} PRIVATE
|
|
|
|
${MICROPY_DIR}/lib/wiznet5k/
|
|
|
|
${MICROPY_DIR}/lib/wiznet5k/Ethernet/
|
|
|
|
)
|
|
|
|
|
|
|
|
list(APPEND MICROPY_SOURCE_LIB
|
|
|
|
${MICROPY_DIR}/lib/wiznet5k/Ethernet/W5100/w5100.c
|
|
|
|
${MICROPY_DIR}/lib/wiznet5k/Ethernet/W5100S/w5100s.c
|
|
|
|
${MICROPY_DIR}/lib/wiznet5k/Ethernet/W5200/w5200.c
|
|
|
|
${MICROPY_DIR}/lib/wiznet5k/Ethernet/W5300/w5300.c
|
|
|
|
${MICROPY_DIR}/lib/wiznet5k/Ethernet/W5500/w5500.c
|
|
|
|
${MICROPY_DIR}/lib/wiznet5k/Ethernet/socket.c
|
|
|
|
${MICROPY_DIR}/lib/wiznet5k/Ethernet/wizchip_conf.c
|
|
|
|
${MICROPY_DIR}/lib/wiznet5k/Internet/DNS/dns.c
|
|
|
|
${MICROPY_DIR}/lib/wiznet5k/Internet/DHCP/dhcp.c
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2022-06-07 05:33:09 +01:00
|
|
|
# Add qstr sources for extmod and usermod, in case they are modified by components above.
|
|
|
|
list(APPEND MICROPY_SOURCE_QSTR
|
|
|
|
${MICROPY_SOURCE_EXTMOD}
|
|
|
|
${MICROPY_SOURCE_USERMOD}
|
|
|
|
)
|
|
|
|
|
2022-03-09 21:28:52 +00:00
|
|
|
# Define mpy-cross flags
|
2022-07-12 12:26:31 +01:00
|
|
|
set(MICROPY_CROSS_FLAGS -march=armv6m)
|
2022-03-09 21:28:52 +00:00
|
|
|
|
|
|
|
# Set the frozen manifest file
|
|
|
|
if (MICROPY_USER_FROZEN_MANIFEST)
|
|
|
|
set(MICROPY_FROZEN_MANIFEST ${MICROPY_USER_FROZEN_MANIFEST})
|
|
|
|
elseif (NOT MICROPY_FROZEN_MANIFEST)
|
2023-06-12 21:15:56 +01:00
|
|
|
set(MICROPY_FROZEN_MANIFEST ${MICROPY_PORT_DIR}/boards/manifest.py)
|
2021-08-07 12:24:14 +01:00
|
|
|
endif()
|
2021-03-14 04:52:33 +00:00
|
|
|
|
|
|
|
target_sources(${MICROPY_TARGET} PRIVATE
|
|
|
|
${MICROPY_SOURCE_PY}
|
|
|
|
${MICROPY_SOURCE_EXTMOD}
|
|
|
|
${MICROPY_SOURCE_LIB}
|
|
|
|
${MICROPY_SOURCE_DRIVERS}
|
|
|
|
${MICROPY_SOURCE_PORT}
|
2021-01-20 13:34:08 +00:00
|
|
|
)
|
|
|
|
|
2022-04-01 00:22:00 +01:00
|
|
|
target_link_libraries(${MICROPY_TARGET} micropy_lib_mbedtls)
|
2022-05-05 03:50:15 +01:00
|
|
|
|
2021-02-23 22:57:14 +00:00
|
|
|
target_link_libraries(${MICROPY_TARGET} usermod)
|
|
|
|
|
2021-03-14 04:52:33 +00:00
|
|
|
target_include_directories(${MICROPY_TARGET} PRIVATE
|
2021-04-08 15:59:16 +01:00
|
|
|
${MICROPY_INC_CORE}
|
2021-02-23 22:57:14 +00:00
|
|
|
${MICROPY_INC_USERMOD}
|
2021-04-05 21:57:18 +01:00
|
|
|
${MICROPY_BOARD_DIR}
|
2023-06-12 21:15:56 +01:00
|
|
|
"${MICROPY_PORT_DIR}"
|
2021-03-14 04:52:33 +00:00
|
|
|
"${CMAKE_BINARY_DIR}"
|
|
|
|
)
|
2021-01-20 13:34:08 +00:00
|
|
|
|
2021-03-14 04:52:33 +00:00
|
|
|
target_compile_options(${MICROPY_TARGET} PRIVATE
|
2021-01-20 13:34:08 +00:00
|
|
|
-Wall
|
2021-03-14 04:52:33 +00:00
|
|
|
-Werror
|
2023-10-05 03:09:40 +01:00
|
|
|
-g # always include debug information in the ELF
|
2021-01-20 13:34:08 +00:00
|
|
|
)
|
|
|
|
|
2023-04-04 01:36:02 +01:00
|
|
|
target_link_options(${MICROPY_TARGET} PRIVATE
|
|
|
|
-Wl,--defsym=__micropy_c_heap_size__=${MICROPY_C_HEAP_SIZE}
|
2023-10-25 03:50:53 +01:00
|
|
|
-Wl,--wrap=dcd_event_handler
|
2023-04-04 01:36:02 +01:00
|
|
|
)
|
|
|
|
|
2021-06-30 03:47:40 +01:00
|
|
|
set_source_files_properties(
|
|
|
|
${PICO_SDK_PATH}/src/rp2_common/pico_double/double_math.c
|
|
|
|
${PICO_SDK_PATH}/src/rp2_common/pico_float/float_math.c
|
|
|
|
PROPERTIES
|
|
|
|
COMPILE_OPTIONS "-Wno-error=uninitialized"
|
|
|
|
)
|
|
|
|
|
|
|
|
set_source_files_properties(
|
|
|
|
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/dcd_rp2040.c
|
|
|
|
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/rp2040_usb.c
|
|
|
|
PROPERTIES
|
|
|
|
COMPILE_OPTIONS "-Wno-error=array-bounds;-Wno-error=unused-but-set-variable"
|
|
|
|
)
|
|
|
|
|
2021-03-14 04:52:33 +00:00
|
|
|
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
|
|
|
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
|
2021-01-20 13:34:08 +00:00
|
|
|
PICO_FLOAT_PROPAGATE_NANS=1
|
|
|
|
PICO_STACK_SIZE=0x2000
|
|
|
|
PICO_CORE1_STACK_SIZE=0
|
|
|
|
PICO_PROGRAM_NAME="MicroPython"
|
|
|
|
PICO_NO_PROGRAM_VERSION_STRING=1 # do it ourselves in main.c
|
|
|
|
MICROPY_BUILD_TYPE="${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} ${CMAKE_BUILD_TYPE}"
|
|
|
|
PICO_NO_BI_STDIO_UART=1 # we call it UART REPL
|
2021-04-01 03:36:26 +01:00
|
|
|
PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1
|
2021-01-20 13:34:08 +00:00
|
|
|
)
|
|
|
|
|
2021-03-14 04:52:33 +00:00
|
|
|
target_link_libraries(${MICROPY_TARGET}
|
|
|
|
${PICO_SDK_COMPONENTS}
|
2021-01-20 13:34:08 +00:00
|
|
|
)
|
|
|
|
|
2021-08-20 13:03:14 +01:00
|
|
|
if (MICROPY_HW_ENABLE_DOUBLE_TAP)
|
|
|
|
# Enable double tap reset into bootrom.
|
|
|
|
target_link_libraries(${MICROPY_TARGET}
|
|
|
|
pico_bootsel_via_double_reset
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-01-20 13:34:08 +00:00
|
|
|
# todo this is a bit brittle, but we want to move a few source files into RAM (which requires
|
|
|
|
# a linker script modification) until we explicitly add macro calls around the function
|
|
|
|
# defs to move them into RAM.
|
|
|
|
if (PICO_ON_DEVICE AND NOT PICO_NO_FLASH AND NOT PICO_COPY_TO_RAM)
|
2021-03-14 04:52:33 +00:00
|
|
|
pico_set_linker_script(${MICROPY_TARGET} ${CMAKE_CURRENT_LIST_DIR}/memmap_mp.ld)
|
2021-01-20 13:34:08 +00:00
|
|
|
endif()
|
|
|
|
|
2021-03-14 04:52:33 +00:00
|
|
|
pico_add_extra_outputs(${MICROPY_TARGET})
|
2021-01-20 13:34:08 +00:00
|
|
|
|
2022-08-09 13:21:05 +01:00
|
|
|
pico_find_compiler(PICO_COMPILER_SIZE ${PICO_GCC_TRIPLE}-size)
|
|
|
|
|
2021-03-14 04:52:33 +00:00
|
|
|
add_custom_command(TARGET ${MICROPY_TARGET}
|
2021-01-20 13:34:08 +00:00
|
|
|
POST_BUILD
|
2022-08-09 13:21:05 +01:00
|
|
|
COMMAND ${PICO_COMPILER_SIZE} --format=berkeley ${PROJECT_BINARY_DIR}/${MICROPY_TARGET}.elf
|
2021-01-20 13:34:08 +00:00
|
|
|
VERBATIM
|
|
|
|
)
|
2021-03-14 04:52:33 +00:00
|
|
|
|
|
|
|
# Collect all the include directories and compile definitions for the pico-sdk components.
|
|
|
|
foreach(comp ${PICO_SDK_COMPONENTS})
|
2021-04-08 14:42:22 +01:00
|
|
|
micropy_gather_target_properties(${comp})
|
|
|
|
micropy_gather_target_properties(${comp}_headers)
|
2021-03-14 04:52:33 +00:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# Include the main MicroPython cmake rules.
|
|
|
|
include(${MICROPY_DIR}/py/mkrules.cmake)
|
2022-10-25 19:45:00 +01:00
|
|
|
|
|
|
|
set(MICROPY_BOARDS_DIR "${MICROPY_PORT_DIR}/boards")
|
|
|
|
set(GEN_PINS_AF_CSV "${MICROPY_BOARDS_DIR}/rp2_af.csv")
|
|
|
|
set(GEN_PINS_PREFIX "${MICROPY_BOARDS_DIR}/rp2_prefix.c")
|
|
|
|
set(GEN_PINS_MKPINS "${MICROPY_BOARDS_DIR}/make-pins.py")
|
|
|
|
set(GEN_PINS_SRC "${CMAKE_BINARY_DIR}/pins_${MICROPY_BOARD}.c")
|
|
|
|
set(GEN_PINS_HDR "${MICROPY_GENHDR_DIR}/pins.h")
|
|
|
|
|
|
|
|
if(EXISTS "${MICROPY_BOARDS_DIR}/${MICROPY_BOARD}/pins.csv")
|
|
|
|
set(GEN_PINS_BOARD_CSV "${MICROPY_BOARDS_DIR}/${MICROPY_BOARD}/pins.csv")
|
2023-08-03 07:48:52 +01:00
|
|
|
set(GEN_PINS_CSV_ARG --board-csv "${GEN_PINS_BOARD_CSV}")
|
2022-10-25 19:45:00 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
target_sources(${MICROPY_TARGET} PRIVATE
|
|
|
|
${GEN_PINS_HDR}
|
|
|
|
)
|
|
|
|
|
|
|
|
# Generate pins
|
|
|
|
add_custom_command(
|
2023-08-03 05:41:25 +01:00
|
|
|
OUTPUT ${GEN_PINS_HDR} ${GEN_PINS_SRC}
|
2023-08-03 07:48:52 +01:00
|
|
|
COMMAND ${Python3_EXECUTABLE} ${GEN_PINS_MKPINS} ${GEN_PINS_CSV_ARG} --af-csv ${GEN_PINS_AF_CSV} --prefix ${GEN_PINS_PREFIX} --output-source ${GEN_PINS_SRC} --output-header ${GEN_PINS_HDR}
|
2022-10-25 19:45:00 +01:00
|
|
|
DEPENDS
|
|
|
|
${GEN_PINS_AF_CSV}
|
|
|
|
${GEN_PINS_BOARD_CSV}
|
|
|
|
${GEN_PINS_MKPINS}
|
|
|
|
${GEN_PINS_PREFIX}
|
|
|
|
${MICROPY_MPVERSION}
|
|
|
|
VERBATIM
|
|
|
|
COMMAND_EXPAND_LISTS
|
|
|
|
)
|