From 3ef72793e87eed362de7ac4dfcbfdde153cf663d Mon Sep 17 00:00:00 2001 From: dzid26 Date: Sat, 25 Apr 2026 23:01:32 +0100 Subject: [PATCH 1/2] wake on can bootkick wake up naming --- board/drivers/bootkick.h | 10 +++++----- board/drivers/can_common.h | 4 +++- board/drivers/drivers.h | 6 ++++-- board/main.c | 7 ++++++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/board/drivers/bootkick.h b/board/drivers/bootkick.h index 4bf990391b6..eaa07be78d1 100644 --- a/board/drivers/bootkick.h +++ b/board/drivers/bootkick.h @@ -2,18 +2,18 @@ bool bootkick_reset_triggered = false; -void bootkick_tick(bool ignition, bool recent_heartbeat) { +void bootkick_tick(bool wake_up, bool recent_heartbeat) { static uint16_t bootkick_last_serial_ptr = 0; static uint8_t waiting_to_boot_countdown = 0; static uint8_t boot_reset_countdown = 0; static uint8_t bootkick_harness_status_prev = HARNESS_STATUS_NC; - static bool bootkick_ign_prev = false; + static bool bootkick_wake_up_prev = false; static BootState boot_state = BOOT_BOOTKICK; BootState boot_state_prev = boot_state; const bool harness_inserted = (harness.status != bootkick_harness_status_prev) && (harness.status != HARNESS_STATUS_NC); - if ((ignition && !bootkick_ign_prev) || harness_inserted) { - // bootkick on rising edge of ignition or harness insertion + if ((wake_up && !bootkick_wake_up_prev) || harness_inserted) { + // bootkick on rising edge of wake-up or harness insertion boot_state = BOOT_BOOTKICK; } else if (recent_heartbeat) { // disable bootkick once openpilot is up @@ -55,7 +55,7 @@ void bootkick_tick(bool ignition, bool recent_heartbeat) { } // update state - bootkick_ign_prev = ignition; + bootkick_wake_up_prev = wake_up; bootkick_harness_status_prev = harness.status; bootkick_last_serial_ptr = uart_ring_som_debug.w_ptr_tx; if (waiting_to_boot_countdown > 0U) { diff --git a/board/drivers/can_common.h b/board/drivers/can_common.h index ef03cdb549c..95165644878 100644 --- a/board/drivers/can_common.h +++ b/board/drivers/can_common.h @@ -7,7 +7,9 @@ uint32_t rx_buffer_overflow = 0; can_health_t can_health[PANDA_CAN_CNT] = {{0}, {0}, {0}}; -// Ignition detected from CAN meessages +// Wake-up and ignition detected from CAN messages +bool wake_on_can = false; +uint32_t wake_on_can_cnt = 0U; bool ignition_can = false; uint32_t ignition_can_cnt = 0U; diff --git a/board/drivers/drivers.h b/board/drivers/drivers.h index c61506707a0..e4d0ee29c3d 100644 --- a/board/drivers/drivers.h +++ b/board/drivers/drivers.h @@ -11,7 +11,7 @@ extern bool bootkick_reset_triggered; -void bootkick_tick(bool ignition, bool recent_heartbeat); +void bootkick_tick(bool wake_up, bool recent_heartbeat); // ******************** can_common ******************** @@ -41,7 +41,9 @@ extern uint32_t rx_buffer_overflow; extern can_health_t can_health[PANDA_CAN_CNT]; -// Ignition detected from CAN meessages +// Wake-up and ignition detected from CAN messages +extern bool wake_on_can; +extern uint32_t wake_on_can_cnt; extern bool ignition_can; extern uint32_t ignition_can_cnt; diff --git a/board/main.c b/board/main.c index e3e98074798..fa7b1a0e8c7 100644 --- a/board/main.c +++ b/board/main.c @@ -173,7 +173,8 @@ static void tick_handler(void) { // tick drivers at 1Hz bool started = harness_check_ignition() || ignition_can; - bootkick_tick(started, recent_heartbeat); + bool wake_up = started || wake_on_can; + bootkick_tick(wake_up, recent_heartbeat); // increase heartbeat counter and cap it at the uint32 limit if (heartbeat_counter < UINT32_MAX) { @@ -251,11 +252,15 @@ static void tick_handler(void) { if (ignition_can_cnt > 2U) { ignition_can = false; } + if (wake_on_can_cnt > 2U) { + wake_on_can = false; + } // on to the next one uptime_cnt += 1U; safety_mode_cnt += 1U; ignition_can_cnt += 1U; + wake_on_can_cnt += 1U; // synchronous safety check safety_tick(¤t_safety_config); From 222d6d16f49096317cf99679c31ed6d0b7235aef Mon Sep 17 00:00:00 2001 From: dzid26 Date: Sat, 25 Apr 2026 23:25:28 +0100 Subject: [PATCH 2/2] Tesla - wake on standby and accessory states (e.g. doors open) --- board/drivers/can_common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/board/drivers/can_common.h b/board/drivers/can_common.h index 95165644878..2c430b8dc3c 100644 --- a/board/drivers/can_common.h +++ b/board/drivers/can_common.h @@ -191,6 +191,8 @@ void ignition_can_hook(CANPacket_t *msg) { if ((counter == ((prev_counter_tesla + 1) % 16)) && (prev_counter_tesla != -1)) { // VCFRONT_LVPowerState->VCFRONT_vehiclePowerState int power_state = (msg->data[0] >> 5U) & 0x3U; + wake_on_can = power_state != 0x0; // VEHICLE_POWER_STATE_OFF=0 + wake_on_can_cnt = 0U; ignition_can = power_state == 0x3; // VEHICLE_POWER_STATE_DRIVE=3 ignition_can_cnt = 0U; }