Add features for rp2040 and rp2350
This commit is contained in:
parent
0014635cae
commit
e26ef569e5
8 changed files with 66 additions and 11 deletions
|
@ -1,12 +1,7 @@
|
|||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||
# Choose a default "cargo run" tool:
|
||||
# - probe-run provides flashing and defmt via a hardware debugger
|
||||
# - cargo embed offers flashing, rtt, defmt and a gdb server via a hardware debugger
|
||||
# it is configured via the Embed.toml in the root of this project
|
||||
# - elf2uf2-rs loads firmware over USB when the rp2040 is in boot mode
|
||||
# runner = "probe-run --chip RP2040"
|
||||
# runner = "cargo embed"
|
||||
runner = "elf2uf2-rs -d"
|
||||
runner = "picotool load -u -v -x -t elf"
|
||||
# runner = "elf2uf2-rs -d" # rp2040
|
||||
|
||||
[build]
|
||||
target = "thumbv8m.main-none-eabihf"
|
||||
# target = "thumbv6m-none-eabi" # rp2040
|
||||
|
|
|
@ -10,7 +10,20 @@ jobs:
|
|||
steps:
|
||||
- uses: https://github.com/actions/checkout@main
|
||||
|
||||
- uses: https://github.com/SebRollen/toml-action@v1.2.0
|
||||
id: read_rust_toolchain
|
||||
with:
|
||||
file: rust-toolchain
|
||||
field: toolchain.targets
|
||||
id: read_rust_components
|
||||
with:
|
||||
file: rust-toolchain
|
||||
field: toolchain.components
|
||||
|
||||
- uses: https://github.com/dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: ${{ steps.read_rust_toolchain.outputs.value }}
|
||||
components: ${{ steps.read_rust_components.outputs.value }}
|
||||
|
||||
- name: Build
|
||||
run: cargo build
|
|
@ -22,3 +22,9 @@ embassy-futures = { version = "0.1.1" }
|
|||
|
||||
cortex-m-rt = "0.7.5"
|
||||
cortex-m = { version = "0.7.7", features = ["inline-asm"] }
|
||||
|
||||
[features]
|
||||
rp2350 = ["embassy-rp/rp235xa"]
|
||||
rp2040 = ["embassy-rp/rp2040"]
|
||||
|
||||
default = ["rp2350"]
|
||||
|
|
14
build.rs
14
build.rs
|
@ -17,10 +17,19 @@ fn main() {
|
|||
// Put `memory.x` in our output directory and ensure it's
|
||||
// on the linker search path.
|
||||
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
|
||||
#[cfg(feature = "rp2040")]
|
||||
File::create(out.join("memory.x"))
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("memory.x"))
|
||||
.write_all(include_bytes!("rp_2040_memory.x"))
|
||||
.unwrap();
|
||||
|
||||
#[cfg(feature = "rp2350")]
|
||||
File::create(out.join("memory.x"))
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("rp_2350_memory.x"))
|
||||
.unwrap();
|
||||
|
||||
println!("cargo:rustc-link-search={}", out.display());
|
||||
|
||||
// By default, Cargo will re-run a build script whenever
|
||||
|
@ -31,4 +40,7 @@ fn main() {
|
|||
|
||||
println!("cargo:rustc-link-arg-bins=--nmagic");
|
||||
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
||||
|
||||
#[cfg(feature = "rp2040")]
|
||||
println!("cargo:rustc-link-arg-bins=-Tlink-rp.x");
|
||||
}
|
||||
|
|
17
rp_2040_memory.x
Normal file
17
rp_2040_memory.x
Normal file
|
@ -0,0 +1,17 @@
|
|||
MEMORY {
|
||||
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
|
||||
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
|
||||
|
||||
/* Pick one of the two options for RAM layout */
|
||||
|
||||
/* OPTION A: Use all RAM banks as one big block */
|
||||
/* Reasonable, unless you are doing something */
|
||||
/* really particular with DMA or other concurrent */
|
||||
/* access that would benefit from striping */
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 264K
|
||||
|
||||
/* OPTION B: Keep the unstriped sections separate */
|
||||
/* RAM: ORIGIN = 0x20000000, LENGTH = 256K */
|
||||
/* SCRATCH_A: ORIGIN = 0x20040000, LENGTH = 4K */
|
||||
/* SCRATCH_B: ORIGIN = 0x20041000, LENGTH = 4K */
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
[toolchain]
|
||||
components = [ "rust-src", "rustfmt", "llvm-tools" ]
|
||||
targets = ["thumbv6m-none-eabi"]
|
||||
components = ["rust-src", "rustfmt", "llvm-tools"]
|
||||
targets = ["thumbv8m.main-none-eabihf"]
|
||||
# targets = ["thumbv6m-none-eabi"]
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -1,6 +1,12 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
#[cfg(not(all(
|
||||
not(all(feature = "rp2040", feature = "rp2350")),
|
||||
any(feature = "rp2040", feature = "rp2350")
|
||||
)))]
|
||||
compile_error!("Enable either feature rp2040 (pico 1) or feature rp2350 (pico 2)");
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
use embassy_executor::Spawner;
|
||||
|
@ -11,6 +17,11 @@ fn panic(_info: &PanicInfo) -> ! {
|
|||
loop {}
|
||||
}
|
||||
|
||||
#[cfg(feature = "rp2350")]
|
||||
#[link_section = ".start_block"]
|
||||
#[used]
|
||||
pub static IMAGE_DEF: embassy_rp::block::ImageDef = embassy_rp::block::ImageDef::secure_exe();
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
let p = embassy_rp::init(Default::default());
|
||||
|
|
Loading…
Reference in a new issue