Skip to content

soc: raspberrypi: rpi_pico: Improvement linker configuration #79460

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions dts/arm/raspberrypi/rpi_pico/rp2040.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,14 @@
io-channels = <&adc 4>;
status = "disabled";
};

boot_flash: flash@10000000 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we put this in 'unit address' order, this helps to highlight that something isn't right about this approach. Similarly, a quick grep of the codebase suggests that flash@unitaddress is always used to refer to some non-volatile storage, not to something stored at that location.

compatible = "zephyr,memory-region";
reg = <0x10000000 0x100>;
zephyr,memory-region = "BOOT_FLASH";
zephyr,memory-region-flags = "r";
status = "okay";
};
};

&nvic {
Expand Down
8 changes: 8 additions & 0 deletions dts/arm/raspberrypi/rpi_pico/rp2350.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
};
Comment on lines +439 to 446
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having looked at this further, I don't think this is correct. It needs changing.

boards/raspberrypi/rpi_pico2/rpi_pico2.dtsi defines the partitions in flash. The RP2350A and RP2350B don't even have flash, so anything related to defining things in flash doesn't make sense in the base file rp2350.dtsi.

Similarly, it's a board and/or application (app) specific thing to decide where this information is (it doesn't have to be at the very beginning of flash, for example).

6 changes: 5 additions & 1 deletion soc/raspberrypi/rpi_pico/rp2040/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
29 changes: 0 additions & 29 deletions soc/raspberrypi/rpi_pico/rp2040/linker.ld

This file was deleted.

16 changes: 16 additions & 0 deletions soc/raspberrypi/rpi_pico/rp2040/sections.ld
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion soc/raspberrypi/rpi_pico/rp2350/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
27 changes: 0 additions & 27 deletions soc/raspberrypi/rpi_pico/rp2350/linker.ld

This file was deleted.

15 changes: 15 additions & 0 deletions soc/raspberrypi/rpi_pico/rp2350/sections.ld
Original file line number Diff line number Diff line change
@@ -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
Loading