diff --git a/dts/arm/raspberrypi/rpi_pico/rp2040.dtsi b/dts/arm/raspberrypi/rpi_pico/rp2040.dtsi index 6398674e0e02..90c54c595872 100644 --- a/dts/arm/raspberrypi/rpi_pico/rp2040.dtsi +++ b/dts/arm/raspberrypi/rpi_pico/rp2040.dtsi @@ -429,6 +429,14 @@ io-channels = <&adc 4>; status = "disabled"; }; + + boot_flash: flash@10000000 { + compatible = "zephyr,memory-region"; + reg = <0x10000000 0x100>; + zephyr,memory-region = "BOOT_FLASH"; + zephyr,memory-region-flags = "r"; + status = "okay"; + }; }; &nvic { diff --git a/dts/arm/raspberrypi/rpi_pico/rp2350.dtsi b/dts/arm/raspberrypi/rpi_pico/rp2350.dtsi index 687cafc19aad..ab57b5d4ece2 100644 --- a/dts/arm/raspberrypi/rpi_pico/rp2350.dtsi +++ b/dts/arm/raspberrypi/rpi_pico/rp2350.dtsi @@ -435,4 +435,12 @@ compatible = "raspberrypi,pico-temp"; status = "disabled"; }; + + image_def_flash: flash@10000000 { + compatible = "zephyr,memory-region"; + reg = <0x10000000 0x80>; + zephyr,memory-region = "IMAGE_DEF_FLASH"; + zephyr,memory-region-flags = "r"; + status = "okay"; + }; }; diff --git a/soc/raspberrypi/rpi_pico/rp2040/CMakeLists.txt b/soc/raspberrypi/rpi_pico/rp2040/CMakeLists.txt index 4c53cf10d0fd..3d4501b5c9cc 100644 --- a/soc/raspberrypi/rpi_pico/rp2040/CMakeLists.txt +++ b/soc/raspberrypi/rpi_pico/rp2040/CMakeLists.txt @@ -3,4 +3,8 @@ zephyr_include_directories(.) -set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld CACHE INTERNAL "") +zephyr_linker_sources_ifdef(CONFIG_RP2_REQUIRES_SECOND_STAGE_BOOT + SECTIONS sections.ld +) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/raspberrypi/rpi_pico/rp2040/linker.ld b/soc/raspberrypi/rpi_pico/rp2040/linker.ld deleted file mode 100644 index 5e1db9a81758..000000000000 --- a/soc/raspberrypi/rpi_pico/rp2040/linker.ld +++ /dev/null @@ -1,29 +0,0 @@ -/* linker.ld - Linker command/script file */ - -/* - * Copyright (c) 2014 Wind River Systems, Inc. - * Copyright (c) 2021 Yonatan Schachter - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/* - * The Second Stage Bootloader is only linked to the app that - * resides at 0x100. This can be the application, or a bootloader - * such as mcuboot. - */ -#if CONFIG_RP2_REQUIRES_SECOND_STAGE_BOOT -MEMORY -{ - BOOT_FLASH (r) : ORIGIN = 0x10000000, LENGTH = 256 -} - -SECTIONS -{ - .boot2 : { - KEEP(*(.boot2)) - } > BOOT_FLASH -} -#endif /* CONFIG_RP2_REQUIRES_SECOND_STAGE_BOOT */ - -#include diff --git a/soc/raspberrypi/rpi_pico/rp2040/sections.ld b/soc/raspberrypi/rpi_pico/rp2040/sections.ld new file mode 100644 index 000000000000..3c3f27759acd --- /dev/null +++ b/soc/raspberrypi/rpi_pico/rp2040/sections.ld @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2014 Wind River Systems, Inc. + * Copyright (c) 2021 Yonatan Schachter + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * The Second Stage Bootloader is only linked to the app that + * resides at 0x100. This can be the application, or a bootloader + * such as mcuboot. + */ + +.boot2 : { + KEEP(*(.boot2)) +} > BOOT_FLASH diff --git a/soc/raspberrypi/rpi_pico/rp2350/CMakeLists.txt b/soc/raspberrypi/rpi_pico/rp2350/CMakeLists.txt index 8f48fc01aba9..36e38d5b59d8 100644 --- a/soc/raspberrypi/rpi_pico/rp2350/CMakeLists.txt +++ b/soc/raspberrypi/rpi_pico/rp2350/CMakeLists.txt @@ -7,4 +7,6 @@ zephyr_library_sources(soc.c) zephyr_include_directories(.) -set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld CACHE INTERNAL "") +zephyr_linker_sources(SECTIONS sections.ld) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/raspberrypi/rpi_pico/rp2350/linker.ld b/soc/raspberrypi/rpi_pico/rp2350/linker.ld deleted file mode 100644 index 6368409c9e27..000000000000 --- a/soc/raspberrypi/rpi_pico/rp2350/linker.ld +++ /dev/null @@ -1,27 +0,0 @@ -/* linker.ld - Linker command/script file */ - -/* - * Copyright (c) 2024 Andrew Featherstone - * - * SPDX-License-Identifier: Apache-2.0 - */ - -MEMORY -{ - IMAGE_DEF_FLASH (r) : ORIGIN = 0x10000000, LENGTH = 128 -} - -SECTIONS -{ - .image_def : { - LONG(0xffffded3) /* PICOBIN_BLOCK_MARKER_START */ - LONG(0x10210142) /* IMAGE_DEF Item */ - LONG(0x00000203) /* VECTOR_TABLE Item */ - LONG(ABSOLUTE(_vector_start)) /* - Address of the vector table in flash */ - LONG(0x000003ff) /* Last Item in Block */ - LONG(0x00000000) /* End of block loop */ - LONG(0xab123579) /* PICOBIN_BLOCK_MARKER_END */ - } > IMAGE_DEF_FLASH -} - -#include diff --git a/soc/raspberrypi/rpi_pico/rp2350/sections.ld b/soc/raspberrypi/rpi_pico/rp2350/sections.ld new file mode 100644 index 000000000000..827efa671187 --- /dev/null +++ b/soc/raspberrypi/rpi_pico/rp2350/sections.ld @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 Andrew Featherstone + * + * SPDX-License-Identifier: Apache-2.0 + */ + +.image_def : { + LONG(0xffffded3) /* PICOBIN_BLOCK_MARKER_START */ + LONG(0x10210142) /* IMAGE_DEF Item */ + LONG(0x00000203) /* VECTOR_TABLE Item */ + LONG(ABSOLUTE(_vector_start)) /* - Address of the vector table in flash */ + LONG(0x000003ff) /* Last Item in Block */ + LONG(0x00000000) /* End of block loop */ + LONG(0xab123579) /* PICOBIN_BLOCK_MARKER_END */ +} > IMAGE_DEF_FLASH