Skip to content

soc: rp2350: Add basic Asymmetric Multiprocessing (AMP) support #90922

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 3 commits into
base: main
Choose a base branch
from

Conversation

dancollins
Copy link
Contributor

I have a project using the RP2350, and figured it would be cool to run Zephyr on both cores. I have got a basic sample working that has both cores running Zephyr and printing a message on their respective UARTs.

I have noticed the reset controller, as an example, makes use of read-modify-writes that will not be compatible with my AMP setup. This, along with other peripherals, will need to either have hardware locking (RP2350 includes a hardware spinlock) or atomic access (RP2350 has memory addresses for atomic set/clear).

No doubt issues will crop up as I use this implementation - so I will keep it in draft status until I stop needing to make any changes to it. I intend on being able to demonstrate an OpenAMP sample running, as this should provide all the basic functionality needed for AMP.

@dancollins dancollins force-pushed the rp2350-amp branch 5 times, most recently from 9d3b389 to 66d1cf1 Compare June 2, 2025 02:59
@soburi soburi added the platform: Raspberry Pi Pico Raspberry Pi Pico (RPi Pico) label Jun 2, 2025
@josuah
Copy link
Collaborator

josuah commented Jun 2, 2025

The CI error message:

/__w/zephyr/modules/hal/rpi_pico/src/rp2_common/hardware_base/include/hardware/address_mapped.h:124:27: error: implicit declaration of function 'typeof' [-Werror=implicit-function-declaration]
  124 | #define hw_xor_alias(p) ((typeof(p))hw_xor_alias_untyped(p))
      |                           ^~~~~~
/__w/zephyr/modules/hal/rpi_pico/src/rp2_common/hardware_flash/flash.c:302:6: note: in expansion of macro 'hw_xor_alias'
  302 |     *hw_xor_alias(devinfo) = (*devinfo ^ wdata) & mask;
      |      ^~~~~~~~~~~~
/__w/zephyr/modules/hal/rpi_pico/src/rp2_common/hardware_base/include/hardware/address_mapped.h:124:27: error: called object is not a function or function pointer
  124 | #define hw_xor_alias(p) ((typeof(p))hw_xor_alias_untyped(p))
      |                          ~^~~~~~~~~~
/__w/zephyr/modules/hal/rpi_pico/src/rp2_common/hardware_flash/flash.c:302:6: note: in expansion of macro 'hw_xor_alias'
  302 |     *hw_xor_alias(devinfo) = (*devinfo ^ wdata) & mask;
      |      ^~~~~~~~~~~~
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.

It looks like C language features used in RPi SDK are getting in the way.

@josuah
Copy link
Collaborator

josuah commented Jun 2, 2025

The documentation says the developer toolchain should require at least C11, so this might require a bit of discussion.

@soburi may I request your advise?

@josuah josuah requested a review from soburi June 2, 2025 10:21
@dancollins
Copy link
Contributor Author

Hopefully patch in #90939 help fix the tests!

@dancollins dancollins force-pushed the rp2350-amp branch 4 times, most recently from 37d4d17 to 44e146c Compare June 5, 2025 11:38
Copy link
Contributor

@dsseng dsseng left a comment

Choose a reason for hiding this comment

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

just some thoughts

type: mcu
arch: arm
flash: 4096
ram: 520
ram: 264

This comment was marked as resolved.

type: mcu
arch: arm
flash: 4096
ram: 264

This comment was marked as resolved.

@@ -17,4 +17,10 @@ config RPI_PICO_ROSC_USE_MEASURED_FREQ
Instead of the dts value, use the value measured by
the frequency counter as the rosc frequency.

config RPI_PICO_SKIP_CLOCK_INIT
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps needs some more DT-centric approach as I've discussed in Discord

Copy link
Contributor

Choose a reason for hiding this comment

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

Because there are other parts like clock and reset controllers for peripherals

This commit introduces a means to build Zephyr for both
Cortex M33 cores of the RP2350, and for CPU0 to boot CPU1.
It includes a partition table for the rpi_pico2 board that
demonstrates how the two cores can operate independently.

Signed-off-by: Dan Collins <dan@collinsnz.com>
We don't want to reinitialise the clock control when
we boot the second core - so this commit introduces a
means to skip initialisation (i.e. assume it is already
initialised).

Signed-off-by: Dan Collins <dan@collinsnz.com>
This commit introduces an interprocess mailbox driver
for the Raspberry Pi Pico.

Signed-off-by: Dan Collins <dan@collinsnz.com>
@dancollins
Copy link
Contributor Author

I have split this out into three commits for now - this makes it easier to track what's going on. I've also removed the changes to the various samples/tests as I really like @dsseng's idea to avoid forcing the _cpu0 label onto all the non-AMP builds.

I also like the idea of using the device tree for disabling the clock init, rather than the Kconfig symbol I have. I'm not sure how to do that exactly - whether it's a special compat for the second core, or just a flag.

@dsseng
Copy link
Contributor

dsseng commented Jun 29, 2025

As we discussed with @dancollins on Discord, I'll do some work, including implementing my proposed changes and perhaps IPM on my branch and notify here when some major progress is there

Copy link

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
None yet
Development

Successfully merging this pull request may close these issues.

4 participants