diff --git a/bao1x-boot/boot1/src/main.rs b/bao1x-boot/boot1/src/main.rs index e46a7c31e..b45d8280b 100644 --- a/bao1x-boot/boot1/src/main.rs +++ b/bao1x-boot/boot1/src/main.rs @@ -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, se0_port: bao1x_api::IoxPort, se0_pin: u8) -> ! { if let Some(ref mut sh1107) = oled { 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. // without this, USB init will hang later on. 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 // check that all pages in the SPI memory page cache have been written out diff --git a/bao1x-boot/boot1/src/repl.rs b/bao1x-boot/boot1/src/repl.rs index 8017f89c6..dec8cb71c 100644 --- a/bao1x-boot/boot1/src/repl.rs +++ b/bao1x-boot/boot1/src/repl.rs @@ -106,7 +106,25 @@ impl Repl { rcurst.wo(utra::sysctrl::SFR_RCURST0, 0x55AA); } "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::() { + // 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" => { use base64::{Engine as _, engine::general_purpose};