Skip to content

Commit

Permalink
Remove non-EON panda build (commaai#671)
Browse files Browse the repository at this point in the history
* Remove non-EON panda build

* missed that

* fixup readme

* more readme

* simplify ci

* add USB command to disable heartbeat checks in debug mode

* clean that up too

* more cleanup

* fix path

* disable heartbeat in set_safety_mode

* more red

* remove one more EON ref
  • Loading branch information
adeebshihadeh authored Jun 21, 2021
1 parent 4c57ebd commit 78c2498
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 216 deletions.
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ RUN pip install --upgrade pip==18.0
COPY requirements.txt /tmp/
RUN pip install -r /tmp/requirements.txt

RUN mkdir -p /home/batman
ENV HOME /home/batman

ENV PYTHONPATH /tmp:$PYTHONPATH

RUN cd /tmp && git clone https://github.com/commaai/panda_jungle.git
Expand Down
44 changes: 9 additions & 35 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
pipeline {
agent any
environment {
AUTHOR = """${sh(
returnStdout: true,
script: "git --no-pager show -s --format='%an' ${GIT_COMMIT}"
).trim()}"""

DOCKER_IMAGE_TAG = "panda:build-${env.GIT_COMMIT}"
DOCKER_NAME = "panda-test-${env.GIT_COMMIT}"
}
stages {
stage('Build Docker Image') {
Expand All @@ -20,41 +14,21 @@ pipeline {
}
}
}
stage('Test Dev Build') {
stage('HITL tests') {
steps {
lock(resource: "Pandas", inversePrecedence: true, quantity: 1){
timeout(time: 60, unit: 'MINUTES') {
lock(resource: "pandas", inversePrecedence: true, quantity: 1) {
timeout(time: 20, unit: 'MINUTES') {
script {
sh "docker run --name ${env.DOCKER_NAME} --privileged --volume /dev/bus/usb:/dev/bus/usb --volume /var/run/dbus:/var/run/dbus --net host ${env.DOCKER_IMAGE_TAG} bash -c 'cd /tmp/panda; scons; ./run_automated_tests.sh'"
sh "docker cp ${env.DOCKER_NAME}:/tmp/panda/nosetests.xml test_results_dev.xml"
sh "docker rm ${env.DOCKER_NAME}"
sh "docker run --rm --privileged \
--volume /dev/bus/usb:/dev/bus/usb \
--volume /var/run/dbus:/var/run/dbus \
--net host \
${env.DOCKER_IMAGE_TAG} \
bash -c 'cd /tmp/panda && scons && ./tests/automated/test.sh'"
}
}
}
}
}
stage('Test EON Build') {
steps {
lock(resource: "Pandas", inversePrecedence: true, quantity: 1){
timeout(time: 60, unit: 'MINUTES') {
script {
sh "docker run --name ${env.DOCKER_NAME} --privileged --volume /dev/bus/usb:/dev/bus/usb --volume /var/run/dbus:/var/run/dbus --net host ${env.DOCKER_IMAGE_TAG} bash -c 'touch /EON; cd /tmp/panda; scons; ./run_automated_tests.sh'"
sh "docker cp ${env.DOCKER_NAME}:/tmp/panda/nosetests.xml test_results_eon.xml"
sh "docker rm ${env.DOCKER_NAME}"
}
}
}
}
}
}
post {
failure {
script {
sh "docker rm ${env.DOCKER_NAME} || true"
}
}
always {
junit "test_results*.xml"
}
}
}
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ As a universal car interface, it should support every reasonable software interf

## Directory structure

- board -- Code that runs on the STM32
- drivers -- Drivers (not needed for use with python)
- python   -- Python userspace library for interfacing with the panda
- tests -- Tests and helper programs for panda
```
.
├── board # Code that runs on the STM32
├── drivers # Drivers (not needed for use with python)
├── python # Python userspace library for interfacing with the panda
├── tests # Tests and helper programs for panda
```

## Programming

Expand All @@ -79,20 +82,19 @@ Safety modes optionally supports `controls_allowed`, which allows or blocks a su

## Code Rigor

When compiled from a comma device, the panda FW is configured and optimized (at compile time) for its use in
conjuction with [openpilot](https://github.com/commaai/openpilot). The panda FW, through its safety model, provides and enforces the
The panda firmware is written for its use in conjuction with [openpilot](https://github.com/commaai/openpilot). The panda firmware, 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://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.
* Compiler options are relatively strict: the flags `-Wall -Wextra -Wstrict-prototypes -Werror` are enforced.
* The [safety logic](https://github.com/commaai/panda/tree/master/board/safety) is tested and verified by [unit tests](https://github.com/commaai/panda/tree/master/tests/safety) for each supported car variant.
* A recorded drive for each supported car variant is [replayed through the safety logic](https://github.com/commaai/panda/tree/master/tests/safety_replay)
to ensure that the behavior remains unchanged.
* An internal Hardware-in-the-loop test, which currently only runs on pull requests opened by comma.ai's organization members, verifies the following functionalities:
* compiling the code in various configuration and flashing it both through USB.
* Receiving, sending and forwarding CAN messages on all buses, over USB.
* compiling the code and flashing it through USB.
* receiving, sending, and forwarding CAN messages on all buses, over USB.

In addition, we run the [pylint](https://www.pylint.org/) and [flake8](https://github.com/PyCQA/flake8) linters on all python files within the panda repo.

Expand Down
8 changes: 0 additions & 8 deletions board/SConscript
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import os
import subprocess

EON = os.path.isfile('/EON')
TICI = os.path.isfile('/TICI')
PC = not (EON or TICI)

PREFIX = "arm-none-eabi-"
BUILDER = "DEV"

Expand Down Expand Up @@ -36,10 +32,6 @@ else:
"-g",
]

if not PC:
PROJECT_FLAGS += ["-DEON"]
BUILDER = "EON"


def get_version(builder, build_type):
version_file = File('../VERSION').srcnode().abspath
Expand Down
72 changes: 1 addition & 71 deletions board/boards/white.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@ void white_set_gps_mode(uint8_t mode) {
set_gpio_output(GPIOC, 14, 0);
set_gpio_output(GPIOC, 5, 0);
break;
#ifndef EON
case GPS_ENABLED:
// ESP ON
set_gpio_output(GPIOC, 14, 1);
set_gpio_output(GPIOC, 5, 1);
break;
#endif
case GPS_BOOTMODE:
set_gpio_output(GPIOC, 14, 1);
set_gpio_output(GPIOC, 5, 0);
Expand Down Expand Up @@ -158,71 +151,8 @@ uint32_t white_read_current(void){
return adc_get(ADCCHAN_CURRENT);
}

uint32_t marker = 0;
void white_usb_power_mode_tick(uint32_t uptime){

// on EON or BOOTSTUB, no state machine
#if !defined(BOOTSTUB) && !defined(EON)
#define CURRENT_THRESHOLD 0xF00U
#define CLICKS 5U // 5 seconds to switch modes

uint32_t current = white_read_current();

// ~0x9a = 500 ma
// puth(current); puts("\n");

switch (usb_power_mode) {
case USB_POWER_CLIENT:
if ((uptime - marker) >= CLICKS) {
if (!is_enumerated) {
puts("USBP: didn't enumerate, switching to CDP mode\n");
// switch to CDP
white_set_usb_power_mode(USB_POWER_CDP);
marker = uptime;
}
}
// keep resetting the timer if it's enumerated
if (is_enumerated) {
marker = uptime;
}
break;
case USB_POWER_CDP:
// been CLICKS clicks since we switched to CDP
if ((uptime - marker) >= CLICKS) {
// measure current draw, if positive and no enumeration, switch to DCP
if (!is_enumerated && (current < CURRENT_THRESHOLD)) {
puts("USBP: no enumeration with current draw, switching to DCP mode\n");
white_set_usb_power_mode(USB_POWER_DCP);
marker = uptime;
}
}
// keep resetting the timer if there's no current draw in CDP
if (current >= CURRENT_THRESHOLD) {
marker = uptime;
}
break;
case USB_POWER_DCP:
// been at least CLICKS clicks since we switched to DCP
if ((uptime - marker) >= CLICKS) {
// if no current draw, switch back to CDP
if (current >= CURRENT_THRESHOLD) {
puts("USBP: no current draw, switching back to CDP mode\n");
white_set_usb_power_mode(USB_POWER_CDP);
marker = uptime;
}
}
// keep resetting the timer if there's current draw in DCP
if (current < CURRENT_THRESHOLD) {
marker = uptime;
}
break;
default:
puts("USB power mode invalid\n"); // set_usb_power_mode prevents assigning invalid values
break;
}
#else
UNUSED(uptime);
#endif
}

void white_set_ir_power(uint8_t percentage){
Expand Down Expand Up @@ -313,7 +243,7 @@ void white_grey_common_init(void) {
// Init usb power mode
uint32_t voltage = adc_get_voltage();
// Init in CDP mode only if panda is powered by 12V.
// Otherwise a PC would not be able to flash a standalone panda with EON build
// Otherwise a PC would not be able to flash a standalone panda
if (voltage > 8000U) { // 8V threshold
white_set_usb_power_mode(USB_POWER_CDP);
} else {
Expand Down
Loading

0 comments on commit 78c2498

Please sign in to comment.