From 84bbf001289a6b45aed8ad86bc638f17983cafa7 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Mon, 7 Mar 2022 15:28:22 +0800 Subject: [PATCH 1/5] net_settings: read mac from eeprom for kasli-soc --- libconfig/src/net_settings.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libconfig/src/net_settings.rs b/libconfig/src/net_settings.rs index 453b247..0e99e12 100644 --- a/libconfig/src/net_settings.rs +++ b/libconfig/src/net_settings.rs @@ -30,6 +30,18 @@ impl fmt::Display for NetAddresses { } } +#[cfg(feature = "target_kasli_soc")] +fn get_address_from_eeprom() -> EthernetAddress { + use libboard_zynq::i2c::{I2c, eeprom}; + + let mut i2c = I2c::i2c0(); + i2c.init().unwrap(); + let mut eeprom = eeprom::EEPROM::new(&mut i2c, 16); + let address = eeprom.read_eui48().unwrap_or([0x02, 0x00, 0x00, 0x00, 0x00, 0x56]); + + EthernetAddress(address) +} + pub fn get_adresses(cfg: &Config) -> NetAddresses { #[cfg(feature = "target_zc706")] let mut hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x52]); @@ -44,7 +56,7 @@ pub fn get_adresses(cfg: &Config) -> NetAddresses { #[cfg(feature = "target_redpitaya")] let mut ipv4_addr = IpAddress::v4(192, 168, 1, 55); #[cfg(feature = "target_kasli_soc")] - let mut hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x56]); + let mut hardware_addr = get_address_from_eeprom(); #[cfg(feature = "target_kasli_soc")] let mut ipv4_addr = IpAddress::v4(192, 168, 1, 56); -- 2.42.0 From ce6589c01770914c2ceb327e9b1dd11eccf0602e Mon Sep 17 00:00:00 2001 From: mwojcik Date: Mon, 7 Mar 2022 15:29:37 +0800 Subject: [PATCH 2/5] net_settings: fix typo in fn name (get_addresses) --- libconfig/src/net_settings.rs | 2 +- szl/src/netboot.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libconfig/src/net_settings.rs b/libconfig/src/net_settings.rs index 0e99e12..fa3079f 100644 --- a/libconfig/src/net_settings.rs +++ b/libconfig/src/net_settings.rs @@ -42,7 +42,7 @@ fn get_address_from_eeprom() -> EthernetAddress { EthernetAddress(address) } -pub fn get_adresses(cfg: &Config) -> NetAddresses { +pub fn get_addresses(cfg: &Config) -> NetAddresses { #[cfg(feature = "target_zc706")] let mut hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x52]); #[cfg(feature = "target_zc706")] diff --git a/szl/src/netboot.rs b/szl/src/netboot.rs index 02ff235..8552a6e 100644 --- a/szl/src/netboot.rs +++ b/szl/src/netboot.rs @@ -316,7 +316,7 @@ pub fn netboot( runtime_max_len: usize, ) { log::info!("Preparing network for netboot"); - let net_addresses = net_settings::get_adresses(&cfg); + let net_addresses = net_settings::get_addresses(&cfg); log::info!("Network addresses: {}", net_addresses); let eth = Eth::eth0(net_addresses.hardware_addr.0.clone()); let eth = eth.start_rx(8); -- 2.42.0 From c52de6b2d7238fad514a44ff0898c66507a9fe7e Mon Sep 17 00:00:00 2001 From: mwojcik Date: Mon, 7 Mar 2022 15:56:23 +0800 Subject: [PATCH 3/5] add no_i2c feature for szl to fit in ocm --- libconfig/Cargo.toml | 1 + libconfig/src/net_settings.rs | 6 ++++-- szl/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libconfig/Cargo.toml b/libconfig/Cargo.toml index a490764..7e3649c 100644 --- a/libconfig/Cargo.toml +++ b/libconfig/Cargo.toml @@ -15,4 +15,5 @@ target_zc706 = [] target_coraz7 = [] target_redpitaya = [] target_kasli_soc = [] +no_i2c = [] ipv6 = [] diff --git a/libconfig/src/net_settings.rs b/libconfig/src/net_settings.rs index fa3079f..0a16426 100644 --- a/libconfig/src/net_settings.rs +++ b/libconfig/src/net_settings.rs @@ -30,7 +30,7 @@ impl fmt::Display for NetAddresses { } } -#[cfg(feature = "target_kasli_soc")] +#[cfg(all(feature = "target_kasli_soc", not(feature = "no_i2c")))] fn get_address_from_eeprom() -> EthernetAddress { use libboard_zynq::i2c::{I2c, eeprom}; @@ -55,8 +55,10 @@ pub fn get_addresses(cfg: &Config) -> NetAddresses { 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); - #[cfg(feature = "target_kasli_soc")] + #[cfg(all(feature = "target_kasli_soc", not(feature = "no_i2c")))] let mut hardware_addr = get_address_from_eeprom(); + #[cfg(all(feature = "target_kasli_soc", feature = "no_i2c"))] + let mut hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x56]); #[cfg(feature = "target_kasli_soc")] let mut ipv4_addr = IpAddress::v4(192, 168, 1, 56); diff --git a/szl/Cargo.toml b/szl/Cargo.toml index b1a33ae..7e031b7 100644 --- a/szl/Cargo.toml +++ b/szl/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" target_zc706 = ["libboard_zynq/target_zc706", "libsupport_zynq/target_zc706", "libconfig/target_zc706"] target_coraz7 = ["libboard_zynq/target_coraz7", "libsupport_zynq/target_coraz7", "libconfig/target_coraz7"] target_redpitaya = ["libboard_zynq/target_redpitaya", "libsupport_zynq/target_redpitaya", "libconfig/target_redpitaya"] -target_kasli_soc = ["libboard_zynq/target_kasli_soc", "libsupport_zynq/target_kasli_soc", "libconfig/target_kasli_soc"] +target_kasli_soc = ["libboard_zynq/target_kasli_soc", "libsupport_zynq/target_kasli_soc", "libconfig/target_kasli_soc", "libconfig/no_i2c"] default = ["target_zc706"] [dependencies] -- 2.42.0 From 6d828bb348ecf965c0bed418fe9fa15bb073996c Mon Sep 17 00:00:00 2001 From: mwojcik Date: Mon, 7 Mar 2022 16:55:44 +0800 Subject: [PATCH 4/5] szl: move libconfig no_i2c feature to lib settings --- szl/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/szl/Cargo.toml b/szl/Cargo.toml index 7e031b7..51ef256 100644 --- a/szl/Cargo.toml +++ b/szl/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" target_zc706 = ["libboard_zynq/target_zc706", "libsupport_zynq/target_zc706", "libconfig/target_zc706"] target_coraz7 = ["libboard_zynq/target_coraz7", "libsupport_zynq/target_coraz7", "libconfig/target_coraz7"] target_redpitaya = ["libboard_zynq/target_redpitaya", "libsupport_zynq/target_redpitaya", "libconfig/target_redpitaya"] -target_kasli_soc = ["libboard_zynq/target_kasli_soc", "libsupport_zynq/target_kasli_soc", "libconfig/target_kasli_soc", "libconfig/no_i2c"] +target_kasli_soc = ["libboard_zynq/target_kasli_soc", "libsupport_zynq/target_kasli_soc", "libconfig/target_kasli_soc"] default = ["target_zc706"] [dependencies] @@ -21,4 +21,4 @@ libboard_zynq = { path = "../libboard_zynq" } libsupport_zynq = { path = "../libsupport_zynq" } libcortex_a9 = { path = "../libcortex_a9" } libregister = { path = "../libregister" } -libconfig = { path = "../libconfig" } +libconfig = { path = "../libconfig", features = ["no_i2c"] } -- 2.42.0 From 20bb50931c795554aec0f1adaf5fc020c22e2907 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Mon, 7 Mar 2022 17:51:32 +0800 Subject: [PATCH 5/5] libconfig: remove "no_i2c" feature, opt-level 's' --- Cargo.toml | 2 +- libconfig/Cargo.toml | 1 - libconfig/src/net_settings.rs | 6 ++---- szl/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c23f4aa..8f18210 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ members = [ panic = "abort" debug = true codegen-units = 1 -opt-level = 'z' +opt-level = 's' lto = true debug-assertions = false overflow-checks = false diff --git a/libconfig/Cargo.toml b/libconfig/Cargo.toml index 7e3649c..a490764 100644 --- a/libconfig/Cargo.toml +++ b/libconfig/Cargo.toml @@ -15,5 +15,4 @@ target_zc706 = [] target_coraz7 = [] target_redpitaya = [] target_kasli_soc = [] -no_i2c = [] ipv6 = [] diff --git a/libconfig/src/net_settings.rs b/libconfig/src/net_settings.rs index 0a16426..fa3079f 100644 --- a/libconfig/src/net_settings.rs +++ b/libconfig/src/net_settings.rs @@ -30,7 +30,7 @@ impl fmt::Display for NetAddresses { } } -#[cfg(all(feature = "target_kasli_soc", not(feature = "no_i2c")))] +#[cfg(feature = "target_kasli_soc")] fn get_address_from_eeprom() -> EthernetAddress { use libboard_zynq::i2c::{I2c, eeprom}; @@ -55,10 +55,8 @@ pub fn get_addresses(cfg: &Config) -> NetAddresses { 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); - #[cfg(all(feature = "target_kasli_soc", not(feature = "no_i2c")))] + #[cfg(feature = "target_kasli_soc")] let mut hardware_addr = get_address_from_eeprom(); - #[cfg(all(feature = "target_kasli_soc", feature = "no_i2c"))] - let mut hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x56]); #[cfg(feature = "target_kasli_soc")] let mut ipv4_addr = IpAddress::v4(192, 168, 1, 56); diff --git a/szl/Cargo.toml b/szl/Cargo.toml index 51ef256..b1a33ae 100644 --- a/szl/Cargo.toml +++ b/szl/Cargo.toml @@ -21,4 +21,4 @@ libboard_zynq = { path = "../libboard_zynq" } libsupport_zynq = { path = "../libsupport_zynq" } libcortex_a9 = { path = "../libcortex_a9" } libregister = { path = "../libregister" } -libconfig = { path = "../libconfig", features = ["no_i2c"] } +libconfig = { path = "../libconfig" } -- 2.42.0