Skip to content
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

Add initial support for the Raspberry Pi Pico 2 #77368

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

Conversation

ajf58
Copy link
Contributor

@ajf58 ajf58 commented Aug 21, 2024

https://builds.zephyrproject.io/zephyr/pr/77368/docs/boards/index.html#name=pico+2

This is a PR to add support for the Raspberry Pi Pico 2 board, and the RP2350 SoC. See also the discussion at #77329

This should not be merged currently, as it includes changes that will break the clock control driver for the RP2040.

Dependencies

  1. west: hal_rpi_pico: Update Pico-SDK to 2.0.0 #76986
  2. Updating hal_rpi_pico incorporate the change for raspberrypi/pico-sdk@0e5ef0f

cc: @yonsch @soburi

@zephyrbot
Copy link
Collaborator

zephyrbot commented Aug 21, 2024

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff

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

@zephyrbot zephyrbot added manifest manifest-hal_rpi_pico DNM This PR should not be merged (Do Not Merge) labels Aug 21, 2024
@soburi
Copy link
Member

soburi commented Aug 22, 2024

@ajf58
First, I've listed some points that caught my attention at a glance.
I haven't been able to check it thoroughly yet, so I'll look at it a bit more.

soc/raspberrypi/rp2xxx/Kconfig Outdated Show resolved Hide resolved
soc/raspberrypi/soc.yml Outdated Show resolved Hide resolved
@soburi
Copy link
Member

soburi commented Aug 22, 2024

modules/hal_rpi_pico/CMakeLists.txt Outdated Show resolved Hide resolved
dts/arm/rpi_pico/rpi_pico_2_common.dtsi Outdated Show resolved Hide resolved
soc/raspberrypi/CMakeLists.txt Outdated Show resolved Hide resolved
west.yml Outdated Show resolved Hide resolved
nordicjm
nordicjm previously approved these changes Aug 27, 2024
Copy link
Collaborator

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

Updates are OK. Though migration guide entry needed for the SoC symbol change

boards/raspberrypi/rpi_pico_2/rpi_pico_2-pinctrl.dtsi Outdated Show resolved Hide resolved
@ajf58 ajf58 force-pushed the add-rpi-pico-2-support branch 5 times, most recently from b4d5164 to f5d043c Compare August 29, 2024 07:25
@ajf58 ajf58 force-pushed the add-rpi-pico-2-support branch 2 times, most recently from be3d6b9 to 384b0ee Compare August 29, 2024 21:01
@ajf58
Copy link
Contributor Author

ajf58 commented Aug 30, 2024

Updates are OK. Though migration guide entry needed for the SoC symbol change

@nordicjm where should this update go? Is under boards in doc/releases/migration-guide-4.0.rst correct?

@nordicjm
Copy link
Collaborator

nordicjm commented Sep 2, 2024

Updates are OK. Though migration guide entry needed for the SoC symbol change

@nordicjm where should this update go? Is under boards in doc/releases/migration-guide-4.0.rst correct?

Yes

ajf58 and others added 12 commits November 10, 2024 09:53
The Raspberry Pi Pico 2's device is compatible with the existing Pico 1.
The build system requires a `<board>.overlay` file, but these use the
pre-processing to #include the sibling rpi_pico.overlay files rather
than duplicating the contents as an attempt to keep things DRY.

Tested locally.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
For these tests' needs, the RP2350 on the Pico 2 is compatible with the
RP2040 on the Pico 1. #include the latter's overlay in preference to
duplicating the content.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
Add some documentation for the board itself (mostly aiming to refer to
canonical sources of information rather duplicate). Add entries in the
release notes where applicable.

boards/raspberrypi/rpi_pico2/doc/img/rpi_pico2.webp is a cropped and
compressed version of https://www.raspberrypi.com/documentation/microcontrollers/images/pico-2.png
which is released under the CC-BY-SA-4.0 license. See https://github.com/raspberrypi/documentation/blob/develop/LICENSE.md

Co-authored-by: Benjamin Cabé <kartben@gmail.com>
Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
Add OpenOCD debugger support.
For now we will need a Raspberry Pi'a forked version of OpenOCD from
https://github.com/raspberrypi/openocd .

The default adapter speed is set to match Raspberry Pi's documentation.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
Extend gpio_api_1pin so that tests can require a test fixture to provide
an external pulldown resistor to the board under test. Use the new
test-gpio-external-pulldown device tree binding to define where that
GPIO is, and, finally, add a device tree overlay for the Raspberry Pi
Pico 2 board that defines where the pulldown provided by the fixture
will be.

Tested locally using `--fixture gpio_external_pull_down` when running
Twister on the command line, or by creating and using a Hardware Map
file, in combination with a modified Pico 2.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
Add initial support for the RP2350's PIO peripherals, extend the
existing example under samples/boards/raspberrypi/rpi_pico/uart_pio to
demonstrate this on the Raspberry Pi Pico 2, and update the board's
documentation.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
Signed-off-by: Manuel Aebischer <manuel.aebischer@belden.com>
Add initial support for the RP2350's DMA peripheral, allow tests
under drivers/dma/loop_transfer to run on on the Raspberry Pi Pico 2,
and update the board's documentation.

Signed-off-by: Manuel Aebischer <manuel.aebischer@belden.com>
Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
Avoid referring to Pico 2 (the name of a board). In this context,
RPI_PICO is used to refer to the (Zephyr) `SOC_FAMILY` rather than the
Pico 1 board. This clarifies common numerical values between the RP2040
and RP2350 SoC series, and enables existing DTS files to be used with
RP2350-based boards with fewer changes.

Remove the use of Zehpyr's `CONFIG_` macros from the device tree files,
and replace them with `SOC_SERIES`-specific files. Update the driver
implementation to conditionally include the correct file. Update
documentation and samples to match.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
From the API documentation, `dma_api_chan_filter`` can be given a value
of NULL for `filter_param`. Match the behaviour of most implementations,
and return true. This removes misleading error messages logged during
tests (e.g. `test_tst_dma0_m2m_loop`).

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
Increase test coverage for Raspberry Pi's SoCs. Use the `socs` folder
rather than `boards` to enable these tests to run on any boards with the
same SoCs.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
The RP2350's PWM peripheral is largely unchanged from the RP2040's, but
the higher clock frequency means the long blink delay must be lower.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
Assume that users want to run a dual Cortex-M33 on the Pico 2, and
update various parts of the codebase to match. I expect the majority of
the soc's definition will move from `dts/arm/raspberrypi` to
`dts/common/raspberrypi` if/when support is added for the Hazard3 cores.

Some parts of the codebase can cope without encoding the cluster in the
filename (e.g. Twister seems to use the identifier in
`boards/raspberrypi/rpi_pico2/rpi_pico2.yaml` rather than the filename
itself), others can't (e.g. `rpi_pico2_m33_defconfig`) which itself is
a form of <board>_<cpucluster>_defconfig and doesn't refer to the SoC.
Despite this, some files have been given the verbose fully-specified
name because this matches the current documentation.

Update documentation to try to highlight the capabilities and
limitations of the current support within Zephyr for the Pico 2 board
and the underlying SoC.

Update `.overlay` and `.conf` files in `samples/` and `tests/` to match
the new requirement.

Limited tested locally with no issues found.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
Copy link
Contributor Author

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

File name fettling has been done. Please note the commit message did (and still does) highlight that in several cases this wasn't required.

Since this is now not going into v4.0, I've also modified the relevant commit so that the documentation updates target v4.1's release notes.

Please note my comment regarding the squashing of rp2350: Define and implement a cpucluster of Cortex-M33s. I'm not going to do that for the reasons I've already outlined above.

boards/raspberrypi/rpi_pico2/rpi_pico2_m33.dts Outdated Show resolved Hide resolved
boards/raspberrypi/rpi_pico2/rpi_pico2_m33.dts Outdated Show resolved Hide resolved
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2024 Andrew Featherstone <andrew.featherstone@gmail.com>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please can you mark this "conversation" as resolved? I don't think there's any more discussion to be had here.

Copy link
Member

@soburi soburi left a comment

Choose a reason for hiding this comment

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

LGTM

@nordicjm
Copy link
Collaborator

Please note my comment regarding the squashing of rp2350: Define and implement a cpucluster of Cortex-M33s. I'm not going to do that for the reasons I've already outlined above.

This is clearly defined in the zephyr contribution guidelines, the exact point of which you have been made aware of earlier https://docs.zephyrproject.org/latest/contribute/guidelines.html#contribution-workflow

If reviewers do request changes to your patch, you can interactively rebase commit(s) to fix review issues. In your development repo:

git rebase -i <offending-commit-id>^

In the interactive rebase editor, replace pick with edit to select a specific commit (if there’s more than one in your pull request), or remove the line to delete a commit entirely. Then edit files to fix the issues in the review.

As before, inspect and test your changes. When ready, continue the patch submission:

git add [file(s)]
git rebase --continue

Update commit comment if needed, and continue:

git push --force origin fix_comment_typo

History has nothing to do with it, you're trying to claim if someone submits a PR with C code changes that do not compile, instead of fixing them in the original commit, they should add a new commit which fixes them on top of it to preserve the history, this makes absolutely no sense.

Copy link
Collaborator

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

Squash requested changes into original commits

@kartben
Copy link
Collaborator

kartben commented Nov 11, 2024

... you're trying to claim if someone submits a PR with C code changes that do not compile

@nordicjm that's not at all what @ajf58 is saying (let alone "claiming"). Please, pretty please, refrain from telling people what they are saying "make no sense", especially if you're going into a straw man argument.

The commit that's left "unsquashed" is transitioning from a working state to another working state, AFAICT, and reflecting changes along the lines of "initial support" --> "slightly improved initial support". That last commit would have likely been a different, follow-up, PR in other circumstances.

@nordicjm
Copy link
Collaborator

... you're trying to claim if someone submits a PR with C code changes that do not compile

@nordicjm that's not at all what @ajf58 is saying (let alone "claiming"). Please, pretty please, refrain from telling people what they are saying "make no sense", especially if you're going into a straw man argument.

The C part is applying the same logic here to code instead of a dts file. See #80707 (review)

The commit that's left "unsquashed" is transitioning from a working state to another working state, AFAICT, and reflecting changes along the lines of "initial support" --> "slightly improved initial support". That last commit would have likely been a different, follow-up, PR in other circumstances.

Because we don't rebase history that has been merged, this has not been merged, you submit a clean PR which does what is needed, not add commits that you later fix up in the same PR, and this isn't even a zephyr this, this is a common sense thing with projects and git in general

@fabiobaltieri
Copy link
Member

fabiobaltieri commented Nov 11, 2024

The commit that's left "unsquashed" is transitioning from a working state to another working state, AFAICT, and reflecting changes along the lines of "initial support" --> "slightly improved initial support". That last commit would have likely been a different, follow-up, PR in other circumstances.

That is not how code review works here, or in Linux (which the process is inspired from), or I imagine in any other project with a maintainer structure. Fixups go in the commit that introduced a file, sure in other circumstances it would be fine, but this is not that and the fixup commit makes the stack incredibly hard to review and the whole PR evolution very VERY hard to follow, leading to this being delayed further. There's a reason why that's the process documented in the contribution guidelines.

@soburi
Copy link
Member

soburi commented Nov 11, 2024

@ajf58

The commit content should not include the discussion process that led to this point, but rather revise it to a direct commit that reflects the final conclusion and commit it.
Also, please try to avoid making modifications to the same file within a PR as much as possible.

I have sorted it out. Please check it out. (Need to clone the repository)
https://github.com/soburi/zephyr/tree/pr77368_squash

There are some parts in the revision process that use my name,
so please use git format-patch and git am to revise and use it.

@ajf58
Copy link
Contributor Author

ajf58 commented Nov 12, 2024

Do Not Merge @soburi 's branch.

@kartben's comment is absolutely correct at #77368 (comment) .

When @fabiobaltieri says:

fixups go in the commit that introduced a file

There is no fixup commit.

Again, kartben is absolutely spot on. This PR could have been merged as-is without the last commit. I don't endorse it, but it has to have my sign off because the "signed off by" process mandates it.

I have sorted it out. Please check it out. (Need to clone the repository)
https://github.com/soburi/zephyr/tree/pr77368_squash

@soburi the branch you've created now really is wrong. At the very least:

  1. because you've squashed at least one commit together, but failed to correctly change the commit message, the commit message is wrong.
  2. You've messed up the committer and author on at least one commit.
  3. You've created commits that will fail the Compliance Checks.

There are some parts in the revision process that use my name,
so please use git format-patch and git am to revise and use it.

No, absolutely not. You cannot take my work, break it, give it back to me, and expect me to fix it.

@nordicjm
Copy link
Collaborator

Had a quick look at @soburi's branch and looks ok.

because you've squashed at least one commit together, but failed to correctly change the commit message, the commit message is wrong.

He's correctly squashed requested changes into the base commits

You've messed up the committer and author on at least one commit.

Have you ever actually used git before? This is what happens when you rebase, even if you make no changes, go and rebase and git commit --amend --reset-author to fix.

You've created commits that will fail the Compliance Checks.

Where?

@soburi
Copy link
Member

soburi commented Nov 12, 2024

@ajf58

and expect me to fix it.

That's true.
That's why I'm not presenting this in a mergeable form.
But I think it's useful enough to show what I, @nordicjm and @fabiobaltieri expect.
Explaining this in words would be too long, so it's better to show an example, which is what I'm doing here.

@soburi
Copy link
Member

soburi commented Nov 12, 2024

@ajf58

Do Not Merge @soburi 's branch.

No one said my branch to merge.
In the first place, how can anyone merge something that isn't even a PR?

No, absolutely not. You cannot take my work, break it, give it back to me, and expect me to fix it.

Ok, of course, I'd welcome you to solve the problem your way.

@soburi
Copy link
Member

soburi commented Nov 12, 2024

I share @fabiobaltieri 's concern.
Even if policy changes as the PR branch evolves, the ultimately merged commits should be easy to read and organized based on the final policy.
Because the source code is usually "Write once, read many times."
As pointed out, the guideline's statement that we should rebase and force push also makes it undesirable to have "intermediate states" in a PR, I think.

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)
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.