Add the HAL frequency actuator and a --boot command
source-pr / source (pull_request) Successful in 14s
source-pr / source (pull_request) Successful in 14s
The tuner produced a frequency the hardware contract had no way to apply, so detection and tuning could not affect a real board. SET_CHAIN_FREQUENCY joins the HAL verbs behind its own capability bit, and HalClient refuses to use it when the backend does not advertise it. --boot HAL_SOCKET PROFILES.json TARGET [PIC|NOPIC] [TICKS] now runs the real path: detect over the socket, serve the API and UI, read the hottest sensor, tick the runtime, apply the frequency to each active chain and the fan duty when the target owns the fan, then print the published document. A missing socket exits 1 with a backend error instead of a half-booted miner.
This commit is contained in:
+16
-3
@@ -31,11 +31,13 @@ const CAPABILITIES: u8 = 7;
|
||||
const PROBE_CHAIN: u8 = 8;
|
||||
const READ_EEPROM: u8 = 9;
|
||||
const IDENTIFY_PSU: u8 = 10;
|
||||
const SET_CHAIN_FREQUENCY: u8 = 11;
|
||||
|
||||
/// Backend feature bits reported by `CAPABILITIES`.
|
||||
pub const CAP_CHAIN_PROBE: u32 = 1 << 0;
|
||||
pub const CAP_EEPROM: u32 = 1 << 1;
|
||||
pub const CAP_PSU_IDENTITY: u32 = 1 << 2;
|
||||
pub const CAP_FREQUENCY: u32 = 1 << 3;
|
||||
|
||||
const PROBE_IDENTIFIED: u8 = 0;
|
||||
const PROBE_SILENT: u8 = 1;
|
||||
@@ -420,6 +422,15 @@ impl HalClient {
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply a chain frequency in MHz. The backend owns the PLL write; the OS owns the decision.
|
||||
pub fn set_chain_frequency(&mut self, chain: u8, mhz: u16) -> Result<(), HalError> {
|
||||
self.require(CAP_FREQUENCY)?;
|
||||
let mut payload = [0_u8; 3];
|
||||
payload[0] = chain;
|
||||
payload[1..].copy_from_slice(&mhz.to_le_bytes());
|
||||
self.empty_reply(SET_CHAIN_FREQUENCY, &payload)
|
||||
}
|
||||
|
||||
pub fn identify_psu(&mut self) -> Result<PsuCapability, HalError> {
|
||||
self.require(CAP_PSU_IDENTITY)?;
|
||||
let body = self.exchange(IDENTIFY_PSU, &[])?;
|
||||
@@ -577,7 +588,8 @@ mod tests {
|
||||
CAPABILITIES => {
|
||||
let mut body = vec![0_u8];
|
||||
body.extend_from_slice(
|
||||
&(CAP_CHAIN_PROBE | CAP_EEPROM | CAP_PSU_IDENTITY).to_le_bytes(),
|
||||
&(CAP_CHAIN_PROBE | CAP_EEPROM | CAP_PSU_IDENTITY | CAP_FREQUENCY)
|
||||
.to_le_bytes(),
|
||||
);
|
||||
body
|
||||
}
|
||||
@@ -597,7 +609,7 @@ mod tests {
|
||||
}
|
||||
body
|
||||
}
|
||||
SET_FAN_TARGET => vec![0],
|
||||
SET_FAN_TARGET | SET_CHAIN_FREQUENCY => vec![0],
|
||||
READ_TEMPERATURE => {
|
||||
let mut body = vec![0_u8];
|
||||
body.extend_from_slice(&42_000_i32.to_le_bytes());
|
||||
@@ -626,7 +638,7 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
client.capabilities().expect("capabilities"),
|
||||
CAP_CHAIN_PROBE | CAP_EEPROM | CAP_PSU_IDENTITY
|
||||
CAP_CHAIN_PROBE | CAP_EEPROM | CAP_PSU_IDENTITY | CAP_FREQUENCY
|
||||
);
|
||||
match client.probe_chain(0, 0).expect("probe") {
|
||||
ProbeOutcome::Identified { chip, chips } => {
|
||||
@@ -647,6 +659,7 @@ mod tests {
|
||||
assert_eq!(psu.envelope.v_max_mv, 1600);
|
||||
assert_eq!(psu.max_dc_watts, 3600);
|
||||
|
||||
client.set_chain_frequency(2, 512).expect("set frequency");
|
||||
client.set_fan(1, 60).expect("set fan");
|
||||
assert_eq!(client.read_zone(2).expect("read zone"), 42_000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user