Skip to content

Conversation

@JohnAZoidberg
Copy link
Member

No description provided.

@JohnAZoidberg
Copy link
Member Author

Need to add a command to read them and a note that it's not supported on all platforms.

@JohnAZoidberg JohnAZoidberg force-pushed the boardid branch 2 times, most recently from 878250a to f5cf9a1 Compare January 17, 2026 08:48
@JohnAZoidberg JohnAZoidberg marked this pull request as ready for review January 17, 2026 08:49
@JohnAZoidberg JohnAZoidberg requested a review from Copilot January 17, 2026 08:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds functionality to read and display board IDs for various hardware components via a new host command to the Chromium EC. The implementation introduces a new --boardid command-line flag that queries the EC for board IDs of different components like the mainboard, power button board, touchpad, audio board, and dGPU modules.

Changes:

  • Added EC host command (ReadBoardId) to query board IDs from the embedded controller
  • Implemented command-line flag --boardid to trigger board ID reading
  • Created board ID type enumeration for different hardware components

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
framework_lib/src/chromium_ec/command.rs Added new EC command enum value for ReadBoardId
framework_lib/src/chromium_ec/commands.rs Defined BoardIdType enum and request/response structures for board ID reading
framework_lib/src/chromium_ec/mod.rs Implemented read_board_id_hc method to handle board ID queries
framework_lib/src/commandline/mod.rs Added boardid CLI field and print_board_ids function to display results
framework_lib/src/commandline/clap_std.rs Added boardid argument to clap CLI parser
framework_lib/src/commandline/uefi.rs Added boardid argument to UEFI CLI parser

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1743 to +1754
pub fn read_board_id_hc(&self, board_id_type: BoardIdType) -> EcResult<Option<u8>> {
let res = EcRequestReadBoardId {
board_id_type: board_id_type as u8,
}
.send_command(self)?;
match res.board_id {
-1 => Err(EcError::DeviceError(format!(
"Failed to read Board ID {:?}",
board_id_type
))),
15 => Ok(None),
0..=14 => Ok(Some(res.board_id as u8)),
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic numbers -1 and 15 should be defined as named constants to improve code clarity. Consider defining constants like BOARD_ID_INVALID = -1 and BOARD_ID_NOT_PRESENT = 15 near the function or in the BoardIdType enum implementation.

Suggested change
pub fn read_board_id_hc(&self, board_id_type: BoardIdType) -> EcResult<Option<u8>> {
let res = EcRequestReadBoardId {
board_id_type: board_id_type as u8,
}
.send_command(self)?;
match res.board_id {
-1 => Err(EcError::DeviceError(format!(
"Failed to read Board ID {:?}",
board_id_type
))),
15 => Ok(None),
0..=14 => Ok(Some(res.board_id as u8)),
const BOARD_ID_INVALID: i32 = -1;
const BOARD_ID_NOT_PRESENT: i32 = 15;
const BOARD_ID_MAX_VALID: i32 = BOARD_ID_NOT_PRESENT - 1;
pub fn read_board_id_hc(&self, board_id_type: BoardIdType) -> EcResult<Option<u8>> {
let res = EcRequestReadBoardId {
board_id_type: board_id_type as u8,
}
.send_command(self)?;
match res.board_id {
BOARD_ID_INVALID => Err(EcError::DeviceError(format!(
"Failed to read Board ID {:?}",
board_id_type
))),
BOARD_ID_NOT_PRESENT => Ok(None),
0..=BOARD_ID_MAX_VALID => Ok(Some(res.board_id as u8)),

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm let's not do that for now

#[repr(C, packed)]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct EcResponseReadBoardId {
/// Board ID (-1 invalid, 15 not present)
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment describes the special values but doesn't explain what values 0-14 represent. Add documentation explaining that valid board IDs are in the range 0-14.

Suggested change
/// Board ID (-1 invalid, 15 not present)
/// Board ID: 0–14 valid, -1 invalid, 15 not present

Copilot uses AI. Check for mistakes.
This command is not present on all systems, it was only recently added
to our main branch and will be slowly backported.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
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
Board IDs
  Mainboard:    Ok(Some(6))
  PowerButton:  Err(Response(InvalidResponse))
  Touchpad:     Ok(Some(7))
  AudioBoard:   Ok(Some(7))
  dGPU0:        Err(Response(InvalidCommand))
  dGPU1:        Err(Response(InvalidCommand))
```

Signed-off-by: Daniel Schaefer <dhs@frame.work>
@JohnAZoidberg JohnAZoidberg merged commit 6fddfd8 into main Jan 17, 2026
7 checks passed
@JohnAZoidberg JohnAZoidberg deleted the boardid branch January 17, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants