diff --git a/baremetal/Cargo.toml b/baremetal/Cargo.toml index 6810c29b4..789ce422d 100644 --- a/baremetal/Cargo.toml +++ b/baremetal/Cargo.toml @@ -42,12 +42,13 @@ artyvexii = ["utralib/artyvexii", "linked_list_allocator"] bao1x = [ "utralib/bao1x", "linked_list_allocator", - "bao1x-hal/loader-baosec", "bao1x-hal/debug-print-uart", "bao1x-api", "digest", "sha2-bao1x", ] +board-baosec = ["bao1x-hal/loader-baosec"] +board-dabao = ["bao1x-hal/board-dabao"] # activates BIO test suite bao1x-bio = [ "xous-bio-bdma/bio-mul", @@ -80,4 +81,4 @@ test-boot0-writeprotect = [] spim-tests = [] verilator-only = [] -default = ["bao1x-usb", "dabao-selftest"] +default = ["bao1x-usb"] diff --git a/baremetal/src/platform/bao1x/bao1x.rs b/baremetal/src/platform/bao1x/bao1x.rs index 832f5ae1d..824b094ba 100644 --- a/baremetal/src/platform/bao1x/bao1x.rs +++ b/baremetal/src/platform/bao1x/bao1x.rs @@ -29,7 +29,6 @@ pub const SCRATCH_PAGE: usize = HEAP_START + HEAP_LEN + 4096; pub const UART_IFRAM_ADDR: usize = bao1x_hal::board::UART_DMA_TX_BUF_PHYS; pub const SYSTEM_CLOCK_FREQUENCY: u32 = 700_000_000; -use bao1x_api::SYSTEM_TICK_INTERVAL_MS; pub fn early_init() { let iox = Iox::new(utra::iox::HW_IOX_BASE as *mut u32); @@ -91,13 +90,23 @@ pub fn early_init() { // Baosec specific: // Setup I/Os so things that should be powered off are actually off - bao1x_hal::board::setup_display_pins(&iox); - bao1x_hal::board::setup_memory_pins(&iox); - bao1x_hal::board::setup_i2c_pins(&iox); - bao1x_hal::board::setup_camera_pins(&iox); - bao1x_hal::board::setup_kb_pins(&iox); - bao1x_hal::board::setup_oled_power_pin(&iox); - bao1x_hal::board::setup_trng_power_pin(&iox); + #[cfg(feature = "board-baosec")] + { + bao1x_hal::board::setup_display_pins(&iox); + bao1x_hal::board::setup_memory_pins(&iox); + bao1x_hal::board::setup_i2c_pins(&iox); + bao1x_hal::board::setup_camera_pins(&iox); + bao1x_hal::board::setup_kb_pins(&iox); + bao1x_hal::board::setup_oled_power_pin(&iox); + bao1x_hal::board::setup_trng_power_pin(&iox); + } + #[cfg(feature = "board-dabao")] + { + // this actively drives the pin high, allowing USB to connect + bao1x_hal::board::setup_usb_pins(&iox); + // this puts the pin into a tri-state + bao1x_hal::board::setup_boot_pin(&iox); + } crate::println!("scratch page: {:x}, heap start: {:x}", SCRATCH_PAGE, HEAP_START); crate::println!("CPU freq: {} MHz", SYSTEM_CLOCK_FREQUENCY / 2); } @@ -109,7 +118,7 @@ pub fn setup_timer() { timer.wfo(utra::timer0::EV_ENABLE_ZERO, 0); timer.wfo(utra::timer0::EV_PENDING_ZERO, 1); - let ms = SYSTEM_TICK_INTERVAL_MS; + let ms = 1; timer.wfo(utra::timer0::EN_EN, 0b0); // disable the timer // load its values timer.wfo(utra::timer0::LOAD_LOAD, 0); diff --git a/baremetal/src/repl.rs b/baremetal/src/repl.rs index 8f04c3fea..01fa69f66 100644 --- a/baremetal/src/repl.rs +++ b/baremetal/src/repl.rs @@ -669,7 +669,7 @@ impl Repl { } } } - #[cfg(all(feature = "bao1x", not(feature = "bao1x-evb")))] + #[cfg(all(feature = "bao1x", feature = "board-baosec"))] "ldo" => { if args.len() != 1 { return Err(Error::help("vdd85 [on|off]")); @@ -736,7 +736,7 @@ impl Repl { iox.set_gpio_pin_value(IoxPort::PA, 5, IoxValue::High); } } - #[cfg(all(feature = "bao1x", not(feature = "bao1x-evb")))] + #[cfg(all(feature = "bao1x", feature = "board-baosec"))] "wfi" => { let iox = bao1x_hal::iox::Iox::new(utra::iox::HW_IOX_BASE as *mut u32); @@ -1143,7 +1143,7 @@ impl Repl { crate::print!(", mon"); #[cfg(feature = "bao1x-bio")] crate::print!(", bio, bdma, pin"); - #[cfg(all(feature = "bao1x", not(feature = "bao1x-evb")))] + #[cfg(all(feature = "bao1x", feature = "board-baosec"))] crate::print!(", ldo, wfi"); #[cfg(feature = "bao1x-usb")] crate::print!(", usb"); diff --git a/libs/bao1x-hal/src/udma/spim.rs b/libs/bao1x-hal/src/udma/spim.rs index 06bed6792..bd6e37533 100644 --- a/libs/bao1x-hal/src/udma/spim.rs +++ b/libs/bao1x-hal/src/udma/spim.rs @@ -1338,7 +1338,6 @@ impl Spim { } CommandSet::Xtx => { self.mem_param_set(true, 0x31, &[((sr & 0xFF00 >> 8) as u8) | 0b0000_0010]); - let status = self.flash_read_status_register(); } } } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index cfc5c89f9..938ec2d87 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -605,7 +605,24 @@ fn main() -> Result<(), Box> { builder.target_artyvexii(); } - Some("baremetal-bao1x") | Some("bao1x-baremetal") => { + Some("baremetal-bao1x") | Some("bao1x-baremetal-baosec") => { + let board = "board-baosec"; + builder.set_board(board); + builder.add_loader_feature(board); + builder.add_loader_feature("bao1x-usb"); + let sigblock_size = 0x300; + update_flash_origin( + "baremetal/src/platform/bao1x/link.x", + (bao1x_api::BAREMETAL_START + sigblock_size + STATICS_LEN) as u32, + )?; + builder.set_baremetal(true).target_baremetal_bao1x("baremetal").set_sigblock_size(sigblock_size); + } + + Some("bao1x-baremetal-dabao") => { + let board = "board-dabao"; + builder.set_board(board); + builder.add_loader_feature(board); + builder.add_loader_feature("bao1x-usb"); let sigblock_size = 0x300; update_flash_origin( "baremetal/src/platform/bao1x/link.x", @@ -914,7 +931,8 @@ Hardware images: tiny Precursor tiny image. For testing with services built out-of-tree. baosec Baosec application target image. dabao Dabao application target image. - bao1x-baremetal Baremetal image for baochip1x targets. + bao1x-baremetal-baosec Baremetal image for baosec boards. + bao1x-baremetal-dabao Baremetal image for dabao boards. bao1x-boot0 Boot0 partition for baochip1x targets. bao1x-boot1 Boot1 partition for baochip1x targets. bao1x-alt-boot1 Alterante boot1 partition for baochip1x targets. Burns into the 'loader/baremetal' region