diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-04-11 22:14:27 +0200 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-04-11 22:14:27 +0200 |
commit | 41d5e8501cc4ce4498a7d218b45f5c9a123d89f2 (patch) | |
tree | e27240a1d218cb6edaf993faf14cc966aaebdc4e | |
parent | 0661ca3436550fe4dd3ad7648823c59fa66e0b49 (diff) |
extract device trees
-rw-r--r-- | src/main.rs | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 85c9782..c15435c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use clap::Parser; use std::env; use std::ffi::OsStr; use std::fs::{self, File}; -use std::io::prelude::*; +use std::io::{self, prelude::*}; use std::path::Path; use std::process::{Command, Stdio}; @@ -887,8 +887,13 @@ fn compile(arch: &str, cross: Option<String>, img: &str) -> anyhow::Result<()> { make.arg(cross_compile); } - make.arg(img) - .arg("modules") + make.arg(img); + + if arch == "rpi" { + make.arg(dtbs); + } + + make.arg("modules") .arg("-j".to_owned() + &num_cpus::get().to_string()); if !make.spawn()?.wait()?.success() { @@ -948,6 +953,29 @@ fn main() -> anyhow::Result<()> { format!("vmlinuz-{}", args.arch), )?; + if arch == "rpi" { + copy_file( + "arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dtb", + "bcm2710-rpi-3-b.dtb", + )?; + copy_file( + "arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b-plus.dtb", + "bcm2710-rpi-3-b-plus.dtb", + )?; + copy_file( + "arch/arm64/boot/dts/broadcom/bcm2837-rpi-cm3-io3.dtb", + "bcm2710-rpi-cm3.dtb", + )?; + copy_file( + "arch/arm64/boot/dts/broadcom/bcm2711-rpi-4-b.dtb", + "bcm2711-rpi-4-b.dtb", + )?; + copy_file( + "arch/arm64/boot/dts/broadcom/bcm2837-rpi-zero-2-w.dtb", + "bcm2710-rpi-zero-2-w.dtb", + )?; + } + fs::remove_file(file_name)?; fs::remove_dir_all(file_name.trim_end_matches(".tar.xz"))?; @@ -960,3 +988,7 @@ fn no_stdin<S: AsRef<OsStr>>(program: S) -> Command { cmd } + +fn copy_file<T: AsRef<Path>>(base: &Path, path: &str, to: T) -> io::Result<()> { + fs::copy(Path::new(base.trim_end_matches(".tar.xz")).join(path), to) +} |