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 Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN pip3 install --break-system-packages --no-cache-dir $PYTHONPATH/panda/[dev]

# 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="da0a5e3d2b3984b56ebf5e25d9769f5c77807e4d"
ENV OPENDBC_REF="d631299b8d49253fdeb5b709684af031ab1d18be"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be updated after commaai/opendbc#2248 lands

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/ && \
Expand Down
2 changes: 2 additions & 0 deletions SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def build_project(project_name, project, extra_flags):
'..',
panda_root,
f"{panda_root}/board/",
f"{panda_root}/../opendbc/",
f"{panda_root}/../opendbc/safety/",
f"{panda_root}/../opendbc/safety/board/",
]

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

// bump this when changing the CAN packet
#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.

20 changes: 3 additions & 17 deletions board/drivers/can_common.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "can_common_declarations.h"
#include "can.h"
#include "safety/board/drivers/can_common.h"
#include "safety/safety_declarations.h"

uint32_t safety_tx_blocked = 0;
uint32_t safety_rx_invalid = 0;
Expand Down Expand Up @@ -218,23 +221,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
1 change: 1 addition & 0 deletions board/drivers/registers.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "registers_declarations.h"
#include "safety/board/faults.h"

static reg register_map[REGISTER_MAP_SIZE];

Expand Down
2 changes: 1 addition & 1 deletion board/fake_stm.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdint.h>
#include <stdlib.h>

#include "utils.h"
#include "safety/board/utils.h"

#define CANFD
#define ALLOW_DEBUG
Expand Down
25 changes: 0 additions & 25 deletions board/faults.h

This file was deleted.

7 changes: 1 addition & 6 deletions board/faults_declarations.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "safety/board/faults_declarations.h"

#define FAULT_STATUS_NONE 0U
#define FAULT_STATUS_TEMPORARY 1U
Expand Down Expand Up @@ -36,9 +37,3 @@

// 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);
3 changes: 1 addition & 2 deletions board/jungle/main.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// ********************* Includes *********************
#include "board/config.h"

#include "safety.h"

#include "safety/safety.h"
#include "board/drivers/led.h"
#include "board/drivers/pwm.h"
#include "board/drivers/usb.h"
Expand Down
3 changes: 1 addition & 2 deletions board/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#include "early_init.h"
#include "provision.h"

#include "safety.h"

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

#include "drivers/can_common.h"
Expand Down
5 changes: 2 additions & 3 deletions board/stm32f4/stm32f4_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#define PROVISION_CHUNK_ADDRESS 0x1FFF79E0U
#define DEVICE_SERIAL_NUMBER_ADDRESS 0x1FFF79C0U

#include "can.h"
#include "comms_definitions.h"

#ifndef BOOTSTUB
Expand All @@ -41,8 +40,8 @@

#include "libc.h"
#include "critical.h"
#include "faults.h"
#include "utils.h"
#include "faults_declarations.h"
#include "safety/board/utils.h"

#include "drivers/registers.h"
#include "drivers/interrupts.h"
Expand Down
5 changes: 2 additions & 3 deletions board/stm32h7/stm32h7_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ separate IRQs for RX and TX.
#define PROVISION_CHUNK_ADDRESS 0x080FFFE0U
#define DEVICE_SERIAL_NUMBER_ADDRESS 0x080FFFC0U

#include "can.h"
#include "comms_definitions.h"

#ifndef BOOTSTUB
Expand All @@ -54,8 +53,8 @@ separate IRQs for RX and TX.

#include "libc.h"
#include "critical.h"
#include "faults.h"
#include "utils.h"
#include "faults_declarations.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.

8 changes: 7 additions & 1 deletion tests/libpanda/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ env = Environment(
'-Wfatal-errors',
'-Wno-pointer-to-int-cast',
],
CPPPATH=[".", "../../board/", "../../../opendbc/safety/"],
CPPPATH=[
".",
"../../board/",
"../../../opendbc/",
"../../../opendbc/safety/",
"../../../opendbc/safety/board/",
],
)
if system == "Darwin":
env.PrependENVPath('PATH', '/opt/homebrew/bin')
Expand Down
5 changes: 3 additions & 2 deletions tests/libpanda/panda.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ void can_tx_comms_resume_usb(void) { };
void can_tx_comms_resume_spi(void) { };

#include "health.h"
#include "faults.h"
#include "faults_declarations.h"
#include "libc.h"
#include "boards/board_declarations.h"
#include "safety.h"
#include "safety/board/faults.h"
#include "safety/safety.h"
#include "main_definitions.h"
#include "drivers/can_common.h"

Expand Down
2 changes: 2 additions & 0 deletions tests/misra/test_misra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ cppcheck() {
$CPPCHECK_DIR/cppcheck --inline-suppr -I $PANDA_DIR/board/ \
-I "$(arm-none-eabi-gcc -print-file-name=include)" \
-I $PANDA_DIR/board/stm32f4/inc/ -I $PANDA_DIR/board/stm32h7/inc/ \
-I $PANDA_DIR/../opendbc/ \
-I $PANDA_DIR/../opendbc/safety/ \
-I $PANDA_DIR/../opendbc/safety/board/ \
--suppressions-list=$DIR/suppressions.txt --suppress=*:*inc/* \
--suppress=*:*include/* --error-exitcode=2 --check-level=exhaustive --safety \
--platform=arm32-wchar_t4 $COMMON_DEFINES --checkers-report=$CHECKLIST.tmp \
Expand Down
Loading