From 21a9a75e9ab7761b1e17f7a3dd2d00980df2f424 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Fri, 22 Aug 2025 15:53:45 +0800 Subject: [PATCH 1/3] xspiloader: Use p_filesz, skip zero length Only filesz data should be written, not memsz. This is a problem for noload sram2 headers, which need to be skipped since they can't be written when the bootloader is running. Signed-off-by: Matt Johnston --- xspiloader/src/main.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/xspiloader/src/main.rs b/xspiloader/src/main.rs index ffd629b..03c176f 100644 --- a/xspiloader/src/main.rs +++ b/xspiloader/src/main.rs @@ -247,27 +247,25 @@ async fn load_elf( }; // Attempt to load PT_LOAD segments - if ph.p_type() == neotron_loader::ProgramHeader::PT_LOAD { + if ph.p_type() == neotron_loader::ProgramHeader::PT_LOAD + && ph.p_filesz() > 0 + { info!( "loading 0x{:x} len 0x{:x} from 0x{:x}", ph.p_paddr(), - ph.p_memsz(), + ph.p_filesz(), ph.p_offset() ); // Flush in case it faults log::logger().flush(); - if !valid_dest(ph.p_paddr(), ph.p_memsz()) { + if !valid_dest(ph.p_paddr(), ph.p_filesz()) { error!("Invalid dest"); return Err(()); } - if ph.p_memsz() == 0 { - continue; - } - let (foff, addr, sz) = if ph.p_paddr() != 0 { - (ph.p_offset(), ph.p_paddr(), ph.p_memsz()) + (ph.p_offset(), ph.p_paddr(), ph.p_filesz()) } else { // Rust disallows NULL pointers, which is unfortunate given // 0x0 is the start of ITCM where reset vectors can go. @@ -288,7 +286,7 @@ async fn load_elf( ); } - (ph.p_offset() + 1, ph.p_paddr() + 1, ph.p_memsz() - 1) + (ph.p_offset() + 1, ph.p_paddr() + 1, ph.p_filesz() - 1) }; let dest = (addr as usize) as *mut u8; From 4a5d5190ebb07c52e94cba4bafbb160a1dbc35c1 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Fri, 22 Aug 2025 16:19:05 +0800 Subject: [PATCH 2/3] xspiloader: Update neotron-loader for Rust 1.89 ELF ELF header output changed in Rust 1.89 and wasn't recognised by the loader, "Wrong ELF format". Signed-off-by: Matt Johnston --- Cargo.lock | 3 +-- xspiloader/Cargo.toml | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 850ccfe..71565f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -739,8 +739,7 @@ checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] name = "neotron-loader" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b8634a088b9d5b338a96b3f6ef45a3bc0b9c0f0d562c7d00e498265fd96e8f" +source = "git+https://github.com/Neotron-Compute/neotron-loader?rev=ab92cecd8a458044aef30b39c87112244deb69c6#ab92cecd8a458044aef30b39c87112244deb69c6" [[package]] name = "no_std_io2" diff --git a/xspiloader/Cargo.toml b/xspiloader/Cargo.toml index 2f4bb50..3d1bc9e 100644 --- a/xspiloader/Cargo.toml +++ b/xspiloader/Cargo.toml @@ -17,4 +17,6 @@ cortex-m = { workspace = true } cortex-m-rt = { workspace = true } panic-probe = { workspace = true } -neotron-loader = "0.1.0" +# Required for ELF payloads build with Rust 1.89 +# https://github.com/Neotron-Compute/neotron-loader/pull/2 +neotron-loader = { git = "https://github.com/Neotron-Compute/neotron-loader", rev = "ab92cecd8a458044aef30b39c87112244deb69c6" } From cc52d70873a75045b038c9a12c6e80c1cbf7f632 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Fri, 22 Aug 2025 16:49:25 +0800 Subject: [PATCH 3/3] Update nvme-mi-dev Signed-off-by: Matt Johnston --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 71565f6..8cb957e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -773,7 +773,7 @@ dependencies = [ [[package]] name = "nvme-mi-dev" version = "0.1.0" -source = "git+https://github.com/CodeConstruct/nvme-mi-dev#6dc246aae5fdc46d655b6e0b8126ec34546152d9" +source = "git+https://github.com/CodeConstruct/nvme-mi-dev#b6614f2651dc46df5e7798c133a43669cebfee70" dependencies = [ "crc", "deku 0.19.1 (git+https://github.com/sharksforarms/deku.git?rev=e5363bc11e123bfcfd3467a2a90aeef8b588f432)",