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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

soburi
Copy link
Member

@soburi soburi commented Oct 5, 2024

Improve linker settings to a modern way using zephyr_linker_sources() and "zephyr,memory-region."

@zephyrbot
Copy link
Collaborator

zephyrbot commented Oct 5, 2024

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@soburi soburi added the platform: Raspberry Pi Pico Raspberry Pi Pico (RPi Pico) label Oct 5, 2024
@decsny decsny removed their request for review October 7, 2024 14:38
@soburi soburi marked this pull request as draft October 15, 2024 23:16
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Dec 15, 2024
@soburi soburi force-pushed the rp2350-linker-improvement branch from dc8c277 to 347ea2a Compare December 19, 2024 09:47
@zephyrbot zephyrbot removed manifest manifest-hal_rpi_pico DNM This PR should not be merged (Do Not Merge) labels Dec 19, 2024
@github-actions github-actions bot removed the Stale label Dec 20, 2024
@soburi soburi force-pushed the rp2350-linker-improvement branch 2 times, most recently from d02a706 to e0d540b Compare December 24, 2024 07:17
@soburi soburi marked this pull request as ready for review December 24, 2024 07:18
dkalowsk
dkalowsk previously approved these changes Dec 25, 2024
Copy link
Collaborator

@dkalowsk dkalowsk left a comment

Choose a reason for hiding this comment

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

Nice clean up! Not tested locally, but everything looks correct to me.

@@ -435,4 +435,12 @@
compatible = "raspberrypi,pico-temp";
status = "disabled";
};

id_code: id_code@10000000 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this have image def flash in the name?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@thedjnK I had that same debate as well when reviewing. My understanding was the id_code naming was the shorthand for ImageDef_CODE (apologies for the caps mess) which covered the same naming area.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would also like to see this renamed. I wrote the image definition block. ID is a common abbreviation for with "identifier/identicification", and this isn't code (or a code, or encoding...).

It is a Block of metadata (sometimes referred to as a PICOBIN_BLOCK) of type Image Definition, referred to as an IMAGE_DEF throughout the vendor's documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was my careless mistake.
It's common to match the label here to the region name.

@@ -435,4 +435,12 @@
compatible = "raspberrypi,pico-temp";
status = "disabled";
};

id_code: id_code@10000000 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would also like to see this renamed. I wrote the image definition block. ID is a common abbreviation for with "identifier/identicification", and this isn't code (or a code, or encoding...).

It is a Block of metadata (sometimes referred to as a PICOBIN_BLOCK) of type Image Definition, referred to as an IMAGE_DEF throughout the vendor's documentation.

Comment on lines 440 to 444
compatible = "zephyr,memory-region";
zephyr,memory-region = "IMAGE_DEF_FLASH";
zephyr,memory-region-flags = "r";
reg = <0x10000000 0x80>;
status = "okay";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please match the style here https://docs.kernel.org/devicetree/bindings/dts-coding-style.html#order-of-properties-in-device-node .

It's not mandated by the Zephyr Project, but conscious effort was made to ensure this was the case elsewhere in this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed.

The definition of memory areas will be changed to use DeviceTree,
which makes it easier to coexist with other Zephyr functions.

Signed-off-by: TOKITA Hiroshi <[email protected]>
Use zephyr_linker_sources() to separate definitions of soc-specific
sections.

Also, we can directly include
`include/zephyr/arch/arm/cortex_m/scripts/linker.ld` in CMakeLists.txt,
which will fit Zephyr's build system properly.

Signed-off-by: TOKITA Hiroshi <[email protected]>
@soburi soburi force-pushed the rp2350-linker-improvement branch from 9d33674 to 864d042 Compare December 28, 2024 03:41
@soburi soburi requested review from dkalowsk and thedjnK December 28, 2024 03:41
Copy link
Collaborator

@ajf58 ajf58 left a comment

Choose a reason for hiding this comment

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

I think this needs more design thought before being approved. I've highlighted some concerns below. I think the most fundamental is that the RP2350A and RP2350B don't even have flash storage, so anything related to storing IMAGE_DEF blocks in flash don't make sense in the context of rp2350.dtsi.

Edit:
In the earlier versions of the implementation, config RP2_REQUIRES_IMAGE_DEFINITION_BLOCK was a bit more meaningful, and the IMAGE_DEF section was conditionally included into the binary image. That got rebased into oblivion (pretty sure it's left my reflog by now), and that was not correct, leading to this confusing state.

Comment on lines +439 to 446
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";
};
};
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).

@@ -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.

Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Apr 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: Raspberry Pi Pico Raspberry Pi Pico (RPi Pico) Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants