|
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | + |
| 3 | +include(ExternalProject) |
| 4 | + |
| 5 | +if(CONFIG_HAS_RPI_PICO) |
| 6 | + zephyr_library() |
| 7 | + |
| 8 | + set(rp2_common_dir ${ZEPHYR_HAL_RPI_PICO_MODULE_DIR}/src/rp2_common) |
| 9 | + set(rp2040_dir ${ZEPHYR_HAL_RPI_PICO_MODULE_DIR}/src/rp2040) |
| 10 | + set(common_dir ${ZEPHYR_HAL_RPI_PICO_MODULE_DIR}/src/common) |
| 11 | + set(boot_stage_dir ${rp2_common_dir}/boot_stage2) |
| 12 | + |
| 13 | + # The Second Stage Bootloader is only linked to the app that resides |
| 14 | + # at 0x100. Therefore, only if the app's offset is 0x100, the second |
| 15 | + # stage bootloader should be compiled. |
| 16 | + if(CONFIG_RP2_REQUIRES_SECOND_STAGE_BOOT) |
| 17 | + foreach(flash W25Q080 GENERIC_03H IS25LP080 W25X10CL AT25SF128A) |
| 18 | + if(CONFIG_RP2_FLASH_${flash}) |
| 19 | + set(flash_type ${flash}) |
| 20 | + break() |
| 21 | + endif() |
| 22 | + endforeach() |
| 23 | + |
| 24 | + set(rp2_bootloader_prefix ${CMAKE_BINARY_DIR}/bootloader) |
| 25 | + ExternalProject_Add( |
| 26 | + second_stage_bootloader |
| 27 | + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/bootloader |
| 28 | + BINARY_DIR ${rp2_bootloader_prefix} |
| 29 | + CMAKE_ARGS |
| 30 | + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} |
| 31 | + -DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER} |
| 32 | + -DZEPHYR_HAL_RPI_PICO_MODULE_DIR=${ZEPHYR_HAL_RPI_PICO_MODULE_DIR} |
| 33 | + -DZEPHYR_BASE=${ZEPHYR_BASE} |
| 34 | + -DFLASH_TYPE=${flash_type} |
| 35 | + -DPYTHON_EXECUTABLE=${Python3_EXECUTABLE} |
| 36 | + INSTALL_COMMAND "" # No installation needed |
| 37 | + BUILD_BYPRODUCTS ${rp2_bootloader_prefix}/boot_stage2.S |
| 38 | + BUILD_ALWAYS TRUE |
| 39 | + ) |
| 40 | + zephyr_library_sources(${rp2_bootloader_prefix}/boot_stage2.S) |
| 41 | + endif() |
| 42 | + |
| 43 | + # Pico sources and headers necessary for every build. |
| 44 | + # These contain definitions and implementation used mostly for |
| 45 | + # initializing the SoC, and therefore are always required. |
| 46 | + |
| 47 | + zephyr_library_sources( |
| 48 | + ${rp2_common_dir}/hardware_clocks/clocks.c |
| 49 | + ${rp2_common_dir}/hardware_pll/pll.c |
| 50 | + ${rp2_common_dir}/hardware_xosc/xosc.c |
| 51 | + ${rp2_common_dir}/hardware_watchdog/watchdog.c |
| 52 | + ${rp2_common_dir}/pico_platform/platform.c |
| 53 | + ) |
| 54 | + |
| 55 | + zephyr_include_directories( |
| 56 | + ${rp2_common_dir}/hardware_base/include |
| 57 | + ${rp2_common_dir}/hardware_clocks/include |
| 58 | + ${rp2_common_dir}/hardware_watchdog/include |
| 59 | + ${rp2_common_dir}/hardware_xosc/include |
| 60 | + ${rp2_common_dir}/hardware_pll/include |
| 61 | + ${rp2_common_dir}/hardware_irq/include |
| 62 | + ${rp2_common_dir}/hardware_sync/include |
| 63 | + ${rp2_common_dir}/hardware_timer/include |
| 64 | + ${rp2_common_dir}/hardware_resets/include |
| 65 | + ${rp2040_dir}/hardware_regs/include |
| 66 | + ${rp2040_dir}/hardware_structs/include |
| 67 | + ${common_dir}/pico_base/include |
| 68 | + ${rp2_common_dir}/pico_platform/include |
| 69 | + ${CMAKE_CURRENT_LIST_DIR} |
| 70 | + ) |
| 71 | + |
| 72 | + zephyr_library_sources_ifdef(CONFIG_PICOSDK_USE_GPIO |
| 73 | + ${rp2_common_dir}/hardware_gpio/gpio.c) |
| 74 | + zephyr_include_directories_ifdef(CONFIG_PICOSDK_USE_GPIO |
| 75 | + ${rp2_common_dir}/hardware_gpio/include) |
| 76 | + |
| 77 | + zephyr_library_sources_ifdef(CONFIG_PICOSDK_USE_UART |
| 78 | + ${rp2_common_dir}/hardware_uart/uart.c) |
| 79 | + zephyr_include_directories_ifdef(CONFIG_PICOSDK_USE_UART |
| 80 | + ${rp2_common_dir}/hardware_uart/include) |
| 81 | +endif() |
0 commit comments