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

initial esp support #121

Merged
merged 8 commits into from
Mar 12, 2024
Merged

initial esp support #121

merged 8 commits into from
Mar 12, 2024

Conversation

kaspar030
Copy link
Collaborator

@kaspar030 kaspar030 commented Feb 27, 2024

This PR adds initial esp32 support.

Currently, this adds support for a random esp32c3 (RISC-V based) board, the necessary infra for esp-hal, and esp-wifi.

There's no preemptive scheduling (riot-rs-threads) yet.
A single thread-mode executor is used.

edit

I'm testing with:

CONFIG_WIFI_NETWORK="your-ssid" CONFIG_WIFI_PASSWORD="your-pwd" laze build -Cexamples/embassy-http-server -b ai-c3 -s debug-console -d silent-panic run

This implies connecting to wifi but using the hard-coded IP address. to make the esp use dhcp, remove the "override-network-config" from examples/embassy-http-server/Cargo.toml.

Ah, it needs some toolchain support.
At least laze b install-toolchain and cargo install espflash.

Copy link
Collaborator

@ROMemories ROMemories left a comment

Choose a reason for hiding this comment

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

Cool stuff! I think a few things could be factored in the wifi module

laze-project.yml Show resolved Hide resolved
src/riot-rs-boards/ai-c3/Cargo.toml Outdated Show resolved Hide resolved
src/riot-rs-embassy/Cargo.toml Outdated Show resolved Hide resolved
src/riot-rs-embassy/Cargo.toml Outdated Show resolved Hide resolved
src/riot-rs-embassy/src/arch/esp.rs Outdated Show resolved Hide resolved
src/riot-rs-rt/src/esp.rs Outdated Show resolved Hide resolved
src/riot-rs/Cargo.toml Outdated Show resolved Hide resolved
src/riot-rs-embassy/src/wifi/cyw43.rs Outdated Show resolved Hide resolved
laze-project.yml Outdated Show resolved Hide resolved
src/riot-rs-rt/src/esp.rs Outdated Show resolved Hide resolved
@kaspar030
Copy link
Collaborator Author

@ROMemories I think I got most of your review comments. (sorry for already squashing, I had trouble absorbing the fixes into the right commits)

@elenaf9
Copy link
Collaborator

elenaf9 commented Mar 11, 2024

How is exception/ interrupt handling implementing in esp-hal?

I have only started looking into this, but it might be that this PR will conflict with a riscv implementation in riot-rs-threading.

Interrupts/ traps in RISC-V are handled by writing the address of the trap entry function into a CSR (mtvec).
From what I understand/ read so far, I think esp-hal and riscv-rt (used in riot-rs-threading) both setup the mtvec register with their own trap handling logic 1 2, which could cause problems when both are enabled.
Have you looked into this? I believe esp-hal offers some API for implementing a custom interrupt handler 3, which might help resolving this conflict, but I don't know how that would impact the rest of its functionality.

Footnotes

  1. https://github.com/esp-rs/esp-hal/blob/85ee3807085ceff0e4e03b5ad053baebd7c8c109/esp-riscv-rt/src/lib.rs#L251C5-L251C11

  2. https://github.com/rust-embedded/riscv/blob/555441cbcd4c4d3dcee9185de56694a7cedec163/riscv-rt/src/asm.rs#L76-L81

  3. https://github.com/esp-rs/esp-hal/blob/85ee3807085ceff0e4e03b5ad053baebd7c8c109/esp-hal/ld/esp32c3/esp32c3.x#L20-L22

@kaspar030 kaspar030 added this pull request to the merge queue Mar 12, 2024
Merged via the queue into main with commit 1c675e0 Mar 12, 2024
16 checks passed
@kaspar030 kaspar030 deleted the esp branch March 12, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch Architecture support board Board support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants