Skip to content

Commit

Permalink
remove pedal fw (commaai#1872)
Browse files Browse the repository at this point in the history
* remove pedal fw

* little more

* one more

* and tests

* rest of it

* little more

* fix linter

* more fix
  • Loading branch information
adeebshihadeh authored Feb 17, 2024
1 parent 39671c3 commit c076a9f
Show file tree
Hide file tree
Showing 32 changed files with 114 additions and 936 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
7 changes: 0 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,6 @@ pipeline {
}

/*
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
93 changes: 0 additions & 93 deletions board/boards/pedal.h

This file was deleted.

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
5 changes: 0 additions & 5 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
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
160 changes: 10 additions & 150 deletions board/flasher.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,19 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) {
break;
// **** 0xc3: fetch MCU UID
case 0xc3:
#ifdef UID_BASE
(void)memcpy(resp, ((uint8_t *)UID_BASE), 12);
resp_len = 12;
#endif
(void)memcpy(resp, ((uint8_t *)UID_BASE), 12);
resp_len = 12;
break;
// **** 0xd0: fetch serial number
case 0xd0:
#ifndef STM32F2
// addresses are OTP
if (req->param1 == 1) {
memcpy(resp, (void *)DEVICE_SERIAL_NUMBER_ADDRESS, 0x10);
resp_len = 0x10;
} else {
get_provision_chunk(resp);
resp_len = PROVISION_CHUNK_LEN;
}
#endif
// addresses are OTP
if (req->param1 == 1) {
memcpy(resp, (void *)DEVICE_SERIAL_NUMBER_ADDRESS, 0x10);
resp_len = 0x10;
} else {
get_provision_chunk(resp);
resp_len = PROVISION_CHUNK_LEN;
}
break;
// **** 0xd1: enter bootloader mode
case 0xd1:
Expand Down Expand Up @@ -147,149 +143,13 @@ int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out) {
return resp_len;
}

#ifdef PEDAL

#include "stm32fx/llbxcan.h"
#define CANx CAN1

#define CAN_BL_INPUT 0x1
#define CAN_BL_OUTPUT 0x2

void CAN1_TX_IRQ_Handler(void) {
// clear interrupt
CANx->TSR |= CAN_TSR_RQCP0;
}

#define ISOTP_BUF_SIZE 0x110

uint8_t isotp_buf[ISOTP_BUF_SIZE];
uint8_t *isotp_buf_ptr = NULL;
int isotp_buf_remain = 0;

uint8_t isotp_buf_out[ISOTP_BUF_SIZE];
uint8_t *isotp_buf_out_ptr = NULL;
int isotp_buf_out_remain = 0;
int isotp_buf_out_idx = 0;

void bl_can_send(uint8_t *odat) {
// wait for send
while (!(CANx->TSR & CAN_TSR_TME0));

// send continue
CANx->sTxMailBox[0].TDLR = ((uint32_t*)odat)[0];
CANx->sTxMailBox[0].TDHR = ((uint32_t*)odat)[1];
CANx->sTxMailBox[0].TDTR = 8;
CANx->sTxMailBox[0].TIR = (CAN_BL_OUTPUT << 21) | 1;
}

void CAN1_RX0_IRQ_Handler(void) {
while (CANx->RF0R & CAN_RF0R_FMP0) {
if ((CANx->sFIFOMailBox[0].RIR>>21) == CAN_BL_INPUT) {
uint8_t dat[8];
for (int i = 0; i < 8; i++) {
dat[i] = GET_MAILBOX_BYTE(&CANx->sFIFOMailBox[0], i);
}
uint8_t odat[8];
uint8_t type = dat[0] & 0xF0;
if (type == 0x30) {
// continue
while (isotp_buf_out_remain > 0) {
// wait for send
while (!(CANx->TSR & CAN_TSR_TME0));

odat[0] = 0x20 | isotp_buf_out_idx;
memcpy(odat+1, isotp_buf_out_ptr, 7);
isotp_buf_out_remain -= 7;
isotp_buf_out_ptr += 7;
isotp_buf_out_idx++;

bl_can_send(odat);
}
} else if (type == 0x20) {
if (isotp_buf_remain > 0) {
memcpy(isotp_buf_ptr, dat+1, 7);
isotp_buf_ptr += 7;
isotp_buf_remain -= 7;
}
if (isotp_buf_remain <= 0) {
int len = isotp_buf_ptr - isotp_buf + isotp_buf_remain;

// call the function
memset(isotp_buf_out, 0, ISOTP_BUF_SIZE);
isotp_buf_out_remain = spi_cb_rx(isotp_buf, len, isotp_buf_out);
isotp_buf_out_ptr = isotp_buf_out;
isotp_buf_out_idx = 0;

// send initial
if (isotp_buf_out_remain <= 7) {
odat[0] = isotp_buf_out_remain;
memcpy(odat+1, isotp_buf_out_ptr, isotp_buf_out_remain);
} else {
odat[0] = 0x10 | (isotp_buf_out_remain>>8);
odat[1] = isotp_buf_out_remain & 0xFF;
memcpy(odat+2, isotp_buf_out_ptr, 6);
isotp_buf_out_remain -= 6;
isotp_buf_out_ptr += 6;
isotp_buf_out_idx++;
}

bl_can_send(odat);
}
} else if (type == 0x10) {
int len = ((dat[0]&0xF)<<8) | dat[1];

// setup buffer
isotp_buf_ptr = isotp_buf;
memcpy(isotp_buf_ptr, dat+2, 6);

if (len < (ISOTP_BUF_SIZE-0x10)) {
isotp_buf_ptr += 6;
isotp_buf_remain = len-6;
}

memset(odat, 0, 8);
odat[0] = 0x30;
bl_can_send(odat);
}
}
// next
CANx->RF0R |= CAN_RF0R_RFOM0;
}
}

void CAN1_SCE_IRQ_Handler(void) {
llcan_clear_send(CANx);
}

#endif

void soft_flasher_start(void) {
#ifdef PEDAL
REGISTER_INTERRUPT(CAN1_TX_IRQn, CAN1_TX_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1)
REGISTER_INTERRUPT(CAN1_RX0_IRQn, CAN1_RX0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1)
REGISTER_INTERRUPT(CAN1_SCE_IRQn, CAN1_SCE_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1)
#endif

print("\n\n\n************************ FLASHER START ************************\n");

enter_bootloader_mode = 0;

flasher_peripherals_init();

// pedal has the canloader
#ifdef PEDAL
RCC->APB1ENR |= RCC_APB1ENR_CAN1EN;

// B8,B9: CAN 1
set_gpio_alternate(GPIOB, 8, GPIO_AF9_CAN1);
set_gpio_alternate(GPIOB, 9, GPIO_AF9_CAN1);
current_board->enable_can_transceiver(1, true);

// init can
llcan_set_speed(CANx, 5000, false, false);
llcan_init(CANx);
#endif

gpio_usart2_init();
gpio_usb_init();

Expand Down
1 change: 0 additions & 1 deletion board/pedal/.gitignore

This file was deleted.

Loading

0 comments on commit c076a9f

Please sign in to comment.