QSPI Spansion Remove Page Alignement Constraint #51

Merged
muellerr merged 3 commits from meier/qspi-remove-page-alignment-constraint into main 2026-03-10 13:28:43 +01:00
4 changed files with 16 additions and 14 deletions
+2 -2
View File
@@ -129,13 +129,13 @@ async fn main(_spawner: Spawner) -> ! {
spansion_qspi
.erase_sector(0x10000)
.expect("erasing sector failed");
spansion_qspi.read_page_fast_read(0x10000, &mut read_buf, true);
spansion_qspi.read_fast_read(0x10000, &mut read_buf, true);
for read in read_buf.iter() {
assert_eq!(*read, 0xFF);
}
read_buf.fill(0);
spansion_qspi.write_pages(0x10000, &write_buf).unwrap();
spansion_qspi.read_page_fast_read(0x10000, &mut read_buf, true);
spansion_qspi.read_fast_read(0x10000, &mut read_buf, true);
for (read, written) in read_buf.iter().zip(write_buf.iter()) {
assert_eq!(read, written);
}
+6 -9
View File
@@ -500,7 +500,7 @@ impl QspiSpansionS25Fl256SIoMode {
return Err(AddrError::Alignment.into());
}
for chunk in data.chunks(PAGE_SIZE) {
self.program_page(addr, chunk)?;
self.program(addr, chunk)?;
addr += PAGE_SIZE as u32;
}
Ok(())
@@ -510,13 +510,10 @@ impl QspiSpansionS25Fl256SIoMode {
/// This function will block until the operation has completed.
///
/// The data length max not exceed the page size [PAGE_SIZE].
pub fn program_page(&mut self, addr: u32, data: &[u8]) -> Result<(), ProgramPageError> {
pub fn program(&mut self, addr: u32, data: &[u8]) -> Result<(), ProgramPageError> {
if addr + data.len() as u32 > u24::MAX.as_u32() {
return Err(AddrError::OutOfRange.into());
}
if !addr.is_multiple_of(PAGE_SIZE as u32) {
return Err(AddrError::Alignment.into());
}
if data.len() > PAGE_SIZE {
return Err(ProgramPageError::DataLargerThanPage);
}
@@ -613,7 +610,7 @@ impl QspiSpansionS25Fl256SIoMode {
}
}
fn generic_read_page(&self, addr: u32, buf: &mut [u8], dummy_byte: bool, fast_read: bool) {
fn generic_read(&self, addr: u32, buf: &mut [u8], dummy_byte: bool, fast_read: bool) {
let mut offset = 0;
let reg_id = if fast_read {
RegisterId::FastRead
@@ -733,13 +730,13 @@ impl QspiSpansionS25Fl256SIoMode {
}
}
pub fn read_page_fast_read(&self, addr: u32, buf: &mut [u8], dummy_byte: bool) {
self.generic_read_page(addr, buf, dummy_byte, true)
pub fn read_fast_read(&self, addr: u32, buf: &mut [u8], dummy_byte: bool) {
self.generic_read(addr, buf, dummy_byte, true)
}
/// Only works if the clock speed is slower than 50 MHz according to datasheet.
pub fn read_page_read(&self, addr: u32, buf: &mut [u8]) {
self.generic_read_page(addr, buf, false, false)
self.generic_read(addr, buf, false, false)
}
}
+6 -1
View File
@@ -11,4 +11,9 @@ The main `justfile` provides a convenience runner:
just flash-nor-zedboard <path to my boot.bin>
```
Please note that `xsct` must be callable for this to be usable.
Please note that `xsct` must be callable for this to be usable which is part of a Xilinx Vitis installation.
If the hardware server is running on a remote target the IP address can be specified by setting the environment variable ip_address_hw_server.
````sh
$ export ip_address_hw_server=<ip-address>
````
+2 -2
View File
@@ -148,7 +148,7 @@ fn main() -> ! {
let write_size = core::cmp::min(qspi_spansion::PAGE_SIZE, boot_bin_size - current_addr);
let write_slice = &boot_bin_slice[current_addr..current_addr + write_size];
log::debug!("Programming address {:#x}", current_addr);
match spansion_qspi.program_page(current_addr as u32, write_slice) {
match spansion_qspi.program(current_addr as u32, write_slice) {
Ok(()) => {}
Err(e) => {
log::error!(
@@ -160,7 +160,7 @@ fn main() -> ! {
}
}
if VERIFY_PROGRAMMING {
spansion_qspi.read_page_fast_read(
spansion_qspi.read_fast_read(
current_addr as u32,
&mut read_buf[0..write_size],
true,