Skip to content
Closed
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
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export GIT_BRANCH=${env.GIT_BRANCH}
export GIT_COMMIT=${env.GIT_COMMIT}
export PYTHONPATH=${env.TEST_DIR}/../
export PYTHONWARNINGS=error
ln -sf /data/openpilot/opendbc_repo/opendbc /data/opendbc
ln -sf /data/openpilot/opendbc_repo /data/opendbc

cd ${env.TEST_DIR} || true
${cmd}
Expand Down
3 changes: 2 additions & 1 deletion SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def build_project(project_name, project, extra_flags):
'..',
panda_root,
f"{panda_root}/board/",
f"{panda_root}/../opendbc/safety/",
f"{panda_root}/../opendbc",
f"{panda_root}/../opendbc/safety",
]

env = Environment(
Expand Down
7 changes: 4 additions & 3 deletions board/can.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once
#include "can_declarations.h"
#include "safety/board/can.h"

#define CANPACKET_HEAD_SIZE 6U
#define CAN_PACKET_VERSION 4

static const uint8_t PANDA_CAN_CNT = 3U;
static const uint8_t PANDA_BUS_CNT = 3U;

static const unsigned char dlc_to_len[] = {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 12U, 16U, 20U, 24U, 32U, 48U, 64U};
29 changes: 0 additions & 29 deletions board/can_declarations.h

This file was deleted.

2 changes: 1 addition & 1 deletion board/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
#else
// TODO: uncomment this, cppcheck complains
// building for tests
//#include "fake_stm.h"
//#include "fake_stm_panda.h"
#endif
20 changes: 2 additions & 18 deletions board/drivers/can_common.h → board/drivers/can_common_panda.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "can_common_declarations.h"
#include "can_common_panda_declarations.h"
#include "safety/board/drivers/can_common.h"

uint32_t safety_tx_blocked = 0;
uint32_t safety_rx_invalid = 0;
Expand Down Expand Up @@ -219,23 +220,6 @@ bool can_tx_check_min_slots_free(uint32_t min) {
(can_slots_empty(&can_tx3_q) >= min);
}

uint8_t calculate_checksum(const uint8_t *dat, uint32_t len) {
uint8_t checksum = 0U;
for (uint32_t i = 0U; i < len; i++) {
checksum ^= dat[i];
}
return checksum;
}

void can_set_checksum(CANPacket_t *packet) {
packet->checksum = 0U;
packet->checksum = calculate_checksum((uint8_t *) packet, CANPACKET_HEAD_SIZE + GET_LEN(packet));
}

bool can_check_checksum(CANPacket_t *packet) {
return (calculate_checksum((uint8_t *) packet, CANPACKET_HEAD_SIZE + GET_LEN(packet)) == 0U);
}

void can_send(CANPacket_t *to_push, uint8_t bus_number, bool skip_tx_hook) {
if (skip_tx_hook || safety_tx_hook(to_push) != 0) {
if (bus_number < PANDA_BUS_CNT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ void can_set_forwarding(uint8_t from, uint8_t to);
#endif
void ignition_can_hook(CANPacket_t *to_push);
bool can_tx_check_min_slots_free(uint32_t min);
uint8_t calculate_checksum(const uint8_t *dat, uint32_t len);
void can_set_checksum(CANPacket_t *packet);
bool can_check_checksum(CANPacket_t *packet);
void can_send(CANPacket_t *to_push, uint8_t bus_number, bool skip_tx_hook);
bool is_speed_valid(uint32_t speed, const uint32_t *all_speeds, uint8_t len);
35 changes: 0 additions & 35 deletions board/fake_stm.h

This file was deleted.

13 changes: 13 additions & 0 deletions board/fake_stm_panda.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// minimal code to fake a panda for tests
#pragma once
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "safety/board/fake_stm.h"

#define CANFD

#define ENTER_CRITICAL() 0
#define EXIT_CRITICAL() 0

typedef uint32_t GPIO_TypeDef;
1 change: 1 addition & 0 deletions board/faults.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "faults_declarations.h"
#include "safety/board/faults_declarations.h"

uint8_t fault_status = FAULT_STATUS_NONE;
uint32_t faults = 0U;
Expand Down
14 changes: 0 additions & 14 deletions board/faults_declarations.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#pragma once

#define FAULT_STATUS_NONE 0U
#define FAULT_STATUS_TEMPORARY 1U
#define FAULT_STATUS_PERMANENT 2U

// Fault types, matches cereal.log.PandaState.FaultType
#define FAULT_RELAY_MALFUNCTION (1UL << 0)
#define FAULT_UNUSED_INTERRUPT_HANDLED (1UL << 1)
#define FAULT_INTERRUPT_RATE_CAN_1 (1UL << 2)
#define FAULT_INTERRUPT_RATE_CAN_2 (1UL << 3)
Expand Down Expand Up @@ -33,12 +28,3 @@
#define FAULT_SIREN_MALFUNCTION (1UL << 25)
#define FAULT_HEARTBEAT_LOOP_WATCHDOG (1UL << 26)
#define FAULT_INTERRUPT_RATE_SOUND_DMA (1UL << 27)

// Permanent faults
#define PERMANENT_FAULTS 0U

extern uint8_t fault_status;
extern uint32_t faults;

void fault_occurred(uint32_t fault);
void fault_recovered(uint32_t fault);
4 changes: 2 additions & 2 deletions board/jungle/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ********************* Includes *********************
#include "board/config.h"

#include "safety.h"
#include "safety/safety.h"

#include "board/drivers/led.h"
#include "board/drivers/pwm.h"
Expand All @@ -13,7 +13,7 @@
#include "board/health.h"
#include "jungle_health.h"

#include "board/drivers/can_common.h"
#include "board/drivers/can_common_panda.h"

#ifdef STM32H7
#include "board/drivers/fdcan.h"
Expand Down
4 changes: 2 additions & 2 deletions board/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include "early_init.h"
#include "provision.h"

#include "safety.h"
#include "safety/safety.h"

#include "health.h"

#include "drivers/can_common.h"
#include "drivers/can_common_panda.h"

#ifdef STM32H7
#include "drivers/fdcan.h"
Expand Down
2 changes: 1 addition & 1 deletion board/stm32f4/stm32f4_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "libc.h"
#include "critical.h"
#include "faults.h"
#include "utils.h"
#include "safety/board/utils.h"

#include "drivers/registers.h"
#include "drivers/interrupts.h"
Expand Down
2 changes: 1 addition & 1 deletion board/stm32h7/stm32h7_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ separate IRQs for RX and TX.
#include "libc.h"
#include "critical.h"
#include "faults.h"
#include "utils.h"
#include "safety/board/utils.h"

#include "drivers/registers.h"
#include "drivers/interrupts.h"
Expand Down
47 changes: 0 additions & 47 deletions board/utils.h

This file was deleted.

6 changes: 5 additions & 1 deletion tests/libpanda/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ env = Environment(
'-Wfatal-errors',
'-Wno-pointer-to-int-cast',
],
CPPPATH=[".", "../../board/", "../../../opendbc/safety/"],
CPPPATH=[
".",
"../../board/",
"../../../opendbc/",
"../../../opendbc/safety/"],
)
if system == "Darwin":
env.PrependENVPath('PATH', '/opt/homebrew/bin')
Expand Down
6 changes: 3 additions & 3 deletions tests/libpanda/panda.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "fake_stm.h"
#include "fake_stm_panda.h"
#include "config.h"
#include "can.h"

Expand All @@ -15,9 +15,9 @@ void can_tx_comms_resume_spi(void) { };
#include "faults.h"
#include "libc.h"
#include "boards/board_declarations.h"
#include "safety.h"
#include "safety/safety.h"
#include "main_definitions.h"
#include "drivers/can_common.h"
#include "drivers/can_common_panda.h"

can_ring *rx_q = &can_rx_q;
can_ring *tx1_q = &can_tx1_q;
Expand Down
4 changes: 2 additions & 2 deletions tests/misra/checkers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Cppcheck checkers list from test_misra.sh:


TEST variant options:
--enable=all --disable=unusedFunction -DPANDA --addon=misra -DSTM32F4 -DSTM32F413xx /board/main.c
--enable=all --disable=unusedFunction -DPANDA --addon=misra -I /../opendbc -I /../opendbc/safety/ -DSTM32F4 -DSTM32F413xx /board/main.c


Critical errors
Expand Down Expand Up @@ -460,7 +460,7 @@ Not available, Cppcheck Premium is not used


TEST variant options:
--enable=all --disable=unusedFunction -DPANDA --addon=misra -DSTM32H7 -DSTM32H725xx /board/main.c
--enable=all --disable=unusedFunction -DPANDA --addon=misra -I /../opendbc -I /../opendbc/safety/ -DSTM32H7 -DSTM32H725xx /board/main.c


Critical errors
Expand Down
2 changes: 1 addition & 1 deletion tests/misra/test_misra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ cppcheck() {
fi
}

PANDA_OPTS="--enable=all --disable=unusedFunction -DPANDA --addon=misra"
PANDA_OPTS="--enable=all --disable=unusedFunction -DPANDA --addon=misra -I $PANDA_DIR/../opendbc -I $PANDA_DIR/../opendbc/safety/ "

printf "\n${GREEN}** PANDA F4 CODE **${NC}\n"
cppcheck $PANDA_OPTS -DSTM32F4 -DSTM32F413xx $PANDA_DIR/board/main.c
Expand Down
Loading