Skip to content

Commit f5cf9a1

Browse files
committed
--boardid: Print all available board IDs
Using a native host command to get the ID from the EC instead of having the sotware measure ADC and evaluate the host command. This is better because the ADC values represent different board IDs on different platforms (Microchip vs Nuvoton based ECs) > sudo framework_tool --boardid Mainboard Board ID: Ok(Some(4)) PowerButton Board ID: Err(Response(InvalidResponse)) Touchpad Board ID: Err(Response(InvalidResponse)) AudioBoard Board ID: Err(Response(InvalidResponse)) dGPU0 Board ID: Err(Response(InvalidResponse)) dGPU1 Board ID: Err(Response(InvalidResponse)) ``` Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 97c5cab commit f5cf9a1

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

framework_lib/src/commandline/clap_std.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ struct ClapCli {
273273
#[arg(long)]
274274
test_retimer: bool,
275275

276+
/// Print all board IDs
277+
#[arg(long)]
278+
boardid: bool,
279+
276280
/// Force execution of an unsafe command - may render your hardware unbootable!
277281
#[arg(long, short)]
278282
force: bool,
@@ -472,6 +476,7 @@ pub fn parse(args: &[String]) -> Cli {
472476
pd_ports,
473477
test: args.test,
474478
test_retimer: args.test_retimer,
479+
boardid: args.boardid,
475480
dry_run: args.dry_run,
476481
force: args.force,
477482
// TODO: Set help. Not very important because Clap handles this by itself

framework_lib/src/commandline/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use crate::ccgx::device::{FwMode, PdController, PdPort};
3535
use crate::ccgx::hid::{check_ccg_fw_version, find_devices, DP_CARD_PID, HDMI_CARD_PID};
3636
use crate::ccgx::{self, MainPdVersions, PdVersions, SiliconId::*};
3737
use crate::chromium_ec;
38+
use crate::chromium_ec::commands::BoardIdType;
3839
use crate::chromium_ec::commands::DeckStateMode;
3940
use crate::chromium_ec::commands::FpLedBrightnessLevel;
4041
use crate::chromium_ec::commands::RebootEcCmd;
@@ -192,6 +193,7 @@ pub struct Cli {
192193
pub driver: Option<CrosEcDriverType>,
193194
pub test: bool,
194195
pub test_retimer: bool,
196+
pub boardid: bool,
195197
pub dry_run: bool,
196198
pub force: bool,
197199
pub intrusion: bool,
@@ -279,6 +281,7 @@ pub fn parse(args: &[String]) -> Cli {
279281
driver: cli.driver,
280282
test: cli.test,
281283
test_retimer: cli.test_retimer,
284+
boardid: cli.boardid,
282285
dry_run: cli.dry_run,
283286
// force
284287
intrusion: cli.intrusion,
@@ -1487,6 +1490,8 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
14871490
if let Err(err) = selftest_retimer(&ec) {
14881491
println!(" Failed: {:?}", err);
14891492
}
1493+
} else if args.boardid {
1494+
print_board_ids(&ec);
14901495
} else if args.power {
14911496
return power::get_and_print_power_info(&ec);
14921497
} else if args.thermal {
@@ -1850,6 +1855,16 @@ fn hash(data: &[u8]) {
18501855
util::print_buffer(sha512);
18511856
}
18521857

1858+
fn print_board_ids(ec: &CrosEc) {
1859+
println!("Board IDs");
1860+
println!(" Mainboard: {:?}", ec.read_board_id_hc(BoardIdType::Mainboard));
1861+
println!(" PowerButton: {:?}", ec.read_board_id_hc(BoardIdType::PowerButtonBoard));
1862+
println!(" Touchpad: {:?}", ec.read_board_id_hc(BoardIdType::Touchpad));
1863+
println!(" AudioBoard: {:?}", ec.read_board_id_hc(BoardIdType::AudioBoard));
1864+
println!(" dGPU0: {:?}", ec.read_board_id_hc(BoardIdType::DGpu0));
1865+
println!(" dGPU1: {:?}", ec.read_board_id_hc(BoardIdType::DGpu1));
1866+
}
1867+
18531868
fn selftest(ec: &CrosEc) -> Option<()> {
18541869
if let Some(platform) = smbios::get_platform() {
18551870
println!(" SMBIOS Platform: {:?}", platform);

framework_lib/src/commandline/uefi.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ pub fn parse(args: &[String]) -> Cli {
8787
pd_ports: None,
8888
test: false,
8989
test_retimer: false,
90+
boardid: false,
9091
dry_run: false,
9192
force: false,
9293
help: false,
@@ -511,6 +512,9 @@ pub fn parse(args: &[String]) -> Cli {
511512
} else if arg == "-t" || arg == "--test-retimer" {
512513
cli.test_retimer = true;
513514
found_an_option = true;
515+
} else if arg == "--boardid" {
516+
cli.boardid = true;
517+
found_an_option = true;
514518
} else if arg == "-f" || arg == "--force" {
515519
cli.force = true;
516520
found_an_option = true;

0 commit comments

Comments
 (0)