Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync 20240831 #35

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ee7b385
CI: add jenkins-trigger
adeebshihadeh Aug 2, 2024
b70ba5e
Detect H723 in firmware (#1988)
robbederks Aug 2, 2024
5d81523
1min is all you need
adeebshihadeh Aug 2, 2024
3c1def1
pre-commit: autoupdate hooks (#1979)
commaci-public Aug 2, 2024
1cbcc13
use and configure custom logger (#1994)
sshane Aug 5, 2024
87572e0
Update README.md to fix dead link (#1996)
geeth345 Aug 13, 2024
0234e75
STM32H7: add missing interrupt handlers (#1997)
robbederks Aug 16, 2024
e7a04b5
make uds and isotp general imports (#1998)
sshane Aug 17, 2024
c4e75ee
remove cereal dependence (#2000)
adeebshihadeh Aug 18, 2024
cfa8b79
cleanup dependencies (#2001)
adeebshihadeh Aug 18, 2024
080e53f
Cuatro fan (#1999)
robbederks Aug 19, 2024
e53c802
tres: fix SOM reset line blinking (#2003)
adeebshihadeh Aug 23, 2024
30d0434
cuatro: disable SOM reset
Aug 23, 2024
866bd9c
cuatro: disable LED for now
adeebshihadeh Aug 24, 2024
2b94e4f
Enable CAN3 printer (#1991)
dzid26 Aug 27, 2024
0a09122
update bash scripts to #!/usr/bin/env bash (#1987)
andiradulescu Aug 27, 2024
8587ae3
drivers: log can core reset when switching multiplexing (#1972)
sshane Aug 27, 2024
bd6cec3
cuatro LED (#2005)
robbederks Aug 30, 2024
a36ca22
Defining types in return dictionaries (#1923)
MarinkoMagla Aug 31, 2024
160ea08
misra: bump to cppcheck 2.15.0 (#2008)
adeebshihadeh Aug 31, 2024
9ec02e7
socketcan: skip install in CI for now
adeebshihadeh Aug 31, 2024
c1caf0c
Merge remote-tracking branch 'comma/master' into sync-20240831
rav4kumar Aug 31, 2024
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
6 changes: 4 additions & 2 deletions .github/workflows/drivers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
build_socketcan:
name: socketcan build
runs-on: ubuntu-latest
timeout-minutes: 5
timeout-minutes: 1
steps:
- uses: actions/checkout@v2
- name: Install dependencies
Expand All @@ -16,7 +16,9 @@ jobs:
cd drivers/linux
make link
make build
make install

# FIXME: install doesn't work sometimes in GH Actions
#make install
- name: Print make log
if: always()
continue-on-error: true
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/jenkins-pr-trigger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: jenkins scan

on:
issue_comment:
types: [created, edited]

jobs:
# TODO: gc old branches in a separate job in this workflow
scan-comments:
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request }}
steps:
- name: Check for trigger phrase
id: check_comment
uses: actions/github-script@v7
with:
script: |
const triggerPhrase = "trigger-jenkins";
const comment = context.payload.comment.body;
const commenter = context.payload.comment.user.login;

const { data: permissions } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: commenter
});

const hasWriteAccess = permissions.permission === 'write' || permissions.permission === 'admin';

return (hasWriteAccess && comment.includes(triggerPhrase));
result-encoding: json

- name: Checkout repository
if: steps.check_comment.outputs.result == 'true'
uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/head

- name: Push to tmp-jenkins branch
if: steps.check_comment.outputs.result == 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b tmp-jenkins-${{ github.event.issue.number }}
GIT_LFS_SKIP_PUSH=1 git push -f origin tmp-jenkins-${{ github.event.issue.number }}
8 changes: 4 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
cancel-in-progress: true

env:
RUN: docker run -v ${{ github.workspace }}:/tmp/openpilot/panda -w /tmp/openpilot/panda --rm panda /bin/bash -c
RUN: docker run -v ${{ github.workspace }}:/tmp/pythonpath/panda -w /tmp/pythonpath/panda --rm panda /bin/bash -c
BUILD: |
export DOCKER_BUILDKIT=1
docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ghcr.io/commaai/panda:latest -t panda -f Dockerfile .
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Build Docker image
run: eval "$BUILD"
- name: Test python package installer
run: ${{ env.RUN }} "python setup.py install"
run: ${{ env.RUN }} "python3 setup.py install"
- name: Build panda images and bootstub
run: ${{ env.RUN }} "scons -j4"
- name: Build panda with SPI support
Expand Down Expand Up @@ -103,8 +103,8 @@ jobs:
timeout-minutes: 5
run: ${{ env.RUN }} "cd tests/misra && pytest -n8 test_mutation.py"

python_linter:
name: python linter
static_analysis:
name: static analysis
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ repos:
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.11.1
hooks:
- id: mypy
additional_dependencies: ['numpy', 'types-requests', 'types-atomicwrites',
'types-pycurl']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.7
rev: v0.5.5
hooks:
- id: ruff
54 changes: 16 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,67 +1,45 @@
FROM ubuntu:24.04

ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /tmp/openpilot:$PYTHONPATH
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/tmp/pythonpath

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
make \
bzip2 \
ca-certificates \
capnproto \
clang \
g++ \
gcc-arm-none-eabi libnewlib-arm-none-eabi \
git \
libarchive-dev \
libbz2-dev \
libcapnp-dev \
libffi-dev \
libtool \
libusb-1.0-0 \
libzmq3-dev \
locales \
opencl-headers \
ocl-icd-opencl-dev \
python3 \
python3-dev \
python3-pip \
python-is-python3 \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/* && \
apt clean && \
cd /usr/lib/gcc/arm-none-eabi/* && \
rm -rf arm/ && \
rm -rf thumb/nofp thumb/v6* thumb/v8* thumb/v7+fp thumb/v7-r+fp.sp

RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

COPY requirements.txt /tmp/
RUN pip3 install --break-system-packages --no-cache-dir -r /tmp/requirements.txt

ENV CPPCHECK_DIR=/tmp/cppcheck
COPY tests/misra/install.sh /tmp/
RUN /tmp/install.sh && rm -rf $CPPCHECK_DIR/.git/
ENV SKIP_CPPCHECK_INSTALL=1

ENV CEREAL_REF="861144c136c91f70dcbc652c2ffe99f57440ad47"
ENV OPENDBC_REF="8e9d3688412405154a8189c421cfdc9d5feea715"
COPY setup.py __init__.py $PYTHONPATH/panda/
COPY python/__init__.py $PYTHONPATH/panda/python/
RUN pip3 install --break-system-packages --no-cache-dir $PYTHONPATH/panda/[dev]

RUN git config --global --add safe.directory /tmp/openpilot/panda
RUN mkdir -p /tmp/openpilot/ && \
cd /tmp/openpilot/ && \
git clone --depth 1 https://github.com/commaai/cereal && \
git clone --depth 1 https://github.com/commaai/opendbc && \
cd cereal && git fetch origin $CEREAL_REF && git checkout FETCH_HEAD && rm -rf .git/ && cd .. && \
cd opendbc && git fetch origin $OPENDBC_REF && git checkout FETCH_HEAD && rm -rf .git/ && cd .. && \
cp -pR opendbc/SConstruct opendbc/site_scons/ . && \
pip3 install --break-system-packages --no-cache-dir -r opendbc/requirements.txt && \
scons -j8 --minimal opendbc/ cereal/
# TODO: this should be a "pip install" or not even in this repo at all
RUN git config --global --add safe.directory $PYTHONPATH/panda
ENV OPENDBC_REF="5ed7a834a4e0e24c3968dd1e98ceb4b9d5f9791a"
RUN cd /tmp/ && \
git clone --depth 1 https://github.com/commaai/opendbc opendbc_repo && \
cd opendbc_repo && git fetch origin $OPENDBC_REF && git checkout FETCH_HEAD && rm -rf .git/ && \
pip3 install --break-system-packages --no-cache-dir Cython numpy && \
scons -j8 --minimal opendbc/ && \
ln -s $PWD/opendbc $PYTHONPATH/opendbc

# for Jenkins
COPY README.md panda.tar.* /tmp/
RUN mkdir /tmp/openpilot/panda && \
tar -xvf /tmp/panda.tar.gz -C /tmp/openpilot/panda/ || true
RUN mkdir -p /tmp/pythonpath/panda && \
tar -xvf /tmp/panda.tar.gz -C /tmp/pythonpath/panda/ || true
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def docker_run(String step_label, int timeout_mins, String cmd) {
--env PYTHONWARNINGS=error \
--volume /dev/bus/usb:/dev/bus/usb \
--volume /var/run/dbus:/var/run/dbus \
--workdir /tmp/openpilot/panda \
--workdir /tmp/pythonpath/panda \
--net host \
${env.DOCKER_IMAGE_TAG} \
bash -c 'scons -j8 && ${cmd}'", \
Expand Down Expand Up @@ -92,7 +92,7 @@ pipeline {
steps {
script {
retry (3) {
docker_run("reset hardware", 3, "python ./tests/hitl/reset_jungles.py")
docker_run("reset hardware", 3, "python3 ./tests/hitl/reset_jungles.py")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ git clone https://github.com/commaai/panda.git
cd panda

# install dependencies
pip install -r requirements.txt
pip install -e .[dev]

# install panda
python setup.py install
Expand Down Expand Up @@ -97,7 +97,7 @@ The panda jungle uses different udev rules. See [the repo](https://github.com/co
As a universal car interface, it should support every reasonable software interface.

- [Python library](https://github.com/commaai/panda/tree/master/python)
- [C++ library](https://github.com/commaai/openpilot/tree/master/selfdrive/boardd)
- [C++ library](https://github.com/commaai/openpilot/tree/master/selfdrive/pandad)
- [socketcan in kernel](https://github.com/commaai/panda/tree/master/drivers/linux) (alpha)

## Licensing
Expand Down
3 changes: 2 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from .python.spi import PandaSpiException, PandaProtocolMismatch, STBootloaderSPIHandle # noqa: F401
from .python.serial import PandaSerial # noqa: F401
from .python.canhandle import CanHandle # noqa: F401
from .python import (Panda, PandaDFU, # noqa: F401
from .python.utils import logger # noqa: F401
from .python import (Panda, PandaDFU, uds, isotp, # noqa: F401
pack_can_buffer, unpack_can_buffer, calculate_checksum,
DLC_TO_LEN, LEN_TO_DLC, ALTERNATIVE_EXPERIENCE, CANPACKET_HEAD_SIZE)

Expand Down
3 changes: 0 additions & 3 deletions board/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,4 @@ for project_name, project in build_projects.items():
if ("ENABLE_SPI" in os.environ or "h7" in project_name):
flags.append('-DENABLE_SPI')

if "H723" in os.environ:
flags.append('-DSTM32H723')

build_project(project_name, project, flags)
1 change: 1 addition & 0 deletions board/boards/black.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ board board_black = {
.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,
Expand Down
1 change: 1 addition & 0 deletions board/boards/board_declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct board {
const uint16_t avdd_mV;
const bool fan_stall_recovery;
const uint8_t fan_enable_cooldown_time;
const uint8_t fan_max_pwm;
board_init init;
board_init_bootloader init_bootloader;
board_enable_can_transceiver enable_can_transceiver;
Expand Down
28 changes: 22 additions & 6 deletions board/boards/cuatro.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void cuatro_set_led(uint8_t color, bool enabled) {
case LED_RED:
set_gpio_output(GPIOD, 15, !enabled);
break;
case LED_GREEN:
case LED_GREEN:
set_gpio_output(GPIOD, 14, !enabled);
break;
case LED_BLUE:
Expand Down Expand Up @@ -57,9 +57,24 @@ uint32_t cuatro_read_current_mA(void) {
return adc_get_mV(3) * 2U;
}

void cuatro_set_fan_enabled(bool enabled) {
set_gpio_output(GPIOD, 3, !enabled);
}

void cuatro_set_bootkick(BootState state) {
set_gpio_output(GPIOA, 0, state != BOOT_BOOTKICK);
// only use if we have to
//set_gpio_output(GPIOC, 12, state != BOOT_RESET);
}

void cuatro_init(void) {
red_chiplet_init();

// init LEDs as open drain
set_gpio_output_type(GPIOE, 2, OUTPUT_TYPE_OPEN_DRAIN);
set_gpio_output_type(GPIOD, 14, OUTPUT_TYPE_OPEN_DRAIN);
set_gpio_output_type(GPIOD, 15, OUTPUT_TYPE_OPEN_DRAIN);

// Power readout
set_gpio_mode(GPIOC, 5, MODE_ANALOG);
set_gpio_mode(GPIOA, 6, MODE_ANALOG);
Expand All @@ -81,8 +96,7 @@ void cuatro_init(void) {
set_gpio_pullup(GPIOC, 2, PULL_DOWN);

// SOM bootkick + reset lines
set_gpio_mode(GPIOC, 12, MODE_OUTPUT);
tres_set_bootkick(BOOT_BOOTKICK);
cuatro_set_bootkick(BOOT_BOOTKICK);

// SOM debugging UART
gpio_uart7_init();
Expand All @@ -93,6 +107,7 @@ void cuatro_init(void) {

// fan setup
set_gpio_alternate(GPIOC, 8, GPIO_AF2_TIM3);
register_set_bits(&(GPIOC->OTYPER), GPIO_OTYPER_OT8); // open drain

// Initialize IR PWM and set to 0%
set_gpio_alternate(GPIOC, 9, GPIO_AF2_TIM3);
Expand All @@ -108,7 +123,8 @@ board board_cuatro = {
.has_obd = true,
.has_spi = true,
.has_canfd = true,
.fan_max_rpm = 6600U,
.fan_max_rpm = 12500U,
.fan_max_pwm = 99U, // it can go up to 14k RPM, but 99% -> 100% is very non-linear
.avdd_mV = 1800U,
.fan_stall_recovery = false,
.fan_enable_cooldown_time = 3U,
Expand All @@ -121,9 +137,9 @@ board board_cuatro = {
.check_ignition = red_check_ignition,
.read_voltage_mV = cuatro_read_voltage_mV,
.read_current_mA = cuatro_read_current_mA,
.set_fan_enabled = tres_set_fan_enabled,
.set_fan_enabled = cuatro_set_fan_enabled,
.set_ir_power = tres_set_ir_power,
.set_siren = unused_set_siren,
.set_bootkick = tres_set_bootkick,
.set_bootkick = cuatro_set_bootkick,
.read_som_gpio = tres_read_som_gpio
};
1 change: 1 addition & 0 deletions board/boards/dos.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ board board_dos = {
#endif
.has_canfd = false,
.fan_max_rpm = 6500U,
.fan_max_pwm = 100U,
.avdd_mV = 3300U,
.fan_stall_recovery = true,
.fan_enable_cooldown_time = 3U,
Expand Down
1 change: 1 addition & 0 deletions board/boards/grey.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ board board_grey = {
.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,
Expand Down
1 change: 1 addition & 0 deletions board/boards/red.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ board board_red = {
.has_spi = false,
.has_canfd = true,
.fan_max_rpm = 0U,
.fan_max_pwm = 100U,
.avdd_mV = 3300U,
.fan_stall_recovery = false,
.fan_enable_cooldown_time = 0U,
Expand Down
4 changes: 3 additions & 1 deletion board/boards/tres.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ void tres_init(void) {
set_gpio_pullup(GPIOC, 2, PULL_DOWN);

// SOM bootkick + reset lines
set_gpio_mode(GPIOC, 12, MODE_OUTPUT);
// WARNING: make sure output state is set before configuring as output
tres_set_bootkick(BOOT_BOOTKICK);
set_gpio_mode(GPIOC, 12, MODE_OUTPUT);

// SOM debugging UART
gpio_uart7_init();
Expand Down Expand Up @@ -76,6 +77,7 @@ board board_tres = {
.has_spi = true,
.has_canfd = true,
.fan_max_rpm = 6600U,
.fan_max_pwm = 100U,
.avdd_mV = 1800U,
.fan_stall_recovery = false,
.fan_enable_cooldown_time = 3U,
Expand Down
1 change: 1 addition & 0 deletions board/boards/uno.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ board board_uno = {
.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,
Expand Down
1 change: 1 addition & 0 deletions board/boards/white.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ board board_white = {
.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,
Expand Down
Loading