From 80d12d57802b9b78aa45b821a147f71444d401f0 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 14 Oct 2020 12:53:32 +0800 Subject: [PATCH] libconfig: make default IP/MAC depend on board --- libconfig/Cargo.toml | 4 +++- libconfig/src/net_settings.rs | 10 ++++++++++ szl/Cargo.toml | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libconfig/Cargo.toml b/libconfig/Cargo.toml index fcfaa74..c3356ab 100644 --- a/libconfig/Cargo.toml +++ b/libconfig/Cargo.toml @@ -11,5 +11,7 @@ fatfs = { version = "0.3", features = ["core_io"], default-features = false } log = "0.4" [features] +target_zc706 = [] +target_cora_z7_10 = [] +target_redpitaya = [] ipv6 = [] - diff --git a/libconfig/src/net_settings.rs b/libconfig/src/net_settings.rs index 76ddbb2..9439dbc 100644 --- a/libconfig/src/net_settings.rs +++ b/libconfig/src/net_settings.rs @@ -31,8 +31,18 @@ impl fmt::Display for NetAddresses { } pub fn get_adresses(cfg: &Config) -> NetAddresses { + #[cfg(feature = "target_zc706")] let mut hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x52]); + #[cfg(feature = "target_zc706")] let mut ipv4_addr = IpAddress::v4(192, 168, 1, 52); + #[cfg(feature = "target_cora_z7_10")] + let mut hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x54]); + #[cfg(feature = "target_cora_z7_10")] + let mut ipv4_addr = IpAddress::v4(192, 168, 1, 54); + #[cfg(feature = "target_redpitaya")] + let mut hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x55]); + #[cfg(feature = "target_redpitaya")] + let mut ipv4_addr = IpAddress::v4(192, 168, 1, 55); if let Ok(Ok(addr)) = cfg.read_str("mac").map(|s| s.parse()) { hardware_addr = addr; diff --git a/szl/Cargo.toml b/szl/Cargo.toml index 8af58fb..32beb36 100644 --- a/szl/Cargo.toml +++ b/szl/Cargo.toml @@ -6,8 +6,8 @@ authors = ["M-Labs"] edition = "2018" [features] -target_zc706 = ["libboard_zynq/target_zc706", "libsupport_zynq/target_zc706"] -target_redpitaya = ["libboard_zynq/target_redpitaya", "libsupport_zynq/target_redpitaya"] +target_zc706 = ["libboard_zynq/target_zc706", "libsupport_zynq/target_zc706", "libconfig/target_zc706"] +target_redpitaya = ["libboard_zynq/target_redpitaya", "libsupport_zynq/target_redpitaya", "libconfig/target_redpitaya"] default = ["target_zc706"] [dependencies]