From 1020d355584265391eb3acb556e4353b581fa9c0 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 6 Jun 2025 11:36:21 -0700 Subject: [PATCH] Deprecate uno + grey (#2223) * Deprecate uno + grey * lil more --- board/boards/board_declarations.h | 8 +- board/boards/grey.h | 35 ---- board/boards/uno.h | 166 ------------------ .../scripts/panda_identification_test.py | 45 ----- board/stm32f4/board.h | 8 +- tests/hitl/7_internal.py | 1 - 6 files changed, 5 insertions(+), 258 deletions(-) delete mode 100644 board/boards/grey.h delete mode 100644 board/boards/uno.h delete mode 100755 board/jungle/scripts/panda_identification_test.py diff --git a/board/boards/board_declarations.h b/board/boards/board_declarations.h index b351b3d4..aa41fe3a 100644 --- a/board/boards/board_declarations.h +++ b/board/boards/board_declarations.h @@ -55,10 +55,10 @@ struct board { // These should match the enums in cereal/log.capnp and __init__.py #define HW_TYPE_UNKNOWN 0U #define HW_TYPE_WHITE_PANDA 1U -#define HW_TYPE_GREY_PANDA 2U +//#define HW_TYPE_GREY_PANDA 2U #define HW_TYPE_BLACK_PANDA 3U -#define HW_TYPE_PEDAL 4U -#define HW_TYPE_UNO 5U +//#define HW_TYPE_PEDAL 4U +//#define HW_TYPE_UNO 5U #define HW_TYPE_DOS 6U #define HW_TYPE_RED_PANDA 7U #define HW_TYPE_RED_PANDA_V2 8U @@ -77,9 +77,7 @@ struct board { extern struct board board_black; extern struct board board_dos; -extern struct board board_uno; extern struct board board_tres; -extern struct board board_grey; extern struct board board_white; extern struct board board_cuatro; extern struct board board_red; diff --git a/board/boards/grey.h b/board/boards/grey.h deleted file mode 100644 index 6ba07b4d..00000000 --- a/board/boards/grey.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include "board_declarations.h" - -// //////////////////// // -// Grey Panda (STM32F4) // -// //////////////////// // - -// Most hardware functionality is similar to white panda - -board board_grey = { - .set_bootkick = unused_set_bootkick, - .harness_config = &white_harness_config, - .has_spi = false, - .has_canfd = false, - .fan_max_rpm = 0U, - .fan_max_pwm = 100U, - .avdd_mV = 3300U, - .fan_stall_recovery = false, - .fan_enable_cooldown_time = 0U, - .init = white_grey_init, - .init_bootloader = white_grey_init_bootloader, - .enable_can_transceiver = white_enable_can_transceiver, - .led_GPIO = {GPIOC, GPIOC, GPIOC}, - .led_pin = {9, 7, 6}, - .set_can_mode = white_set_can_mode, - .check_ignition = white_check_ignition, - .read_voltage_mV = white_read_voltage_mV, - .read_current_mA = white_read_current_mA, - .set_fan_enabled = unused_set_fan_enabled, - .set_ir_power = unused_set_ir_power, - .set_siren = unused_set_siren, - .read_som_gpio = unused_read_som_gpio, - .set_amp_enabled = unused_set_amp_enabled -}; diff --git a/board/boards/uno.h b/board/boards/uno.h deleted file mode 100644 index fd71460a..00000000 --- a/board/boards/uno.h +++ /dev/null @@ -1,166 +0,0 @@ -#pragma once - -#include "board_declarations.h" - -// /////////////////////// // -// Uno (STM32F4) + Harness // -// /////////////////////// // - -static void uno_enable_can_transceiver(uint8_t transceiver, bool enabled) { - switch (transceiver){ - case 1U: - set_gpio_output(GPIOC, 1, !enabled); - break; - case 2U: - set_gpio_output(GPIOC, 13, !enabled); - break; - case 3U: - set_gpio_output(GPIOA, 0, !enabled); - break; - case 4U: - set_gpio_output(GPIOB, 10, !enabled); - break; - default: - print("Invalid CAN transceiver ("); puth(transceiver); print("): enabling failed\n"); - break; - } -} - -static void uno_set_bootkick(BootState state) { - if (state == BOOT_BOOTKICK) { - set_gpio_output(GPIOB, 14, false); - } else { - // We want the pin to be floating, not forced high! - set_gpio_mode(GPIOB, 14, MODE_INPUT); - } -} - -static void uno_set_can_mode(uint8_t mode) { - uno_enable_can_transceiver(2U, false); - uno_enable_can_transceiver(4U, false); - switch (mode) { - case CAN_MODE_NORMAL: - case CAN_MODE_OBD_CAN2: - if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(harness.status == HARNESS_STATUS_FLIPPED)) { - // B12,B13: disable OBD mode - set_gpio_mode(GPIOB, 12, MODE_INPUT); - set_gpio_mode(GPIOB, 13, MODE_INPUT); - - // B5,B6: normal CAN2 mode - set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); - set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); - uno_enable_can_transceiver(2U, true); - } else { - // B5,B6: disable normal CAN2 mode - set_gpio_mode(GPIOB, 5, MODE_INPUT); - set_gpio_mode(GPIOB, 6, MODE_INPUT); - - // B12,B13: OBD mode - set_gpio_alternate(GPIOB, 12, GPIO_AF9_CAN2); - set_gpio_alternate(GPIOB, 13, GPIO_AF9_CAN2); - uno_enable_can_transceiver(4U, true); - } - break; - default: - print("Tried to set unsupported CAN mode: "); puth(mode); print("\n"); - break; - } -} - -static bool uno_check_ignition(void){ - // ignition is checked through harness - return harness_check_ignition(); -} - -static void uno_set_usb_switch(bool phone){ - set_gpio_output(GPIOB, 3, phone); -} - -static void uno_set_ir_power(uint8_t percentage){ - pwm_set(TIM4, 2, percentage); -} - -static void uno_set_fan_enabled(bool enabled){ - set_gpio_output(GPIOA, 1, enabled); -} - -static void uno_init(void) { - common_init_gpio(); - - // A8,A15: normal CAN3 mode - set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); - set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); - - // GPS off - set_gpio_output(GPIOB, 1, 0); - set_gpio_output(GPIOC, 5, 0); - set_gpio_output(GPIOC, 12, 0); - - // C8: FAN PWM aka TIM3_CH3 - set_gpio_alternate(GPIOC, 8, GPIO_AF2_TIM3); - - // Turn on phone regulator - set_gpio_output(GPIOB, 4, true); - - // Initialize IR PWM and set to 0% - set_gpio_alternate(GPIOB, 7, GPIO_AF2_TIM4); - pwm_init(TIM4, 2); - uno_set_ir_power(0U); - - // Switch to phone usb mode if harness connection is powered by less than 7V - if(white_read_voltage_mV() < 7000U){ - uno_set_usb_switch(true); - } else { - uno_set_usb_switch(false); - } - - // Bootkick phone - uno_set_bootkick(BOOT_BOOTKICK); -} - -static void uno_init_bootloader(void) { - // GPS off - set_gpio_output(GPIOB, 1, 0); - set_gpio_output(GPIOC, 5, 0); - set_gpio_output(GPIOC, 12, 0); -} - -static harness_configuration uno_harness_config = { - .has_harness = true, - .GPIO_SBU1 = GPIOC, - .GPIO_SBU2 = GPIOC, - .GPIO_relay_SBU1 = GPIOC, - .GPIO_relay_SBU2 = GPIOC, - .pin_SBU1 = 0, - .pin_SBU2 = 3, - .pin_relay_SBU1 = 10, - .pin_relay_SBU2 = 11, - .adc_channel_SBU1 = 10, - .adc_channel_SBU2 = 13 -}; - -board board_uno = { - .harness_config = &uno_harness_config, - .has_spi = false, - .has_canfd = false, - .fan_max_rpm = 5100U, - .fan_max_pwm = 100U, - .avdd_mV = 3300U, - .fan_stall_recovery = false, - .fan_enable_cooldown_time = 0U, - .init = uno_init, - .init_bootloader = uno_init_bootloader, - .enable_can_transceiver = uno_enable_can_transceiver, - .led_GPIO = {GPIOC, GPIOC, GPIOC}, - .led_pin = {9, 7, 6}, - .set_can_mode = uno_set_can_mode, - .check_ignition = uno_check_ignition, - .read_voltage_mV = white_read_voltage_mV, - .read_current_mA = unused_read_current, - .set_fan_enabled = uno_set_fan_enabled, - .set_ir_power = uno_set_ir_power, - .set_siren = unused_set_siren, - .set_bootkick = uno_set_bootkick, - .read_som_gpio = unused_read_som_gpio, - .set_amp_enabled = unused_set_amp_enabled -}; diff --git a/board/jungle/scripts/panda_identification_test.py b/board/jungle/scripts/panda_identification_test.py deleted file mode 100755 index a61b0d60..00000000 --- a/board/jungle/scripts/panda_identification_test.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python3 -import os -import time -import random -import contextlib - -from panda import PandaJungle -from panda import Panda - -PANDA_UNDER_TEST = Panda.HW_TYPE_UNO - -panda_jungle = PandaJungle() - -def silent_panda_connect(): - with open(os.devnull, "w") as devnull: - with contextlib.redirect_stdout(devnull): - panda = Panda() - return panda - -def reboot_panda(harness_orientation=PandaJungle.HARNESS_ORIENTATION_NONE, ignition=False): - print(f"Restarting panda with harness orientation: {harness_orientation} and ignition: {ignition}") - panda_jungle.set_panda_power(False) - panda_jungle.set_harness_orientation(harness_orientation) - panda_jungle.set_ignition(ignition) - time.sleep(2) - panda_jungle.set_panda_power(True) - time.sleep(2) - -count = 0 -if __name__ == "__main__": - while True: - ignition = random.randint(0, 1) - harness_orientation = random.randint(0, 2) - reboot_panda(harness_orientation, ignition) - - p = silent_panda_connect() - assert p.get_type() == PANDA_UNDER_TEST - assert p.health()['car_harness_status'] == harness_orientation - if harness_orientation != PandaJungle.HARNESS_ORIENTATION_NONE: - assert p.health()['ignition_line'] == ignition - - count += 1 - print(f"Passed {count} loops") - - diff --git a/board/stm32f4/board.h b/board/stm32f4/board.h index cd10c173..3f1f78b3 100644 --- a/board/stm32f4/board.h +++ b/board/stm32f4/board.h @@ -11,9 +11,7 @@ #include "stm32f4/llfan.h" #include "drivers/clock_source.h" #include "boards/white.h" -#include "boards/grey.h" #include "boards/black.h" -#include "boards/uno.h" #include "boards/dos.h" // Unused functions on F4 @@ -30,11 +28,9 @@ void detect_board_type(void) { hw_type = HW_TYPE_WHITE_PANDA; current_board = &board_white; } else if(detect_with_pull(GPIOA, 13, PULL_DOWN)) { // Rev AB deprecated, so no pullup means black. In REV C, A13 is pulled up to 5V with a 10K - hw_type = HW_TYPE_GREY_PANDA; - current_board = &board_grey; + // grey is deprecated } else if(!detect_with_pull(GPIOB, 15, PULL_UP)) { - hw_type = HW_TYPE_UNO; - current_board = &board_uno; + // uno is deprecated } else { hw_type = HW_TYPE_BLACK_PANDA; current_board = &board_black; diff --git a/tests/hitl/7_internal.py b/tests/hitl/7_internal.py index aad62bad..478fb65e 100644 --- a/tests/hitl/7_internal.py +++ b/tests/hitl/7_internal.py @@ -4,7 +4,6 @@ import pytest from panda import Panda pytestmark = [ - pytest.mark.skip_panda_types(Panda.HW_TYPE_UNO), pytest.mark.test_panda_types(Panda.INTERNAL_DEVICES) ]