mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-08 15:12:10 +08:00
5234a121f9
Add a StarPilot vehicle toggle that selects alternate Panda firmware for Hyundai/Kia/Genesis CAN-FD EVs. The firmware keeps the HKG CAN bus active while Panda is in power save and treats the app climate-active frame, bus 1 address 0x384 with byte 3 nonzero, as a Panda boot wake source without publishing it as CAN ignition. Wire the toggle through StarPilot vehicle settings, Galaxy device settings, parameter definitions, and pandad firmware selection. Disabling the toggle selects the default Panda firmware again. Tested on a Kia EV9 and 2023 Kia EV6. EV9 remote climate active used 0x384 byte 3 equal to 0x01; EV6 remote climate active used 0x0a. Both stopped/off states observed byte 3 equal to 0x00. Toggle-off negative testing on EV9 saw the remote climate frame on CAN but pandaStates.ignitionCan stayed false. Toggle-on testing verified the active Panda signature matched panda_h7_hkg_remote.bin.signed. Follow-up testing changed the HKG path to wake-only after remote climate caused partial-car fingerprinting and Dashcam Mode; wake-only firmware was built, flashed, and verified on both devices.
60 lines
1.8 KiB
C
60 lines
1.8 KiB
C
#include "power_saving_declarations.h"
|
|
|
|
// WARNING: To stay in compliance with the SIL2 rules laid out in STM UM1840, we should never implement any of the available hardware low power modes.
|
|
// See rule: CoU_3
|
|
|
|
int power_save_status = POWER_SAVE_STATUS_DISABLED;
|
|
|
|
void enable_can_transceivers(bool enabled) {
|
|
// Leave main CAN always on for CAN-based ignition detection
|
|
uint8_t main_bus = (harness.status == HARNESS_STATUS_FLIPPED) ? 3U : 1U;
|
|
for(uint8_t i=1U; i<=4U; i++){
|
|
bool transceiver_enabled = (i == main_bus) || enabled;
|
|
#ifdef PANDA_HKG_REMOTE_START
|
|
uint8_t hkg_bus = (harness.status == HARNESS_STATUS_FLIPPED) ? 4U : 2U;
|
|
transceiver_enabled = transceiver_enabled || (i == hkg_bus);
|
|
#endif
|
|
current_board->enable_can_transceiver(i, transceiver_enabled);
|
|
}
|
|
}
|
|
|
|
void set_power_save_state(int state) {
|
|
bool is_valid_state = (state == POWER_SAVE_STATUS_ENABLED) || (state == POWER_SAVE_STATUS_DISABLED);
|
|
if (is_valid_state && (state != power_save_status)) {
|
|
bool enable = false;
|
|
if (state == POWER_SAVE_STATUS_ENABLED) {
|
|
print("enable power savings\n");
|
|
|
|
// Disable CAN interrupts
|
|
if (harness.status == HARNESS_STATUS_FLIPPED) {
|
|
llcan_irq_disable(cans[0]);
|
|
} else {
|
|
llcan_irq_disable(cans[2]);
|
|
}
|
|
#ifndef PANDA_HKG_REMOTE_START
|
|
llcan_irq_disable(cans[1]);
|
|
#endif
|
|
} else {
|
|
print("disable power savings\n");
|
|
|
|
if (harness.status == HARNESS_STATUS_FLIPPED) {
|
|
llcan_irq_enable(cans[0]);
|
|
} else {
|
|
llcan_irq_enable(cans[2]);
|
|
}
|
|
llcan_irq_enable(cans[1]);
|
|
|
|
enable = true;
|
|
}
|
|
|
|
enable_can_transceivers(enable);
|
|
|
|
// Switch off IR when in power saving
|
|
if(!enable){
|
|
current_board->set_ir_power(0U);
|
|
}
|
|
|
|
power_save_status = state;
|
|
}
|
|
}
|