From a4e228bdd69fd9e8e66198424247f68877192ec5 Mon Sep 17 00:00:00 2001 From: macronova Date: Sat, 12 Oct 2024 19:58:43 -0700 Subject: [PATCH] Remove defmt --- .cargo/config.toml | 5 +-- Cargo.lock | 76 ++++----------------------------------- Cargo.toml | 14 ++++---- build.rs | 1 - memory.x | 90 +++++++++++++++++++++++++++++++++++++++------- src/main.rs | 7 ++-- 6 files changed, 93 insertions(+), 100 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 4837907..b407f46 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,8 +1,5 @@ [build] target = "thumbv6m-none-eabi" -[env] -DEFMT_LOG = "debug" - [target.'cfg(all(target_arch = "arm", target_os = "none"))'] -runner = "elf2uf2-rs -d" +runner = "elf2uf2-rs --deploy --serial" diff --git a/Cargo.lock b/Cargo.lock index f441c5e..3278811 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,12 +77,6 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.6.0" @@ -178,7 +172,6 @@ checksum = "04c691efd1af993c7c4cb79eb13da4b901c1e8c6d148280e2a36ae2885f83218" dependencies = [ "cortex-m", "cortex-m-rt", - "defmt", "embassy-futures", "embassy-net-driver-channel", "embassy-sync", @@ -196,7 +189,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22bb644457cfefdd1f0eeea7a3a708a61f9ab223aaf56b7f50589180808d302a" dependencies = [ "cyw43", - "defmt", "embassy-rp", "fixed", "pio", @@ -244,48 +236,6 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f578e8e2c440e7297e008bb5486a3a8a194775224bbc23729b0dbdfaeebf162e" -[[package]] -name = "defmt" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a99dd22262668b887121d4672af5a64b238f026099f1a2a1b322066c9ecfe9e0" -dependencies = [ - "bitflags 1.3.2", - "defmt-macros", -] - -[[package]] -name = "defmt-macros" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a9f309eff1f79b3ebdf252954d90ae440599c26c2c553fe87a2d17195f2dcb" -dependencies = [ - "defmt-parser", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 2.0.79", -] - -[[package]] -name = "defmt-parser" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4a5fefe330e8d7f31b16a318f9ce81000d8e35e69b93eae154d16d2278f70f" -dependencies = [ - "thiserror", -] - -[[package]] -name = "defmt-rtt" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab697b3dbbc1750b7c8b821aa6f6e7f2480b47a99bc057a2ed7b170ebef0c51" -dependencies = [ - "critical-section", - "defmt", -] - [[package]] name = "diff" version = "0.1.13" @@ -353,7 +303,6 @@ checksum = "09ed0e24bdd4a5f4ff1b72ee4f264b1d23e179ea71a77d984b5fd24877a2bbe1" dependencies = [ "cortex-m", "critical-section", - "defmt", "document-features", "embassy-executor-macros", "embassy-time-driver", @@ -386,7 +335,6 @@ checksum = "0ef3bac31ec146321248a169e9c7b5799f1e0b3829c7a9b324cb4600a7438f59" dependencies = [ "cortex-m", "critical-section", - "defmt", "num-traits", ] @@ -418,7 +366,6 @@ dependencies = [ "cortex-m", "cortex-m-rt", "critical-section", - "defmt", "document-features", "embassy-embedded-hal", "embassy-futures", @@ -465,7 +412,6 @@ checksum = "158080d48f824fad101d7b2fae2d83ac39e3f7a6fa01811034f7ab8ffc6e7309" dependencies = [ "cfg-if", "critical-section", - "defmt", "document-features", "embassy-time-driver", "embassy-time-queue-driver", @@ -496,9 +442,6 @@ name = "embassy-usb-driver" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fc247028eae04174b6635104a35b1ed336aabef4654f5e87a8f32327d231970" -dependencies = [ - "defmt", -] [[package]] name = "embedded-hal" @@ -719,7 +662,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" dependencies = [ - "defmt", "hash32", "stable_deref_trait", ] @@ -809,7 +751,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags", "libc", ] @@ -898,14 +840,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] -name = "panic-probe" -version = "0.3.2" +name = "panic-halt" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4047d9235d1423d66cc97da7d07eddb54d4f154d6c13805c6d0793956f4f25b0" -dependencies = [ - "cortex-m", - "defmt", -] +checksum = "de96540e0ebde571dc55c73d60ef407c653844e6f9a1e2fdbd40c07b9252d812" [[package]] name = "parking_lot" @@ -962,12 +900,10 @@ dependencies = [ "cortex-m-rt", "cyw43", "cyw43-pio", - "defmt", - "defmt-rtt", "embassy-executor", "embassy-rp", "embassy-time", - "panic-probe", + "panic-halt", "portable-atomic", "static_cell", ] @@ -1093,7 +1029,7 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ - "bitflags 2.6.0", + "bitflags", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d593089..acd446c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,14 +6,12 @@ license = "MIT" [dependencies] cortex-m-rt = "*" -cyw43 = { version = "*", features = ["defmt", "firmware-logs"] } -cyw43-pio = { version = "*", features = ["defmt"] } -defmt = "*" -defmt-rtt = "*" -embassy-executor = { version = "*", features = ["arch-cortex-m", "defmt", "executor-interrupt", "executor-thread", "integrated-timers", "task-arena-size-98304"] } -embassy-rp = { version = "*", features = ["critical-section-impl", "defmt", "time-driver"] } -embassy-time = { version = "*", features = ["defmt", "defmt-timestamp-uptime"] } -panic-probe = { version = "*", features = ["print-defmt"] } +cyw43 = "*" +cyw43-pio = "*" +embassy-executor = { version = "*", features = ["arch-cortex-m", "executor-interrupt", "executor-thread", "integrated-timers", "task-arena-size-98304"] } +embassy-rp = { version = "*", features = ["critical-section-impl", "time-driver"] } +embassy-time = "*" +panic-halt = "*" portable-atomic = { version = "*", features = ["critical-section"] } static_cell = "*" diff --git a/build.rs b/build.rs index 3f915f9..7affe2e 100644 --- a/build.rs +++ b/build.rs @@ -32,5 +32,4 @@ fn main() { println!("cargo:rustc-link-arg-bins=--nmagic"); println!("cargo:rustc-link-arg-bins=-Tlink.x"); println!("cargo:rustc-link-arg-bins=-Tlink-rp.x"); - println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); } diff --git a/memory.x b/memory.x index ef19dff..10c6cfa 100644 --- a/memory.x +++ b/memory.x @@ -1,17 +1,83 @@ MEMORY { BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100 + /* + * Here we assume you have 2048 KiB of Flash. This is what the Pi Pico + * has, but your board may have more or less Flash and you should adjust + * this value to suit. + */ FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100 + /* + * RAM consists of 4 banks, SRAM0-SRAM3, with a striped mapping. + * This is usually good for performance, as it distributes load on + * those banks evenly. + */ + RAM : ORIGIN = 0x20000000, LENGTH = 256K + /* + * RAM banks 4 and 5 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. + */ + SRAM4 : ORIGIN = 0x20040000, LENGTH = 4k + SRAM5 : ORIGIN = 0x20041000, LENGTH = 4k - /* 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 */ + /* SRAM banks 0-3 can also be accessed directly. However, those ranges + alias with the RAM mapping, above. So don't use them at the same time! + SRAM0 : ORIGIN = 0x21000000, LENGTH = 64k + SRAM1 : ORIGIN = 0x21010000, LENGTH = 64k + SRAM2 : ORIGIN = 0x21020000, LENGTH = 64k + SRAM3 : ORIGIN = 0x21030000, LENGTH = 64k + */ } + +EXTERN(BOOT2_FIRMWARE) + +SECTIONS { + /* ### Boot loader + * + * An executable block of code which sets up the QSPI interface for + * 'Execute-In-Place' (or XIP) mode. Also sends chip-specific commands to + * the external flash chip. + * + * Must go at the start of external flash, where the Boot ROM expects it. + */ + .boot2 ORIGIN(BOOT2) : + { + KEEP(*(.boot2)); + } > BOOT2 +} INSERT BEFORE .text; + +SECTIONS { + /* ### Boot ROM info + * + * Goes after .vector_table, to keep it in the first 512 bytes of flash, + * where picotool can find it + */ + .boot_info : ALIGN(4) + { + KEEP(*(.boot_info)); + } > FLASH + +} INSERT AFTER .vector_table; + +/* move .text to start /after/ the boot info */ +_stext = ADDR(.boot_info) + SIZEOF(.boot_info); + +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; diff --git a/src/main.rs b/src/main.rs index 107b853..4d985de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,8 @@ #![no_std] #![no_main] +extern crate panic_halt; use cyw43_pio::PioSpi; -use defmt::*; -use defmt_rtt as _; use embassy_executor::Spawner; use embassy_rp::{ bind_interrupts, @@ -12,7 +11,6 @@ use embassy_rp::{ pio::{InterruptHandler, Pio}, }; use embassy_time::Timer; -use panic_probe as _; use static_cell::StaticCell; // bind interrupt request to handler @@ -65,7 +63,7 @@ async fn main(spawner: Spawner) { // spawn network task let (_, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; - unwrap!(spawner.spawn(cyw43_task(runner))); + spawner.spawn(cyw43_task(runner)).unwrap(); // initialize wireless control.init(clm).await; @@ -76,7 +74,6 @@ async fn main(spawner: Spawner) { // time to blink let mut led = false; loop { - info!("Blink!"); led = !led; control.gpio_set(0, led).await; Timer::after_secs(1).await;