Added NO_VTOR to disable interrupt table relocation

pull/1/head
Daniele Lacamera 2018-10-20 10:46:07 +02:00
parent 4dbffd19e1
commit 34a8ae443d
3 changed files with 19 additions and 10 deletions

View File

@ -10,6 +10,7 @@ BOOT0_OFFSET?=0x20000
SIGN?=ED25519
TARGET?=stm32f4
DEBUG?=0
VTOR?=1
LSCRIPT:=hal/$(TARGET).ld
@ -49,14 +50,16 @@ ifeq ($(SIGN),EC256)
CFLAGS+=-DBOOT_SIGN_EC256
endif
ifeq ($(DEBUG),1)
CFLAGS+=-O0 -g -ggdb3 -DDEBUG=1
else
CFLAGS+=-Os
endif
ifeq ($(VTOR),0)
CFLAGS+=-DNO_VTOR
endif
LDFLAGS:=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=wolfboot.map -ffreestanding -nostartfiles -mcpu=cortex-m3 -mthumb -nostdlib
@ -68,6 +71,9 @@ wolfboot.bin: wolfboot.elf
$(OBJCOPY) -O binary $^ $@
$(SIZE) wolfboot.elf
wolfboot.hex: wolfboot.elf
$(OBJCOPY) -O ihex $^ $@
align: wolfboot-align.bin
wolfboot-align.bin: wolfboot.elf
@ -103,7 +109,7 @@ keys: ed25519.der
clean:
rm -f *.bin *.elf $(OBJS) wolfboot.map *.bin
rm -f *.bin *.elf $(OBJS) wolfboot.map *.bin *.hex
make -C test-app clean
distclean: clean

View File

@ -1,7 +1,7 @@
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x001FFE0
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000
FLASH (rx) : ORIGIN = 0x0001f000, LENGTH = 0x0010000
RAM (rwx) : ORIGIN = 0x20002800, LENGTH = 0xD800
}
SECTIONS

View File

@ -21,7 +21,6 @@
#include "bootutil/image.h"
#include "bootutil/bootutil.h"
#include <stdint.h>
#define BOOTLOADER
extern unsigned int _stored_data;
extern unsigned int _start_data;
extern unsigned int _end_data;
@ -61,13 +60,12 @@ void isr_fault(void)
void isr_empty(void)
{
/* Ignore the event and continue */
/* Ignore unmapped event and continue */
}
#define VTOR (*(volatile uint32_t *)(0xE000ED08))
/* This is the main program loop for the bootloader.
/* This is the main loop for the bootloader.
*
* It performs the following actions:
* - globally disable interrutps
@ -82,11 +80,13 @@ void do_boot(const uint32_t *app_offset)
const uint32_t * const app_IV = (const uint32_t *)app_offset;
void *app_entry;
uint32_t app_end_stack;
#ifndef NO_VTOR
/* Disable interrupts */
asm volatile("cpsid i");
/* Update IV */
VTOR = ((uint32_t)app_IV);
#endif
/* Get stack pointer, entry point */
app_end_stack = (*((uint32_t *)(app_offset)));
@ -94,6 +94,9 @@ void do_boot(const uint32_t *app_offset)
/* Update stack pointer */
asm volatile("msr msp, %0" ::"r"(app_end_stack));
#ifndef NO_VTOR
asm volatile("cpsie i");
#endif
/* Unconditionally jump to app_entry */
asm volatile("mov pc, %0" ::"r"(app_entry));
}