Skip to content

Conversation

@CBJamo
Copy link
Contributor

@CBJamo CBJamo commented Aug 9, 2024

There are many places that could reasonably be bikesheded, as I'm the only person who's spent any time with this code and names are important. I especially want input on the feature names and organization.

Features not yet supported:

  • hstx
  • powman
  • risc-v cores
  • new pio features
  • most bootrom features
  • otp
  • psram

Examples have been run locally during development for sanity checks, but there is not yet a test suite, as probe-rs does not yet support the rp2350.

Many thanks to @thejpster for doing all the hard parts and for writing the start block and binary info code.

This depends on rp-pac#5. rp23-pac should probably be moved to the embassy-rs org.

Marked draft at least until rp-pac and rp23-pac are updated/moved/released and the related cargo.tomls are updated.

CBJamo added 3 commits August 8, 2024 21:35
Examples have been run, but there is not yet a test suite.
@CBJamo
Copy link
Contributor Author

CBJamo commented Aug 9, 2024

CI build fails because currently neither the 2040 nor rp235x are selected by default, so there is no pac. I'm not sure what the best way to handle that is. If it's built with -F rp2040 -F rt-2040 or -F rp235x -F rt-235x it should pass.

Tests fail because there are no tests.

I'm actually quite confused about how the nightly build worked. Is embassy-rp not built with nightly? For anyone who comes across this, the nightly ci only builds embassy-executor, as it's the only crate with a nightly feature at time of writing.

@CBJamo CBJamo mentioned this pull request Aug 9, 2024
@Dirbaio
Copy link
Member

Dirbaio commented Aug 9, 2024

I will review fully soon, just one quick thought for now:

I think we should add rp235x to rp-pac (stm32-metapac style) instead of making separate crates per chip (nrfxxx-pac style). It's much less annoying to release and manage Cargo features. Also it makes sense given the crate is named rp-pac.

Chiptool doesn't have builtin support for that. Either we could add something, or we could just make chiptool generate the two sub-pacs and write lib.rs manually to include either one or the other.

@CBJamo
Copy link
Contributor Author

CBJamo commented Aug 9, 2024

rp-pac#5 now supports both the 2040 and 2350. I had assumed it'd be hard to do, but it wasn't too bad. I just updated the update.sh to make both and hand wrote a tiny lib.rs. Features did indeed clean up with the single pac.

@CBJamo
Copy link
Contributor Author

CBJamo commented Aug 9, 2024

ci.sh fails, but I don't understand why. Building embassy-rp with (as far as I know) the same args works.

if let Some(pin) = &clk {
pin.gpio().ctrl().write(|w| w.set_funcsel(1));
pin.pad_ctrl().write(|w| {
#[cfg(feature = "rp235x")]
Copy link

Choose a reason for hiding this comment

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

Looks little suspicious. Is cfg intended here or before whole write? (Same for other three same blocks below ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is correct, only the 235x has isolation latches for the gpio pads. The remainder of the pad config is the same.

@Dirbaio
Copy link
Member

Dirbaio commented Aug 11, 2024

i've done some hacking on the PAC, mostly to arrayify/deduplicate more stuff. The PAC builds ~2x faster now.

Cherry-pick this commit into your branch to fix CI. 1ff027b . BTW I'd request for next PRs you enable the "allow maintainers to push to the branch" thing, it's nice to allow maintainers to do small fixes like that directly on the PR.

#[inline(never)]
#[link_section = ".data.ram_func"]
#[cfg(feature = "rp235x")]
unsafe fn write_flash_inner(_addr: u32, _len: u32, _data: Option<&[u8]>, _ptrs: *const FlashFunctionPointers) {}
Copy link
Member

Choose a reason for hiding this comment

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

please don't leave empty functions if unimplemented. Either add a todo!() or ideally make the API inaccessible for the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've left this as TODO, flash will be my next pr.

impl_pin!(PIN_28, Bank::Bank0, 28);
impl_pin!(PIN_29, Bank::Bank0, 29);

#[cfg(feature = "rp235xb")]
Copy link
Member

Choose a reason for hiding this comment

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

this needs adjusting (probably renaming...) BANK0_PIN_COUNT / BANK0_WAKERS, or async wait_for_* will panic due to OOB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've done the cfg bits, but didn't rename anything. Pi still calls all 48 pins on the B bank 0. I think it's because of the gpio co-processor that lets you access all 48 pins in a single cycle. On the other hand, that's not implemented here yet...

Copy link
Member

Choose a reason for hiding this comment

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

Pi still calls all 48 pins on the B bank 0.

Huh, okay.

Dirbaio and others added 4 commits August 12, 2024 03:25
The rp235x doc test requires an unfortunate workaround using a private
feature, "_test", in order compile.
@CBJamo CBJamo marked this pull request as ready for review August 12, 2024 09:56
@CBJamo
Copy link
Contributor Author

CBJamo commented Aug 12, 2024

If it's not an issue to use the git dep for the pac then I think this is ready.

Copy link
Member

@Dirbaio Dirbaio left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! This is awesome. I've got some rp2350's in the mail, can't wait to test it out 🙃

@Dirbaio Dirbaio added this pull request to the merge queue Aug 12, 2024
Merged via the queue into embassy-rs:main with commit 66a5a33 Aug 12, 2024
@thejpster
Copy link
Contributor

Hello! Just a reminder that under the terms of the licences under which my HAL was placed, you have to include the copyright line from my MIT file along with the paragraphs below it in any copies or substantial portions of the software. As this PR lifts several modules wholesale, I’d say that counts. If I had included a NOTICES file you would also have to carry that, but I didn’t include one.

@Dirbaio
Copy link
Member

Dirbaio commented Aug 12, 2024

@thejpster can you send a PR?

@thejpster
Copy link
Contributor

Not from my phone. Maybe in a week after my vacation.

@thejpster
Copy link
Contributor

@thejpster can you send a PR?

#3261

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants