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 pico-w BSP #380

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
48a3439
Initial work on a BSP for Pico W
jannic Jul 6, 2022
e44b2fd
Add section about rp-pico-w to README.md
jannic Jul 7, 2022
6a0d16c
Update READMEs
jannic Jul 9, 2022
f00613b
Apply suggestions from code review
jannic Jul 9, 2022
b2dc4d2
Implement blinky
jannic Aug 4, 2022
4907194
use released version of embassy-futures
jannic Aug 30, 2022
a6077b9
use net-stable
jannic Aug 30, 2022
2f7a29b
Implement joining network
jannic Aug 30, 2022
27b26b8
Mark dev-dependencies as such
jannic Aug 30, 2022
eca0788
update embassy version
jannic Aug 31, 2022
7f63895
WIP
jannic Aug 31, 2022
389cc7d
Make firmware flashing optional
jannic Aug 31, 2022
a524d33
Uset timer::Instant
jannic Aug 31, 2022
034681b
Avoid ill-defined > operation on Instant
jannic Sep 2, 2022
cebf1e5
Avoid ill-defined > operation on Instant
jannic Sep 2, 2022
f87f942
Cleanups
jannic Sep 5, 2022
5e52e86
Updates from main branch
jannic Sep 5, 2022
69f68fa
cargo fmt
jannic Sep 5, 2022
ce4032c
Make environment variable WIFI_NETWORK optional
jannic Sep 5, 2022
afd2bc5
cargo fmt
jannic Sep 5, 2022
859e21b
Fix udeps error in CI
jannic Sep 6, 2022
4d5eb76
Shrink several buffers to avoid stack overflows
jannic Sep 6, 2022
6eb094f
Get firmware from cyw43 driver
jannic Sep 7, 2022
577ba2a
Use new function into_readable_output_in_state
jannic Sep 17, 2022
d2b3317
Revert "Use new function into_readable_output_in_state"
jannic Nov 9, 2022
1e50ec9
Update embassy dependencies
jannic Nov 17, 2022
cfb952d
Merge branch 'main' into pico-w
jannic Nov 17, 2022
8ffb889
cargo fmt
jannic Nov 17, 2022
cee0398
Use released version of embassy-executor
jannic Nov 23, 2022
983332d
Merge branch 'main' into pico-w
jannic Dec 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ members = [
"boards/pimoroni-servo2040",
"boards/pimoroni-tiny2040",
"boards/rp-pico",
"boards/rp-pico-w",
"boards/seeeduino-xiao-rp2040",
"boards/solderparty-rp2040-stamp",
"boards/sparkfun-pro-micro-rp2040",
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ RP2040 chip according to how it is connected up on the Pico.
[Raspberry Pi Pico]: https://www.raspberrypi.org/products/raspberry-pi-pico/
[rp-pico]: https://github.com/rp-rs/rp-hal/tree/main/boards/rp-pico

### [rp-pico-w] - Board Support for the [Raspberry Pi Pico] W

You should include this crate if you are writing code that you want to run on
a [Raspberry Pi Pico] W - the Wifi enabled version of the [Raspberry Pi Pico].

This crate includes the [rp2040-hal], but also configures each pin of the
RP2040 chip according to how it is connected up on the Pico W.

**NOTE**: This is work in progress. Wifi access is not yet implemented.

[Raspberry Pi Pico]: https://www.raspberrypi.org/products/raspberry-pi-pico/
[rp-pico-w]: https://github.com/rp-rs/rp-hal/tree/main/boards/rp-pico-w

### [adafruit-feather-rp2040] - Board Support for the [Adafruit Feather RP2040]

You should include this crate if you are writing code that you want to run on
Expand Down
11 changes: 11 additions & 0 deletions boards/rp-pico-w/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
28 changes: 28 additions & 0 deletions boards/rp-pico-w/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

Created based on the rp-pico BSP.

### Added

- None

### Changed

- Pin assignments to match Pico W hardware.

### TODO

- Implement Wifi driver
- Add led pin (not a native GPIO, but could provide a compatible
API so rp-pico examples can work on rp-pico-w with little modification)
- Fix pico_w_blinky example.

[@jannic]: https://github.com/jannic
[rp-rs]: https://github.com/rp-rs
43 changes: 43 additions & 0 deletions boards/rp-pico-w/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[package]
name = "rp-pico-w"
version = "0.0.1"
authors = ["The rp-rs Developers"]
edition = "2018"
homepage = "https://github.com/rp-rs/rp-hal/tree/main/boards/rp-pico-w"
description = "Board Support Package for the Raspberry Pi Pico W"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rp-rs/rp-hal.git"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cortex-m = "0.7.2"
rp2040-boot2 = { version = "0.2.0", optional = true }
rp2040-hal = { path = "../../rp2040-hal", version = "0.6.0", features=["eh1_0_alpha"] }
cortex-m-rt = { version = "0.7", optional = true }
embassy-time = { version = "0.1.0", features = ["tick-hz-1_000_000"] }
embassy-sync = { version = "0.1.0" }

defmt = "0.3"

atomic-polyfill = "0.1.8"
critical-section = "1.1.0"
embedded-hal = "0.2.7"
embedded-hal-1 = { version = "=1.0.0-alpha.9", package = "embedded-hal" }
fugit = "0.3.6"

[dev-dependencies]
panic-probe = { version = "0.3", features = ["print-defmt"] }
cyw43 = { version = "0.1.0", git = "https://github.com/jannic-dev-forks/cyw43", branch = "stable", features=["defmt"] }
embassy-executor = { version = "0.1.1", features=["integrated-timers"] }
embassy-futures = { version = "0.1.0" }
embassy-net = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", rev = "2528f451387e6c7b27c3140cd87d47521d1971a2", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"] }
defmt-rtt = "0.3"
embedded-hal-bus = "0.1.0-alpha.1"

[features]
default = ["boot2", "rt", "critical-section-impl"]
critical-section-impl = ["rp2040-hal/critical-section-impl"]
boot2 = ["rp2040-boot2"]
rt = ["cortex-m-rt","rp2040-hal/rt"]
fix_fw = ["cyw43/fix_fw"]
97 changes: 97 additions & 0 deletions boards/rp-pico-w/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# [rp-pico-w] - Board Support for the [Raspberry Pi Pico] W

You should include this crate if you are writing code that you want to run on
a [Raspberry Pi Pico] W - the Wifi enabled version of the [Raspberry Pi Pico].

This crate includes the [rp2040-hal], but also configures each pin of the
RP2040 chip according to how it is connected up on the Pico W.

**NOTE**: This is work in progress. Wifi access is not yet implemented.

[Raspberry Pi Pico]: https://www.raspberrypi.org/products/raspberry-pi-pico/
[rp-pico-w]: https://github.com/rp-rs/rp-hal/tree/main/boards/rp-pico-w
[rp2040-hal]: https://github.com/rp-rs/rp-hal/tree/main/rp2040-hal
[Raspberry Silicon RP2040]: https://www.raspberrypi.org/products/rp2040/

## Using

To use this crate, your `Cargo.toml` file should contain:

```toml
rp-pico-w = "0.0.1"
```

In your program, you will need to call `rp_pico_w::Pins::new` to create
a new `Pins` structure. This will set up all the GPIOs for any on-board
devices. See the [examples](./examples) folder for more details.

## Examples

### General Instructions

To compile an example, clone the _rp-hal_ repository and run:

```console
rp-hal/boards/rp-pico-w $ cargo build --release --example <name>
```

You will get an ELF file called
`./target/thumbv6m-none-eabi/release/examples/<name>`, where the `target`
folder is located at the top of the _rp-hal_ repository checkout. Normally
you would also need to specify `--target=thumbv6m-none-eabi` but when
building examples from this git repository, that is set as the default.

If you want to convert the ELF file to a UF2 and automatically copy it to the
USB drive exported by the RP2040 bootloader, simply boot your board into
bootloader mode and run:

```console
rp-hal/boards/rp-pico-w $ cargo run --release --example <name>
```

If you get an error about not being able to find `elf2uf2-rs`, try:

```console
$ cargo install elf2uf2-rs
```
then try repeating the `cargo run` command above.

### [pico_w_blinky](./examples/pico_w_blinky.rs)

Flashes the Pico W's on-board LED on and off.

## Contributing

Contributions are what make the open source community such an amazing place to
be learn, inspire, and create. Any contributions you make are **greatly
appreciated**.

The steps are:

1. Fork the Project by clicking the 'Fork' button at the top of the page.
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Make some changes to the code or documentation.
4. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
5. Push to the Feature Branch (`git push origin feature/AmazingFeature`)
6. Create a [New Pull Request](https://github.com/rp-rs/rp-hal/pulls)
7. An admin will review the Pull Request and discuss any changes that may be required.
8. Once everyone is happy, the Pull Request can be merged by an admin, and your work is part of our project!

## Code of Conduct

Contribution to this crate is organized under the terms of the [Rust Code of
Conduct][CoC], and the maintainer of this crate, the [rp-rs team], promises
to intervene to uphold that code of conduct.

[CoC]: CODE_OF_CONDUCT.md
[rp-rs team]: https://github.com/orgs/rp-rs/teams/rp-rs

## License

The contents of this repository are dual-licensed under the _MIT OR Apache
2.0_ License. That means you can choose either the MIT license or the
Apache-2.0 license when you re-use this code. See `MIT` or `APACHE2.0` for more
information on each specific license.

Any submissions to this project (e.g. as Pull Requests) must be made available
under these terms.
6 changes: 6 additions & 0 deletions boards/rp-pico-w/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! This build script makes sure the linker flag -Tdefmt.x is added
//! for the examples.

fn main() {
println!("cargo:rustc-link-arg-examples=-Tdefmt.x");
}
Loading