From 284ad1ce8599116e31126a7d245fbc43a25f8cba Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 27 Feb 2026 19:05:28 -0800 Subject: [PATCH 1/6] simplify a bunch of stuff --- .github/workflows/test.yaml | 8 ++------ SConscript | 10 ++-------- SConstruct | 12 +++--------- board/jungle/main.c | 32 -------------------------------- setup.sh | 5 ++--- tests/libpanda/SConscript | 23 ----------------------- 6 files changed, 9 insertions(+), 81 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 06a69c3546c..c9956fbc28e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -24,13 +24,9 @@ jobs: - name: Test python package installer run: ${{ env.RUN }} "pip install --break-system-packages .[dev]" - name: Build panda images and bootstub - run: ${{ env.RUN }} "scons -j4" - - name: Build with UBSan - run: ${{ env.RUN }} "scons -j4 --ubsan" - - name: Build jungle firmware with FINAL_PROVISIONING support - run: ${{ env.RUN }} "FINAL_PROVISIONING=1 scons -j4 board/jungle" + run: ${{ env.RUN }} "scons" - name: Build panda in release mode - run: ${{ env.RUN }} "CERT=certs/debug RELEASE=1 scons -j4" + run: ${{ env.RUN }} "CERT=certs/debug RELEASE=1 scons" test: name: ./test.sh diff --git a/SConscript b/SConscript index 957982cae81..019296b6483 100644 --- a/SConscript +++ b/SConscript @@ -154,16 +154,10 @@ with open("board/obj/cert.h", "w") as f: build_project("panda_h7", base_project_h7, "./board/main.c", []) # panda jungle fw -flags = [ - "-DPANDA_JUNGLE", -] -if os.getenv("FINAL_PROVISIONING"): - flags += ["-DFINAL_PROVISIONING"] -build_project("panda_jungle_h7", base_project_h7, "./board/jungle/main.c", flags) +build_project("panda_jungle_h7", base_project_h7, "./board/jungle/main.c", ["-DPANDA_JUNGLE"]) # body fw build_project("body_h7", base_project_h7, "./board/body/main.c", ["-DPANDA_BODY"]) # test files -if GetOption('extras'): - SConscript('tests/libpanda/SConscript') +SConscript('tests/libpanda/SConscript') diff --git a/SConstruct b/SConstruct index 2d263ccc384..6e40beb0141 100644 --- a/SConstruct +++ b/SConstruct @@ -1,18 +1,12 @@ -AddOption('--minimal', - action='store_false', - dest='extras', - default=True, - help='the minimum build. no tests, tools, etc.') - -AddOption('--ubsan', - action='store_true', - help='turn on UBSan') +import os env = Environment( COMPILATIONDB_USE_ABSPATH=True, tools=["default", "compilation_db"], ) +SetOption('num_jobs', max(1, int((os.cpu_count() or 1)-1))) + env.CompilationDatabase("compile_commands.json") # panda fw & test files diff --git a/board/jungle/main.c b/board/jungle/main.c index 7bac6d751b9..4ef9950666d 100644 --- a/board/jungle/main.c +++ b/board/jungle/main.c @@ -75,11 +75,6 @@ void tick_handler(void) { // turn off the blue LED, turned on by CAN led_set(LED_BLUE, false); - // Blink and OBD CAN -#ifdef FINAL_PROVISIONING - current_board->set_can_mode(can_mode == CAN_MODE_NORMAL ? CAN_MODE_OBD_CAN2 : CAN_MODE_NORMAL); -#endif - // on to the next one uptime_cnt += 1U; } @@ -91,33 +86,12 @@ void tick_handler(void) { current_board->set_panda_power(!panda_power); } -#ifdef FINAL_PROVISIONING - // Ignition blinking - uint8_t ignition_bitmask = 0U; - for (uint8_t i = 0U; i < 6U; i++) { - ignition_bitmask |= ((loop_counter % 12U) < ((uint32_t) i + 2U)) << i; - } - current_board->set_individual_ignition(ignition_bitmask); - - // SBU voltage reporting - for (uint8_t i = 0U; i < 6U; i++) { - CANPacket_t pkt = { 0 }; - pkt.data_len_code = 8U; - pkt.addr = 0x100U + i; - *(uint16_t *) &pkt.data[0] = current_board->get_sbu_mV(i + 1U, SBU1); - *(uint16_t *) &pkt.data[2] = current_board->get_sbu_mV(i + 1U, SBU2); - pkt.data[4] = (ignition_bitmask >> i) & 1U; - can_set_checksum(&pkt); - can_send(&pkt, 0U, false); - } -#else // toggle ignition on button press static bool prev_button_status = false; if (!current_button_status && prev_button_status && button_press_cnt < 10){ current_board->set_ignition(!ignition); } prev_button_status = current_button_status; -#endif button_press_cnt = current_button_status ? button_press_cnt + 1 : 0; @@ -181,12 +155,6 @@ int main(void) { can_init_all(); current_board->set_harness_orientation(HARNESS_ORIENTATION_1); -#ifdef FINAL_PROVISIONING - print("---- FINAL PROVISIONING BUILD ---- \n"); - can_set_forwarding(0, 2); - can_set_forwarding(1, 2); -#endif - // LED should keep on blinking all the time uint32_t cnt = 0; for (cnt=0;;cnt++) { diff --git a/setup.sh b/setup.sh index 648432e1c68..7b376253d95 100755 --- a/setup.sh +++ b/setup.sh @@ -17,12 +17,11 @@ elif [[ $PLATFORM == "Linux" ]]; then fi sudo apt-get install -y --no-install-recommends \ - curl ca-certificates \ - make g++ git \ + curl git \ libusb-1.0-0 \ python3-dev python3-pip python3-venv else - echo "WARNING: unsupported platform. skipping apt/brew install." + echo "WARNING: unsupported platform" fi if ! command -v uv &>/dev/null; then diff --git a/tests/libpanda/SConscript b/tests/libpanda/SConscript index a5bdd7ce745..1b82b0e450f 100644 --- a/tests/libpanda/SConscript +++ b/tests/libpanda/SConscript @@ -1,19 +1,6 @@ import opendbc -import platform - -CC = 'gcc' -system = platform.system() -mac_ver = platform.mac_ver() - -# gcc installed by homebrew has version suffix (e.g. gcc-12) in order to be -# distinguishable from system one - which acts as a symlink to clang -# clang works on macOS 15 and greater but has issues on earlier macOS versions. -# see: https://github.com/commaai/openpilot/issues/35093 -if system == 'Darwin' and mac_ver[0] and mac_ver[0] < '15': - CC += '-13' env = Environment( - CC=CC, CFLAGS=[ '-nostdlib', '-fno-builtin', @@ -23,16 +10,6 @@ env = Environment( ], CPPPATH=[".", "../../", "../../board/", opendbc.INCLUDE_PATH], ) -if system == "Darwin": - env.PrependENVPath('PATH', '/opt/homebrew/bin') - -if GetOption('ubsan'): - flags = [ - "-fsanitize=undefined", - "-fno-sanitize-recover=undefined", - ] - env['CFLAGS'] += flags - env['LINKFLAGS'] += flags panda = env.SharedObject("panda.os", "panda.c") libpanda = env.SharedLibrary("libpanda.so", [panda]) From bb1098ff63bfdc6ee52b602bd7b4a406955c916a Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 27 Feb 2026 19:15:56 -0800 Subject: [PATCH 2/6] lil more --- .github/workflows/test.yaml | 46 ++++++++++++++----------------------- setup.sh | 5 ++-- tests/misra/test_misra.sh | 2 +- 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c9956fbc28e..f7bba751077 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,24 +10,7 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/master' && github.ref || github.run_id }}-${{ github.event_name }} cancel-in-progress: true -env: - RUN: source .venv/bin/activate && /bin/bash -c - jobs: - build: - name: build - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 - - run: ./setup.sh - - name: Test python package installer - run: ${{ env.RUN }} "pip install --break-system-packages .[dev]" - - name: Build panda images and bootstub - run: ${{ env.RUN }} "scons" - - name: Build panda in release mode - run: ${{ env.RUN }} "CERT=certs/debug RELEASE=1 scons" - test: name: ./test.sh runs-on: ${{ matrix.os }} @@ -35,10 +18,16 @@ jobs: fail-fast: false matrix: os: ['macos-latest', 'ubuntu-latest'] - timeout-minutes: 10 + timeout-minutes: 3 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - run: ./test.sh + - name: Build panda in release mode + run: | + source .venv/bin/activate + CERT=certs/debug RELEASE=1 scons + - name: Test python package installer + run: pip install --break-system-packages .[dev] windows: name: windows pip package test @@ -59,23 +48,22 @@ jobs: misra_linter: name: MISRA C:2012 Linter runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 3 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - run: ./setup.sh - - name: Build FW - run: ${{ env.RUN }} "scons -j$(nproc)" - name: Run MISRA C:2012 analysis - run: ${{ env.RUN }} "cd tests/misra && ./test_misra.sh" + run: ./tests/misra/test_misra.sh misra_mutation: name: MISRA C:2012 Mutation runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 3 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - run: ./setup.sh - - name: Build FW - run: ${{ env.RUN }} "scons -j$(nproc)" - name: MISRA mutation tests - run: ${{ env.RUN }} "cd tests/misra && pytest test_mutation.py" + run: | + source .venv/bin/activate + cd tests/misra + pytest test_mutation.py diff --git a/setup.sh b/setup.sh index 7b376253d95..648432e1c68 100755 --- a/setup.sh +++ b/setup.sh @@ -17,11 +17,12 @@ elif [[ $PLATFORM == "Linux" ]]; then fi sudo apt-get install -y --no-install-recommends \ - curl git \ + curl ca-certificates \ + make g++ git \ libusb-1.0-0 \ python3-dev python3-pip python3-venv else - echo "WARNING: unsupported platform" + echo "WARNING: unsupported platform. skipping apt/brew install." fi if ! command -v uv &>/dev/null; then diff --git a/tests/misra/test_misra.sh b/tests/misra/test_misra.sh index 5d59c1a3a45..ba38568075c 100755 --- a/tests/misra/test_misra.sh +++ b/tests/misra/test_misra.sh @@ -24,7 +24,7 @@ fi cd $PANDA_DIR if [ -z "${SKIP_BUILD}" ]; then - scons -j8 + scons fi CHECKLIST=$DIR/checkers.txt From 517a6d6de1b4e88d1f1604826a20529bdc94d59c Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 27 Feb 2026 19:22:02 -0800 Subject: [PATCH 3/6] lil more --- .gitignore | 1 + pyproject.toml | 2 +- tests/misra/test_misra.sh | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 67edc8b6904..fda7bec5b80 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ *.os *.d *.dump +*.ctu-info a.out *~ .#* diff --git a/pyproject.toml b/pyproject.toml index 1af5798aed4..11c262fc026 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "pandacan" version = "0.0.10" description = "Code powering the comma.ai panda" readme = "README.md" -requires-python = ">=3.11,<3.13" # macOS doesn't work with 3.13 due to pycapnp from opendbc +requires-python = ">=3.11,<4" license = {text = "MIT"} authors = [{name = "comma.ai"}] classifiers = [ diff --git a/tests/misra/test_misra.sh b/tests/misra/test_misra.sh index ba38568075c..0b6eb42793c 100755 --- a/tests/misra/test_misra.sh +++ b/tests/misra/test_misra.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash set -e +PANDA_DIR=$(git rev-parse --show-toplevel) +source $PANDA_DIR/setup.sh + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -PANDA_DIR=$(realpath $DIR/../../) OPENDBC_ROOT=$(python3 -c "import opendbc; print(opendbc.INCLUDE_PATH)") GREEN="\e[1;32m" From 0f9572cd36cfcc8d496c6608bf48c91b55d60b60 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 27 Feb 2026 19:27:56 -0800 Subject: [PATCH 4/6] rm lock --- setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 648432e1c68..9327a35071f 100755 --- a/setup.sh +++ b/setup.sh @@ -36,5 +36,6 @@ if ! command -v uv &>/dev/null; then fi export UV_PROJECT_ENVIRONMENT="$DIR/.venv" -uv sync --all-extras --upgrade +rm -f uv.lock +uv sync --all-extras source "$DIR/.venv/bin/activate" From e80d01d925a292a49bdc467f9a55d6ea2eb502a2 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 27 Feb 2026 19:30:24 -0800 Subject: [PATCH 5/6] filter warnings --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 11c262fc026..76145ebd9b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,6 +77,10 @@ flake8-implicit-str-concat.allow-multiline=false [tool.pytest.ini_options] addopts = "-Werror --strict-config --strict-markers --durations=10 --ignore-glob='*.sh' --ignore=tests/misra --ignore=tests/som --ignore=tests/hitl" +filterwarnings = [ + "error", + "ignore::DeprecationWarning:usb1._libusb1", +] python_files = "test_*.py" testpaths = [ "tests/" From c3099be952dbee9b062f6e061f1616911c1fba91 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 27 Feb 2026 19:33:30 -0800 Subject: [PATCH 6/6] ugh --- pyproject.toml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 76145ebd9b0..6154b5a5ebe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,11 +76,7 @@ flake8-implicit-str-concat.allow-multiline=false "pytest.main".msg = "pytest.main requires special handling that is easy to mess up!" [tool.pytest.ini_options] -addopts = "-Werror --strict-config --strict-markers --durations=10 --ignore-glob='*.sh' --ignore=tests/misra --ignore=tests/som --ignore=tests/hitl" -filterwarnings = [ - "error", - "ignore::DeprecationWarning:usb1._libusb1", -] +addopts = "--durations=10 --ignore-glob='*.sh' --ignore=tests/misra --ignore=tests/som --ignore=tests/hitl" python_files = "test_*.py" testpaths = [ "tests/"