Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions res/firmware.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,23 @@ if "%2" == "ec2" then
exit 1
endif

if "%2" == "serial" then
if exist amide.efi then
if exist amide.tag then
rm amide.tag
amide.efi /SS "%3"
exit %lasterror%
else
echo > amide.tag
if not exist amide.tag then
echo "failed to create amide.tag"
exit 1
endif

reset
endif
endif
endif

echo "unknown command '%2'"
exit 1
38 changes: 38 additions & 0 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ mod ec;
mod mapper;
mod pci;

static AMIDETAG: &str = concat!("\\", env!("BASEDIR"), "\\firmware\\amide.tag");
static ECROM: &str = concat!("\\", env!("BASEDIR"), "\\firmware\\ec.rom");
static ECTAG: &str = concat!("\\", env!("BASEDIR"), "\\firmware\\ec.tag");
static EC2ROM: &str = concat!("\\", env!("BASEDIR"), "\\firmware\\ec2.rom");
Expand All @@ -50,6 +51,7 @@ static IFLASHV: &str = concat!("\\", env!("BASEDIR"), "\\firmware\\iflashv.efi")
static IFLASHVTAG: &str = concat!("\\", env!("BASEDIR"), "\\firmware\\iflashv.tag");
static IPXEEFI: &str = concat!("\\", env!("BASEDIR"), "\\firmware\\ipxe.efi");
static MESETTAG: &str = concat!("\\", env!("BASEDIR"), "\\firmware\\meset.tag");
static SERIAL: &str = concat!("\\", env!("BASEDIR"), "\\serial");
static SHELLEFI: &str = concat!("\\", env!("BASEDIR"), "\\res\\shell.efi");
static SPLASHBMP: &str = concat!("\\", env!("BASEDIR"), "\\res\\splash.bmp");
static UEFIFLASH: &str = concat!("\\", env!("BASEDIR"), "\\firmware\\uefiflash.efi");
Expand Down Expand Up @@ -77,6 +79,18 @@ fn ac_connected() -> bool {
}
}

fn set_serial(serial: &str) -> Result<()> {
find(FIRMWARENSH)?;
let cmd = format!("{} {} serial {}", FIRMWARENSH, FIRMWAREDIR, serial);
let status = shell(&cmd)?;
if status == 0 {
Ok(())
} else {
println!("Set Serial Error: {}", status);
Err(Error::DeviceError)
}
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum ValidateKind {
Found,
Expand Down Expand Up @@ -255,6 +269,11 @@ fn inner() -> Result<()> {
components.clear();
validations.clear();
'\n'
} else if find(AMIDETAG).is_ok() {
// Skip enter if writing serial
components.clear();
validations.clear();
'\n'
} else if find(UEFIFLASH).is_ok() {
// Skip enter if flashing a meerkat
if find(UEFIFLASHTAG).is_ok() {
Expand Down Expand Up @@ -296,6 +315,25 @@ fn inner() -> Result<()> {
println!("Failed to reset DMI: {:?}", err);
}

if let Ok(serial_vec) = load(SERIAL) {
match String::from_utf8(serial_vec) {
Ok(serial_str) => {
let serial = serial_str.trim();
match set_serial(&serial) {
Ok(()) => {
println!("Set serial to '{}'", serial);
},
Err(err) => {
println!("Failed to set serial to '{}': {:?}", serial, err);
}
}
},
Err(err) => {
println!("Failed to parse serial: {:?}", err);
}
}
}

if setup_menu {
let supported = get_os_indications_supported().unwrap_or(0);
if supported & 1 == 1 {
Expand Down