From 818d6b2f5abb5cd7fa9f56d8692013076c83a19e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 21 Oct 2019 13:28:17 +0800 Subject: [PATCH] bootloader: fix compilation problems --- artiq/firmware/bootloader/main.rs | 27 ++++++++----------- artiq/firmware/libboard_misoc/net_settings.rs | 10 ++----- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/artiq/firmware/bootloader/main.rs b/artiq/firmware/bootloader/main.rs index 545e3a73c..f44f0b757 100644 --- a/artiq/firmware/bootloader/main.rs +++ b/artiq/firmware/bootloader/main.rs @@ -12,7 +12,7 @@ use crc::crc32; use byteorder::{ByteOrder, BigEndian}; use board_misoc::{ident, cache, sdram, boot, mem as board_mem}; #[cfg(has_ethmac)] -use board_misoc::{clock, config, ethmac, net_settings}; +use board_misoc::{clock, ethmac, net_settings}; use board_misoc::uart_console::Console; fn check_integrity() -> bool { @@ -151,7 +151,7 @@ fn flash_boot() { #[cfg(has_ethmac)] fn network_boot() { - use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr}; + use smoltcp::wire::IpCidr; println!("Initializing network..."); @@ -161,33 +161,28 @@ fn network_boot() { let mut neighbor_map = [None; 2]; let neighbor_cache = smoltcp::iface::NeighborCache::new(&mut neighbor_map[..]); - let mut ip_addrs = [IpCidr::new(ip_addr, 0)]; let net_addresses = net_settings::get_adresses(); println!("network addresses: {}", net_addresses); + let mut ip_addrs = [ + IpCidr::new(net_addresses.ipv4_addr, 0), + IpCidr::new(net_addresses.ipv6_ll_addr, 0), + IpCidr::new(net_addresses.ipv6_ll_addr, 0) + ]; let mut interface = match net_addresses.ipv6_addr { Some(addr) => { - let ip_addrs = [ - IpCidr::new(net_addresses.ipv4_addr, 0), - IpCidr::new(net_addresses.ipv6_ll_addr, 0), - IpCidr::new(addr, 0) - ]; + ip_addrs[2] = IpCidr::new(addr, 0); smoltcp::iface::EthernetInterfaceBuilder::new(net_device) .ethernet_addr(net_addresses.hardware_addr) - .ip_addrs(ip_addrs) + .ip_addrs(&mut ip_addrs[..]) .neighbor_cache(neighbor_cache) .finalize() } - None => { - let ip_addrs = [ - IpCidr::new(net_addresses.ipv4_addr, 0), - IpCidr::new(net_addresses.ipv6_ll_addr, 0) - ]; + None => smoltcp::iface::EthernetInterfaceBuilder::new(net_device) .ethernet_addr(net_addresses.hardware_addr) - .ip_addrs(ip_addrs) + .ip_addrs(&mut ip_addrs[..2]) .neighbor_cache(neighbor_cache) .finalize() - } }; let mut socket_set_storage = []; diff --git a/artiq/firmware/libboard_misoc/net_settings.rs b/artiq/firmware/libboard_misoc/net_settings.rs index 3636c6924..1ab25b4e6 100644 --- a/artiq/firmware/libboard_misoc/net_settings.rs +++ b/artiq/firmware/libboard_misoc/net_settings.rs @@ -36,14 +36,8 @@ pub fn get_adresses() -> NetAddresses { let eeprom = i2c_eeprom::EEPROM::kasli_eeprom(); hardware_addr = eeprom.read_eui48() - .map(|addr_buf| { - let hardware_addr = EthernetAddress(addr_buf); - hardware_addr - }) - .unwrap_or_else(|e| { - let hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x21]); - hardware_addr - }); + .map(|addr_buf| EthernetAddress(addr_buf)) + .unwrap_or_else(|_e| EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x21])); } #[cfg(soc_platform = "sayma_amc")] { hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x11]); }