diff --git a/artiq/firmware/runtime/Cargo.toml b/artiq/firmware/runtime/Cargo.toml index 4c187b1ff..c2404fc4c 100644 --- a/artiq/firmware/runtime/Cargo.toml +++ b/artiq/firmware/runtime/Cargo.toml @@ -27,7 +27,7 @@ board_misoc = { path = "../libboard_misoc", features = ["uart_console", "smoltcp logger_artiq = { path = "../liblogger_artiq" } board_artiq = { path = "../libboard_artiq" } proto_artiq = { path = "../libproto_artiq", features = ["log", "alloc"] } -smoltcp = { version = "0.5.0", default-features = false, features = ["rust-1_28", "alloc", "log", "proto-ipv4", "socket-tcp"] } +smoltcp = { version = "0.5.0", default-features = false, features = ["rust-1_28", "alloc", "log", "proto-ipv4", "proto-ipv6", "socket-tcp"] } [dependencies.fringe] git = "https://github.com/m-labs/libfringe" diff --git a/artiq/firmware/runtime/main.rs b/artiq/firmware/runtime/main.rs index 82f691a35..6e37f42e1 100644 --- a/artiq/firmware/runtime/main.rs +++ b/artiq/firmware/runtime/main.rs @@ -170,7 +170,7 @@ fn startup() { match config::read_str("ip", |r| r.map(|s| s.parse())) { Ok(Ok(addr)) => { protocol_addr = addr; - info!("using IP address {}", protocol_addr); + info!("using IPv4 address {}", protocol_addr); } _ => { #[cfg(soc_platform = "kasli")] @@ -189,9 +189,23 @@ fn startup() { { protocol_addr = IpAddress::v4(192, 168, 1, 50); } - info!("using default IP address {}", protocol_addr); + info!("using default IPv4 address {}", protocol_addr); } } + let protocol_addr6_ll = IpAddress::v6( + 0xfe80, 0x0000, 0x0000, 0x0000, + (((hardware_addr.0[0] ^ 0x02) as u16) << 8) | (hardware_addr.0[1] as u16), + ((hardware_addr.0[2] as u16) << 8) | 0x00ff, + 0xfe00 | (hardware_addr.0[3] as u16), + ((hardware_addr.0[4] as u16) << 8) | (hardware_addr.0[5] as u16)); + info!("using IPv6 link-local address {}", protocol_addr6_ll); + let protocol_addr6 = match config::read_str("ip6", |r| r.map(|s| s.parse())) { + Ok(Ok(addr)) => { + info!("using IPv6 configured address {}", addr); + Some(addr) + } + _ => None + }; let mut net_device = unsafe { ethmac::EthernetDevice::new() }; net_device.reset_phy_if_any(); @@ -218,12 +232,31 @@ fn startup() { let neighbor_cache = smoltcp::iface::NeighborCache::new(alloc::btree_map::BTreeMap::new()); - let mut interface = - smoltcp::iface::EthernetInterfaceBuilder::new(net_device) - .neighbor_cache(neighbor_cache) + let mut interface = match protocol_addr6 { + Some(addr) => { + let ip_addrs = [ + IpCidr::new(protocol_addr, 0), + IpCidr::new(protocol_addr6_ll, 0), + IpCidr::new(addr, 0) + ]; + smoltcp::iface::EthernetInterfaceBuilder::new(net_device) .ethernet_addr(hardware_addr) - .ip_addrs([IpCidr::new(protocol_addr, 0)]) - .finalize(); + .ip_addrs(ip_addrs) + .neighbor_cache(neighbor_cache) + .finalize() + } + None => { + let ip_addrs = [ + IpCidr::new(protocol_addr, 0), + IpCidr::new(protocol_addr6_ll, 0) + ]; + smoltcp::iface::EthernetInterfaceBuilder::new(net_device) + .ethernet_addr(hardware_addr) + .ip_addrs(ip_addrs) + .neighbor_cache(neighbor_cache) + .finalize() + } + }; #[cfg(has_drtio)] let drtio_routing_table = urc::Urc::new(RefCell::new( diff --git a/doc/manual/installing.rst b/doc/manual/installing.rst index e75f447c5..5ce4f1259 100644 --- a/doc/manual/installing.rst +++ b/doc/manual/installing.rst @@ -240,6 +240,8 @@ In other cases, install OpenOCD as before, and flash the IP and MAC addresses di Check that you can ping the device. If ping fails, check that the Ethernet link LED is ON - on Kasli, it is the LED next to the SFP0 connector. As a next step, look at the messages emitted on the UART during boot. Use a program such as flterm or PuTTY to connect to the device's serial port at 115200bps 8-N-1 and reboot the device. On Kasli, the serial port is on FTDI channel 2 with v1.1 hardware (with channel 0 being JTAG) and on FTDI channel 1 with v1.0 hardware. +If you want to use IPv6, the device also has a link-local address that corresponds to its EUI-64, and an additional arbitrary IPv6 address can be defined by using the ``ip6`` configuration key. All IPv4 and IPv6 addresses can be used at the same time. + Miscellaneous configuration of the core device ----------------------------------------------