style: rustfmt the a113d flash engine + CLI (cargo fmt)
#52's verify never actually ran before (the alkane-verify runner was offline), so cargo fmt --check was never enforced on this branch. Apply rustfmt to the three flagged files (alkane-cli main.rs, alkane-flash aml_ubi.rs and zynq_nand.rs) to match the toolkit's CI fmt gate. No behavioural change; vendored thirdparty/ is untouched (CI only formats the named crates). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
This commit is contained in:
@@ -22,8 +22,8 @@ use alkane_flash::preflight::{preflight, PreflightOptions};
|
|||||||
use alkane_flash::stock;
|
use alkane_flash::stock;
|
||||||
use alkane_flash::stock::{InPlaceOptions, InPlaceOutcome, RestoreImages};
|
use alkane_flash::stock::{InPlaceOptions, InPlaceOutcome, RestoreImages};
|
||||||
use alkane_flash::stock_firmware;
|
use alkane_flash::stock_firmware;
|
||||||
use alkane_flash::zynq_nand;
|
|
||||||
use alkane_flash::transport::{Remote, RootMethod, SshOptions, SshTransport};
|
use alkane_flash::transport::{Remote, RootMethod, SshOptions, SshTransport};
|
||||||
|
use alkane_flash::zynq_nand;
|
||||||
use std::collections::{BTreeMap, BTreeSet};
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
@@ -1042,7 +1042,10 @@ fn latest_backup(dir: &Path) -> Option<PathBuf> {
|
|||||||
/// of these; `compat` lists them so an operator knows what is supported.
|
/// of these; `compat` lists them so an operator knows what is supported.
|
||||||
const SUPPORTED: &[(&str, &str)] = &[
|
const SUPPORTED: &[(&str, &str)] = &[
|
||||||
("zynq-7010", "Antminer S17 (Xilinx Zynq-7010 control board)"),
|
("zynq-7010", "Antminer S17 (Xilinx Zynq-7010 control board)"),
|
||||||
("a113d", "Antminer BHB42XXX / S19k Pro (Amlogic A113D/AXG control board)"),
|
(
|
||||||
|
"a113d",
|
||||||
|
"Antminer BHB42XXX / S19k Pro (Amlogic A113D/AXG control board)",
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
fn is_supported(board: &str) -> bool {
|
fn is_supported(board: &str) -> bool {
|
||||||
@@ -1128,7 +1131,9 @@ fn run_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Error>>
|
|||||||
None => {
|
None => {
|
||||||
if opts.flag("dry-run") {
|
if opts.flag("dry-run") {
|
||||||
println!("DRY RUN: would restore {host} to stock by flipping the A113D boot flag");
|
println!("DRY RUN: would restore {host} to stock by flipping the A113D boot flag");
|
||||||
println!("(no stock firmware needed; the untouched stock boot partition is booted).");
|
println!(
|
||||||
|
"(no stock firmware needed; the untouched stock boot partition is booted)."
|
||||||
|
);
|
||||||
println!("Re-run with --confirm FLASH.");
|
println!("Re-run with --confirm FLASH.");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -1138,7 +1143,9 @@ fn run_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Error>>
|
|||||||
println!("restoring {host} to genuine stock (A113D flag flip, network-only)...");
|
println!("restoring {host} to genuine stock (A113D flag flip, network-only)...");
|
||||||
match stock::restore_aml_flag(&host, password.as_deref()) {
|
match stock::restore_aml_flag(&host, password.as_deref()) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
println!("restore reported success (boot flag cleared; stock boots via storeboot).");
|
println!(
|
||||||
|
"restore reported success (boot flag cleared; stock boots via storeboot)."
|
||||||
|
);
|
||||||
println!("verify independently: the board should present genuine stock");
|
println!("verify independently: the board should present genuine stock");
|
||||||
println!("(cgminer API on :4028, lighttpd 401 on :80, dropbear 2018.x).");
|
println!("(cgminer API on :4028, lighttpd 401 on :80, dropbear 2018.x).");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -1186,9 +1193,7 @@ fn run_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Error>>
|
|||||||
fn run_root_run(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
fn run_root_run(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let opts = parse_args(args, ssh_values(), &[])?;
|
let opts = parse_args(args, ssh_values(), &[])?;
|
||||||
let host = opts.value("host").ok_or("--host is required")?.to_owned();
|
let host = opts.value("host").ok_or("--host is required")?.to_owned();
|
||||||
let cmd = opts
|
let cmd = opts.positionals.join(" ");
|
||||||
.positionals
|
|
||||||
.join(" ");
|
|
||||||
if cmd.trim().is_empty() {
|
if cmd.trim().is_empty() {
|
||||||
return Err("usage: alkane-cli afw root-run --host <ip> <command...>".into());
|
return Err("usage: alkane-cli afw root-run --host <ip> <command...>".into());
|
||||||
}
|
}
|
||||||
@@ -1203,7 +1208,11 @@ fn run_root_run(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
/// backup, write the boot slots and reboot. Drives the DSH root-on-stock
|
/// backup, write the boot slots and reboot. Drives the DSH root-on-stock
|
||||||
/// primitive; board must be on stock (credential root/root).
|
/// primitive; board must be on stock (credential root/root).
|
||||||
fn run_nand_install(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
fn run_nand_install(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let opts = parse_args(args, &[ssh_values(), &["confirm"]].concat(), &["allow-unsigned"])?;
|
let opts = parse_args(
|
||||||
|
args,
|
||||||
|
&[ssh_values(), &["confirm"]].concat(),
|
||||||
|
&["allow-unsigned"],
|
||||||
|
)?;
|
||||||
let host = opts.value("host").ok_or("--host is required")?.to_owned();
|
let host = opts.value("host").ok_or("--host is required")?.to_owned();
|
||||||
let afw_path = opts
|
let afw_path = opts
|
||||||
.positionals
|
.positionals
|
||||||
@@ -1211,18 +1220,33 @@ fn run_nand_install(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.ok_or("usage: alkane-cli afw nand-install <afw> --host <ip> --confirm FLASH")?;
|
.ok_or("usage: alkane-cli afw nand-install <afw> --host <ip> --confirm FLASH")?;
|
||||||
let verified = load_afw(afw_path, &opts)?;
|
let verified = load_afw(afw_path, &opts)?;
|
||||||
if !zynq::owns_board(&verified.manifest.board) {
|
if !zynq::owns_board(&verified.manifest.board) {
|
||||||
return Err(format!("nand-install is zynq-7010 only, not {}", verified.manifest.board).into());
|
return Err(format!(
|
||||||
|
"nand-install is zynq-7010 only, not {}",
|
||||||
|
verified.manifest.board
|
||||||
|
)
|
||||||
|
.into());
|
||||||
}
|
}
|
||||||
if opts.value("confirm") != Some("FLASH") {
|
if opts.value("confirm") != Some("FLASH") {
|
||||||
return Err("refusing to install without --confirm FLASH".into());
|
return Err("refusing to install without --confirm FLASH".into());
|
||||||
}
|
}
|
||||||
let kernel = verified.image("kernel").ok_or("afw missing kernel image")?.1;
|
let kernel = verified
|
||||||
|
.image("kernel")
|
||||||
|
.ok_or("afw missing kernel image")?
|
||||||
|
.1;
|
||||||
let dtb = verified.image("dtb").ok_or("afw missing dtb image")?.1;
|
let dtb = verified.image("dtb").ok_or("afw missing dtb image")?.1;
|
||||||
let rootfs = verified.image("rootfs").ok_or("afw missing rootfs image")?.1;
|
let rootfs = verified
|
||||||
|
.image("rootfs")
|
||||||
|
.ok_or("afw missing rootfs image")?
|
||||||
|
.1;
|
||||||
let password = read_board_password(&opts)?;
|
let password = read_board_password(&opts)?;
|
||||||
println!("installing {} onto stock board {host} (readable NAND path)...", verified.manifest.board);
|
println!(
|
||||||
|
"installing {} onto stock board {host} (readable NAND path)...",
|
||||||
|
verified.manifest.board
|
||||||
|
);
|
||||||
zynq_nand::install_from_stock(&host, kernel, dtb, rootfs, password.as_deref())?;
|
zynq_nand::install_from_stock(&host, kernel, dtb, rootfs, password.as_deref())?;
|
||||||
println!("install reported success (on-board stock backup carved; boot slots written; rebooting).");
|
println!(
|
||||||
|
"install reported success (on-board stock backup carved; boot slots written; rebooting)."
|
||||||
|
);
|
||||||
print!("{}", zynq_verify_hint(&host));
|
print!("{}", zynq_verify_hint(&host));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1231,9 +1255,15 @@ fn run_nand_install(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
/// back to the boot slots over SSH (board on alkane). Needs the alkane image
|
/// back to the boot slots over SSH (board on alkane). Needs the alkane image
|
||||||
/// that exposes the boot partitions.
|
/// that exposes the boot partitions.
|
||||||
fn run_nand_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
fn run_nand_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let opts = parse_args(args, &[ssh_values(), &["confirm", "stock-firmware"]].concat(), &["dry-run"])?;
|
let opts = parse_args(
|
||||||
|
args,
|
||||||
|
&[ssh_values(), &["confirm", "stock-firmware"]].concat(),
|
||||||
|
&["dry-run"],
|
||||||
|
)?;
|
||||||
let host = opts.value("host").ok_or("--host is required")?.to_owned();
|
let host = opts.value("host").ok_or("--host is required")?.to_owned();
|
||||||
let firmware = opts.value("stock-firmware").ok_or("--stock-firmware <file> is required")?;
|
let firmware = opts
|
||||||
|
.value("stock-firmware")
|
||||||
|
.ok_or("--stock-firmware <file> is required")?;
|
||||||
let fw = stock_firmware::parse(Path::new(firmware))?;
|
let fw = stock_firmware::parse(Path::new(firmware))?;
|
||||||
println!("stock firmware: {}", fw.summary());
|
println!("stock firmware: {}", fw.summary());
|
||||||
if opts.value("confirm") != Some("FLASH") {
|
if opts.value("confirm") != Some("FLASH") {
|
||||||
@@ -1241,8 +1271,16 @@ fn run_nand_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Err
|
|||||||
}
|
}
|
||||||
let password = read_board_password(&opts)?;
|
let password = read_board_password(&opts)?;
|
||||||
println!("restoring {host} to genuine stock (readable NAND path)...");
|
println!("restoring {host} to genuine stock (readable NAND path)...");
|
||||||
zynq_nand::restore_to_stock(&host, &fw.kernel, &fw.rootfs, fw.dtb.as_deref(), password.as_deref())?;
|
zynq_nand::restore_to_stock(
|
||||||
println!("restore-to-stock reported success (stock kernel/dtb/rootfs written, BOOT.bin preserved).");
|
&host,
|
||||||
|
&fw.kernel,
|
||||||
|
&fw.rootfs,
|
||||||
|
fw.dtb.as_deref(),
|
||||||
|
password.as_deref(),
|
||||||
|
)?;
|
||||||
|
println!(
|
||||||
|
"restore-to-stock reported success (stock kernel/dtb/rootfs written, BOOT.bin preserved)."
|
||||||
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1344,7 +1382,9 @@ fn run_restore_onboard(args: &[String]) -> Result<(), Box<dyn std::error::Error>
|
|||||||
password.as_deref(),
|
password.as_deref(),
|
||||||
std::time::Duration::from_secs(300),
|
std::time::Duration::from_secs(300),
|
||||||
)?;
|
)?;
|
||||||
println!("restore-from-onboard reported success. Verify independently the board answers as stock.");
|
println!(
|
||||||
|
"restore-from-onboard reported success. Verify independently the board answers as stock."
|
||||||
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ const FLAG_MAGIC: [u8; 4] = *b"ALAN";
|
|||||||
const KRNADDR: &str = "0x1200000";
|
const KRNADDR: &str = "0x1200000";
|
||||||
const FDTADDR: &str = "0x8000000";
|
const FDTADDR: &str = "0x8000000";
|
||||||
const RDADDR: &str = "0x8100000";
|
const RDADDR: &str = "0x8100000";
|
||||||
const ALK_BOOTARGS: &str =
|
const ALK_BOOTARGS: &str = "console=ttyAML0,115200 earlycon=meson,0xff803000 no_console_suspend";
|
||||||
"console=ttyAML0,115200 earlycon=meson,0xff803000 no_console_suspend";
|
|
||||||
|
|
||||||
/// The on-board basenames inside the nvdata UBI volume's `alkane/` directory.
|
/// The on-board basenames inside the nvdata UBI volume's `alkane/` directory.
|
||||||
const ALKANE_DIR: &str = "alkane";
|
const ALKANE_DIR: &str = "alkane";
|
||||||
@@ -110,8 +109,8 @@ impl AlkaneShell {
|
|||||||
root_method: crate::transport::RootMethod::Auto,
|
root_method: crate::transport::RootMethod::Auto,
|
||||||
update_daemon_port: None,
|
update_daemon_port: None,
|
||||||
};
|
};
|
||||||
let transport = SshTransport::connect(options, true)
|
let transport =
|
||||||
.map_err(|e| StockError::Network(e.to_string()))?;
|
SshTransport::connect(options, true).map_err(|e| StockError::Network(e.to_string()))?;
|
||||||
Ok(AlkaneShell {
|
Ok(AlkaneShell {
|
||||||
transport,
|
transport,
|
||||||
_secret: secret,
|
_secret: secret,
|
||||||
@@ -607,7 +606,10 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn env_roundtrips_with_crc() {
|
fn env_roundtrips_with_crc() {
|
||||||
let vars = vec![
|
let vars = vec![
|
||||||
("bootcmd".to_owned(), "run checkalk; run storeboot".to_owned()),
|
(
|
||||||
|
"bootcmd".to_owned(),
|
||||||
|
"run checkalk; run storeboot".to_owned(),
|
||||||
|
),
|
||||||
("bootdelay".to_owned(), "1".to_owned()),
|
("bootdelay".to_owned(), "1".to_owned()),
|
||||||
("checkalk".to_owned(), checkalk_value()),
|
("checkalk".to_owned(), checkalk_value()),
|
||||||
];
|
];
|
||||||
@@ -616,8 +618,10 @@ mod tests {
|
|||||||
let stored = u32::from_le_bytes([blob[0], blob[1], blob[2], blob[3]]);
|
let stored = u32::from_le_bytes([blob[0], blob[1], blob[2], blob[3]]);
|
||||||
assert_eq!(crc32(&blob[4..]), stored);
|
assert_eq!(crc32(&blob[4..]), stored);
|
||||||
let parsed = parse_env(&blob);
|
let parsed = parse_env(&blob);
|
||||||
assert_eq!(parsed.iter().find(|(k, _)| k == "bootcmd").unwrap().1,
|
assert_eq!(
|
||||||
"run checkalk; run storeboot");
|
parsed.iter().find(|(k, _)| k == "bootcmd").unwrap().1,
|
||||||
|
"run checkalk; run storeboot"
|
||||||
|
);
|
||||||
assert!(parsed.iter().any(|(k, _)| k == "checkalk"));
|
assert!(parsed.iter().any(|(k, _)| k == "checkalk"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,8 +157,8 @@ impl AlkaneShell {
|
|||||||
root_method: crate::transport::RootMethod::Auto,
|
root_method: crate::transport::RootMethod::Auto,
|
||||||
update_daemon_port: None,
|
update_daemon_port: None,
|
||||||
};
|
};
|
||||||
let transport = SshTransport::connect(options, true)
|
let transport =
|
||||||
.map_err(|e| StockError::Network(e.to_string()))?;
|
SshTransport::connect(options, true).map_err(|e| StockError::Network(e.to_string()))?;
|
||||||
Ok(AlkaneShell {
|
Ok(AlkaneShell {
|
||||||
transport,
|
transport,
|
||||||
_secret: secret,
|
_secret: secret,
|
||||||
@@ -225,11 +225,7 @@ fn read_mtd_table(sh: &mut dyn Shell) -> Result<Vec<Mtd>, StockError> {
|
|||||||
.and_then(|h| u64::from_str_radix(h, 16).ok())
|
.and_then(|h| u64::from_str_radix(h, 16).ok())
|
||||||
.ok_or_else(|| StockError::Method(format!("bad /proc/mtd line: {line}")))?;
|
.ok_or_else(|| StockError::Method(format!("bad /proc/mtd line: {line}")))?;
|
||||||
let _erase = it.next();
|
let _erase = it.next();
|
||||||
let name = line
|
let name = line.split('"').nth(1).unwrap_or("").to_owned();
|
||||||
.split('"')
|
|
||||||
.nth(1)
|
|
||||||
.unwrap_or("")
|
|
||||||
.to_owned();
|
|
||||||
let base = match sysfs_offset(sh, dev) {
|
let base = match sysfs_offset(sh, dev) {
|
||||||
Some(off) => off,
|
Some(off) => off,
|
||||||
None => cursor,
|
None => cursor,
|
||||||
@@ -257,11 +253,7 @@ fn sysfs_offset(sh: &mut dyn Shell, dev: &str) -> Option<u64> {
|
|||||||
|
|
||||||
/// Find the partition that contains `abs` and holding at least `len` bytes from
|
/// Find the partition that contains `abs` and holding at least `len` bytes from
|
||||||
/// there; return (device, relative offset).
|
/// there; return (device, relative offset).
|
||||||
fn locate<'a>(
|
fn locate<'a>(table: &'a [Mtd], abs: u64, len: u64) -> Result<(&'a str, u64), StockError> {
|
||||||
table: &'a [Mtd],
|
|
||||||
abs: u64,
|
|
||||||
len: u64,
|
|
||||||
) -> Result<(&'a str, u64), StockError> {
|
|
||||||
for m in table {
|
for m in table {
|
||||||
if abs >= m.base && abs < m.base + m.size {
|
if abs >= m.base && abs < m.base + m.size {
|
||||||
let rel = abs - m.base;
|
let rel = abs - m.base;
|
||||||
@@ -335,7 +327,9 @@ fn write_abs(
|
|||||||
if o.contains("WROTE") {
|
if o.contains("WROTE") {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(StockError::Method(format!("{label}: erase/write failed: {o}")))
|
Err(StockError::Method(format!(
|
||||||
|
"{label}: erase/write failed: {o}"
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
let readlen = round_up(data.len() as u64, PAGE);
|
let readlen = round_up(data.len() as u64, PAGE);
|
||||||
@@ -513,7 +507,13 @@ fn carve_backup(sh: &mut dyn Shell, table: &[Mtd]) -> Result<BackupManifest, Sto
|
|||||||
rootfs_abs: r_dst,
|
rootfs_abs: r_dst,
|
||||||
rootfs_len,
|
rootfs_len,
|
||||||
};
|
};
|
||||||
write_abs(sh, table, BK_MANIFEST, &manifest.encode(), "stock-backup-manifest")?;
|
write_abs(
|
||||||
|
sh,
|
||||||
|
table,
|
||||||
|
BK_MANIFEST,
|
||||||
|
&manifest.encode(),
|
||||||
|
"stock-backup-manifest",
|
||||||
|
)?;
|
||||||
Ok(manifest)
|
Ok(manifest)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,11 +569,7 @@ struct BootImages {
|
|||||||
rootfs_uimage: Vec<u8>,
|
rootfs_uimage: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_boot_slots(
|
fn write_boot_slots(sh: &mut dyn Shell, table: &[Mtd], img: &BootImages) -> Result<(), StockError> {
|
||||||
sh: &mut dyn Shell,
|
|
||||||
table: &[Mtd],
|
|
||||||
img: &BootImages,
|
|
||||||
) -> Result<(), StockError> {
|
|
||||||
// rootfs, dtb, kernel order: an interrupted run never leaves a new rootfs
|
// rootfs, dtb, kernel order: an interrupted run never leaves a new rootfs
|
||||||
// under an old kernel.
|
// under an old kernel.
|
||||||
if img.rootfs_uimage.len() as u64 > SLOT_ROOTFS {
|
if img.rootfs_uimage.len() as u64 > SLOT_ROOTFS {
|
||||||
@@ -623,7 +619,9 @@ pub fn install_from_stock(
|
|||||||
password: password.map(str::to_owned),
|
password: password.map(str::to_owned),
|
||||||
};
|
};
|
||||||
if first_token(&sh.exec("id -u")?) != "0" {
|
if first_token(&sh.exec("id -u")?) != "0" {
|
||||||
return Err(StockError::Auth("did not obtain root on the stock board".into()));
|
return Err(StockError::Auth(
|
||||||
|
"did not obtain root on the stock board".into(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
let table = read_mtd_table(&mut sh)?;
|
let table = read_mtd_table(&mut sh)?;
|
||||||
// Carve the genuine-stock backup from the live stock NAND before any write.
|
// Carve the genuine-stock backup from the live stock NAND before any write.
|
||||||
@@ -674,7 +672,14 @@ pub fn restore_to_stock(
|
|||||||
"no stock dtb supplied and no on-board backup to take one from".into(),
|
"no stock dtb supplied and no on-board backup to take one from".into(),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
copy_abs(&mut sh, &table, manifest.dtb_abs, OFF_DTB, manifest.dtb_len, "dtb")?;
|
copy_abs(
|
||||||
|
&mut sh,
|
||||||
|
&table,
|
||||||
|
manifest.dtb_abs,
|
||||||
|
OFF_DTB,
|
||||||
|
manifest.dtb_len,
|
||||||
|
"dtb",
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write_abs(&mut sh, &table, OFF_KERNEL, kernel_uimage, "kernel")?;
|
write_abs(&mut sh, &table, OFF_KERNEL, kernel_uimage, "kernel")?;
|
||||||
@@ -703,14 +708,34 @@ pub fn restore_from_onboard(host: &str, password: Option<&str>) -> Result<(), St
|
|||||||
let manifest = read_backup_manifest(&mut sh, &table)?
|
let manifest = read_backup_manifest(&mut sh, &table)?
|
||||||
.ok_or_else(|| StockError::Method("no complete on-board stock backup".into()))?;
|
.ok_or_else(|| StockError::Method("no complete on-board stock backup".into()))?;
|
||||||
// Copy within NAND: backup region -> boot slots.
|
// Copy within NAND: backup region -> boot slots.
|
||||||
copy_abs(&mut sh, &table, manifest.rootfs_abs, OFF_ROOTFS, manifest.rootfs_len, "rootfs")?;
|
copy_abs(
|
||||||
copy_abs(&mut sh, &table, manifest.dtb_abs, OFF_DTB, manifest.dtb_len, "dtb")?;
|
&mut sh,
|
||||||
copy_abs(&mut sh, &table, manifest.kernel_abs, OFF_KERNEL, manifest.kernel_len, "kernel")?;
|
&table,
|
||||||
|
manifest.rootfs_abs,
|
||||||
|
OFF_ROOTFS,
|
||||||
|
manifest.rootfs_len,
|
||||||
|
"rootfs",
|
||||||
|
)?;
|
||||||
|
copy_abs(
|
||||||
|
&mut sh,
|
||||||
|
&table,
|
||||||
|
manifest.dtb_abs,
|
||||||
|
OFF_DTB,
|
||||||
|
manifest.dtb_len,
|
||||||
|
"dtb",
|
||||||
|
)?;
|
||||||
|
copy_abs(
|
||||||
|
&mut sh,
|
||||||
|
&table,
|
||||||
|
manifest.kernel_abs,
|
||||||
|
OFF_KERNEL,
|
||||||
|
manifest.kernel_len,
|
||||||
|
"kernel",
|
||||||
|
)?;
|
||||||
reboot(&mut sh);
|
reboot(&mut sh);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -751,8 +776,18 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn locate_maps_absolute_to_partition() {
|
fn locate_maps_absolute_to_partition() {
|
||||||
let table = vec![
|
let table = vec![
|
||||||
Mtd { dev: "mtd0".into(), base: 0x0, size: 0x2800000, name: "x".into() },
|
Mtd {
|
||||||
Mtd { dev: "mtd1".into(), base: 0x2800000, size: 0x2000000, name: "y".into() },
|
dev: "mtd0".into(),
|
||||||
|
base: 0x0,
|
||||||
|
size: 0x2800000,
|
||||||
|
name: "x".into(),
|
||||||
|
},
|
||||||
|
Mtd {
|
||||||
|
dev: "mtd1".into(),
|
||||||
|
base: 0x2800000,
|
||||||
|
size: 0x2000000,
|
||||||
|
name: "y".into(),
|
||||||
|
},
|
||||||
];
|
];
|
||||||
assert_eq!(locate(&table, 0x2000000, 100).unwrap(), ("mtd0", 0x2000000));
|
assert_eq!(locate(&table, 0x2000000, 100).unwrap(), ("mtd0", 0x2000000));
|
||||||
assert_eq!(locate(&table, 0x2800000, 100).unwrap(), ("mtd1", 0));
|
assert_eq!(locate(&table, 0x2800000, 100).unwrap(), ("mtd1", 0));
|
||||||
|
|||||||
Reference in New Issue
Block a user