Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 17 additions & 33 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,24 @@ 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 -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"
- name: Build panda in release mode
run: ${{ env.RUN }} "CERT=certs/debug RELEASE=1 scons -j4"

test:
name: ./test.sh
runs-on: ${{ matrix.os }}
strategy:
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
Expand All @@ -63,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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*.os
*.d
*.dump
*.ctu-info
a.out
*~
.#*
Expand Down
10 changes: 2 additions & 8 deletions SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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')
12 changes: 3 additions & 9 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 0 additions & 32 deletions board/jungle/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;

Expand Down Expand Up @@ -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++) {
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -76,7 +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"
addopts = "--durations=10 --ignore-glob='*.sh' --ignore=tests/misra --ignore=tests/som --ignore=tests/hitl"
python_files = "test_*.py"
testpaths = [
"tests/"
Expand Down
3 changes: 2 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
23 changes: 0 additions & 23 deletions tests/libpanda/SConscript
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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])
6 changes: 4 additions & 2 deletions tests/misra/test_misra.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -24,7 +26,7 @@ fi

cd $PANDA_DIR
if [ -z "${SKIP_BUILD}" ]; then
scons -j8
scons
fi

CHECKLIST=$DIR/checkers.txt
Expand Down
Loading