Merge branch 'main' of github.com:betrusted-io/xous-core into keystore-dabao

This commit is contained in:
bunnie 2025-11-02 08:02:17 +08:00
commit 2f0895b46c
4 changed files with 27 additions and 3 deletions

View file

@ -273,6 +273,10 @@ pub unsafe extern "C" fn rust_entry() -> ! {
} }
} }
boot(&iox, oled, se0_port, se0_pin)
}
pub fn boot(iox: &Iox, mut oled: Option<Oled128x128>, se0_port: bao1x_api::IoxPort, se0_pin: u8) -> ! {
if let Some(ref mut sh1107) = oled { if let Some(ref mut sh1107) = oled {
marquee(sh1107, "Booting..."); marquee(sh1107, "Booting...");
} }
@ -280,6 +284,7 @@ pub unsafe extern "C" fn rust_entry() -> ! {
// stop the USB subsystem so it can be re-init'd by the next stage. // stop the USB subsystem so it can be re-init'd by the next stage.
// without this, USB init will hang later on. // without this, USB init will hang later on.
glue::shutdown(); glue::shutdown();
iox.set_gpio_dir(se0_port, se0_pin, bao1x_api::IoxDir::Output);
iox.set_gpio_pin(se0_port, se0_pin, bao1x_api::IoxValue::Low); // put the USB port into SE0, so we re-enumerate with the OS stack iox.set_gpio_pin(se0_port, se0_pin, bao1x_api::IoxValue::Low); // put the USB port into SE0, so we re-enumerate with the OS stack
// check that all pages in the SPI memory page cache have been written out // check that all pages in the SPI memory page cache have been written out

View file

@ -106,7 +106,25 @@ impl Repl {
rcurst.wo(utra::sysctrl::SFR_RCURST0, 0x55AA); rcurst.wo(utra::sysctrl::SFR_RCURST0, 0x55AA);
} }
"boot" => { "boot" => {
crate::secboot::try_boot(true); use bao1x_hal::iox::Iox;
let one_way = OneWayCounter::new();
let iox = Iox::new(utra::iox::HW_IOX_BASE as *mut u32);
let (port, pin) = match one_way.get_decoded::<bao1x_api::BoardTypeCoding>() {
// the default map is baosec in boot1
Ok(bao1x_api::BoardTypeCoding::Baosec) => bao1x_hal::board::setup_usb_pins(&iox),
// otherwise assume dabao mapping
_ => crate::setup_dabao_se0_pin(&iox),
};
// assert SE0 pin here. We add a delay even though crate:boot() calls this, because
// a button press initiated SE0 includes a certain minimum "low"; a direct serial command
// does not.
iox.set_gpio_pin(port, pin, IoxValue::Low);
crate::platform::delay(20); // minimum is 2.5ms
// note: the SE0 pin is now asserted & configured as an output as it goes to the next stage
// it us up to the next USB stack to de-assert this.
crate::boot(&iox, None, port, pin);
} }
"uf2" => { "uf2" => {
use base64::{Engine as _, engine::general_purpose}; use base64::{Engine as _, engine::general_purpose};

View file

@ -54,4 +54,4 @@ pub const GUARD_MEMORY_BYTES: usize = 8 * crate::PAGE_SIZE; // 1 extra page for
pub const SWAPPER_PID: u8 = 2; pub const SWAPPER_PID: u8 = 2;
#[cfg(feature = "bao1x")] #[cfg(feature = "bao1x")]
pub const SYSTEM_CLOCK_FREQUENCY: u32 = 800_000_000; pub const SYSTEM_CLOCK_FREQUENCY: u32 = bao1x_hal::board::DEFAULT_FCLK_FREQUENCY / 2;

View file

@ -36,7 +36,8 @@ pub fn delay(quantum: usize) {
use utralib::{CSR, utra}; use utralib::{CSR, utra};
// abuse the d11ctime timer to create some time-out like thing // abuse the d11ctime timer to create some time-out like thing
let mut d11c = CSR::new(utra::d11ctime::HW_D11CTIME_BASE as *mut u32); let mut d11c = CSR::new(utra::d11ctime::HW_D11CTIME_BASE as *mut u32);
d11c.wfo(utra::d11ctime::CONTROL_COUNT, 333_333); // 1.0ms per interval // 1.0ms per interval
d11c.wfo(utra::d11ctime::CONTROL_COUNT, crate::SYSTEM_CLOCK_FREQUENCY / 1000);
let mut polarity = d11c.rf(utra::d11ctime::HEARTBEAT_BEAT); let mut polarity = d11c.rf(utra::d11ctime::HEARTBEAT_BEAT);
for _ in 0..quantum { for _ in 0..quantum {
while polarity == d11c.rf(utra::d11ctime::HEARTBEAT_BEAT) {} while polarity == d11c.rf(utra::d11ctime::HEARTBEAT_BEAT) {}