forked from M-Labs/artiq
firmware: allow building without system UART.
This commit is contained in:
parent
158ceb0881
commit
9ea7d7a804
|
@ -18,6 +18,7 @@ include!(concat!(env!("BUILDINC_DIRECTORY"), "/generated/sdram_phy.rs"));
|
||||||
pub mod sdram;
|
pub mod sdram;
|
||||||
pub mod ident;
|
pub mod ident;
|
||||||
pub mod clock;
|
pub mod clock;
|
||||||
|
#[cfg(has_uart)]
|
||||||
pub mod uart;
|
pub mod uart;
|
||||||
#[cfg(has_spiflash)]
|
#[cfg(has_spiflash)]
|
||||||
pub mod spiflash;
|
pub mod spiflash;
|
||||||
|
|
|
@ -1,16 +1,24 @@
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use csr;
|
|
||||||
|
|
||||||
pub struct Console;
|
pub struct Console;
|
||||||
|
|
||||||
impl fmt::Write for Console {
|
impl fmt::Write for Console {
|
||||||
|
#[cfg(has_uart)]
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
|
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
|
||||||
|
use csr;
|
||||||
|
|
||||||
for c in s.bytes() {
|
for c in s.bytes() {
|
||||||
unsafe {
|
unsafe {
|
||||||
while csr::uart::txfull_read() != 0 {}
|
while csr::uart::txfull_read() != 0 {}
|
||||||
csr::uart::rxtx_write(c)
|
csr::uart::rxtx_write(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(has_uart))]
|
||||||
|
fn write_str(&mut self, _s: &str) -> Result<(), fmt::Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,17 +77,19 @@ fn startup() {
|
||||||
#[cfg(has_serwb_phy_amc)]
|
#[cfg(has_serwb_phy_amc)]
|
||||||
board_artiq::serwb::wait_init();
|
board_artiq::serwb::wait_init();
|
||||||
|
|
||||||
let t = board::clock::get_ms();
|
#[cfg(has_uart)] {
|
||||||
info!("press 'e' to erase startup and idle kernels...");
|
let t = board::clock::get_ms();
|
||||||
while board::clock::get_ms() < t + 1000 {
|
info!("press 'e' to erase startup and idle kernels...");
|
||||||
if unsafe { board::csr::uart::rxtx_read() == b'e' } {
|
while board::clock::get_ms() < t + 1000 {
|
||||||
config::remove("startup_kernel").unwrap();
|
if unsafe { board::csr::uart::rxtx_read() == b'e' } {
|
||||||
config::remove("idle_kernel").unwrap();
|
config::remove("startup_kernel").unwrap();
|
||||||
info!("startup and idle kernels erased");
|
config::remove("idle_kernel").unwrap();
|
||||||
break
|
info!("startup and idle kernels erased");
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
info!("continuing boot");
|
||||||
}
|
}
|
||||||
info!("continuing boot");
|
|
||||||
|
|
||||||
#[cfg(has_i2c)]
|
#[cfg(has_i2c)]
|
||||||
board_artiq::i2c::init();
|
board_artiq::i2c::init();
|
||||||
|
|
Loading…
Reference in New Issue