diff --git a/board/pedal/Makefile b/board/pedal/Makefile index ed0ccbd3b031fc..47431d9ed13a41 100644 --- a/board/pedal/Makefile +++ b/board/pedal/Makefile @@ -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/* diff --git a/board/pedal/main.c b/board/pedal/main.c index fe281f32bc1ded..f7c0cc84a5a5c0 100644 --- a/board/pedal/main.c +++ b/board/pedal/main.c @@ -2,8 +2,6 @@ //#define CAN_LOOPBACK_MODE //#define USE_INTERNAL_OSC -#define PEDAL - #include "../config.h" #include "drivers/drivers.h" @@ -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 ********************* diff --git a/tests/can_printer.py b/tests/can_printer.py index b79f3d5d40b7ba..e863889c16424b 100755 --- a/tests/can_printer.py +++ b/tests/can_printer.py @@ -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()