Merge pull request #711 from betrusted-io/xtx-cleanup

Xtx cleanup
This commit is contained in:
bunnie 2025-10-31 11:14:48 +08:00 committed by GitHub
commit c6d5199c78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 44 additions and 17 deletions

View file

@ -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"]

View file

@ -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);

View file

@ -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");

View file

@ -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();
}
}
}

View file

@ -605,7 +605,24 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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