remove peekpoke dependency
authorSven Rademakers <sven.rademakers@gmail.com>
Wed, 13 Mar 2024 11:05:10 +0000 (11:05 +0000)
committerSven Rademakers <sven.rademakers@gmail.com>
Wed, 13 Mar 2024 11:11:56 +0000 (11:11 +0000)
peekpoke requires a clang toolchain in order to build.
Use a simple write to /dev/mem instead. which doesnt require any
additional packages.

Cargo.lock
Cargo.toml
src/app/bmc_application.rs
src/hal/power_controller.rs

index ee7dd493224700b9aa2fa65f6f60677257e1ee2c..d943d346752ed251c02f705259a5880a1e9817ee 100644 (file)
@@ -494,28 +494,6 @@ dependencies = [
  "serde",
 ]
 
-[[package]]
-name = "bindgen"
-version = "0.64.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4"
-dependencies = [
- "bitflags 1.3.2",
- "cexpr",
- "clang-sys",
- "lazy_static",
- "lazycell",
- "log",
- "peeking_take_while",
- "proc-macro2",
- "quote",
- "regex",
- "rustc-hash",
- "shlex",
- "syn 1.0.109",
- "which",
-]
-
 [[package]]
 name = "bitflags"
 version = "1.3.2"
@@ -600,7 +578,6 @@ dependencies = [
  "log",
  "nix 0.27.1",
  "openssl",
- "peekpoke",
  "pin-project",
  "pwhash",
  "rand 0.8.5",
@@ -694,15 +671,6 @@ dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "cexpr"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
-dependencies = [
- "nom",
-]
-
 [[package]]
 name = "cfg-if"
 version = "1.0.0"
@@ -739,17 +707,6 @@ version = "0.1.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b8da9d36ad01a07a2c380bdece16e418820ffa8eda01d3debed9bff3f296a84f"
 
-[[package]]
-name = "clang-sys"
-version = "1.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1"
-dependencies = [
- "glob",
- "libc",
- "libloading",
-]
-
 [[package]]
 name = "clap"
 version = "4.4.18"
@@ -971,12 +928,6 @@ dependencies = [
  "crypto-common",
 ]
 
-[[package]]
-name = "either"
-version = "1.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
-
 [[package]]
 name = "encoding_rs"
 version = "0.8.33"
@@ -1212,12 +1163,6 @@ version = "0.28.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
 
-[[package]]
-name = "glob"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
-
 [[package]]
 name = "gpiod"
 version = "0.2.3"
@@ -1289,15 +1234,6 @@ dependencies = [
  "digest 0.9.0",
 ]
 
-[[package]]
-name = "home"
-version = "0.5.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
-dependencies = [
- "windows-sys 0.52.0",
-]
-
 [[package]]
 name = "http"
 version = "0.2.11"
@@ -1541,28 +1477,12 @@ version = "1.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 
-[[package]]
-name = "lazycell"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
-
 [[package]]
 name = "libc"
 version = "0.2.153"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
 
-[[package]]
-name = "libloading"
-version = "0.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161"
-dependencies = [
- "cfg-if",
- "windows-sys 0.48.0",
-]
-
 [[package]]
 name = "libm"
 version = "0.2.8"
@@ -1691,12 +1611,6 @@ dependencies = [
  "unicase",
 ]
 
-[[package]]
-name = "minimal-lexical"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
-
 [[package]]
 name = "miniz_oxide"
 version = "0.7.2"
@@ -1786,16 +1700,6 @@ dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "nom"
-version = "7.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
-dependencies = [
- "memchr",
- "minimal-lexical",
-]
-
 [[package]]
 name = "num-conv"
 version = "0.1.0"
@@ -1961,22 +1865,6 @@ version = "1.0.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
 
-[[package]]
-name = "peeking_take_while"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
-
-[[package]]
-name = "peekpoke"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0d3446e3a050c7a2727b1a6318a1043cbf5c0a0a2fc5db3bc5dd84234bddbcf"
-dependencies = [
- "bindgen",
- "cc",
-]
-
 [[package]]
 name = "percent-encoding"
 version = "2.3.1"
@@ -2277,12 +2165,6 @@ version = "0.1.23"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
 
-[[package]]
-name = "rustc-hash"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
-
 [[package]]
 name = "rustc_version"
 version = "0.4.0"
@@ -2535,12 +2417,6 @@ dependencies = [
  "digest 0.10.7",
 ]
 
-[[package]]
-name = "shlex"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
-
 [[package]]
 name = "signal-hook-registry"
 version = "1.4.1"
@@ -3087,18 +2963,6 @@ dependencies = [
  "wasm-bindgen",
 ]
 
-[[package]]
-name = "which"
-version = "4.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
-dependencies = [
- "either",
- "home",
- "once_cell",
- "rustix",
-]
-
 [[package]]
 name = "winapi"
 version = "0.3.9"
index d30801b65f2cb12cba2f4b0f92a37633be752122..26eafd1e77955c9475a676e7089cfd55b8a35c17 100644 (file)
@@ -34,7 +34,6 @@ inotify = "0.10.2"
 log = "0.4.21"
 nix = { version = "0.27.1", features = ["fs", "feature"] }
 openssl = "0.10.64"
-peekpoke = "0.3.0"
 pin-project = "1.1.5"
 pwhash = "1.0.0"
 rand = "0.8.5"
index 78f2a3eda2a9c21a3e3d71ec53b19b1c8f4b6a69..e13996f6836550bce1ffc13270acc4809168b2d4 100644 (file)
@@ -31,7 +31,8 @@ use std::collections::HashMap;
 use std::path::PathBuf;
 use std::process::Command;
 use std::time::Duration;
-use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite};
+use tokio::fs::OpenOptions;
+use tokio::io::{AsyncRead, AsyncSeek, AsyncSeekExt, AsyncWrite, AsyncWriteExt};
 
 pub type NodeInfos = [NodeInfo; 4];
 
@@ -297,7 +298,9 @@ impl BmcApplication {
 
     pub async fn reboot(&self, fel: bool) -> anyhow::Result<()> {
         if fel {
-            peekpoke::write(0x0709_0108, 0x5AA5_A55A);
+            let mut mem = OpenOptions::new().write(true).open("/dev/mem").await?;
+            mem.seek(std::io::SeekFrom::Start(0x0709_0108)).await?;
+            mem.write_u32(0x5AA5_A55A).await?;
             log::warn!("system reboot into FEL");
         }
 
index ffc099be59b941fe3974accdde8828bf42f799cf..2a35c95f8dad780d9634f83552aee9823eb4c659 100644 (file)
@@ -65,8 +65,8 @@ impl PowerController {
 
         let enable = gpio_output_array!(chip1, port1, port2, port3, port4);
 
-        let sysfs_power = fallback_when_not_exists(SYS_LED, SYS_LED_2_0_5);
-        let sysfs_reset = fallback_when_not_exists(STATUS_LED, STATUS_LED_2_0_5);
+        let sysfs_power = fallback_if_not_exist(SYS_LED, SYS_LED_2_0_5);
+        let sysfs_reset = fallback_if_not_exist(STATUS_LED, STATUS_LED_2_0_5);
 
         Ok(PowerController {
             enable,
@@ -137,7 +137,7 @@ async fn set_mode(node_id: usize, node_state: u8) -> std::io::Result<()> {
     tokio::fs::write(sys_path, node_value).await
 }
 
-fn fallback_when_not_exists(sysfs: &str, fallback: &str) -> PathBuf {
+fn fallback_if_not_exist(sysfs: &str, fallback: &str) -> PathBuf {
     let mut sysfs = PathBuf::from_str(sysfs).expect("valid utf8 path");
     if !sysfs.exists() {
         sysfs = PathBuf::from_str(fallback).expect("valid utf8 path");