Skip to content

Commit

Permalink
Squashed 'panda/' changes from 869f123..07e668e
Browse files Browse the repository at this point in the history
07e668e Fast CI (#539)
5307bf7 Fix multi message iso tp requests
0610ed1 Hyundai wheel speed counter is actually 4 bits spread over two signals
0d581aa dockerfile optimization
eaefa2f fix docker file path
243a65f pull base image
0dd9470 only push to dockerhub from master
55b79b4 GitHub Actions (#535)
b2c720b Dos (#533)
01bf740 remove 0x1BE checksum test
0bd06c9 remove 0x1BE check (breaks some vehicles)
c31b899 honda bosch longitudinal safety
66250c4 Disable docker layer caching (#534)
6b19fa4 include nissan safety in release build
db31886 gate mazda safety behind debug flag
e4558c0 Safety: message length check on RX and TX (#529)

git-subtree-dir: panda
git-subtree-split: 07e668e
  • Loading branch information
Vehicle Researcher committed May 21, 2020
1 parent eb0dff8 commit 49619bc
Show file tree
Hide file tree
Showing 33 changed files with 721 additions and 1,117 deletions.
118 changes: 0 additions & 118 deletions .circleci/config.yml

This file was deleted.

129 changes: 129 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: panda tests
on: [push, pull_request]

env:
RUN: docker run --rm panda /bin/bash -c
PERSIST: docker run --name panda panda /bin/sh -c
BUILD: |
docker pull $(grep -ioP '(?<=^from)\s+\S+' Dockerfile.panda) || true
docker pull docker.io/commaai/panda:latest || true
docker build --cache-from docker.io/commaai/panda:latest -t panda -f Dockerfile.panda .
jobs:
docker_push:
name: docker push
runs-on: ubuntu-16.04
timeout-minutes: 45
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/panda'
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: eval "$BUILD"
- name: Login to dockerhub
run: docker login -u wmelching -p ${{ secrets.DOCKERHUB_TOKEN }}
- name: Tag image
run: docker tag panda docker.io/commaai/panda:latest
- name: Push image
run: docker push docker.io/commaai/panda:latest

build:
name: build
runs-on: ubuntu-16.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: eval "$BUILD"
- name: Test python package installer
run: $RUN "cd /tmp/openpilot/panda && python setup.py install"
- name: Build panda STM image
run: $RUN "cd /tmp/openpilot/panda/board && make bin"
- name: Build panda STM bootstub image
run: $RUN "cd /tmp/openpilot/panda/board && make obj/bootstub.panda.bin"
- name: Build pedal STM image
run: $RUN "cd /tmp/openpilot/panda/board/pedal && make obj/comma.bin"
- name: Build pedal STM bootstub image
run: $RUN "cd /tmp/openpilot/panda/board/pedal && make obj/bootstub.bin"

build_esp:
name: build esp
runs-on: ubuntu-16.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v2
- name: Build docker image
run: |
docker pull $(grep -ioP '(?<=^from)\s+\S+' tests/build/Dockerfile.panda_esp) || true
docker pull docker.io/commaai/panda_esp:latest || true
docker build --cache-from docker.io/commaai/panda_esp:latest -t panda_esp -f tests/build/Dockerfile.panda_esp .
- name: Build ESP image
run: docker run --rm panda_esp /bin/sh -c "cd /panda/boardesp && make user1.bin"
- name: Push image
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/panda'
run: |
docker login -u wmelching -p ${{ secrets.DOCKERHUB_TOKEN }}
docker tag panda_esp docker.io/commaai/panda_esp:latest
docker push docker.io/commaai/panda_esp:latest
safety:
name: safety
runs-on: ubuntu-16.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: eval "$BUILD"
- name: Run safety tests
run: |
$RUN "cd /tmp/openpilot && \
scons -c && \
scons -j$(nproc) opendbc/ cereal/ && \
cd panda/tests/safety && \
./test.sh"
safety_replay:
name: safety replay
runs-on: ubuntu-16.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: eval "$BUILD"
- name: Run safety replay
run: $RUN "cd /tmp/openpilot/panda/tests/safety_replay && ./test_safety_replay.py"

misra:
name: misra c2012
runs-on: ubuntu-16.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: eval "$BUILD"
- name: Run Misra C 2012 analysis
run: $PERSIST "cd /tmp/openpilot/panda/tests/misra && ./test_misra.sh"
- name: Copy analysis outputs
run: docker cp panda:/tmp/misra /tmp
- uses: actions/upload-artifact@v2
if: always()
with:
name: cppcheck.txt
path: /tmp/misra/cppcheck_output.txt
- uses: actions/upload-artifact@v2
if: always()
with:
name: misra.txt
path: /tmp/misra/misra_output.txt

python_linter:
name: python linter
runs-on: ubuntu-16.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: eval "$BUILD"
- name: Run linters
run: |
$RUN "cd /tmp/openpilot/panda/tests/linter_python/ && ./flake8_panda.sh"
$RUN "cd /tmp/openpilot/panda/tests/linter_python/ && ./pylint_panda.sh"
64 changes: 64 additions & 0 deletions Dockerfile.panda
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
FROM ubuntu:16.04
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /tmp/openpilot:$PYTHONPATH

RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
automake \
bzip2 \
capnproto \
clang \
curl \
g++ \
gcc-arm-none-eabi libnewlib-arm-none-eabi \
git \
libarchive-dev \
libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev libswscale-dev libavresample-dev libavfilter-dev \
libbz2-dev \
libcapnp-dev \
libcurl4-openssl-dev \
libffi-dev \
libtool \
libssl-dev \
libusb-1.0-0 \
libzmq3-dev \
locales \
make \
pkg-config \
python \
python-dev \
python-pip \
unzip \
wget \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

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

RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"

COPY requirements.txt /tmp/
RUN pyenv install 3.7.3 && \
pyenv global 3.7.3 && \
pyenv rehash && \
pip install --no-cache-dir --upgrade pip==18.0 && \
pip install --no-cache-dir -r /tmp/requirements.txt

RUN cd /tmp && \
git clone https://github.com/commaai/openpilot.git tmppilot || true && \
cd /tmp/tmppilot && \
git pull && git checkout 44560b5bb74e451767725144c3fa5f1564481a20 && \
git submodule update --init cereal opendbc && \
mkdir /tmp/openpilot && \
cp -pR SConstruct tools/ selfdrive/ common/ cereal/ opendbc/ /tmp/openpilot && \
rm -rf /tmp/tmppilot

RUN cd /tmp/openpilot && \
pip install --no-cache-dir -r opendbc/requirements.txt && \
pip install --no-cache-dir -r tools/requirements.txt

COPY . /tmp/openpilot/panda
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ It uses an [STM32F413](http://www.st.com/en/microcontrollers/stm32f413-423.html?

It is 2nd gen hardware, reusing code and parts from the [NEO](https://github.com/commaai/neo) interface board.

[![CircleCI](https://circleci.com/gh/commaai/panda.svg?style=svg)](https://circleci.com/gh/commaai/panda)
![panda tests](https://github.com/commaai/panda/workflows/panda%20tests/badge.svg)

Usage (Python)
------
Expand Down Expand Up @@ -99,7 +99,7 @@ When compiled from an [EON Dev Kit](https://comma.ai/shop/products/eon-gold-dash
conjuction with [openpilot](https://github.com/commaai/openpilot). The panda FW, through its safety model, provides and enforces the
[openpilot Safety](https://github.com/commaai/openpilot/blob/devel/SAFETY.md). Due to its critical function, it's important that the application code rigor within the `board` folder is held to high standards.

These are the [CI regression tests](https://circleci.com/gh/commaai/panda) we have in place:
These are the [CI regression tests](https://github.com/commaai/panda/actions) we have in place:
* A generic static code analysis is performed by [Cppcheck](https://github.com/danmar/cppcheck/).
* In addition, [Cppcheck](https://github.com/danmar/cppcheck/) has a specific addon to check for [MISRA C:2012](https://www.misra.org.uk/MISRAHome/MISRAC2012/tabid/196/Default.aspx) violations. See [current coverage](https://github.com/commaai/panda/blob/master/tests/misra/coverage_table).
* Compiler options are relatively strict: the flags `-Wall -Wextra -Wstrict-prototypes -Werror` are enforced on board and pedal makefiles.
Expand Down
12 changes: 8 additions & 4 deletions board/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "boards/grey.h"
#include "boards/black.h"
#include "boards/uno.h"
#include "boards/dos.h"
#else
#include "boards/pedal.h"
#endif
Expand All @@ -22,7 +23,10 @@ void detect_board_type(void) {
// SPI lines floating: white (TODO: is this reliable? Not really, we have to enable ESP/GPS to be able to detect this on the UART)
set_gpio_output(GPIOC, 14, 1);
set_gpio_output(GPIOC, 5, 1);
if((detect_with_pull(GPIOA, 4, PULL_DOWN)) || (detect_with_pull(GPIOA, 5, PULL_DOWN)) || (detect_with_pull(GPIOA, 6, PULL_DOWN)) || (detect_with_pull(GPIOA, 7, PULL_DOWN))){
if(!detect_with_pull(GPIOB, 1, PULL_UP)){
hw_type = HW_TYPE_DOS;
current_board = &board_dos;
} else if((detect_with_pull(GPIOA, 4, PULL_DOWN)) || (detect_with_pull(GPIOA, 5, PULL_DOWN)) || (detect_with_pull(GPIOA, 6, PULL_DOWN)) || (detect_with_pull(GPIOA, 7, PULL_DOWN))){
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
Expand Down Expand Up @@ -78,17 +82,17 @@ bool board_has_gmlan(void) {
}

bool board_has_obd(void) {
return ((hw_type == HW_TYPE_BLACK_PANDA) || (hw_type == HW_TYPE_UNO));
return ((hw_type == HW_TYPE_BLACK_PANDA) || (hw_type == HW_TYPE_UNO) || (hw_type == HW_TYPE_DOS));
}

bool board_has_lin(void) {
return ((hw_type == HW_TYPE_WHITE_PANDA) || (hw_type == HW_TYPE_GREY_PANDA));
}

bool board_has_rtc(void) {
return (hw_type == HW_TYPE_UNO);
return ((hw_type == HW_TYPE_UNO) || (hw_type == HW_TYPE_DOS));
}

bool board_has_relay(void) {
return ((hw_type == HW_TYPE_BLACK_PANDA) || (hw_type == HW_TYPE_UNO));
return ((hw_type == HW_TYPE_BLACK_PANDA) || (hw_type == HW_TYPE_UNO) || (hw_type == HW_TYPE_DOS));
}
1 change: 1 addition & 0 deletions board/board_declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct board {
#define HW_TYPE_BLACK_PANDA 3U
#define HW_TYPE_PEDAL 4U
#define HW_TYPE_UNO 5U
#define HW_TYPE_DOS 6U

// LED colors
#define LED_RED 0U
Expand Down
Loading

0 comments on commit 49619bc

Please sign in to comment.