mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +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 const SYSTEM_TICK_INTERVAL_MS: u32 = 1;
|
||||||
|
|
||||||
pub fn early_init() {
|
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 {};
|
let uart = crate::debug::Uart {};
|
||||||
|
|
||||||
for _ in 0..100 {
|
for _ in 0..100 {
|
||||||
|
|
@ -37,7 +49,6 @@ pub fn early_init() {
|
||||||
unsafe {
|
unsafe {
|
||||||
// this block is mandatory in all cases to get clocks set into some consistent, expected mode
|
// 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
|
// 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_0.offset()).write_volatile(0x7f7f);
|
||||||
daric_cgu.add(utra::sysctrl::SFR_CGUFD_CFGFDCR_0_4_1.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 {
|
impl SerialRead for Uart {
|
||||||
fn getc(&mut self) -> Option<u8> {
|
fn getc(&mut self) -> Option<u8> {
|
||||||
let uart_buf_addr = crate::platform::UART_IFRAM_ADDR;
|
let uart_buf_addr = crate::platform::UART_IFRAM_ADDR;
|
||||||
|
#[cfg(feature = "nto-evb")]
|
||||||
let mut udma_uart = unsafe {
|
let mut udma_uart = unsafe {
|
||||||
// safety: this is safe to call, because we set up clock and events prior to calling new.
|
// 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)
|
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;
|
let mut c = 0u8;
|
||||||
udma_uart.read_async(&mut c);
|
udma_uart.read_async(&mut c);
|
||||||
|
|
||||||
|
|
@ -111,26 +117,51 @@ macro_rules! println
|
||||||
|
|
||||||
pub fn setup_rx(perclk: u32) -> cramium_hal::udma::Uart {
|
pub fn setup_rx(perclk: u32) -> cramium_hal::udma::Uart {
|
||||||
let iox = Iox::new(utra::iox::HW_IOX_BASE as *mut u32);
|
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();
|
let udma_global = GlobalConfig::new();
|
||||||
udma_global.clock_on(PeriphId::Uart1);
|
#[cfg(feature = "nto-evb")]
|
||||||
udma_global.map_event(
|
{
|
||||||
PeriphId::Uart1,
|
iox.set_alternate_function(IoxPort::PD, 13, IoxFunction::AF1);
|
||||||
PeriphEventType::Uart(EventUartOffset::Rx),
|
iox.set_alternate_function(IoxPort::PD, 14, IoxFunction::AF1);
|
||||||
EventChannel::Channel0,
|
// rx as input, with pull-up
|
||||||
);
|
iox.set_gpio_dir(IoxPort::PD, 13, IoxDir::Input);
|
||||||
udma_global.map_event(
|
iox.set_gpio_pullup(IoxPort::PD, 13, IoxEnable::Enable);
|
||||||
PeriphId::Uart1,
|
// tx as output
|
||||||
PeriphEventType::Uart(EventUartOffset::Tx),
|
iox.set_gpio_dir(IoxPort::PD, 14, IoxDir::Output);
|
||||||
EventChannel::Channel1,
|
|
||||||
);
|
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 baudrate: u32 = 115200;
|
||||||
let freq: u32 = perclk / 2;
|
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
|
// IFRAM0. This is a convention that must be respected by the UDMA UART library implementation
|
||||||
// for things to work.
|
// for things to work.
|
||||||
let uart_buf_addr = crate::platform::UART_IFRAM_ADDR;
|
let uart_buf_addr = crate::platform::UART_IFRAM_ADDR;
|
||||||
|
#[cfg(feature = "nto-evb")]
|
||||||
let mut udma_uart = unsafe {
|
let mut udma_uart = unsafe {
|
||||||
// safety: this is safe to call, because we set up clock and events prior to calling new.
|
// 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)
|
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.set_baud(baudrate, freq);
|
||||||
udma_uart.setup_async_read();
|
udma_uart.setup_async_read();
|
||||||
|
|
||||||
// setup interrupt here
|
// setup interrupt here
|
||||||
let mut uart_irq = UartIrq::new();
|
let mut uart_irq = UartIrq::new();
|
||||||
|
#[cfg(feature = "nto-evb")]
|
||||||
uart_irq.rx_irq_ena(udma::UartChannel::Uart1, true);
|
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
|
udma_uart
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
FLASH : ORIGIN = 0x61000000, LENGTH = 256k
|
FLASH : ORIGIN = 0x60000000, LENGTH = 256k
|
||||||
RAM : ORIGIN = 0x61080000, LENGTH = 1536k
|
RAM : ORIGIN = 0x61080000, LENGTH = 1536k
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -241,11 +241,11 @@ impl Repl {
|
||||||
// host_fifo_tests
|
// host_fifo_tests
|
||||||
+ 1
|
+ 1
|
||||||
// spi_test
|
// spi_test
|
||||||
+ 1
|
// + 1
|
||||||
// i2c_test
|
// i2c_test
|
||||||
+ 1
|
// + 1
|
||||||
// complex_i2c_test
|
// complex_i2c_test
|
||||||
+ 1
|
// + 1
|
||||||
// fifo_level_tests
|
// fifo_level_tests
|
||||||
+ 1
|
+ 1
|
||||||
// fifo_alias_tests
|
// fifo_alias_tests
|
||||||
|
|
@ -283,8 +283,27 @@ impl Repl {
|
||||||
|
|
||||||
passing_tests += bio_tests::units::hello_multiverse();
|
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 ***");
|
crate::println!("*** CLKMODE 3 ***");
|
||||||
passing_tests += bio_tests::dma::dma_basic(false, 3); // 4
|
passing_tests += bio_tests::dma::dma_basic(false, 3); // 4
|
||||||
passing_tests += bio_tests::dma::dma_basic(true, 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_coincident(3); // 4
|
||||||
passing_tests += bio_tests::dma::dma_multicore(3); // 1
|
passing_tests += bio_tests::dma::dma_multicore(3); // 1
|
||||||
|
|
||||||
passing_tests += bio_tests::units::hello_world();
|
// passing_tests += bio_tests::spi::spi_test();
|
||||||
passing_tests += bio_tests::arith::stack_test();
|
// passing_tests += bio_tests::i2c::i2c_test();
|
||||||
|
// passing_tests += bio_tests::i2c::complex_i2c_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();
|
|
||||||
|
|
||||||
// Final report
|
// Final report
|
||||||
crate::println!("\n--- BIO Tests Complete: {}/{} passed. ---\n", passing_tests, BIO_TESTS);
|
crate::println!("\n--- BIO Tests Complete: {}/{} passed. ---\n", passing_tests, BIO_TESTS);
|
||||||
|
|
@ -335,7 +332,7 @@ impl Repl {
|
||||||
crate::print!(", rram");
|
crate::print!(", rram");
|
||||||
#[cfg(not(feature = "cramium-soc"))]
|
#[cfg(not(feature = "cramium-soc"))]
|
||||||
crate::print!(", mon");
|
crate::print!(", mon");
|
||||||
#[cfg(not(feature = "nto-bio"))]
|
#[cfg(feature = "nto-bio")]
|
||||||
crate::print!(", bio");
|
crate::print!(", bio");
|
||||||
crate::println!("");
|
crate::println!("");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue