loader tracking api changes; needs refinement still.

This commit is contained in:
bunnie 2025-10-01 02:57:32 +08:00
parent f04a856037
commit ed935c66cb
5 changed files with 205 additions and 192 deletions

View file

@ -14,6 +14,10 @@ ed25519-dalek-loader = { path = "ed25519-dalek-loader", default-features = false
curve25519-dalek-loader = { path = "curve25519-dalek-loader", default-features = false, features = [ curve25519-dalek-loader = { path = "curve25519-dalek-loader", default-features = false, features = [
"u32e_backend", "u32e_backend",
], optional = true } ], optional = true }
ed25519-dalek-bao1x = { path = "../bao1x-boot/ed25519-dalek-bao1x", default-features = false, features = [
"digest",
], optional = true }
sha2-bao1x = { path = "../bao1x-boot/sha2-bao1x", optional = true, default-features = false }
utralib = { version = "0.1.25", optional = true, default-features = false } utralib = { version = "0.1.25", optional = true, default-features = false }
armv7 = { git = "https://github.com/Foundation-Devices/armv7.git", branch = "update", optional = true } armv7 = { git = "https://github.com/Foundation-Devices/armv7.git", branch = "update", optional = true }
atsama5d27 = { git = "https://github.com/Foundation-Devices/atsama5d27.git", branch = "master", optional = true } atsama5d27 = { git = "https://github.com/Foundation-Devices/atsama5d27.git", branch = "master", optional = true }
@ -100,13 +104,17 @@ board-baosec = [
"usb", "usb",
"simple-fatfs", "simple-fatfs",
"linked_list_allocator", "linked_list_allocator",
"ed25519-dalek", "ed25519-dalek-bao1x",
"sha2", "sha2-bao1x",
"digest", "digest",
"ux-api/loader-baosec", "ux-api/loader-baosec",
] ]
board-baosor = ["bao1x-hal/loader-baosor"] board-baosor = ["bao1x-hal/loader-baosor"]
board-dabao = ["bao1x-hal/loader-dabao", "bao1x-hal/board-dabao", "linked_list_allocator",] board-dabao = [
"bao1x-hal/loader-dabao",
"bao1x-hal/board-dabao",
"linked_list_allocator",
]
atsama5d27 = ["utralib/atsama5d27", "armv7", "dep:atsama5d27"] atsama5d27 = ["utralib/atsama5d27", "armv7", "dep:atsama5d27"]
# precursor flags # precursor flags

View file

@ -1,3 +1,4 @@
use bao1x_api::signatures::SIGBLOCK_LEN;
#[cfg(not(feature = "verilator-only"))] #[cfg(not(feature = "verilator-only"))]
use bao1x_api::{ use bao1x_api::{
udma::{PeriphId, UdmaGlobalConfig}, udma::{PeriphId, UdmaGlobalConfig},
@ -93,7 +94,7 @@ pub fn delay(quantum: usize) {
pub fn early_init() -> u32 { pub fn early_init() -> u32 {
// For the loader, the statics structure is located just after the signature block // For the loader, the statics structure is located just after the signature block
const STATICS_LOC: usize = FLASH_BASE + 0x1000; const STATICS_LOC: usize = bao1x_api::LOADER_START + SIGBLOCK_LEN;
// safety: this data structure is pre-loaded by the image loader and is guaranteed to // safety: this data structure is pre-loaded by the image loader and is guaranteed to
// only have representable, valid values that are aligned according to the repr(C) spec // only have representable, valid values that are aligned according to the repr(C) spec
@ -112,7 +113,9 @@ pub fn early_init() -> u32 {
data_ptr.add(i).write_volatile(0); data_ptr.add(i).write_volatile(0);
} }
for &(offset, data) in &statics_in_rom.poke_table[..statics_in_rom.valid_pokes as usize] { for &(offset, data) in &statics_in_rom.poke_table[..statics_in_rom.valid_pokes as usize] {
data_ptr.add(offset as usize).write_volatile(data); data_ptr
.add(u16::from_le_bytes(offset) as usize / size_of::<u32>())
.write_volatile(u32::from_le_bytes(data));
} }
} }
@ -286,8 +289,8 @@ pub fn early_init_hw() -> u32 {
let mut iox = Iox::new(utra::iox::HW_IOX_BASE as *mut u32); let mut iox = Iox::new(utra::iox::HW_IOX_BASE as *mut u32);
// setup power to "shut down" - keyboard press should be what's keeping us on at this stage // setup power to "shut down" - keyboard press should be what's keeping us on at this stage
let (port, pin) = bao1x_hal::board::setup_keep_on_pin(&iox); // let (port, pin) = bao1x_hal::board::setup_keep_on_pin(&iox);
iox.set_gpio_pin_value(port, pin, IoxValue::Low); // iox.set_gpio_pin_value(port, pin, IoxValue::Low);
/* /*
// allow for shutdown to process // allow for shutdown to process
iox.setup_pin( iox.setup_pin(

View file

@ -1,6 +1,6 @@
MEMORY MEMORY
{ {
FLASH : ORIGIN = 0x60001100, LENGTH = 252k - 256 FLASH : ORIGIN = 0x60060400, LENGTH = 255k
RAM : ORIGIN = 0x61000000, LENGTH = 2M RAM : ORIGIN = 0x61000000, LENGTH = 2M
} }

View file

@ -9,8 +9,8 @@ use bao1x_hal::sh1107::{Mono, Oled128x128};
use bao1x_hal::udma; use bao1x_hal::udma;
use bao1x_hal::udma::*; use bao1x_hal::udma::*;
use bao1x_hal::usb::driver::UsbDeviceState; use bao1x_hal::usb::driver::UsbDeviceState;
use ed25519_dalek::{Digest, Signature, VerifyingKey}; use ed25519_dalek_bao1x::{Digest, Signature, VerifyingKey};
use sha2::Sha512; use sha2_bao1x::Sha512;
use simple_fatfs::PathBuf; use simple_fatfs::PathBuf;
use utralib::generated::*; use utralib::generated::*;
use ux_api::minigfx::{FrameBuffer, Point}; use ux_api::minigfx::{FrameBuffer, Point};
@ -31,6 +31,8 @@ const TEXT_MIDLINE: isize = 51;
const DISCONNECT_STATE: u32 = 0x40b; // 01_0_0000_0_1_01_1 const DISCONNECT_STATE: u32 = 0x40b; // 01_0_0000_0_1_01_1
const DISCONNECT_STATE_HS: u32 = 0xc6b; // 11_0_0011_0_1_01_1 const DISCONNECT_STATE_HS: u32 = 0xc6b; // 11_0_0011_0_1_01_1
///// TODO: move updates into boot1. Make loader "generic" and just focus on loading the Xous kernel.
// loader is not updateable here because we're XIP. But we can update these other images: // loader is not updateable here because we're XIP. But we can update these other images:
const SWAP_NAME: &'static str = "SWAP.IMG"; const SWAP_NAME: &'static str = "SWAP.IMG";
const KERNEL_NAME: &'static str = "XOUS.BIN"; const KERNEL_NAME: &'static str = "XOUS.BIN";

View file

@ -304,7 +304,7 @@ pub fn usb_ep1_bulk_in_complete(
if let Some((offset, len)) = this.remaining_rd.take() { if let Some((offset, len)) = this.remaining_rd.take() {
let app_buf = conjure_app_buf(); let app_buf = conjure_app_buf();
let disk = conjure_disk(); let disk = conjure_disk();
this.setup_big_read(app_buf, disk, offset, len); this.setup_big_read(app_buf, disk, offset, len, None);
this.ms_state = UmsState::DataPhase; this.ms_state = UmsState::DataPhase;
} else { } else {
this.bulk_xfer(1, USB_SEND, CSW_ADDR, 13, 0, 0); this.bulk_xfer(1, USB_SEND, CSW_ADDR, 13, 0, 0);
@ -652,7 +652,7 @@ fn process_read_command(this: &mut CorigineUsb, cbw: Cbw) {
} }
let app_buf = conjure_app_buf(); let app_buf = conjure_app_buf();
let disk = conjure_disk(); let disk = conjure_disk();
this.setup_big_read(app_buf, disk, lba as usize * SECTOR_SIZE as usize, length as usize); this.setup_big_read(app_buf, disk, lba as usize * SECTOR_SIZE as usize, length as usize, None);
this.ms_state = UmsState::DataPhase; this.ms_state = UmsState::DataPhase;
} }
} }
@ -675,7 +675,7 @@ fn process_write_command(this: &mut CorigineUsb, cbw: Cbw) {
csw.status = 2; csw.status = 2;
let app_buf = conjure_app_buf(); let app_buf = conjure_app_buf();
let disk = conjure_disk(); let disk = conjure_disk();
this.setup_big_read(app_buf, disk, lba as usize * SECTOR_SIZE as usize, length as usize); this.setup_big_read(app_buf, disk, lba as usize * SECTOR_SIZE as usize, length as usize, None);
this.ms_state = UmsState::DataPhase; this.ms_state = UmsState::DataPhase;
csw.update_hw(); csw.update_hw();
return; return;
@ -739,7 +739,7 @@ fn process_write12_command(this: &mut CorigineUsb, cbw: Cbw) {
// does // does
let app_buf = conjure_app_buf(); let app_buf = conjure_app_buf();
let disk = conjure_disk(); let disk = conjure_disk();
this.setup_big_read(app_buf, disk, lba as usize * SECTOR_SIZE as usize, length as usize); this.setup_big_read(app_buf, disk, lba as usize * SECTOR_SIZE as usize, length as usize, None);
this.ms_state = UmsState::DataPhase; this.ms_state = UmsState::DataPhase;
csw.update_hw(); csw.update_hw();
return; return;