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 basic esp32p4 support #2466

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft

Conversation

playfulFence
Copy link
Contributor

@playfulFence playfulFence commented Nov 6, 2024

Submission Checklist 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • My changes were added to the CHANGELOG.md in the proper section.
  • I have added necessary changes to user code to the Migration Guide.
  • My changes are in accordance to the esp-rs API guidelines

Extra:

Pull Request Details 📖

Description

For now, there're still some TODOs left. They'll be incrementally removed as p4 support grows. For example, for now some of checks in CI are off, some code sections and so on.

related to #2285

⚠️ Before merging this PR, make sure that esp-rs/esp-pacs#301 is landed too

Testing

advanced_serial example, some more basic tests like:

//% CHIPS: esp32p4

#![no_std]
#![no_main]

use esp_backtrace as _;
use esp_hal::prelude::*;

#[entry]
fn main() -> ! {
    esp_println::println!("Hello world, from ESP32-P4 :)");

    loop {}
}

@jessebraham jessebraham marked this pull request as draft November 6, 2024 12:38
@jessebraham
Copy link
Member

I don't think we want to include this in this release, so converting to draft for now.

esp-hal/src/dma/gdma.rs Outdated Show resolved Hide resolved
esp-hal/src/system.rs Outdated Show resolved Hide resolved
esp-metadata/devices/esp32p4.toml Outdated Show resolved Hide resolved
examples/src/bin/advanced_serial.rs Outdated Show resolved Hide resolved
Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

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

Thanks! I have some initial comments, mostly around the maintainability of adding more support in the future - we don't want to spend a bunch of time working on something only to realise the function that should be doing something is stubbed out to do nothing :D.

I'll dig out my P4 rev1 board and try the examples soon.

esp-hal/src/clock/mod.rs Outdated Show resolved Hide resolved
esp-hal/src/dma/gdma.rs Outdated Show resolved Hide resolved
esp-hal/src/interrupt/riscv.rs Outdated Show resolved Hide resolved
esp-hal/src/soc/esp32p4/gpio.rs Show resolved Hide resolved
esp-hal/src/soc/esp32p4/mod.rs Outdated Show resolved Hide resolved
esp-hal/src/soc/esp32p4/mod.rs Show resolved Hide resolved
esp-hal/src/system.rs Show resolved Hide resolved
esp-hal/src/uart.rs Show resolved Hide resolved
@playfulFence
Copy link
Contributor Author

Regarding dma stuff: currently we have a lot of drivers which are tightly coupled to dma. UART is one of them, create_peripheral macro as well, so as soon as you exclude gdma from metadata, you'll immediately get an unknown amount of errors.

@bugadani
Copy link
Contributor

bugadani commented Nov 6, 2024

Yeah let's have those errors, I'll move PeripheralMarker to a better place. Alternatively, you could define an axi_gdma and ahb_gdma symbol pair, and cfg-enable dma for those without gdma/pdma parts.

@playfulFence playfulFence force-pushed the rebase/uart branch 4 times, most recently from 7237709 to 55f48fe Compare November 8, 2024 12:28
esp-hal/src/i2c.rs Outdated Show resolved Hide resolved
esp-hal/src/soc/esp32p4/mod.rs Outdated Show resolved Hide resolved
# "systimer",
# "timg0",
# "timg1",
"systimer",
Copy link
Member

Choose a reason for hiding this comment

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

Did systimer and timg work out of the box? Can we enable the examples/tests(I know we can't run them yet) for them?

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 think we can get the examples to even work, but we need to implement interrupt handling. I'm starting to do that right now.

esp32s2 = "run --release --features=esp32s2 --target=xtensa-esp32s2-none-elf"
esp32s3 = "run --release --features=esp32s3 --target=xtensa-esp32s3-none-elf"

[target.'cfg(target_arch = "riscv32")']
runner = "espflash flash --monitor"
runner = "espflash flash --monitor --no-stub"
Copy link
Member

Choose a reason for hiding this comment

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

Nit pick: We probably still want to use the stub for other chips, can we duplicate this and specify target = "riscv32imafc-unknown-none-elf" to only pass --no-stub on the P4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, I'm not even sure why is it there.
It doesn't affect a program run/flash in any sense 🤷

@playfulFence
Copy link
Contributor Author

At this point we're getting this panic message when trying to work with interrupts on esp32p4
image

In general, the interrupts functionality is implemented and works, if you uncomment the code in the _start_trap_rust_hal function, everything will be pretty much fully operational. In actual state, esp32p4 gets inside the above mentioned function even when interrupt is not jumping to the vec handlers from esp-riscv-rt. I have tried to modify the vector_table as needed, however it still does not work properly.

I will switch to other work for now, will come back here a little later. In case someone wants to work on this, you're welcome too!

@MabezDev MabezDev added the status:blocked Unable to progress - dependent on another task label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:blocked Unable to progress - dependent on another task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants