init repo
This commit is contained in:
10
.cargo/config.toml
Normal file
10
.cargo/config.toml
Normal file
@@ -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"
|
||||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/target
|
||||||
1342
Cargo.lock
generated
Normal file
1342
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
47
Cargo.toml
Normal file
47
Cargo.toml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
[package]
|
||||||
|
edition = "2024"
|
||||||
|
name = "my-led-tree"
|
||||||
|
version = "0.1.0"
|
||||||
|
publish = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
embassy-embedded-hal = { version = "0.5.0", features = ["defmt"] }
|
||||||
|
embassy-sync = { version = "0.7.2", features = ["defmt"] }
|
||||||
|
embassy-executor = { version = "0.9.0", features = [
|
||||||
|
"arch-cortex-m",
|
||||||
|
"executor-thread",
|
||||||
|
"executor-interrupt",
|
||||||
|
"defmt",
|
||||||
|
] }
|
||||||
|
embassy-time = { version = "0.5.0", features = [
|
||||||
|
"defmt",
|
||||||
|
"defmt-timestamp-uptime",
|
||||||
|
] }
|
||||||
|
embassy-rp = { version = "0.9.0", features = [
|
||||||
|
"defmt",
|
||||||
|
"unstable-pac",
|
||||||
|
"time-driver",
|
||||||
|
"critical-section-impl",
|
||||||
|
"rp235xa",
|
||||||
|
"binary-info",
|
||||||
|
] }
|
||||||
|
embassy-futures = { version = "0.1.2" }
|
||||||
|
|
||||||
|
defmt = "1.0.1"
|
||||||
|
defmt-rtt = "1.0.0"
|
||||||
|
|
||||||
|
cortex-m = { version = "0.7.6", features = ["inline-asm"] }
|
||||||
|
cortex-m-rt = "0.7.0"
|
||||||
|
panic-probe = { version = "1.0.0", features = ["print-defmt"] }
|
||||||
|
|
||||||
|
embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
|
||||||
|
embedded-hal-async = "1.0"
|
||||||
|
embedded-io-async = { version = "0.7.0", features = ["defmt"] }
|
||||||
|
static_cell = "2.1"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
# Enable generation of debug symbols even on release builds
|
||||||
|
debug = true
|
||||||
|
|
||||||
|
[package.metadata.embassy]
|
||||||
|
build = [{ target = "thumbv8m.main-none-eabihf" }]
|
||||||
35
build.rs
Normal file
35
build.rs
Normal file
@@ -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");
|
||||||
|
}
|
||||||
75
memory.x
Normal file
75
memory.x
Normal file
@@ -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(4)
|
||||||
|
{
|
||||||
|
__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);
|
||||||
15
rust-toolchain.toml
Normal file
15
rust-toolchain.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "1.92"
|
||||||
|
components = [ "rust-src", "rustfmt", "llvm-tools" ]
|
||||||
|
targets = [
|
||||||
|
"thumbv7em-none-eabi",
|
||||||
|
"thumbv7m-none-eabi",
|
||||||
|
"thumbv6m-none-eabi",
|
||||||
|
"thumbv7em-none-eabihf",
|
||||||
|
"thumbv8m.main-none-eabihf",
|
||||||
|
"riscv32imac-unknown-none-elf",
|
||||||
|
"wasm32-unknown-unknown",
|
||||||
|
"armv7a-none-eabi",
|
||||||
|
"armv7r-none-eabi",
|
||||||
|
"armv7r-none-eabihf",
|
||||||
|
]
|
||||||
19
src/main.rs
Normal file
19
src/main.rs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
|
use embassy_executor::Spawner;
|
||||||
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
|
#[unsafe(link_section = ".bi_entries")]
|
||||||
|
#[used]
|
||||||
|
pub static PICOTOOL_ENTRIES: [embassy_rp::binary_info::EntryAddr; 4] = [
|
||||||
|
embassy_rp::binary_info::rp_program_name!(c"My LED tree"),
|
||||||
|
embassy_rp::binary_info::rp_program_description!(c"A LED tree control program"),
|
||||||
|
embassy_rp::binary_info::rp_cargo_version!(),
|
||||||
|
embassy_rp::binary_info::rp_program_build_attribute!(),
|
||||||
|
];
|
||||||
|
|
||||||
|
#[embassy_executor::main]
|
||||||
|
async fn main(spawner: Spawner) {
|
||||||
|
let _ = embassy_rp::init(Default::default());
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user