mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
partial progress on baremetal bringup
This commit is contained in:
parent
cbedc3a091
commit
22151c7d72
4 changed files with 277 additions and 229 deletions
|
|
@ -29,6 +29,18 @@ pub const SYSTEM_CLOCK_FREQUENCY: u32 = 400_000_000;
|
|||
pub const SYSTEM_TICK_INTERVAL_MS: u32 = 1;
|
||||
|
||||
pub fn early_init() {
|
||||
let daric_cgu = sysctrl::HW_SYSCTRL_BASE as *mut u32;
|
||||
/*
|
||||
let ao_sysctrl = utra::ao_sysctrl::HW_AO_SYSCTRL_BASE as *mut u32;
|
||||
unsafe {
|
||||
// this turns off the VDD85D (doesn't work)
|
||||
// ao_sysctrl.add(utra::ao_sysctrl::SFR_PMUCSR.offset()).write_volatile(0x6c);
|
||||
|
||||
// this sets VDD85D to 0.90V
|
||||
ao_sysctrl.add(utra::ao_sysctrl::SFR_PMUTRM0CSR.offset()).write_volatile(0x0842_10E0); // 0x0842_1080 default
|
||||
daric_cgu.add(utra::sysctrl::SFR_IPCARIPFLOW.offset()).write_volatile(0x57);
|
||||
}
|
||||
*/
|
||||
let uart = crate::debug::Uart {};
|
||||
|
||||
for _ in 0..100 {
|
||||
|
|
@ -37,7 +49,6 @@ pub fn early_init() {
|
|||
unsafe {
|
||||
// this block is mandatory in all cases to get clocks set into some consistent, expected mode
|
||||
{
|
||||
let daric_cgu = sysctrl::HW_SYSCTRL_BASE as *mut u32;
|
||||
// conservative dividers
|
||||
daric_cgu.add(utra::sysctrl::SFR_CGUFD_CFGFDCR_0_4_0.offset()).write_volatile(0x7f7f);
|
||||
daric_cgu.add(utra::sysctrl::SFR_CGUFD_CFGFDCR_0_4_1.offset()).write_volatile(0x7f7f);
|
||||
|
|
|
|||
|
|
@ -67,10 +67,16 @@ impl Write for Uart {
|
|||
impl SerialRead for Uart {
|
||||
fn getc(&mut self) -> Option<u8> {
|
||||
let uart_buf_addr = crate::platform::UART_IFRAM_ADDR;
|
||||
#[cfg(feature = "nto-evb")]
|
||||
let mut udma_uart = unsafe {
|
||||
// safety: this is safe to call, because we set up clock and events prior to calling new.
|
||||
udma::Uart::get_handle(utra::udma_uart_1::HW_UDMA_UART_1_BASE, uart_buf_addr, uart_buf_addr)
|
||||
};
|
||||
#[cfg(not(feature = "nto-evb"))]
|
||||
let mut udma_uart = unsafe {
|
||||
// safety: this is safe to call, because we set up clock and events prior to calling new.
|
||||
udma::Uart::get_handle(utra::udma_uart_2::HW_UDMA_UART_2_BASE, uart_buf_addr, uart_buf_addr)
|
||||
};
|
||||
let mut c = 0u8;
|
||||
udma_uart.read_async(&mut c);
|
||||
|
||||
|
|
@ -111,26 +117,51 @@ macro_rules! println
|
|||
|
||||
pub fn setup_rx(perclk: u32) -> cramium_hal::udma::Uart {
|
||||
let iox = Iox::new(utra::iox::HW_IOX_BASE as *mut u32);
|
||||
iox.set_alternate_function(IoxPort::PD, 13, IoxFunction::AF1);
|
||||
iox.set_alternate_function(IoxPort::PD, 14, IoxFunction::AF1);
|
||||
// rx as input, with pull-up
|
||||
iox.set_gpio_dir(IoxPort::PD, 13, IoxDir::Input);
|
||||
iox.set_gpio_pullup(IoxPort::PD, 13, IoxEnable::Enable);
|
||||
// tx as output
|
||||
iox.set_gpio_dir(IoxPort::PD, 14, IoxDir::Output);
|
||||
|
||||
let udma_global = GlobalConfig::new();
|
||||
udma_global.clock_on(PeriphId::Uart1);
|
||||
udma_global.map_event(
|
||||
PeriphId::Uart1,
|
||||
PeriphEventType::Uart(EventUartOffset::Rx),
|
||||
EventChannel::Channel0,
|
||||
);
|
||||
udma_global.map_event(
|
||||
PeriphId::Uart1,
|
||||
PeriphEventType::Uart(EventUartOffset::Tx),
|
||||
EventChannel::Channel1,
|
||||
);
|
||||
#[cfg(feature = "nto-evb")]
|
||||
{
|
||||
iox.set_alternate_function(IoxPort::PD, 13, IoxFunction::AF1);
|
||||
iox.set_alternate_function(IoxPort::PD, 14, IoxFunction::AF1);
|
||||
// rx as input, with pull-up
|
||||
iox.set_gpio_dir(IoxPort::PD, 13, IoxDir::Input);
|
||||
iox.set_gpio_pullup(IoxPort::PD, 13, IoxEnable::Enable);
|
||||
// tx as output
|
||||
iox.set_gpio_dir(IoxPort::PD, 14, IoxDir::Output);
|
||||
|
||||
udma_global.clock_on(PeriphId::Uart1);
|
||||
udma_global.map_event(
|
||||
PeriphId::Uart1,
|
||||
PeriphEventType::Uart(EventUartOffset::Rx),
|
||||
EventChannel::Channel0,
|
||||
);
|
||||
udma_global.map_event(
|
||||
PeriphId::Uart1,
|
||||
PeriphEventType::Uart(EventUartOffset::Tx),
|
||||
EventChannel::Channel1,
|
||||
);
|
||||
}
|
||||
#[cfg(not(feature = "nto-evb"))]
|
||||
{
|
||||
iox.set_alternate_function(IoxPort::PB, 13, IoxFunction::AF1);
|
||||
iox.set_alternate_function(IoxPort::PB, 14, IoxFunction::AF1);
|
||||
// rx as input, with pull-up
|
||||
iox.set_gpio_dir(IoxPort::PB, 13, IoxDir::Input);
|
||||
iox.set_gpio_pullup(IoxPort::PB, 13, IoxEnable::Enable);
|
||||
// tx as output
|
||||
iox.set_gpio_dir(IoxPort::PB, 14, IoxDir::Output);
|
||||
|
||||
udma_global.clock_on(PeriphId::Uart2);
|
||||
udma_global.map_event(
|
||||
PeriphId::Uart2,
|
||||
PeriphEventType::Uart(EventUartOffset::Rx),
|
||||
EventChannel::Channel0,
|
||||
);
|
||||
udma_global.map_event(
|
||||
PeriphId::Uart2,
|
||||
PeriphEventType::Uart(EventUartOffset::Tx),
|
||||
EventChannel::Channel1,
|
||||
);
|
||||
}
|
||||
|
||||
let baudrate: u32 = 115200;
|
||||
let freq: u32 = perclk / 2;
|
||||
|
|
@ -139,16 +170,25 @@ pub fn setup_rx(perclk: u32) -> cramium_hal::udma::Uart {
|
|||
// IFRAM0. This is a convention that must be respected by the UDMA UART library implementation
|
||||
// for things to work.
|
||||
let uart_buf_addr = crate::platform::UART_IFRAM_ADDR;
|
||||
#[cfg(feature = "nto-evb")]
|
||||
let mut udma_uart = unsafe {
|
||||
// safety: this is safe to call, because we set up clock and events prior to calling new.
|
||||
udma::Uart::get_handle(utra::udma_uart_1::HW_UDMA_UART_1_BASE, uart_buf_addr, uart_buf_addr)
|
||||
};
|
||||
#[cfg(not(feature = "nto-evb"))]
|
||||
let mut udma_uart = unsafe {
|
||||
// safety: this is safe to call, because we set up clock and events prior to calling new.
|
||||
udma::Uart::get_handle(utra::udma_uart_2::HW_UDMA_UART_2_BASE, uart_buf_addr, uart_buf_addr)
|
||||
};
|
||||
udma_uart.set_baud(baudrate, freq);
|
||||
udma_uart.setup_async_read();
|
||||
|
||||
// setup interrupt here
|
||||
let mut uart_irq = UartIrq::new();
|
||||
#[cfg(feature = "nto-evb")]
|
||||
uart_irq.rx_irq_ena(udma::UartChannel::Uart1, true);
|
||||
#[cfg(not(feature = "nto-evb"))]
|
||||
uart_irq.rx_irq_ena(udma::UartChannel::Uart2, true);
|
||||
|
||||
udma_uart
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
MEMORY
|
||||
{
|
||||
FLASH : ORIGIN = 0x61000000, LENGTH = 256k
|
||||
FLASH : ORIGIN = 0x60000000, LENGTH = 256k
|
||||
RAM : ORIGIN = 0x61080000, LENGTH = 1536k
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -241,11 +241,11 @@ impl Repl {
|
|||
// host_fifo_tests
|
||||
+ 1
|
||||
// spi_test
|
||||
+ 1
|
||||
// + 1
|
||||
// i2c_test
|
||||
+ 1
|
||||
// + 1
|
||||
// complex_i2c_test
|
||||
+ 1
|
||||
// + 1
|
||||
// fifo_level_tests
|
||||
+ 1
|
||||
// fifo_alias_tests
|
||||
|
|
@ -283,8 +283,27 @@ impl Repl {
|
|||
|
||||
passing_tests += bio_tests::units::hello_multiverse();
|
||||
|
||||
bio_tests::dma::dma_filter_off();
|
||||
passing_tests += bio_tests::units::hello_world();
|
||||
passing_tests += bio_tests::arith::stack_test();
|
||||
|
||||
// safety: this is safe only if the target supports multiplication
|
||||
passing_tests += unsafe { bio_tests::arith::mac_test() }; // 1
|
||||
|
||||
passing_tests += bio_tests::units::aclk_tests();
|
||||
|
||||
passing_tests += bio_tests::units::event_aliases();
|
||||
passing_tests += bio_tests::units::fifo_alias_tests();
|
||||
|
||||
passing_tests += bio_tests::units::fifo_basic();
|
||||
passing_tests += bio_tests::units::host_fifo_tests();
|
||||
|
||||
passing_tests += bio_tests::units::fifo_level_tests();
|
||||
|
||||
passing_tests += bio_tests::dma::filter_test();
|
||||
bio_tests::dma::dma_filter_off();
|
||||
passing_tests += bio_tests::dma::dmareq_test();
|
||||
|
||||
bio_tests::dma::dma_filter_off();
|
||||
crate::println!("*** CLKMODE 3 ***");
|
||||
passing_tests += bio_tests::dma::dma_basic(false, 3); // 4
|
||||
passing_tests += bio_tests::dma::dma_basic(true, 3); // 4
|
||||
|
|
@ -293,31 +312,9 @@ impl Repl {
|
|||
passing_tests += bio_tests::dma::dma_coincident(3); // 4
|
||||
passing_tests += bio_tests::dma::dma_multicore(3); // 1
|
||||
|
||||
passing_tests += bio_tests::units::hello_world();
|
||||
passing_tests += bio_tests::arith::stack_test();
|
||||
|
||||
{
|
||||
// safety: this is safe only if the target supports multiplication
|
||||
passing_tests += unsafe { bio_tests::arith::mac_test() }; // 1
|
||||
}
|
||||
|
||||
passing_tests += bio_tests::units::aclk_tests();
|
||||
|
||||
passing_tests += bio_tests::dma::filter_test();
|
||||
|
||||
bio_tests::dma::dma_filter_off();
|
||||
passing_tests += bio_tests::dma::dmareq_test();
|
||||
passing_tests += bio_tests::units::event_aliases();
|
||||
passing_tests += bio_tests::units::fifo_alias_tests();
|
||||
|
||||
passing_tests += bio_tests::units::fifo_basic();
|
||||
passing_tests += bio_tests::units::host_fifo_tests();
|
||||
|
||||
passing_tests += bio_tests::spi::spi_test();
|
||||
passing_tests += bio_tests::i2c::i2c_test();
|
||||
passing_tests += bio_tests::i2c::complex_i2c_test();
|
||||
|
||||
passing_tests += bio_tests::units::fifo_level_tests();
|
||||
// passing_tests += bio_tests::spi::spi_test();
|
||||
// passing_tests += bio_tests::i2c::i2c_test();
|
||||
// passing_tests += bio_tests::i2c::complex_i2c_test();
|
||||
|
||||
// Final report
|
||||
crate::println!("\n--- BIO Tests Complete: {}/{} passed. ---\n", passing_tests, BIO_TESTS);
|
||||
|
|
@ -335,7 +332,7 @@ impl Repl {
|
|||
crate::print!(", rram");
|
||||
#[cfg(not(feature = "cramium-soc"))]
|
||||
crate::print!(", mon");
|
||||
#[cfg(not(feature = "nto-bio"))]
|
||||
#[cfg(feature = "nto-bio")]
|
||||
crate::print!(", bio");
|
||||
crate::println!("");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue