generated from melfely/embassy-template-rp2350
Initial commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||
runner = "probe-rs run --chip RP235x"
|
||||
#runner = "elf2uf2-rs -d"
|
||||
#runner = "picotool load -u -v -x -t elf"
|
||||
|
||||
[build]
|
||||
target = "thumbv8m.main-none-eabihf"
|
||||
|
||||
[env]
|
||||
DEFMT_LOG = "debug"
|
||||
@@ -0,0 +1 @@
|
||||
/target
|
||||
Generated
+1731
File diff suppressed because it is too large
Load Diff
+22
@@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "embassy_template"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
defmt = "1.1.1"
|
||||
embassy-embedded-hal = { version = "0.6.0", features = ["defmt"] }
|
||||
embassy-executor = { version = "0.10.0", features = ["defmt"] }
|
||||
embassy-futures = { version = "0.1.2", features = ["defmt"] }
|
||||
embassy-rp = { version = "0.10.0", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl", "rp235xa", "binary-info", "executor-thread", "executor-interrupt"] }
|
||||
embassy-sync = { version = "0.8.0", features = ["defmt"] }
|
||||
embassy-time = { version = "0.5.1", features = ["defmt", "defmt-timestamp-uptime"] }
|
||||
embassy-usb = { version = "0.6.0", features = ["defmt"] }
|
||||
cortex-m = { version = "0.7.6", features = ["inline-asm"] }
|
||||
cortex-m-rt = "0.7.0"
|
||||
critical-section = "1.1"
|
||||
panic-probe = { version = "1.0.0", features = ["print-defmt"] }
|
||||
heapless = "0.9"
|
||||
embedded-hal-async = "1.0"
|
||||
embedded-io-async = { version = "0.7.0", features = ["defmt"] }
|
||||
defmt-rtt = "1.3.0"
|
||||
@@ -0,0 +1,5 @@
|
||||
# Minimal Embassy Template For RP2350
|
||||
|
||||
This is a minimialized template for the RP2350. This does NOT include any of the needed information for the cyw43 Wifi Chip on the Pico 2 Wifi. This is a basic init for the RP2350 CORE not for the Pico 2 or Pico 2 W specifically.
|
||||
|
||||
Now both the Pico 2 and Pico 2 W CAN use this because they use the RP2350, but this is a generalized minimialist template to reduce the boiler plate of just getting the *bare* minimum setup
|
||||
@@ -0,0 +1,35 @@
|
||||
//! This build script copies the `memory.x` file from the crate root into
|
||||
//! a directory where the linker can always find it at build time.
|
||||
//! For many projects this is optional, as the linker always searches the
|
||||
//! project root directory -- wherever `Cargo.toml` is. However, if you
|
||||
//! are using a workspace or have a more complicated build setup, this
|
||||
//! build script becomes required. Additionally, by requesting that
|
||||
//! Cargo re-run the build script whenever `memory.x` is changed,
|
||||
//! updating `memory.x` ensures a rebuild of the application with the
|
||||
//! new memory settings.
|
||||
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
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());
|
||||
File::create(out.join("memory.x"))
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("memory.x"))
|
||||
.unwrap();
|
||||
println!("cargo:rustc-link-search={}", out.display());
|
||||
|
||||
// By default, Cargo will re-run a build script whenever
|
||||
// any file in the project changes. By specifying `memory.x`
|
||||
// here, we ensure the build script is only re-run when
|
||||
// `memory.x` is changed.
|
||||
println!("cargo:rerun-if-changed=memory.x");
|
||||
|
||||
println!("cargo:rustc-link-arg-bins=--nmagic");
|
||||
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
||||
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
MEMORY {
|
||||
/*
|
||||
* The RP2350 has either external or internal flash.
|
||||
*
|
||||
* 2 MiB is a safe default here, although a Pico 2 has 4 MiB.
|
||||
*/
|
||||
FLASH : ORIGIN = 0x10000000, LENGTH = 2048K
|
||||
/*
|
||||
* RAM consists of 8 banks, SRAM0-SRAM7, with a striped mapping.
|
||||
* This is usually good for performance, as it distributes load on
|
||||
* those banks evenly.
|
||||
*/
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 512K
|
||||
/*
|
||||
* RAM banks 8 and 9 use a direct mapping. They can be used to have
|
||||
* memory areas dedicated for some specific job, improving predictability
|
||||
* of access times.
|
||||
* Example: Separate stacks for core0 and core1.
|
||||
*/
|
||||
SRAM8 : ORIGIN = 0x20080000, LENGTH = 4K
|
||||
SRAM9 : ORIGIN = 0x20081000, LENGTH = 4K
|
||||
}
|
||||
|
||||
SECTIONS {
|
||||
/* ### Boot ROM info
|
||||
*
|
||||
* Goes after .vector_table, to keep it in the first 4K of flash
|
||||
* where the Boot ROM (and picotool) can find it
|
||||
*/
|
||||
.start_block : ALIGN(8)
|
||||
{
|
||||
__start_block_addr = .;
|
||||
KEEP(*(.start_block));
|
||||
KEEP(*(.boot_info));
|
||||
} > FLASH
|
||||
|
||||
} INSERT AFTER .vector_table;
|
||||
|
||||
/* move .text to start /after/ the boot info */
|
||||
_stext = ADDR(.start_block) + SIZEOF(.start_block);
|
||||
|
||||
SECTIONS {
|
||||
/* ### Picotool 'Binary Info' Entries
|
||||
*
|
||||
* Picotool looks through this block (as we have pointers to it in our
|
||||
* header) to find interesting information.
|
||||
*/
|
||||
.bi_entries : ALIGN(4)
|
||||
{
|
||||
/* We put this in the header */
|
||||
__bi_entries_start = .;
|
||||
/* Here are the entries */
|
||||
KEEP(*(.bi_entries));
|
||||
/* Keep this block a nice round size */
|
||||
. = ALIGN(4);
|
||||
/* We put this in the header */
|
||||
__bi_entries_end = .;
|
||||
} > FLASH
|
||||
} INSERT AFTER .text;
|
||||
|
||||
SECTIONS {
|
||||
/* ### Boot ROM extra info
|
||||
*
|
||||
* Goes after everything in our program, so it can contain a signature.
|
||||
*/
|
||||
.end_block : ALIGN(4)
|
||||
{
|
||||
__end_block_addr = .;
|
||||
KEEP(*(.end_block));
|
||||
} > FLASH
|
||||
|
||||
} INSERT AFTER .uninit;
|
||||
|
||||
PROVIDE(start_to_end = __end_block_addr - __start_block_addr);
|
||||
PROVIDE(end_to_start = __start_block_addr - __end_block_addr);
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use defmt::*;
|
||||
use defmt_rtt as _;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_time::Timer;
|
||||
use panic_probe as _;
|
||||
|
||||
// Program metadata for `picotool info`.
|
||||
// This isn't needed, but it's recommended to have these minimal entries.
|
||||
#[unsafe(link_section = ".bi_entries")]
|
||||
#[used]
|
||||
pub static PICOTOOL_ENTRIES: [embassy_rp::binary_info::EntryAddr; 4] = [
|
||||
embassy_rp::binary_info::rp_program_name!(c"Blinky Example"),
|
||||
embassy_rp::binary_info::rp_program_description!(
|
||||
c"This example tests the RP Pico on board LED, connected to gpio 25"
|
||||
),
|
||||
embassy_rp::binary_info::rp_cargo_version!(),
|
||||
embassy_rp::binary_info::rp_program_build_attribute!(),
|
||||
];
|
||||
|
||||
#[embassy_executor::main(
|
||||
executor = "embassy_rp::executor::Executor",
|
||||
entry = "cortex_m_rt::entry"
|
||||
)]
|
||||
async fn main(_spawner: Spawner) {
|
||||
let p = embassy_rp::init(Default::default());
|
||||
|
||||
loop {
|
||||
info!("led on!");
|
||||
Timer::after_millis(500).await;
|
||||
|
||||
info!("led off!");
|
||||
Timer::after_millis(500).await;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user