add mock stuff for signing
parent
99a2266f88
commit
5959729227
|
@ -1,5 +1,3 @@
|
|||
void *_origin = 0x8004000;
|
||||
|
||||
#ifdef STM32F4
|
||||
#define PANDA
|
||||
#include "stm32f4xx.h"
|
||||
|
@ -12,12 +10,15 @@ void *_origin = 0x8004000;
|
|||
|
||||
void __initialize_hardware_early() {
|
||||
early();
|
||||
|
||||
// jump to flash
|
||||
((void(*)()) _app_start[1])();
|
||||
}
|
||||
|
||||
int main() {
|
||||
clock_init();
|
||||
|
||||
// TODO: do signature check
|
||||
|
||||
// jump to flash
|
||||
((void(*)()) _app_start[1])();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ obj/$(STARTUP_FILE).o: $(STARTUP_FILE).s
|
|||
obj/$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/main.$(PROJ_NAME).o
|
||||
# hack
|
||||
$(CC) -Wl,--section-start,.isr_vector=0x8004000 $(CFLAGS) -o obj/$(PROJ_NAME).elf $^
|
||||
$(OBJCOPY) -v -O binary obj/$(PROJ_NAME).elf $@
|
||||
$(OBJCOPY) -v -O binary obj/$(PROJ_NAME).elf obj/code.bin
|
||||
./tools/sign.py obj/code.bin $@
|
||||
|
||||
obj/bootstub.$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/bootstub.$(PROJ_NAME).o obj/sha.o obj/rsa.o
|
||||
$(CC) $(CFLAGS) -o obj/bootstub.$(PROJ_NAME).elf $^
|
||||
|
|
|
@ -5,22 +5,27 @@ void *g_pfnVectors;
|
|||
|
||||
int has_external_debug_serial = 0;
|
||||
int is_giant_panda = 0;
|
||||
#define PULL_EFFECTIVE_DELAY 10
|
||||
|
||||
// must call again from main because BSS is zeroed
|
||||
inline void detect() {
|
||||
volatile int i;
|
||||
// detect has_external_debug_serial
|
||||
GPIOA->PUPDR |= GPIO_PUPDR_PUPDR3_1;
|
||||
for (i=0;i<PULL_EFFECTIVE_DELAY;i++);
|
||||
has_external_debug_serial = (GPIOA->IDR & (1 << 3)) == (1 << 3);
|
||||
|
||||
// detect is_giant_panda
|
||||
is_giant_panda = 0;
|
||||
#ifdef PANDA
|
||||
GPIOB->PUPDR |= GPIO_PUPDR_PUPDR1_1;
|
||||
for (i=0;i<PULL_EFFECTIVE_DELAY;i++);
|
||||
is_giant_panda = (GPIOB->IDR & (1 << 1)) == (1 << 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void early() {
|
||||
volatile int i;
|
||||
// if wrong chip, reboot
|
||||
volatile unsigned int id = DBGMCU->IDCODE;
|
||||
#ifdef STM32F4
|
||||
|
@ -41,6 +46,16 @@ inline void early() {
|
|||
detect();
|
||||
|
||||
#ifdef PANDA
|
||||
// check if the ESP is trying to put me in boot mode
|
||||
// enable pull up
|
||||
GPIOB->PUPDR |= GPIO_PUPDR_PUPDR0_0;
|
||||
for (i=0;i<PULL_EFFECTIVE_DELAY;i++);
|
||||
|
||||
// if it's driven low, jump to uart bootloader
|
||||
if (!(GPIOB->IDR & 1)) {
|
||||
enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC;
|
||||
}
|
||||
|
||||
// these are outputs to control the ESP
|
||||
GPIOC->MODER = GPIO_MODER_MODER14_0 | GPIO_MODER_MODER5_0;
|
||||
|
||||
|
@ -49,14 +64,6 @@ inline void early() {
|
|||
if (!is_giant_panda) {
|
||||
GPIOC->ODR = (1 << 14) | (1 << 5);
|
||||
}
|
||||
|
||||
// check if the ESP is trying to put me in boot mode
|
||||
// enable pull up
|
||||
GPIOB->PUPDR |= GPIO_PUPDR_PUPDR0_0;
|
||||
// if it's driven low, jump to uart bootloader
|
||||
if (!(GPIOB->IDR & 1)) {
|
||||
enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (enter_bootloader_mode == ENTER_BOOTLOADER_MAGIC) {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python
|
||||
import sys
|
||||
import struct
|
||||
|
||||
with open(sys.argv[1]) as f:
|
||||
dat = f.read()
|
||||
|
||||
print "signing", len(dat), "bytes"
|
||||
|
||||
with open(sys.argv[2], "wb") as f:
|
||||
x = struct.pack("I", len(dat)) + dat[4:]
|
||||
# mock signature of dat[4:]
|
||||
x += "\xaa"*0x80
|
||||
f.write(x)
|
||||
|
Loading…
Reference in New Issue