mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
Merge pull request #683 from betrusted-io/verilate-fixes
Verilate fixes
This commit is contained in:
commit
8d19be2784
15 changed files with 105 additions and 30 deletions
|
|
@ -2,7 +2,11 @@
|
||||||
// SPDX-FileCopyrightText: 2024 bunnie <bunnie@kosagi.com>
|
// SPDX-FileCopyrightText: 2024 bunnie <bunnie@kosagi.com>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "verilator-only")))]
|
||||||
|
#[path = "rand.rs"]
|
||||||
|
pub mod rand;
|
||||||
|
#[cfg(all(feature = "bao1x", feature = "verilator-only"))]
|
||||||
|
#[path = "rand_fake.rs"]
|
||||||
pub mod rand;
|
pub mod rand;
|
||||||
|
|
||||||
#[cfg(any(feature = "debug-print", feature = "print-panics"))]
|
#[cfg(any(feature = "debug-print", feature = "print-panics"))]
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,9 @@ static LOCAL_RNG_STATE: [AtomicU32; 8] = [
|
||||||
|
|
||||||
pub fn init() {}
|
pub fn init() {}
|
||||||
|
|
||||||
/// This a fully deterministic PRNG that relies on Chacha8 for state evolution.
|
/// This a fully deterministic PRNG that relies on Chacha8 for state evolution. This is
|
||||||
|
/// used in verilator simulation environments.
|
||||||
|
#[cfg(feature = "verilator-only")]
|
||||||
pub fn get_u32() -> u32 {
|
pub fn get_u32() -> u32 {
|
||||||
// Local storage for the seed.
|
// Local storage for the seed.
|
||||||
let mut seed = [0u8; 32];
|
let mut seed = [0u8; 32];
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ board-baosec = [
|
||||||
"bmp180",
|
"bmp180",
|
||||||
"utralib/bao1x",
|
"utralib/bao1x",
|
||||||
"ux-api/board-baosec",
|
"ux-api/board-baosec",
|
||||||
|
"ux-api/std",
|
||||||
] # USB form factor token
|
] # USB form factor token
|
||||||
loader-baosec = [
|
loader-baosec = [
|
||||||
"utralib/bao1x",
|
"utralib/bao1x",
|
||||||
|
|
@ -66,9 +67,11 @@ kernel-dabao = ["utralib/bao1x"]
|
||||||
test-baosec = ["ux-api/loader-baosec", "camera-gc2145"]
|
test-baosec = ["ux-api/loader-baosec", "camera-gc2145"]
|
||||||
hosted-baosec = ["std"] # emulated hardware on x86 platform
|
hosted-baosec = ["std"] # emulated hardware on x86 platform
|
||||||
board-baosor = [
|
board-baosor = [
|
||||||
|
"std",
|
||||||
"camera-gc2145",
|
"camera-gc2145",
|
||||||
"axp2101",
|
"axp2101",
|
||||||
"utralib/bao1x",
|
"utralib/bao1x",
|
||||||
|
"ux-api/std",
|
||||||
] # Precursor form factor
|
] # Precursor form factor
|
||||||
loader-baosor = []
|
loader-baosor = []
|
||||||
board-dabao = ["utralib/bao1x"] # Dev board form factor
|
board-dabao = ["utralib/bao1x"] # Dev board form factor
|
||||||
|
|
@ -89,7 +92,6 @@ std = [
|
||||||
"xous-api-names",
|
"xous-api-names",
|
||||||
"usb-device",
|
"usb-device",
|
||||||
"xous-api-ticktimer",
|
"xous-api-ticktimer",
|
||||||
"ux-api/std",
|
|
||||||
"bao1x-api/std",
|
"bao1x-api/std",
|
||||||
]
|
]
|
||||||
derive-rkyv = ["rkyv"]
|
derive-rkyv = ["rkyv"]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Constants that define pin locations, RAM offsets, etc. for the DaBao basic breakout board
|
// Constants that define pin locations, RAM offsets, etc. for the DaBao basic breakout board
|
||||||
use crate::iox::IoSetup;
|
|
||||||
use crate::iox::*;
|
use bao1x_api::*;
|
||||||
|
|
||||||
// console uart buffer
|
// console uart buffer
|
||||||
pub const UART_DMA_TX_BUF_PHYS: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 4096;
|
pub const UART_DMA_TX_BUF_PHYS: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 4096;
|
||||||
|
|
@ -42,7 +42,7 @@ pub fn setup_usb_pins<T: IoSetup + IoGpio>(iox: &T) -> (IoxPort, u8) {
|
||||||
(IoxPort::PB, SE0_PIN)
|
(IoxPort::PB, SE0_PIN)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setup_i2c_pins(iox: &dyn IoSetup) -> crate::udma::I2cChannel {
|
pub fn setup_i2c_pins(iox: &dyn IoSetup) -> bao1x_api::I2cChannel {
|
||||||
// I2C_SCL_B[0]
|
// I2C_SCL_B[0]
|
||||||
iox.setup_pin(
|
iox.setup_pin(
|
||||||
IoxPort::PB,
|
IoxPort::PB,
|
||||||
|
|
@ -65,5 +65,12 @@ pub fn setup_i2c_pins(iox: &dyn IoSetup) -> crate::udma::I2cChannel {
|
||||||
Some(IoxEnable::Enable),
|
Some(IoxEnable::Enable),
|
||||||
Some(IoxDriveStrength::Drive2mA),
|
Some(IoxDriveStrength::Drive2mA),
|
||||||
);
|
);
|
||||||
crate::udma::I2cChannel::Channel0
|
bao1x_api::I2cChannel::Channel0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// these are a bodge to allow some UDMA imports to work - they need to be present even if
|
||||||
|
// there currently no SPINOR devices attached.
|
||||||
|
pub const SPINOR_PAGE_LEN: u32 = 0x100;
|
||||||
|
pub const SPINOR_ERASE_SIZE: u32 = 0x1000; // this is the smallest sector size.
|
||||||
|
pub const SPINOR_BULK_ERASE_SIZE: u32 = 0x1_0000; // this is the bulk erase size.
|
||||||
|
pub const SPINOR_LEN: u32 = 16384 * 1024;
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ pub use baosec::*;
|
||||||
pub mod baosor;
|
pub mod baosor;
|
||||||
#[cfg(any(feature = "board-baosor", feature = "loader-baosor"))]
|
#[cfg(any(feature = "board-baosor", feature = "loader-baosor"))]
|
||||||
pub use baosor::*;
|
pub use baosor::*;
|
||||||
#[cfg(any(feature = "board-dabao", feature = "loader-dabao"))]
|
#[cfg(any(feature = "board-dabao", feature = "loader-dabao", feature = "kernel-dabao"))]
|
||||||
pub mod dabao;
|
pub mod dabao;
|
||||||
#[cfg(any(feature = "board-dabao", feature = "loader-dabao"))]
|
#[cfg(any(feature = "board-dabao", feature = "loader-dabao", feature = "kernel-dabao"))]
|
||||||
pub use dabao::*;
|
pub use dabao::*;
|
||||||
#[cfg(feature = "hosted-baosec")]
|
#[cfg(feature = "hosted-baosec")]
|
||||||
pub mod hosted;
|
pub mod hosted;
|
||||||
|
|
|
||||||
|
|
@ -66,13 +66,13 @@ impl Uart {
|
||||||
|
|
||||||
use core::fmt::{Error, Write};
|
use core::fmt::{Error, Write};
|
||||||
impl Write for Uart {
|
impl Write for Uart {
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
fn write_str(&mut self, _s: &str) -> Result<(), Error> {
|
||||||
#[cfg(not(all(feature = "std", not(feature = "debug-print-usb"))))]
|
#[cfg(not(all(feature = "std", not(feature = "debug-print-usb"))))]
|
||||||
for c in s.bytes() {
|
for c in _s.bytes() {
|
||||||
self.putc(c);
|
self.putc(c);
|
||||||
}
|
}
|
||||||
// #[cfg(all(feature = "std", not(feature = "debug-print-usb")))]
|
// #[cfg(all(feature = "std", not(feature = "debug-print-usb")))]
|
||||||
// log::info!("{}", s);
|
// log::info!("{}", _s);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ board-baosec = [
|
||||||
"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"]
|
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
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ use bao1x_hal::udma;
|
||||||
#[cfg(any(feature = "board-baosec", feature = "board-baosor"))]
|
#[cfg(any(feature = "board-baosec", feature = "board-baosor"))]
|
||||||
use bao1x_hal::{axp2101::Axp2101, udma::GlobalConfig};
|
use bao1x_hal::{axp2101::Axp2101, udma::GlobalConfig};
|
||||||
use utralib::generated::*;
|
use utralib::generated::*;
|
||||||
|
#[cfg(not(feature = "verilator-only"))]
|
||||||
use utralib::utra::sysctrl;
|
use utralib::utra::sysctrl;
|
||||||
|
|
||||||
#[cfg(feature = "qr")]
|
#[cfg(feature = "qr")]
|
||||||
|
|
@ -2199,6 +2200,7 @@ pub fn coreuser_config() {
|
||||||
/// Takes in the top clock in MHz, desired perclk in MHz, and returns a tuple of
|
/// Takes in the top clock in MHz, desired perclk in MHz, and returns a tuple of
|
||||||
/// (min cycle, fd, actual freq)
|
/// (min cycle, fd, actual freq)
|
||||||
/// *tested*
|
/// *tested*
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn clk_to_per(top_in_mhz: u32, perclk_in_mhz: u32) -> Option<(u8, u8, u32)> {
|
pub fn clk_to_per(top_in_mhz: u32, perclk_in_mhz: u32) -> Option<(u8, u8, u32)> {
|
||||||
let fd_platonic = ((256 * perclk_in_mhz) / (top_in_mhz / 2)).min(256);
|
let fd_platonic = ((256 * perclk_in_mhz) / (top_in_mhz / 2)).min(256);
|
||||||
if fd_platonic > 0 {
|
if fd_platonic > 0 {
|
||||||
|
|
@ -2218,6 +2220,7 @@ pub fn clk_to_per(top_in_mhz: u32, perclk_in_mhz: u32) -> Option<(u8, u8, u32)>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Delay with a given system clock frequency. Useful during power mode switching.
|
/// Delay with a given system clock frequency. Useful during power mode switching.
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn delay_at_sysfreq(ms: usize, sysclk_freq: u32) {
|
pub fn delay_at_sysfreq(ms: usize, sysclk_freq: u32) {
|
||||||
let mut timer = utralib::CSR::new(utra::timer0::HW_TIMER0_BASE as *mut u32);
|
let mut timer = utralib::CSR::new(utra::timer0::HW_TIMER0_BASE as *mut u32);
|
||||||
timer.wfo(utra::timer0::EN_EN, 0b0); // disable the timer
|
timer.wfo(utra::timer0::EN_EN, 0b0); // disable the timer
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ board-baosec = ["bao1x-hal/board-baosec"]
|
||||||
board-baosor = ["bao1x-hal/board-baosor"]
|
board-baosor = ["bao1x-hal/board-baosor"]
|
||||||
board-dabao = ["bao1x-hal/board-dabao"]
|
board-dabao = ["bao1x-hal/board-dabao"]
|
||||||
hosted-baosec = []
|
hosted-baosec = []
|
||||||
|
hwsim = []
|
||||||
|
|
||||||
precursor = ["utralib/precursor"]
|
precursor = ["utralib/precursor"]
|
||||||
hosted = ["utralib/hosted"]
|
hosted = ["utralib/hosted"]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use core::fmt::{Error, Write};
|
use core::fmt::{Error, Write};
|
||||||
|
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
use bao1x_hal::udma;
|
use bao1x_hal::udma;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
|
@ -30,7 +30,7 @@ pub struct Uart {}
|
||||||
// this is a hack to bypass an explicit initialization/allocation step for the debug structure
|
// this is a hack to bypass an explicit initialization/allocation step for the debug structure
|
||||||
pub static mut DEFAULT_UART_ADDR: *mut usize = 0x0000_0000 as *mut usize;
|
pub static mut DEFAULT_UART_ADDR: *mut usize = 0x0000_0000 as *mut usize;
|
||||||
|
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
impl Uart {
|
impl Uart {
|
||||||
pub fn putc(&self, c: u8) {
|
pub fn putc(&self, c: u8) {
|
||||||
// check that we've been initialized before attempting to send any characters...
|
// check that we've been initialized before attempting to send any characters...
|
||||||
|
|
@ -56,6 +56,18 @@ impl Uart {
|
||||||
uart.write(&[c]);
|
uart.write(&[c]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(all(feature = "bao1x", feature = "hwsim"))]
|
||||||
|
impl Uart {
|
||||||
|
pub fn putc(&self, c: u8) {
|
||||||
|
// check that we've been initialized before attempting to send any characters...
|
||||||
|
if unsafe { DEFAULT_UART_ADDR } as usize == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let mut uart_csr = unsafe { utralib::CSR::new(DEFAULT_UART_ADDR) };
|
||||||
|
while uart_csr.r(utralib::utra::duart::SFR_SR) != 0 {}
|
||||||
|
uart_csr.wo(utralib::utra::duart::SFR_TXD, c as usize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Write for Uart {
|
impl Write for Uart {
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
use core::fmt::{Error, Write};
|
use core::fmt::{Error, Write};
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
use bao1x_hal::board::UART_DMA_TX_BUF_PHYS;
|
use bao1x_hal::board::UART_DMA_TX_BUF_PHYS;
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
use bao1x_hal::udma;
|
use bao1x_hal::udma;
|
||||||
use utralib::generated::*;
|
use utralib::generated::*;
|
||||||
|
|
||||||
pub struct Output {}
|
pub struct Output {}
|
||||||
|
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
pub static mut UART_DMA_TX_BUF_VIRT: *mut u8 = 0x0000_0000 as *mut u8;
|
pub static mut UART_DMA_TX_BUF_VIRT: *mut u8 = 0x0000_0000 as *mut u8;
|
||||||
|
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
pub static mut UART_IRQ: Option<Pin<Box<bao1x_hal::udma::UartIrq>>> = None;
|
pub static mut UART_IRQ: Option<Pin<Box<bao1x_hal::udma::UartIrq>>> = None;
|
||||||
|
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
pub static mut KBD_CONN: u32 = 0;
|
pub static mut KBD_CONN: u32 = 0;
|
||||||
|
|
||||||
pub fn init() -> Output {
|
pub fn init() -> Output {
|
||||||
// TODO: migrate this to a "proper" UART that is available on SoC hardware, but for now all we have access
|
// TODO: migrate this to a "proper" UART that is available on SoC hardware, but for now all we have access
|
||||||
// to is the DUART.
|
// to is the DUART.
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
let uart = xous::syscall::map_memory(
|
let uart = xous::syscall::map_memory(
|
||||||
xous::MemoryAddress::new(utra::udma_uart_2::HW_UDMA_UART_2_BASE),
|
xous::MemoryAddress::new(utra::udma_uart_2::HW_UDMA_UART_2_BASE),
|
||||||
None,
|
None,
|
||||||
|
|
@ -30,8 +30,11 @@ pub fn init() -> Output {
|
||||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
)
|
)
|
||||||
.expect("couldn't map serial port");
|
.expect("couldn't map serial port");
|
||||||
unsafe { crate::platform::debug::DEFAULT_UART_ADDR = uart.as_mut_ptr() as _ };
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
#[cfg(feature = "bao1x")]
|
unsafe {
|
||||||
|
crate::platform::debug::DEFAULT_UART_ADDR = uart.as_mut_ptr() as _
|
||||||
|
};
|
||||||
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
{
|
{
|
||||||
// Note: for the TX buf, we allocate a pre-reserved portion of IFRAM as our
|
// Note: for the TX buf, we allocate a pre-reserved portion of IFRAM as our
|
||||||
// DMA buffer. We do *not* use the IFRAM allocator in `bao1x-hal-service` because
|
// DMA buffer. We do *not* use the IFRAM allocator in `bao1x-hal-service` because
|
||||||
|
|
@ -65,13 +68,25 @@ pub fn init() -> Output {
|
||||||
};
|
};
|
||||||
udma_uart.setup_async_read();
|
udma_uart.setup_async_read();
|
||||||
}
|
}
|
||||||
|
#[cfg(all(feature = "bao1x", feature = "hwsim"))]
|
||||||
|
let uart = xous::syscall::map_memory(
|
||||||
|
xous::MemoryAddress::new(utra::duart::HW_DUART_BASE),
|
||||||
|
None,
|
||||||
|
4096,
|
||||||
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
|
)
|
||||||
|
.expect("couldn't map UDMA buffer");
|
||||||
|
#[cfg(all(feature = "bao1x", feature = "hwsim"))]
|
||||||
|
unsafe {
|
||||||
|
crate::platform::debug::DEFAULT_UART_ADDR = uart.as_mut_ptr() as _
|
||||||
|
};
|
||||||
println!("Mapped UART @ {:08x}", uart.as_ptr() as usize);
|
println!("Mapped UART @ {:08x}", uart.as_ptr() as usize);
|
||||||
println!("Process: map success!");
|
println!("Process: map success!");
|
||||||
|
|
||||||
Output {}
|
Output {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
fn uart_handler(_irq_no: usize, _arg: *mut usize) {
|
fn uart_handler(_irq_no: usize, _arg: *mut usize) {
|
||||||
let mut uart = unsafe {
|
let mut uart = unsafe {
|
||||||
udma::Uart::get_handle(
|
udma::Uart::get_handle(
|
||||||
|
|
@ -117,7 +132,7 @@ pub struct OutputWriter {}
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
impl OutputWriter {
|
impl OutputWriter {
|
||||||
pub fn putc(&self, c: u8) {
|
pub fn putc(&self, c: u8) {
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
{
|
{
|
||||||
// safety: safe to call as long as the raw parts are initialized and we exclusively
|
// safety: safe to call as long as the raw parts are initialized and we exclusively
|
||||||
// own it; and the UART has been initialized. For this peripheral, initialization
|
// own it; and the UART has been initialized. For this peripheral, initialization
|
||||||
|
|
@ -134,13 +149,19 @@ impl OutputWriter {
|
||||||
// enqueue our character to send via DMA
|
// enqueue our character to send via DMA
|
||||||
uart.write(&[c]);
|
uart.write(&[c]);
|
||||||
}
|
}
|
||||||
|
#[cfg(all(feature = "bao1x", feature = "hwsim"))]
|
||||||
|
{
|
||||||
|
let mut uart_csr = unsafe { CSR::new(crate::platform::debug::DEFAULT_UART_ADDR) };
|
||||||
|
while uart_csr.r(utra::duart::SFR_SR) != 0 {}
|
||||||
|
uart_csr.wo(utra::duart::SFR_TXD, c as usize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write a buffer to the output and return the number of
|
/// Write a buffer to the output and return the number of
|
||||||
/// bytes written. This is mostly compatible with `std::io::Write`,
|
/// bytes written. This is mostly compatible with `std::io::Write`,
|
||||||
/// except it is infallible.
|
/// except it is infallible.
|
||||||
pub fn write(&mut self, buf: &[u8]) -> usize {
|
pub fn write(&mut self, buf: &[u8]) -> usize {
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||||
{
|
{
|
||||||
// safety: safe to call as long as the raw parts are initialized and we exclusively
|
// safety: safe to call as long as the raw parts are initialized and we exclusively
|
||||||
// own it; and the UART has been initialized. For this peripheral, initialization
|
// own it; and the UART has been initialized. For this peripheral, initialization
|
||||||
|
|
@ -155,6 +176,15 @@ impl OutputWriter {
|
||||||
};
|
};
|
||||||
uart.write(buf)
|
uart.write(buf)
|
||||||
}
|
}
|
||||||
|
#[cfg(all(feature = "bao1x", feature = "hwsim"))]
|
||||||
|
{
|
||||||
|
let mut uart_csr = unsafe { CSR::new(crate::platform::debug::DEFAULT_UART_ADDR) };
|
||||||
|
for &c in buf.iter() {
|
||||||
|
while uart_csr.r(utra::duart::SFR_SR) != 0 {}
|
||||||
|
uart_csr.wo(utra::duart::SFR_TXD, c as usize);
|
||||||
|
}
|
||||||
|
buf.len()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_all(&mut self, buf: &[u8]) -> core::result::Result<usize, ()> { Ok(self.write(buf)) }
|
pub fn write_all(&mut self, buf: &[u8]) -> core::result::Result<usize, ()> { Ok(self.write(buf)) }
|
||||||
|
|
|
||||||
2
utralib/bao1x/.gitignore
vendored
Normal file
2
utralib/bao1x/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# this is only present during simulations
|
||||||
|
soc.svd
|
||||||
|
|
@ -123,7 +123,11 @@ fn main() {
|
||||||
let generated_filename = "src/generated/atsama5d27.rs";
|
let generated_filename = "src/generated/atsama5d27.rs";
|
||||||
|
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(feature = "bao1x")]
|
||||||
let svd_filenames = vec!["bao1x/core.svd", "bao1x/bao1x_peri.svd"];
|
let mut svd_filenames = vec!["bao1x/core.svd", "bao1x/bao1x_peri.svd"];
|
||||||
|
#[cfg(feature = "bao1x")]
|
||||||
|
if std::path::Path::new("bao1x/soc.svd").exists() {
|
||||||
|
svd_filenames.push("bao1x/soc.svd");
|
||||||
|
}
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(feature = "bao1x")]
|
||||||
let generated_filename = "src/generated/bao1x.rs";
|
let generated_filename = "src/generated/bao1x.rs";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ impl Builder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disable default features on the loader
|
/// Disable default features on the kernel
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn kernel_disable_defaults(&mut self) -> &mut Builder {
|
pub fn kernel_disable_defaults(&mut self) -> &mut Builder {
|
||||||
self.kernel_disable_defaults = true;
|
self.kernel_disable_defaults = true;
|
||||||
|
|
|
||||||
|
|
@ -499,7 +499,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
builder.add_loader_feature(board);
|
builder.add_loader_feature(board);
|
||||||
builder.add_kernel_feature(board);
|
builder.add_kernel_feature(board);
|
||||||
}
|
}
|
||||||
_ => (), // don't add any board because this is simulation
|
Some("bao1x-sim") => {
|
||||||
|
let board = "board-dabao";
|
||||||
|
// select the board
|
||||||
|
builder.add_feature(board);
|
||||||
|
builder.add_loader_feature(board);
|
||||||
|
builder.add_kernel_feature(board);
|
||||||
|
builder.kernel_disable_defaults(); // need to turn of kernel DUART exclusive access so console can work!
|
||||||
|
}
|
||||||
|
_ => panic!("unhandled configuration"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// placement in flash is a tension between dev convenience and RAM usage. Things in flash
|
// placement in flash is a tension between dev convenience and RAM usage. Things in flash
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue