mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
move console over to UART2 and set speed to 1Mbps
this makes on the go debugging a bit easier. the memory initialiazation also has to be moved earlier because the static initialization of the bool that determines which console mode to use has to be clean early on. It may even need to move into the asm stub, but would prefer to avoid that if I can.
This commit is contained in:
parent
59fa8ad2df
commit
74e3120ba2
2 changed files with 44 additions and 22 deletions
|
|
@ -32,6 +32,22 @@ pub const SYSTEM_CLOCK_FREQUENCY: u32 = 800_000_000;
|
|||
pub const SYSTEM_TICK_INTERVAL_MS: u32 = 1;
|
||||
|
||||
pub fn early_init() {
|
||||
// Define the .data region - bootstrap baremetal using these hard-coded parameters.
|
||||
const DATA_ORIGIN: usize = 0x61080000;
|
||||
const DATA_SIZE_BYTES: usize = 0x5000;
|
||||
const DATA_INIT: [(usize, u32); 1] = [(0x0, 0x1)];
|
||||
|
||||
// Clear .data, .bss, .stack, .heap regions & setup .data values
|
||||
unsafe {
|
||||
let data_ptr = DATA_ORIGIN as *mut u32;
|
||||
for i in 0..DATA_SIZE_BYTES / size_of::<u32>() {
|
||||
data_ptr.add(i).write_volatile(0);
|
||||
}
|
||||
for (offset, data) in DATA_INIT {
|
||||
data_ptr.add(offset).write_volatile(data);
|
||||
}
|
||||
}
|
||||
|
||||
let iox = Iox::new(utra::iox::HW_IOX_BASE as *mut u32);
|
||||
#[cfg(not(feature = "nto-evb"))]
|
||||
{
|
||||
|
|
@ -191,22 +207,6 @@ pub fn early_init() {
|
|||
*/
|
||||
crate::println!("scratch page: {:x}, heap start: {:x}", SCRATCH_PAGE, HEAP_START);
|
||||
|
||||
// Define the .data region - bootstrap baremetal using these hard-coded parameters.
|
||||
const DATA_ORIGIN: usize = 0x61080000;
|
||||
const DATA_SIZE_BYTES: usize = 0x5000;
|
||||
const DATA_INIT: [(usize, u32); 1] = [(0x0, 0x1)];
|
||||
|
||||
// Clear .data, .bss, .stack, .heap regions & setup .data values
|
||||
unsafe {
|
||||
let data_ptr = DATA_ORIGIN as *mut u32;
|
||||
for i in 0..DATA_SIZE_BYTES / size_of::<u32>() {
|
||||
data_ptr.add(i).write_volatile(0);
|
||||
}
|
||||
for (offset, data) in DATA_INIT {
|
||||
data_ptr.add(offset).write_volatile(data);
|
||||
}
|
||||
}
|
||||
|
||||
// setup heap alloc
|
||||
setup_alloc();
|
||||
|
||||
|
|
@ -218,6 +218,8 @@ pub fn early_init() {
|
|||
enable_irq(utra::irqarray5::IRQARRAY5_IRQ);
|
||||
|
||||
udma_uart.write("console up\r\n".as_bytes());
|
||||
crate::debug::USE_CONSOLE.store(true, core::sync::atomic::Ordering::SeqCst);
|
||||
crate::println!("This debug print should be on the UDMA UART");
|
||||
|
||||
// Setup I/Os so things that should be powered off are actually off
|
||||
cramium_hal::board::setup_display_pins(&iox);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
use core::sync::atomic::{AtomicBool, Ordering::SeqCst};
|
||||
|
||||
use cramium_api::*;
|
||||
use cramium_hal::iox::Iox;
|
||||
use cramium_hal::udma::UartIrq;
|
||||
use cramium_hal::{udma, udma::GlobalConfig};
|
||||
use utralib::generated::*;
|
||||
|
||||
pub static USE_CONSOLE: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// A trait for serial like drivers which allows reading from a source.
|
||||
#[allow(dead_code)]
|
||||
pub trait SerialRead {
|
||||
|
|
@ -15,13 +19,29 @@ pub struct Uart {}
|
|||
#[allow(dead_code)]
|
||||
impl Uart {
|
||||
pub fn putc(&self, c: u8) {
|
||||
let base = utra::duart::HW_DUART_BASE as *mut u32;
|
||||
let mut uart = CSR::new(base);
|
||||
if uart.rf(utra::duart::SFR_CR_SFR_CR) == 0 {
|
||||
uart.wfo(utra::duart::SFR_CR_SFR_CR, 1);
|
||||
if !USE_CONSOLE.load(SeqCst) {
|
||||
let base = utra::duart::HW_DUART_BASE as *mut u32;
|
||||
let mut uart = CSR::new(base);
|
||||
if uart.rf(utra::duart::SFR_CR_SFR_CR) == 0 {
|
||||
uart.wfo(utra::duart::SFR_CR_SFR_CR, 1);
|
||||
}
|
||||
while uart.r(utra::duart::SFR_SR) != 0 {}
|
||||
uart.wo(utra::duart::SFR_TXD, c as u32);
|
||||
} else {
|
||||
let buf: [u8; 1] = [c];
|
||||
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.write(&buf);
|
||||
}
|
||||
while uart.r(utra::duart::SFR_SR) != 0 {}
|
||||
uart.wo(utra::duart::SFR_TXD, c as u32);
|
||||
}
|
||||
|
||||
fn put_digit(&mut self, d: u8) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue