Skip to content

Commit

Permalink
fix warnings in board build
Browse files Browse the repository at this point in the history
  • Loading branch information
geohot committed May 2, 2017
1 parent 1db815a commit 8f859ce
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions board/bootstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion board/build.mk
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions board/early.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 7 additions & 6 deletions board/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions board/spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions board/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crypto/rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions crypto/sha.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down

0 comments on commit 8f859ce

Please sign in to comment.