mirror of https://github.com/commaai/panda.git
fix warnings in board build
This commit is contained in:
parent
1db815a7ac
commit
8f859ceec6
|
@ -37,11 +37,11 @@ int main() {
|
|||
clock_init();
|
||||
|
||||
// validate length
|
||||
int len = _app_start[0];
|
||||
int len = (int)_app_start[0];
|
||||
if (len < 8) fail();
|
||||
|
||||
// compute SHA hash
|
||||
char digest[SHA_DIGEST_SIZE];
|
||||
uint8_t digest[SHA_DIGEST_SIZE];
|
||||
SHA_hash(&_app_start[1], len-4, digest);
|
||||
|
||||
// verify RSA signature
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CFLAGS += -I inc -I ../ -nostdlib
|
||||
CFLAGS += -I inc -I ../ -nostdlib -fno-builtin
|
||||
CFLAGS += -Tstm32_flash.ld
|
||||
|
||||
CC = arm-none-eabi-gcc
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
extern uint32_t enter_bootloader_mode;
|
||||
extern void *_app_start[];
|
||||
void *g_pfnVectors;
|
||||
void spi_flasher();
|
||||
|
||||
int has_external_debug_serial = 0;
|
||||
int is_giant_panda = 0;
|
||||
|
|
13
board/main.c
13
board/main.c
|
@ -97,6 +97,7 @@ typedef struct uart_ring {
|
|||
void (*callback)(struct uart_ring*);
|
||||
} uart_ring;
|
||||
|
||||
inline int getc(uart_ring *q, char *elem);
|
||||
inline int putc(uart_ring *q, char elem);
|
||||
|
||||
// esp = USART1
|
||||
|
@ -141,7 +142,7 @@ void accord_framing_callback(uart_ring *q) {
|
|||
int sof1 = -1;
|
||||
int sof2 = -1;
|
||||
int i;
|
||||
uint8_t junk;
|
||||
char junk;
|
||||
int jlen = 0;
|
||||
int plen = 0;
|
||||
while (q->w_ptr_rx != r_ptr_rx_tmp) {
|
||||
|
@ -189,7 +190,7 @@ void accord_framing_callback(uart_ring *q) {
|
|||
|
||||
// get data from queue
|
||||
for (i = 0; i < plen; i++) {
|
||||
getc(q, &(((uint8_t*)(&to_push.RDLR))[i]));
|
||||
getc(q, &(((char*)(&to_push.RDLR))[i]));
|
||||
}
|
||||
|
||||
push(&can_rx_q, &to_push);
|
||||
|
@ -511,7 +512,6 @@ void usb_cb_ep3_out(uint8_t *usbdata, int len, int hardwired) {
|
|||
if (safety_tx_hook(&to_push, hardwired)) {
|
||||
CAN_TypeDef *CAN;
|
||||
can_ring *can_q;
|
||||
int can_number;
|
||||
if (flags == can_numbering[0]) {
|
||||
CAN = CAN1;
|
||||
can_q = &can_tx1_q;
|
||||
|
@ -562,11 +562,12 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
|
|||
case 0xd0:
|
||||
// fetch serial number
|
||||
#ifdef PANDA
|
||||
// addresses are OTP
|
||||
if (setup->b.wValue.w == 1) {
|
||||
memcpy(resp, 0x1fff79c0, 0x10);
|
||||
memcpy(resp, (void *)0x1fff79c0, 0x10);
|
||||
resp_len = 0x10;
|
||||
} else {
|
||||
memcpy(resp, 0x1fff79e0, 0x20);
|
||||
memcpy(resp, (void *)0x1fff79e0, 0x20);
|
||||
resp_len = 0x20;
|
||||
}
|
||||
#endif
|
||||
|
@ -625,7 +626,7 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
|
|||
ur = get_ring_by_number(setup->b.wValue.w);
|
||||
if (!ur) break;
|
||||
// read
|
||||
while (resp_len < min(setup->b.wLength.w, MAX_RESP_LEN) && getc(ur, &resp[resp_len])) {
|
||||
while (resp_len < min(setup->b.wLength.w, MAX_RESP_LEN) && getc(ur, (char*)&resp[resp_len])) {
|
||||
++resp_len;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -13,9 +13,9 @@ void spi_tx_dma(void *addr, int len) {
|
|||
DMA2_Stream3->CR &= ~DMA_SxCR_EN;
|
||||
|
||||
// DMA2, stream 3, channel 3
|
||||
DMA2_Stream3->M0AR = addr;
|
||||
DMA2_Stream3->M0AR = (uint32_t)addr;
|
||||
DMA2_Stream3->NDTR = len;
|
||||
DMA2_Stream3->PAR = &(SPI1->DR);
|
||||
DMA2_Stream3->PAR = (uint32_t)&(SPI1->DR);
|
||||
|
||||
// channel3, increment memory, memory -> periph, enable
|
||||
DMA2_Stream3->CR = DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_EN;
|
||||
|
@ -31,11 +31,12 @@ void spi_rx_dma(void *addr, int len) {
|
|||
|
||||
// drain the bus
|
||||
uint8_t dat = SPI1->DR;
|
||||
(void)dat;
|
||||
|
||||
// DMA2, stream 2, channel 3
|
||||
DMA2_Stream2->M0AR = addr;
|
||||
DMA2_Stream2->M0AR = (uint32_t)addr;
|
||||
DMA2_Stream2->NDTR = len;
|
||||
DMA2_Stream2->PAR = &(SPI1->DR);
|
||||
DMA2_Stream2->PAR = (uint32_t)&(SPI1->DR);
|
||||
|
||||
// channel3, increment memory, periph -> memory, enable
|
||||
DMA2_Stream2->CR = DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0 | DMA_SxCR_MINC | DMA_SxCR_EN;
|
||||
|
|
|
@ -286,13 +286,13 @@ void usb_setup() {
|
|||
case USB_DESC_TYPE_STRING:
|
||||
switch (setup.b.wValue.bw.msb) {
|
||||
case 0:
|
||||
USB_WritePacket(string_0_desc, min(sizeof(string_0_desc), setup.b.wLength.w), 0);
|
||||
USB_WritePacket((uint8_t*)string_0_desc, min(sizeof(string_0_desc), setup.b.wLength.w), 0);
|
||||
break;
|
||||
case 1:
|
||||
USB_WritePacket(string_1_desc, min(sizeof(string_1_desc), setup.b.wLength.w), 0);
|
||||
USB_WritePacket((uint8_t*)string_1_desc, min(sizeof(string_1_desc), setup.b.wLength.w), 0);
|
||||
break;
|
||||
case 2:
|
||||
USB_WritePacket(string_2_desc, min(sizeof(string_2_desc), setup.b.wLength.w), 0);
|
||||
USB_WritePacket((uint8_t*)string_2_desc, min(sizeof(string_2_desc), setup.b.wLength.w), 0);
|
||||
break;
|
||||
case 3:
|
||||
#ifdef PANDA
|
||||
|
|
|
@ -226,7 +226,7 @@ int RSA_verify(const RSAPublicKey *key,
|
|||
const int hash_len) {
|
||||
uint8_t buf[RSANUMBYTES];
|
||||
int i;
|
||||
const uint8_t* padding_hash;
|
||||
//const uint8_t* padding_hash;
|
||||
|
||||
if (key->len != RSANUMWORDS) {
|
||||
return 0; // Wrong key passed in.
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
// Optimized for minimal code size.
|
||||
|
||||
void *memcpy(void *str1, const void *str2, unsigned int n);
|
||||
|
||||
#include "sha.h"
|
||||
|
||||
#define rol(bits, value) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||
|
|
Loading…
Reference in New Issue