diff options
| author | Caleb Jamison <[email protected]> | 2024-08-27 13:19:07 -0400 |
|---|---|---|
| committer | Caleb Jamison <[email protected]> | 2024-08-29 10:47:03 -0400 |
| commit | 372270a9b962196ede9c60a705cc3138ba592fec (patch) | |
| tree | 575ac05a27915fc3165f51adf281b177cddca541 /examples | |
| parent | 0a33edc9976caddcdebe0943cce78376f9c49789 (diff) | |
rp235x flash support.
The 2350 doesn't have a boot2 like the 2040, but it does have the
concept of a xip setup function that could be customized. By default the
bootrom searches for the attached flash chip and provides an xip setup
func at the base of the bootram. That bootram is not executable, so it
still needs to be copied to ram like boot2 would be.
Currently does not use inline assembly.
Also switch to picotool, as elf2uf2 has not been patched to support the
2350.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rp23/.cargo/config.toml | 3 | ||||
| -rw-r--r-- | examples/rp23/src/bin/flash.rs | 15 |
2 files changed, 5 insertions, 13 deletions
diff --git a/examples/rp23/.cargo/config.toml b/examples/rp23/.cargo/config.toml index f77e004dc..9a92b1ce2 100644 --- a/examples/rp23/.cargo/config.toml +++ b/examples/rp23/.cargo/config.toml | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] |
| 2 | #runner = "probe-rs run --chip RP2040" | 2 | #runner = "probe-rs run --chip RP2040" |
| 3 | runner = "elf2uf2-rs -d" | 3 | #runner = "elf2uf2-rs -d" |
| 4 | runner = "picotool load -u -v -x -t elf" | ||
| 4 | 5 | ||
| 5 | [build] | 6 | [build] |
| 6 | target = "thumbv8m.main-none-eabihf" | 7 | target = "thumbv8m.main-none-eabihf" |
diff --git a/examples/rp23/src/bin/flash.rs b/examples/rp23/src/bin/flash.rs index 811561f26..84011e394 100644 --- a/examples/rp23/src/bin/flash.rs +++ b/examples/rp23/src/bin/flash.rs | |||
| @@ -21,7 +21,7 @@ pub static IMAGE_DEF: ImageDef = ImageDef::secure_exe(); | |||
| 21 | pub static PICOTOOL_ENTRIES: [embassy_rp::binary_info::EntryAddr; 4] = [ | 21 | pub static PICOTOOL_ENTRIES: [embassy_rp::binary_info::EntryAddr; 4] = [ |
| 22 | embassy_rp::binary_info::rp_program_name!(c"example"), | 22 | embassy_rp::binary_info::rp_program_name!(c"example"), |
| 23 | embassy_rp::binary_info::rp_cargo_version!(), | 23 | embassy_rp::binary_info::rp_cargo_version!(), |
| 24 | embassy_rp::binary_info::rp_program_description!(c"Blinky"), | 24 | embassy_rp::binary_info::rp_program_description!(c"Flash"), |
| 25 | embassy_rp::binary_info::rp_program_build_attribute!(), | 25 | embassy_rp::binary_info::rp_program_build_attribute!(), |
| 26 | ]; | 26 | ]; |
| 27 | 27 | ||
| @@ -41,22 +41,13 @@ async fn main(_spawner: Spawner) { | |||
| 41 | 41 | ||
| 42 | let mut flash = embassy_rp::flash::Flash::<_, Async, FLASH_SIZE>::new(p.FLASH, p.DMA_CH0); | 42 | let mut flash = embassy_rp::flash::Flash::<_, Async, FLASH_SIZE>::new(p.FLASH, p.DMA_CH0); |
| 43 | 43 | ||
| 44 | // Get JEDEC id | ||
| 45 | let jedec = flash.blocking_jedec_id().unwrap(); | ||
| 46 | info!("jedec id: 0x{:x}", jedec); | ||
| 47 | |||
| 48 | // Get unique id | ||
| 49 | let mut uid = [0; 8]; | ||
| 50 | flash.blocking_unique_id(&mut uid).unwrap(); | ||
| 51 | info!("unique id: {:?}", uid); | ||
| 52 | |||
| 53 | erase_write_sector(&mut flash, 0x00); | 44 | erase_write_sector(&mut flash, 0x00); |
| 54 | 45 | ||
| 55 | multiwrite_bytes(&mut flash, ERASE_SIZE as u32); | 46 | multiwrite_bytes(&mut flash, ERASE_SIZE as u32); |
| 56 | 47 | ||
| 57 | background_read(&mut flash, (ERASE_SIZE * 2) as u32).await; | 48 | background_read(&mut flash, (ERASE_SIZE * 2) as u32).await; |
| 58 | 49 | ||
| 59 | loop {} | 50 | info!("Flash Works!"); |
| 60 | } | 51 | } |
| 61 | 52 | ||
| 62 | fn multiwrite_bytes(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH_SIZE>, offset: u32) { | 53 | fn multiwrite_bytes(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH_SIZE>, offset: u32) { |
| @@ -82,7 +73,7 @@ fn multiwrite_bytes(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH | |||
| 82 | 73 | ||
| 83 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut read_buf)); | 74 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut read_buf)); |
| 84 | info!("Contents after write starts with {=[u8]}", read_buf[0..4]); | 75 | info!("Contents after write starts with {=[u8]}", read_buf[0..4]); |
| 85 | if &read_buf[0..4] != &[0x01, 0x02, 0x03, 0x04] { | 76 | if read_buf[0..4] != [0x01, 0x02, 0x03, 0x04] { |
| 86 | defmt::panic!("unexpected"); | 77 | defmt::panic!("unexpected"); |
| 87 | } | 78 | } |
| 88 | } | 79 | } |
