Skip to content

Commit

Permalink
Merge branch 'master-to-master3' into master3
Browse files Browse the repository at this point in the history
  • Loading branch information
eFiniLan committed Aug 20, 2024
2 parents baca9a1 + 080e53f commit f36800d
Show file tree
Hide file tree
Showing 30 changed files with 289 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .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 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
10 changes: 8 additions & 2 deletions board/boards/cuatro.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ 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_init(void) {
red_chiplet_init();

Expand Down Expand Up @@ -93,6 +97,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 +113,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,7 +127,7 @@ 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,
Expand Down
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
1 change: 1 addition & 0 deletions board/boards/tres.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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
2 changes: 1 addition & 1 deletion board/drivers/fan.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void fan_tick(void) {
float error = fan_state.target_rpm - fan_rpm_fast;
fan_state.error_integral += FAN_I * error;
}
fan_state.power = CLAMP(fan_state.error_integral, 0U, 100U);
fan_state.power = CLAMP(fan_state.error_integral, 0U, current_board->fan_max_pwm);

// Set PWM and enable line
pwm_set(TIM3, 3, fan_state.power);
Expand Down
Loading

0 comments on commit f36800d

Please sign in to comment.