Skip to content

Commit

Permalink
remove peekpoke dependency
Browse files Browse the repository at this point in the history
peekpoke requires a clang toolchain in order to build.
Use a simple write to /dev/mem instead. which doesnt require any
additional packages.
  • Loading branch information
svenrademakers committed Mar 13, 2024
1 parent 0d73714 commit c516208
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 142 deletions.
136 changes: 0 additions & 136 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions src/app/bmc_application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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");
}

Expand Down
6 changes: 3 additions & 3 deletions src/hal/power_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit c516208

Please sign in to comment.