converted codebase to pico 2
This commit is contained in:
parent
ecd0800891
commit
1a0301ddd9
7 changed files with 98 additions and 21 deletions
|
@ -1,5 +1,6 @@
|
||||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||||
runner = "elf2uf2-rs --deploy --serial --verbose"
|
#runner = "elf2uf2-rs --deploy --serial --verbose"
|
||||||
|
runner = "picotool load -u -v -x -t elf"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
target = "thumbv6m-none-eabi"
|
target = "thumbv8m.main-none-eabihf"
|
||||||
|
|
7
southbridge/Cargo.lock
generated
7
southbridge/Cargo.lock
generated
|
@ -404,6 +404,7 @@ dependencies = [
|
||||||
"pio",
|
"pio",
|
||||||
"pio-proc",
|
"pio-proc",
|
||||||
"rand_core",
|
"rand_core",
|
||||||
|
"rp-binary-info",
|
||||||
"rp-pac",
|
"rp-pac",
|
||||||
"rp2040-boot2",
|
"rp2040-boot2",
|
||||||
"sha2-const-stable",
|
"sha2-const-stable",
|
||||||
|
@ -1212,6 +1213,12 @@ dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rp-binary-info"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "534e2a451671116f5b9391cb15fae43b9abdc56817bcaca9a95ed32c3e4c6b38"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rp-pac"
|
name = "rp-pac"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
|
|
|
@ -13,11 +13,11 @@ embedded-storage = "0.3.1"
|
||||||
|
|
||||||
cortex-m-rt = "0.7.3"
|
cortex-m-rt = "0.7.3"
|
||||||
|
|
||||||
embassy-executor = { version = "0.7", features = ["task-arena-size-1024", "arch-cortex-m", "executor-thread", "executor-interrupt"] }
|
embassy-executor = { version = "0.7", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] }
|
||||||
embassy-sync = { version = "0.6" }
|
embassy-sync = { version = "0.6" }
|
||||||
embassy-time = { version = "0.4" }
|
embassy-time = { version = "0.4" }
|
||||||
cortex-m = { version = "0.7.6" }
|
cortex-m = { version = "0.7.6" }
|
||||||
embassy-rp = { version = "0.3", features = ["unstable-pac", "time-driver", "critical-section-impl", "rp2040"] }
|
embassy-rp = { version = "0.3", features = ["unstable-pac", "time-driver", "critical-section-impl", "rp235xa", "binary-info"] }
|
||||||
embassy-usb-logger = "0.4.0"
|
embassy-usb-logger = "0.4.0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
||||||
|
|
|
@ -31,5 +31,4 @@ fn main() {
|
||||||
|
|
||||||
println!("cargo:rustc-link-arg-bins=--nmagic");
|
println!("cargo:rustc-link-arg-bins=--nmagic");
|
||||||
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
||||||
println!("cargo:rustc-link-arg-bins=-Tlink-rp.x");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,75 @@
|
||||||
MEMORY
|
MEMORY {
|
||||||
{
|
/*
|
||||||
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
|
* The RP2350 has either external or internal flash.
|
||||||
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
|
*
|
||||||
RAM : ORIGIN = 0x20000000, LENGTH = 264K
|
* 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.
|
||||||
|
*/
|
||||||
|
SRAM4 : ORIGIN = 0x20080000, LENGTH = 4K
|
||||||
|
SRAM5 : 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);
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
# Before upgrading check that everything is available on all tier1 targets here:
|
|
||||||
# https://rust-lang.github.io/rustup-components-history
|
|
||||||
[toolchain]
|
|
||||||
channel = "stable"
|
|
||||||
components = [ "rustfmt" ]
|
|
||||||
targets = [
|
|
||||||
"thumbv6m-none-eabi",
|
|
||||||
"thumbv7em-none-eabihf",
|
|
||||||
"riscv32imac-unknown-none-elf",
|
|
||||||
]
|
|
|
@ -5,7 +5,7 @@ use core::{panic::PanicInfo, sync::atomic::Ordering};
|
||||||
|
|
||||||
use common::{Command, Response, SensorData, BAUDRATE};
|
use common::{Command, Response, SensorData, BAUDRATE};
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_rp::{bind_interrupts, peripherals::{UART0, UART1, USB}, pwm::{self, Pwm}, uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, BufferedUartTx, Config}, usb::Driver};
|
use embassy_rp::{bind_interrupts, block::ImageDef, gpio::{Level, Output}, peripherals::{UART0, UART1, USB}, pwm::{self, Pwm}, uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, BufferedUartTx, Config}, usb::Driver};
|
||||||
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, channel::Channel};
|
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, channel::Channel};
|
||||||
use embassy_time::{with_deadline, with_timeout, Duration, Instant, Timer};
|
use embassy_time::{with_deadline, with_timeout, Duration, Instant, Timer};
|
||||||
use embedded_io::Write;
|
use embedded_io::Write;
|
||||||
|
@ -25,6 +25,10 @@ bind_interrupts!(struct Irqs {
|
||||||
pub static COMMANDS: Channel<CriticalSectionRawMutex, Command, 5> = Channel::new();
|
pub static COMMANDS: Channel<CriticalSectionRawMutex, Command, 5> = Channel::new();
|
||||||
pub static SENSOR_DATA: Channel<CriticalSectionRawMutex, SensorData, 5> = Channel::new();
|
pub static SENSOR_DATA: Channel<CriticalSectionRawMutex, SensorData, 5> = Channel::new();
|
||||||
|
|
||||||
|
#[link_section = ".start_block"]
|
||||||
|
#[used]
|
||||||
|
pub static IMAGE_DEF: ImageDef = ImageDef::secure_exe();
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
async fn logger_task(driver: Driver<'static, USB>) {
|
async fn logger_task(driver: Driver<'static, USB>) {
|
||||||
embassy_usb_logger::run!(1024, log::LevelFilter::Trace, driver);
|
embassy_usb_logger::run!(1024, log::LevelFilter::Trace, driver);
|
||||||
|
@ -40,6 +44,10 @@ fn panic( info: &PanicInfo) -> ! {
|
||||||
async fn main(spawner: Spawner) {
|
async fn main(spawner: Spawner) {
|
||||||
let p = embassy_rp::init(Default::default());
|
let p = embassy_rp::init(Default::default());
|
||||||
|
|
||||||
|
let mut led = Output::new(p.PIN_25, Level::Low);
|
||||||
|
|
||||||
|
led.set_high();
|
||||||
|
|
||||||
let driver = Driver::new(p.USB, Irqs);
|
let driver = Driver::new(p.USB, Irqs);
|
||||||
spawner.spawn(logger_task(driver)).unwrap();
|
spawner.spawn(logger_task(driver)).unwrap();
|
||||||
|
|
||||||
|
@ -74,6 +82,10 @@ async fn main(spawner: Spawner) {
|
||||||
let mut enable_watchdog = Instant::now();
|
let mut enable_watchdog = Instant::now();
|
||||||
let enable_watchdog_time = Duration::from_millis(50);
|
let enable_watchdog_time = Duration::from_millis(50);
|
||||||
|
|
||||||
|
Timer::after_secs(1).await;
|
||||||
|
info!("ready");
|
||||||
|
Timer::after_secs(1).await;
|
||||||
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if !enabled.load(Ordering::Acquire) {
|
if !enabled.load(Ordering::Acquire) {
|
||||||
|
|
Loading…
Reference in a new issue