forked from M-Labs/artiq
firmware: reset ethphy before initializing smoltcp (fixes #884).
This commit is contained in:
parent
67746cc7a0
commit
fc9766d2fa
|
@ -158,10 +158,12 @@ fn network_boot() {
|
||||||
|
|
||||||
println!("Using MAC address {} and IP address {}", eth_addr, ip_addr);
|
println!("Using MAC address {} and IP address {}", eth_addr, ip_addr);
|
||||||
|
|
||||||
let net_device = unsafe { ethmac::EthernetDevice::new() };
|
let mut net_device = unsafe { ethmac::EthernetDevice::new() };
|
||||||
let mut neighbor_cache_storage = [None; 2];
|
net_device.reset();
|
||||||
|
|
||||||
|
let mut neighbor_map = [None; 2];
|
||||||
let neighbor_cache =
|
let neighbor_cache =
|
||||||
smoltcp::iface::NeighborCache::new(&mut neighbor_cache_storage[..]);
|
smoltcp::iface::NeighborCache::new(&mut neighbor_map[..]);
|
||||||
let mut ip_addrs = [IpCidr::new(ip_addr, 0)];
|
let mut ip_addrs = [IpCidr::new(ip_addr, 0)];
|
||||||
let mut interface =
|
let mut interface =
|
||||||
smoltcp::iface::EthernetInterfaceBuilder::new(net_device)
|
smoltcp::iface::EthernetInterfaceBuilder::new(net_device)
|
||||||
|
|
|
@ -4,6 +4,7 @@ use smoltcp::phy::{self, DeviceCapabilities, Device};
|
||||||
|
|
||||||
use csr;
|
use csr;
|
||||||
use mem::ETHMAC_BASE;
|
use mem::ETHMAC_BASE;
|
||||||
|
use clock;
|
||||||
|
|
||||||
const RX_SLOTS: usize = csr::ETHMAC_RX_SLOTS as usize;
|
const RX_SLOTS: usize = csr::ETHMAC_RX_SLOTS as usize;
|
||||||
const TX_SLOTS: usize = csr::ETHMAC_TX_SLOTS as usize;
|
const TX_SLOTS: usize = csr::ETHMAC_TX_SLOTS as usize;
|
||||||
|
@ -45,6 +46,15 @@ impl EthernetDevice {
|
||||||
pub unsafe fn new() -> EthernetDevice {
|
pub unsafe fn new() -> EthernetDevice {
|
||||||
EthernetDevice(())
|
EthernetDevice(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reset(&mut self) {
|
||||||
|
unsafe {
|
||||||
|
csr::ethphy::crg_reset_write(1);
|
||||||
|
clock::spin_us(2_000);
|
||||||
|
csr::ethphy::crg_reset_write(0);
|
||||||
|
clock::spin_us(2_000);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Device<'a> for EthernetDevice {
|
impl<'a> Device<'a> for EthernetDevice {
|
||||||
|
|
|
@ -130,18 +130,20 @@ fn startup_ethernet() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut net_device = unsafe { ethmac::EthernetDevice::new() };
|
||||||
|
net_device.reset();
|
||||||
|
|
||||||
// fn _net_trace_writer<U>(timestamp: u64, printer: smoltcp::wire::PrettyPrinter<U>)
|
// fn _net_trace_writer<U>(timestamp: u64, printer: smoltcp::wire::PrettyPrinter<U>)
|
||||||
// where U: smoltcp::wire::pretty_print::PrettyPrint {
|
// where U: smoltcp::wire::pretty_print::PrettyPrint {
|
||||||
// let seconds = timestamp / 1000;
|
// let seconds = timestamp / 1000;
|
||||||
// let micros = timestamp % 1000 * 1000;
|
// let micros = timestamp % 1000 * 1000;
|
||||||
// print!("\x1b[37m[{:6}.{:06}s]\n{}\x1b[0m\n", seconds, micros, printer)
|
// print!("\x1b[37m[{:6}.{:06}s]\n{}\x1b[0m\n", seconds, micros, printer)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
let net_device = unsafe { ethmac::EthernetDevice::new() };
|
|
||||||
// let net_device = smoltcp::phy::EthernetTracer::new(net_device, _net_trace_writer);
|
// let net_device = smoltcp::phy::EthernetTracer::new(net_device, _net_trace_writer);
|
||||||
let mut neighbor_cache_storage = [None; 8];
|
|
||||||
|
let mut neighbor_map = [None; 8];
|
||||||
let neighbor_cache =
|
let neighbor_cache =
|
||||||
smoltcp::iface::NeighborCache::new(&mut neighbor_cache_storage[..]);
|
smoltcp::iface::NeighborCache::new(&mut neighbor_map[..]);
|
||||||
let mut interface =
|
let mut interface =
|
||||||
smoltcp::iface::EthernetInterfaceBuilder::new(net_device)
|
smoltcp::iface::EthernetInterfaceBuilder::new(net_device)
|
||||||
.neighbor_cache(neighbor_cache)
|
.neighbor_cache(neighbor_cache)
|
||||||
|
|
Loading…
Reference in New Issue