Skip to content

Conversation

@haydenridd
Copy link
Collaborator

The RP2350 is now running Zig! Credit to @timsavage for some of the initial work in porting.

Restructuring

Some housekeeping for the new chip:

  • port/raspberrypi/rp2040 has become port/raspberrypi/rp2xxx since both chips are under the same HAL
  • examples/raspberrypi/rp2040 has similarly become examples/raspberrypi/rp2xxx
  • compatibility.zig was added to the HAL for determining which chip you're using at compile time

Apologies as this makes the diffs horrendous, but if you have a good diff tool like BeyondCompare it's fairly easy to align the renamed folders to see what changed.

Boot Rom

Unlike the RP2040, there is no longer a need to write your own "stage 2 bootloader" that fits in 256 bytes and has a special header. They've changed things around quite a bit and added lots of functionality to the ROM code that runs on boot. Way too much to go over here, but the TLDR is the boot ROM looks for metadata in your binary that's sitting in flash to determine if/how to run it. I've added a "bare minimum dumb config" that essentially just says "run this binary sitting in flash please". Chapter 5 of the data sheet (Bootrom) is well worth the read as there's some pretty cool stuff we could do with this metadata in the future.

HAL Integration

Zig actually made this part pretty pleasant. You'll see a general pattern of:

switch (get_cpu()) {
        .RP2040 => {},
        .RP2350 => {},
    },

There are two methodologies I've used a bit of both of:

  • Swap out some things "as needed" in the same file if core functionality is pretty similar (see gpio.zig)
  • Separate the two chip's unique functionality into two separate files as there are enough differences to warrant this (see clocks.zig)

Both have their pros and cons, but overall I'm pretty happy with the readability and intuitiveness of both.

Progress

So far I've ported + tested the following from the HAL:

  • clocks.zig
  • gpio.zig
  • pll.zig
  • resets.zig
  • time.zig

Examples

I've modified the examples so that there are:

  • RP2040 only examples (most of them right now due to HAL compatibility)
  • RP2350 only examples (none yet but you could imagine using the new HSTX peripheral would go here)
  • Chip agnostic examples (in the future ideally most of them fall under this category)

This is a pretty easy way to see RP2350 port progress as well, since any example that runs on the RP2350 essentially means I've run that example on my own hardware and made sure it works.

@haydenridd haydenridd requested review from ikskuh and mattnite October 4, 2024 16:09
- Renamed HAL to RP2xxx
- Ported + tested the following HAL support for the RP2350:
    - clock config + PLLs
    - resets
    - GPIO
- Updated examples to reflect examples only for the RP2040 vs RP2350
- Added very basic metadata to RP2350 firmware images just to get them running
@haydenridd haydenridd force-pushed the rp2350/initial-support branch from 51016d0 to a6d784f Compare October 4, 2024 16:20
@haydenridd haydenridd mentioned this pull request Oct 4, 2024
@mattnite mattnite merged commit c24cf90 into main Oct 4, 2024
@mattnite mattnite deleted the rp2350/initial-support branch October 4, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants