Skip to content

Commit

Permalink
pedal has a bootstub now
Browse files Browse the repository at this point in the history
  • Loading branch information
geohot committed Mar 9, 2018
1 parent 3662d1e commit 626e312
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
37 changes: 28 additions & 9 deletions board/pedal/Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
# :set noet
PROJ_NAME = comma

CFLAGS = -O2 -Wall -std=gnu11
CFLAGS = -O2 -Wall -std=gnu11 -DPEDAL
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m3
CFLAGS += -msoft-float -DSTM32F2 -DSTM32F205xx
CFLAGS += -I ../inc -I ../ -nostdlib
CFLAGS += -I ../inc -I ../ -I ../../ -nostdlib
CFLAGS += -T../stm32_flash.ld

STARTUP_FILE = startup_stm32f205xx

CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
OBJDUMP = arm-none-eabi-objdump
DFU_UTIL = "dfu-util"

# pedal only uses the debug cert
CERT = ../../certs/debug
CFLAGS += "-DALLOW_DEBUG"

all: obj/$(PROJ_NAME).bin
#$(OBJDUMP) -d obj/$(PROJ_NAME).elf
dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D $<
all: obj/bootstub.bin obj/$(PROJ_NAME).bin
$(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000 -D obj/$(PROJ_NAME).bin
$(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.bin

obj/main.o: main.c ../*.h
mkdir -p obj
$(CC) $(CFLAGS) -o $@ -c $<

obj/startup_stm32f205xx.o: ../startup_stm32f205xx.s
obj/bootstub.o: ../bootstub.c ../*.h
mkdir -p obj
$(CC) $(CFLAGS) -o $@ -c $<

obj/$(PROJ_NAME).bin: obj/startup_stm32f205xx.o obj/main.o
$(CC) $(CFLAGS) -o obj/$(PROJ_NAME).elf $^
$(OBJCOPY) -v -O binary obj/$(PROJ_NAME).elf $@
obj/$(STARTUP_FILE).o: ../$(STARTUP_FILE).s
$(CC) $(CFLAGS) -o $@ -c $<

obj/%.o: ../../crypto/%.c
$(CC) $(CFLAGS) -o $@ -c $<

obj/$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/main.o
# hack
$(CC) -Wl,--section-start,.isr_vector=0x8004000 $(CFLAGS) -o obj/$(PROJ_NAME).elf $^
$(OBJCOPY) -v -O binary obj/$(PROJ_NAME).elf obj/code.bin
SETLEN=1 ../../crypto/sign.py obj/code.bin $@ $(CERT)

obj/bootstub.bin: obj/$(STARTUP_FILE).o obj/bootstub.o obj/sha.o obj/rsa.o
$(CC) $(CFLAGS) -o obj/bootstub.$(PROJ_NAME).elf $^
$(OBJCOPY) -v -O binary obj/bootstub.$(PROJ_NAME).elf $@

clean:
rm -f obj/*
Expand Down
11 changes: 1 addition & 10 deletions board/pedal/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
//#define CAN_LOOPBACK_MODE
//#define USE_INTERNAL_OSC

#define PEDAL

#include "../config.h"

#include "drivers/drivers.h"
Expand Down Expand Up @@ -32,14 +30,7 @@
uint32_t enter_bootloader_mode;

void __initialize_hardware_early() {
if (enter_bootloader_mode == ENTER_BOOTLOADER_MAGIC) {
enter_bootloader_mode = 0;
void (*bootloader)(void) = (void (*)(void)) (*((uint32_t *)0x1fff0004));
bootloader();

// LOOP
while(1);
}
early();
}

// ********************* serial debugging *********************
Expand Down
1 change: 1 addition & 0 deletions tests/can_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def sec_since_boot():

def can_printer():
p = Panda()
p.set_safety_mode(0x1337)

start = sec_since_boot()
lp = sec_since_boot()
Expand Down

0 comments on commit 626e312

Please sign in to comment.