aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-06-05 22:54:25 +0200
committerDario Nieuwenhuis <[email protected]>2023-06-05 22:55:15 +0200
commitadf053a935d03711b48859e3243e86d3038fa7c4 (patch)
treebca0281f00cfb5b643eee52a51ad9c645a0e1a73
parent5ee26a5dd1af3e172610b94b2657af709b319dad (diff)
rp/flash: unify FLASH_BASE const.
-rw-r--r--embassy-rp/src/flash.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/embassy-rp/src/flash.rs b/embassy-rp/src/flash.rs
index 0410429e0..838b987dc 100644
--- a/embassy-rp/src/flash.rs
+++ b/embassy-rp/src/flash.rs
@@ -9,7 +9,7 @@ use embedded_storage::nor_flash::{
9use crate::pac; 9use crate::pac;
10use crate::peripherals::FLASH; 10use crate::peripherals::FLASH;
11 11
12pub const FLASH_BASE: usize = 0x10000000; 12pub const FLASH_BASE: *const u32 = 0x10000000 as _;
13 13
14// **NOTE**: 14// **NOTE**:
15// 15//
@@ -63,8 +63,8 @@ impl<'d, T: Instance, const FLASH_SIZE: usize> Flash<'d, T, FLASH_SIZE> {
63 pub fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { 63 pub fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> {
64 trace!( 64 trace!(
65 "Reading from 0x{:x} to 0x{:x}", 65 "Reading from 0x{:x} to 0x{:x}",
66 FLASH_BASE + offset as usize, 66 FLASH_BASE as u32 + offset,
67 FLASH_BASE + offset as usize + bytes.len() 67 FLASH_BASE as u32 + offset + bytes.len() as u32
68 ); 68 );
69 check_read(self, offset, bytes.len())?; 69 check_read(self, offset, bytes.len())?;
70 70
@@ -242,6 +242,7 @@ impl<'d, T: Instance, const FLASH_SIZE: usize> NorFlash for Flash<'d, T, FLASH_S
242mod ram_helpers { 242mod ram_helpers {
243 use core::marker::PhantomData; 243 use core::marker::PhantomData;
244 244
245 use super::*;
245 use crate::rom_data; 246 use crate::rom_data;
246 247
247 #[repr(C)] 248 #[repr(C)]
@@ -321,7 +322,7 @@ mod ram_helpers {
321 pub unsafe fn flash_range_erase(addr: u32, len: u32, use_boot2: bool) { 322 pub unsafe fn flash_range_erase(addr: u32, len: u32, use_boot2: bool) {
322 let mut boot2 = [0u32; 256 / 4]; 323 let mut boot2 = [0u32; 256 / 4];
323 let ptrs = if use_boot2 { 324 let ptrs = if use_boot2 {
324 rom_data::memcpy44(&mut boot2 as *mut _, super::FLASH_BASE as *const _, 256); 325 rom_data::memcpy44(&mut boot2 as *mut _, FLASH_BASE, 256);
325 flash_function_pointers_with_boot2(true, false, &boot2) 326 flash_function_pointers_with_boot2(true, false, &boot2)
326 } else { 327 } else {
327 flash_function_pointers(true, false) 328 flash_function_pointers(true, false)
@@ -351,7 +352,7 @@ mod ram_helpers {
351 pub unsafe fn flash_range_erase_and_program(addr: u32, data: &[u8], use_boot2: bool) { 352 pub unsafe fn flash_range_erase_and_program(addr: u32, data: &[u8], use_boot2: bool) {
352 let mut boot2 = [0u32; 256 / 4]; 353 let mut boot2 = [0u32; 256 / 4];
353 let ptrs = if use_boot2 { 354 let ptrs = if use_boot2 {
354 rom_data::memcpy44(&mut boot2 as *mut _, super::FLASH_BASE as *const _, 256); 355 rom_data::memcpy44(&mut boot2 as *mut _, FLASH_BASE, 256);
355 flash_function_pointers_with_boot2(true, true, &boot2) 356 flash_function_pointers_with_boot2(true, true, &boot2)
356 } else { 357 } else {
357 flash_function_pointers(true, true) 358 flash_function_pointers(true, true)
@@ -386,7 +387,7 @@ mod ram_helpers {
386 pub unsafe fn flash_range_program(addr: u32, data: &[u8], use_boot2: bool) { 387 pub unsafe fn flash_range_program(addr: u32, data: &[u8], use_boot2: bool) {
387 let mut boot2 = [0u32; 256 / 4]; 388 let mut boot2 = [0u32; 256 / 4];
388 let ptrs = if use_boot2 { 389 let ptrs = if use_boot2 {
389 rom_data::memcpy44(&mut boot2 as *mut _, super::FLASH_BASE as *const _, 256); 390 rom_data::memcpy44(&mut boot2 as *mut _, FLASH_BASE, 256);
390 flash_function_pointers_with_boot2(false, true, &boot2) 391 flash_function_pointers_with_boot2(false, true, &boot2)
391 } else { 392 } else {
392 flash_function_pointers(false, true) 393 flash_function_pointers(false, true)
@@ -511,7 +512,7 @@ mod ram_helpers {
511 pub unsafe fn flash_unique_id(out: &mut [u8], use_boot2: bool) { 512 pub unsafe fn flash_unique_id(out: &mut [u8], use_boot2: bool) {
512 let mut boot2 = [0u32; 256 / 4]; 513 let mut boot2 = [0u32; 256 / 4];
513 let ptrs = if use_boot2 { 514 let ptrs = if use_boot2 {
514 rom_data::memcpy44(&mut boot2 as *mut _, 0x10000000 as *const _, 256); 515 rom_data::memcpy44(&mut boot2 as *mut _, FLASH_BASE, 256);
515 flash_function_pointers_with_boot2(false, false, &boot2) 516 flash_function_pointers_with_boot2(false, false, &boot2)
516 } else { 517 } else {
517 flash_function_pointers(false, false) 518 flash_function_pointers(false, false)
@@ -539,7 +540,7 @@ mod ram_helpers {
539 pub unsafe fn flash_jedec_id(use_boot2: bool) -> u32 { 540 pub unsafe fn flash_jedec_id(use_boot2: bool) -> u32 {
540 let mut boot2 = [0u32; 256 / 4]; 541 let mut boot2 = [0u32; 256 / 4];
541 let ptrs = if use_boot2 { 542 let ptrs = if use_boot2 {
542 rom_data::memcpy44(&mut boot2 as *mut _, 0x10000000 as *const _, 256); 543 rom_data::memcpy44(&mut boot2 as *mut _, FLASH_BASE, 256);
543 flash_function_pointers_with_boot2(false, false, &boot2) 544 flash_function_pointers_with_boot2(false, false, &boot2)
544 } else { 545 } else {
545 flash_function_pointers(false, false) 546 flash_function_pointers(false, false)