2021-11-30 05:51:48 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
include(ExternalProject)
|
|
|
|
|
|
|
|
if(CONFIG_HAS_RPI_PICO)
|
|
|
|
zephyr_library()
|
|
|
|
|
|
|
|
set(rp2_common_dir ${ZEPHYR_HAL_RPI_PICO_MODULE_DIR}/src/rp2_common)
|
|
|
|
set(rp2040_dir ${ZEPHYR_HAL_RPI_PICO_MODULE_DIR}/src/rp2040)
|
|
|
|
set(common_dir ${ZEPHYR_HAL_RPI_PICO_MODULE_DIR}/src/common)
|
|
|
|
set(boot_stage_dir ${rp2_common_dir}/boot_stage2)
|
|
|
|
|
|
|
|
# The Second Stage Bootloader is only linked to the app that resides
|
|
|
|
# at 0x100. Therefore, only if the app's offset is 0x100, the second
|
|
|
|
# stage bootloader should be compiled.
|
|
|
|
if(CONFIG_RP2_REQUIRES_SECOND_STAGE_BOOT)
|
|
|
|
foreach(flash W25Q080 GENERIC_03H IS25LP080 W25X10CL AT25SF128A)
|
|
|
|
if(CONFIG_RP2_FLASH_${flash})
|
|
|
|
set(flash_type ${flash})
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(rp2_bootloader_prefix ${CMAKE_BINARY_DIR}/bootloader)
|
2022-06-16 23:40:58 +08:00
|
|
|
set(rp2_bootloader_asm ${rp2_bootloader_prefix}/boot_stage2.S)
|
|
|
|
|
2021-11-30 05:51:48 +08:00
|
|
|
ExternalProject_Add(
|
|
|
|
second_stage_bootloader
|
|
|
|
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/bootloader
|
|
|
|
BINARY_DIR ${rp2_bootloader_prefix}
|
|
|
|
CMAKE_ARGS
|
2022-05-02 05:36:49 +08:00
|
|
|
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
2021-11-30 05:51:48 +08:00
|
|
|
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
|
|
|
-DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
|
|
|
|
-DZEPHYR_HAL_RPI_PICO_MODULE_DIR=${ZEPHYR_HAL_RPI_PICO_MODULE_DIR}
|
|
|
|
-DZEPHYR_BASE=${ZEPHYR_BASE}
|
|
|
|
-DFLASH_TYPE=${flash_type}
|
|
|
|
-DPYTHON_EXECUTABLE=${Python3_EXECUTABLE}
|
2022-06-16 23:40:58 +08:00
|
|
|
-DRP2_BOOTLOADER_BYPRODUCT=${rp2_bootloader_asm}
|
2021-11-30 05:51:48 +08:00
|
|
|
INSTALL_COMMAND "" # No installation needed
|
2022-06-16 23:40:58 +08:00
|
|
|
BUILD_BYPRODUCTS ${rp2_bootloader_asm}
|
2021-11-30 05:51:48 +08:00
|
|
|
BUILD_ALWAYS TRUE
|
|
|
|
)
|
2022-06-16 23:40:58 +08:00
|
|
|
|
|
|
|
add_dependencies(${ZEPHYR_CURRENT_LIBRARY} second_stage_bootloader)
|
|
|
|
zephyr_library_sources(${rp2_bootloader_asm})
|
2021-11-30 05:51:48 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Pico sources and headers necessary for every build.
|
|
|
|
# These contain definitions and implementation used mostly for
|
|
|
|
# initializing the SoC, and therefore are always required.
|
|
|
|
|
|
|
|
zephyr_library_sources(
|
|
|
|
${rp2_common_dir}/hardware_clocks/clocks.c
|
|
|
|
${rp2_common_dir}/hardware_pll/pll.c
|
|
|
|
${rp2_common_dir}/hardware_xosc/xosc.c
|
|
|
|
${rp2_common_dir}/hardware_watchdog/watchdog.c
|
|
|
|
${rp2_common_dir}/pico_platform/platform.c
|
2022-02-08 01:49:21 +08:00
|
|
|
${rp2_common_dir}/pico_bootrom/bootrom.c
|
2021-11-30 05:51:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
zephyr_include_directories(
|
|
|
|
${rp2_common_dir}/hardware_base/include
|
|
|
|
${rp2_common_dir}/hardware_clocks/include
|
|
|
|
${rp2_common_dir}/hardware_watchdog/include
|
|
|
|
${rp2_common_dir}/hardware_xosc/include
|
|
|
|
${rp2_common_dir}/hardware_pll/include
|
|
|
|
${rp2_common_dir}/hardware_irq/include
|
|
|
|
${rp2_common_dir}/hardware_sync/include
|
|
|
|
${rp2_common_dir}/hardware_timer/include
|
|
|
|
${rp2_common_dir}/hardware_resets/include
|
2022-02-08 01:49:21 +08:00
|
|
|
${rp2_common_dir}/pico_bootrom/include
|
2021-11-30 05:51:48 +08:00
|
|
|
${rp2040_dir}/hardware_regs/include
|
|
|
|
${rp2040_dir}/hardware_structs/include
|
|
|
|
${common_dir}/pico_base/include
|
|
|
|
${rp2_common_dir}/pico_platform/include
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
zephyr_library_sources_ifdef(CONFIG_PICOSDK_USE_GPIO
|
|
|
|
${rp2_common_dir}/hardware_gpio/gpio.c)
|
|
|
|
zephyr_include_directories_ifdef(CONFIG_PICOSDK_USE_GPIO
|
|
|
|
${rp2_common_dir}/hardware_gpio/include)
|
|
|
|
|
|
|
|
zephyr_library_sources_ifdef(CONFIG_PICOSDK_USE_UART
|
|
|
|
${rp2_common_dir}/hardware_uart/uart.c)
|
|
|
|
zephyr_include_directories_ifdef(CONFIG_PICOSDK_USE_UART
|
|
|
|
${rp2_common_dir}/hardware_uart/include)
|
2022-02-08 03:31:06 +08:00
|
|
|
|
|
|
|
zephyr_library_sources_ifdef(CONFIG_PICOSDK_USE_FLASH
|
|
|
|
${rp2_common_dir}/hardware_flash/flash.c)
|
|
|
|
zephyr_include_directories_ifdef(CONFIG_PICOSDK_USE_FLASH
|
|
|
|
${rp2_common_dir}/hardware_flash/include)
|
|
|
|
|
2022-02-19 04:16:04 +08:00
|
|
|
zephyr_include_directories_ifdef(CONFIG_PICOSDK_USE_PWM
|
|
|
|
${rp2_common_dir}/hardware_pwm/include)
|
|
|
|
|
2022-05-18 22:38:29 +08:00
|
|
|
zephyr_library_sources_ifdef(CONFIG_PICOSDK_USE_ADC
|
|
|
|
${rp2_common_dir}/hardware_adc/adc.c)
|
|
|
|
zephyr_include_directories_ifdef(CONFIG_PICOSDK_USE_ADC
|
|
|
|
${rp2_common_dir}/hardware_adc/include)
|
|
|
|
|
2023-01-18 07:57:14 +08:00
|
|
|
zephyr_library_sources_ifdef(CONFIG_PICOSDK_USE_DMA
|
|
|
|
${rp2_common_dir}/hardware_dma/dma.c)
|
|
|
|
zephyr_include_directories_ifdef(CONFIG_PICOSDK_USE_DMA
|
|
|
|
${rp2_common_dir}/hardware_dma/include)
|
|
|
|
|
2023-04-21 11:26:50 +08:00
|
|
|
zephyr_library_sources_ifdef(CONFIG_PICOSDK_USE_TIMER
|
|
|
|
${rp2_common_dir}/hardware_timer/timer.c)
|
|
|
|
zephyr_include_directories_ifdef(CONFIG_PICOSDK_USE_TIMER
|
|
|
|
${rp2_common_dir}/hardware_timer/include)
|
|
|
|
|
2023-01-18 07:57:14 +08:00
|
|
|
zephyr_library_sources_ifdef(CONFIG_PICOSDK_USE_CLAIM
|
|
|
|
${rp2_common_dir}/hardware_claim/claim.c)
|
|
|
|
zephyr_include_directories_ifdef(CONFIG_PICOSDK_USE_CLAIM
|
|
|
|
${rp2_common_dir}/hardware_claim/include)
|
|
|
|
|
2022-02-08 03:31:06 +08:00
|
|
|
# Some flash driver functions must be executed from the RAM.
|
|
|
|
# Originally pico-sdk places them in the RW data section, so this
|
|
|
|
# implementation does the same.
|
|
|
|
zephyr_linker_sources_ifdef(CONFIG_PICOSDK_USE_FLASH RWDATA timecritical.ld)
|
|
|
|
|
|
|
|
# A function in flash.c adds 1 to a function pointer, causing a warning
|
|
|
|
set_source_files_properties(
|
|
|
|
${rp2_common_dir}/hardware_flash/flash.c
|
|
|
|
PROPERTIES
|
|
|
|
COMPILE_FLAGS $<TARGET_PROPERTY:compiler,warning_no_pointer_arithmetic>
|
|
|
|
)
|
2022-02-19 04:16:04 +08:00
|
|
|
|
2023-03-06 05:06:16 +08:00
|
|
|
zephyr_library_sources_ifdef(CONFIG_PICOSDK_USE_PIO
|
|
|
|
${rp2_common_dir}/hardware_pio/pio.c)
|
|
|
|
zephyr_include_directories_ifdef(CONFIG_PICOSDK_USE_PIO
|
|
|
|
${rp2_common_dir}/hardware_pio/include)
|
|
|
|
|
|
|
|
zephyr_library_sources_ifdef(CONFIG_PICOSDK_USE_CLAIM
|
|
|
|
${rp2_common_dir}/hardware_claim/claim.c)
|
|
|
|
zephyr_include_directories_ifdef(CONFIG_PICOSDK_USE_CLAIM
|
|
|
|
${rp2_common_dir}/hardware_claim/include)
|
|
|
|
|
2021-11-30 05:51:48 +08:00
|
|
|
endif()
|