Skip to content

Commit

Permalink
Merge remote-tracking branch 'comma/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
rav4kumar committed Feb 26, 2024
2 parents 1dc62c6 + 0c7d5f1 commit 30fdf0c
Show file tree
Hide file tree
Showing 98 changed files with 609 additions and 10,450 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: eval "$BUILD"
- name: Test python package installer
run: ${{ env.RUN }} "python setup.py install"
- name: Build panda + pedal images and bootstub
- name: Build panda images and bootstub
run: ${{ env.RUN }} "scons -j4"
- name: Build panda with SPI support
run: ${{ env.RUN }} "ENABLE_SPI=1 scons -j4"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ repos:
additional_dependencies: ['git+https://github.com/numpy/numpy-stubs', 'types-requests', 'types-atomicwrites',
'types-pycurl']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.2.2
hooks:
- id: ruff
13 changes: 3 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pipeline {
["build", "scons -j4"],
["flash", "cd tests/ && ./reflash_internal_panda.py"],
["flash jungle", "cd board/jungle && ./flash.py"],
["test", "cd tests/hitl && HW_TYPES=6 pytest --durations=0 [2-7]*.py -k 'not test_send_recv'"],
["test", "cd tests/hitl && HW_TYPES=6 pytest -n0 --durations=0 [2-7]*.py -k 'not test_send_recv'"],
])
}
}
Expand All @@ -94,7 +94,7 @@ pipeline {
["build", "scons -j4"],
["flash", "cd tests/ && ./reflash_internal_panda.py"],
["flash jungle", "cd board/jungle && ./flash.py"],
["test", "cd tests/hitl && HW_TYPES=9 pytest --durations=0 2*.py [5-9]*.py"],
["test", "cd tests/hitl && HW_TYPES=9 pytest -n0 --durations=0 2*.py [5-9]*.py"],
])
}
}
Expand Down Expand Up @@ -126,19 +126,12 @@ pipeline {
stage('bootkick tests') {
steps {
script {
docker_run("test", 10, "pytest ./tests/som/test_bootkick.py")
docker_run("test", 10, "pytest -n0 ./tests/som/test_bootkick.py")
}
}
}

/*
stage('pedal tests') {
steps {
script {
docker_run("test pedal", 1, "PEDAL_JUNGLE=058010800f51363038363036 python ./tests/pedal/test_pedal.py")
}
}
}
stage('HITL tests') {
steps {
script {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![panda tests](https://github.com/commaai/panda/workflows/tests/badge.svg)
![panda drivers](https://github.com/commaai/panda/workflows/drivers/badge.svg)

panda speaks CAN and CAN FD, and it runs on [STM32F205](https://www.st.com/resource/en/reference_manual/rm0033-stm32f205xx-stm32f207xx-stm32f215xx-and-stm32f217xx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf), [STM32F413](https://www.st.com/resource/en/reference_manual/rm0430-stm32f413423-advanced-armbased-32bit-mcus-stmicroelectronics.pdf), and [STM32H725](https://www.st.com/resource/en/reference_manual/rm0468-stm32h723733-stm32h725735-and-stm32h730-value-line-advanced-armbased-32bit-mcus-stmicroelectronics.pdf).
panda speaks CAN and CAN FD, and it runs on [STM32F413](https://www.st.com/resource/en/reference_manual/rm0430-stm32f413423-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) and [STM32H725](https://www.st.com/resource/en/reference_manual/rm0468-stm32h723733-stm32h725735-and-stm32h730-value-line-advanced-armbased-32bit-mcus-stmicroelectronics.pdf).

## Directory structure

Expand Down
3 changes: 0 additions & 3 deletions SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ with open("board/obj/cert.h", "w") as f:
# panda fw
SConscript('board/SConscript')

# pedal fw
SConscript('board/pedal/SConscript')

# panda jungle fw
SConscript('board/jungle/SConscript')

Expand Down
2 changes: 1 addition & 1 deletion board/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for project_name, project in build_projects.items():
flags = [
"-DPANDA",
]
if ("ENABLE_SPI" in os.environ or "h7" in project_name) and not project_name.startswith('pedal'):
if ("ENABLE_SPI" in os.environ or "h7" in project_name):
flags.append('-DENABLE_SPI')

if "H723" in os.environ:
Expand Down
4 changes: 0 additions & 4 deletions board/boards/dos.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ bool dos_check_ignition(void){
return harness_check_ignition();
}

void dos_set_usb_switch(bool phone){
set_gpio_output(GPIOB, 3, phone);
}

void dos_set_ir_power(uint8_t percentage){
pwm_set(TIM4, 2, percentage);
}
Expand Down
93 changes: 0 additions & 93 deletions board/boards/pedal.h

This file was deleted.

4 changes: 0 additions & 4 deletions board/boards/unused_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ void unused_set_siren(bool enabled) {
UNUSED(enabled);
}

uint32_t unused_read_voltage(void) {
return 0U;
}

uint32_t unused_read_current(void) {
return 0U;
}
Expand Down
1 change: 1 addition & 0 deletions board/bootstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "obj/gitversion.h"
#include "flasher.h"

// cppcheck-suppress unusedFunction ; used in headers not included in cppcheck
void __initialize_hardware_early(void) {
early_initialization();
}
Expand Down
4 changes: 1 addition & 3 deletions board/can_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ const uint8_t PANDA_BUS_CNT = 4U;

#define CANPACKET_HEAD_SIZE 6U

#if !defined(STM32F4) && !defined(STM32F2)
#if !defined(STM32F4)
#define CANFD
#define CANPACKET_DATA_SIZE_MAX 64U
#else
#define CANPACKET_DATA_SIZE_MAX 8U
#endif

#ifndef STM32F2
typedef struct {
unsigned char reserved : 1;
unsigned char bus : 3;
Expand All @@ -27,7 +26,6 @@ typedef struct {
unsigned char checksum;
unsigned char data[CANPACKET_DATA_SIZE_MAX];
} __attribute__((packed, aligned(4))) CANPacket_t;
#endif

const unsigned char dlc_to_len[] = {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 12U, 16U, 20U, 24U, 32U, 48U, 64U};

Expand Down
2 changes: 1 addition & 1 deletion board/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// platform includes
#ifdef STM32H7
#include "stm32h7/stm32h7_config.h"
#elif defined(STM32F2) || defined(STM32F4)
#elif defined(STM32F4)
#include "stm32fx/stm32fx_config.h"
#else
// TODO: uncomment this, cppcheck complains
Expand Down
4 changes: 2 additions & 2 deletions board/drivers/can_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ extern int can_live;
extern int pending_can_live;

// must reinit after changing these
extern int can_loopback;
extern int can_silent;
extern bool can_loopback;

// Ignition detected from CAN meessages
bool ignition_can = false;
Expand All @@ -40,8 +40,8 @@ uint32_t ignition_can_cnt = 0U;

int can_live = 0;
int pending_can_live = 0;
int can_loopback = 0;
int can_silent = ALL_CAN_SILENT;
bool can_loopback = false;

// ******************* functions prototypes *********************
bool can_init(uint8_t can_number);
Expand Down
2 changes: 1 addition & 1 deletion board/drivers/fdcan.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void process_can(uint8_t can_number) {
to_push.rejected = 0U;
to_push.extended = to_send.extended;
to_push.addr = to_send.addr;
to_push.bus = to_send.bus;
to_push.bus = bus_number;
to_push.data_len_code = to_send.data_len_code;
(void)memcpy(to_push.data, to_send.data, dlc_to_len[to_push.data_len_code]);
can_set_checksum(&to_push);
Expand Down
30 changes: 2 additions & 28 deletions board/drivers/gmlan_alt.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ int do_bitstuff(char *out, const char *in, int in_len) {
bit_cnt++;
if (bit_cnt == 5) {
// 5 in a row the same, do stuff
last_bit = !bit;
last_bit = !bit ? 1 : 0;
out[j] = last_bit;
j++;
bit_cnt = 1;
}
} else {
// this is a new bit
last_bit = bit;
last_bit = (int)bit;
bit_cnt = 1;
}
}
Expand Down Expand Up @@ -147,32 +147,6 @@ int inverted_bit_to_send = GMLAN_HIGH;
int gmlan_switch_below_timeout = -1;
int gmlan_switch_timeout_enable = 0;

void gmlan_switch_init(int timeout_enable) {
gmlan_switch_timeout_enable = timeout_enable;
gmlan_alt_mode = GPIO_SWITCH;
gmlan_switch_below_timeout = 1;
set_gpio_mode(GPIOB, 13, MODE_OUTPUT);

setup_timer();

inverted_bit_to_send = GMLAN_LOW; //We got initialized, set the output low
}

void set_gmlan_digital_output(int to_set) {
inverted_bit_to_send = to_set;
/*
print("Writing ");
puth(inverted_bit_to_send);
print("\n");
*/
}

void reset_gmlan_switch_timeout(void) {
can_timeout_counter = GMLAN_TICKS_PER_SECOND;
gmlan_switch_below_timeout = 1;
gmlan_alt_mode = GPIO_SWITCH;
}

void set_bitbanged_gmlan(int val) {
if (val != 0) {
register_set_bits(&(GPIOB->ODR), (1UL << 13));
Expand Down
4 changes: 2 additions & 2 deletions board/drivers/interrupts.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ void interrupt_timer_handler(void) {

// Calculate interrupt load
// The bootstub does not have the FPU enabled, so can't do float operations.
#if !defined(PEDAL) && !defined(BOOTSTUB)
interrupt_load = ((busy_time + idle_time) > 0U) ? ((float) busy_time) / (busy_time + idle_time) : 0.0f;
#if !defined(BOOTSTUB)
interrupt_load = ((busy_time + idle_time) > 0U) ? ((float) (((float) busy_time) / (busy_time + idle_time))) : 0.0f;
#endif
idle_time = 0U;
busy_time = 0U;
Expand Down
15 changes: 0 additions & 15 deletions board/drivers/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,6 @@ bool put_char(uart_ring *q, char elem) {
return ret;
}

// Seems dangerous to use (might lock CPU if called with interrupts disabled f.e.)
// TODO: Remove? Not used anyways
void uart_flush(const uart_ring *q) {
while (q->w_ptr_tx != q->r_ptr_tx) {
__WFI();
}
}

void uart_flush_sync(uart_ring *q) {
// empty the TX buffer
while (q->w_ptr_tx != q->r_ptr_tx) {
uart_tx_ring(q);
}
}

void clear_uart_buff(uart_ring *q) {
ENTER_CRITICAL();
q->w_ptr_tx = 0;
Expand Down
11 changes: 3 additions & 8 deletions board/drivers/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,8 @@ uint16_t string_product_desc[] = {

// default serial number when we're not a panda
uint16_t string_serial_desc[] = {
#ifdef PEDAL
STRING_DESCRIPTOR_HEADER(5),
'p', 'e', 'd', 'a', 'l'
#else
STRING_DESCRIPTOR_HEADER(4),
'n', 'o', 'n', 'e'
#endif
};

// a string containing the default configuration index
Expand Down Expand Up @@ -466,12 +461,12 @@ void usb_reset(void) {
USBx_OUTEP(0)->DOEPTSIZ = USB_OTG_DOEPTSIZ_STUPCNT | (USB_OTG_DOEPTSIZ_PKTCNT & (1UL << 19)) | (3U << 3);
}

char to_hex_char(int a) {
char to_hex_char(uint8_t a) {
char ret;
if (a < 10) {
if (a < 10U) {
ret = '0' + a;
} else {
ret = 'a' + (a - 10);
ret = 'a' + (a - 10U);
}
return ret;
}
Expand Down
6 changes: 0 additions & 6 deletions board/drivers/watchdog.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// TODO: why doesn't it define these?
#ifdef STM32F2
#define IWDG_PR_PR_Msk 0x7U
#define IWDG_RLR_RL_Msk 0xFFFU
#endif

typedef enum {
WATCHDOG_50_MS = (400U - 1U),
WATCHDOG_500_MS = 4000U,
Expand Down
Loading

0 comments on commit 30fdf0c

Please sign in to comment.