mirror of https://github.com/wolfSSL/wolfBoot.git
Added NO_VTOR to disable interrupt table relocation
parent
4dbffd19e1
commit
34a8ae443d
12
Makefile
12
Makefile
|
@ -10,6 +10,7 @@ BOOT0_OFFSET?=0x20000
|
||||||
SIGN?=ED25519
|
SIGN?=ED25519
|
||||||
TARGET?=stm32f4
|
TARGET?=stm32f4
|
||||||
DEBUG?=0
|
DEBUG?=0
|
||||||
|
VTOR?=1
|
||||||
|
|
||||||
LSCRIPT:=hal/$(TARGET).ld
|
LSCRIPT:=hal/$(TARGET).ld
|
||||||
|
|
||||||
|
@ -49,14 +50,16 @@ ifeq ($(SIGN),EC256)
|
||||||
CFLAGS+=-DBOOT_SIGN_EC256
|
CFLAGS+=-DBOOT_SIGN_EC256
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(DEBUG),1)
|
ifeq ($(DEBUG),1)
|
||||||
CFLAGS+=-O0 -g -ggdb3 -DDEBUG=1
|
CFLAGS+=-O0 -g -ggdb3 -DDEBUG=1
|
||||||
else
|
else
|
||||||
CFLAGS+=-Os
|
CFLAGS+=-Os
|
||||||
endif
|
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
|
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 $^ $@
|
$(OBJCOPY) -O binary $^ $@
|
||||||
$(SIZE) wolfboot.elf
|
$(SIZE) wolfboot.elf
|
||||||
|
|
||||||
|
wolfboot.hex: wolfboot.elf
|
||||||
|
$(OBJCOPY) -O ihex $^ $@
|
||||||
|
|
||||||
align: wolfboot-align.bin
|
align: wolfboot-align.bin
|
||||||
|
|
||||||
wolfboot-align.bin: wolfboot.elf
|
wolfboot-align.bin: wolfboot.elf
|
||||||
|
@ -103,7 +109,7 @@ keys: ed25519.der
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.bin *.elf $(OBJS) wolfboot.map *.bin
|
rm -f *.bin *.elf $(OBJS) wolfboot.map *.bin *.hex
|
||||||
make -C test-app clean
|
make -C test-app clean
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x001FFE0
|
FLASH (rx) : ORIGIN = 0x0001f000, LENGTH = 0x0010000
|
||||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000
|
RAM (rwx) : ORIGIN = 0x20002800, LENGTH = 0xD800
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "bootutil/image.h"
|
#include "bootutil/image.h"
|
||||||
#include "bootutil/bootutil.h"
|
#include "bootutil/bootutil.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#define BOOTLOADER
|
|
||||||
extern unsigned int _stored_data;
|
extern unsigned int _stored_data;
|
||||||
extern unsigned int _start_data;
|
extern unsigned int _start_data;
|
||||||
extern unsigned int _end_data;
|
extern unsigned int _end_data;
|
||||||
|
@ -61,13 +60,12 @@ void isr_fault(void)
|
||||||
|
|
||||||
void isr_empty(void)
|
void isr_empty(void)
|
||||||
{
|
{
|
||||||
/* Ignore the event and continue */
|
/* Ignore unmapped event and continue */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define VTOR (*(volatile uint32_t *)(0xE000ED08))
|
#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:
|
* It performs the following actions:
|
||||||
* - globally disable interrutps
|
* - 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;
|
const uint32_t * const app_IV = (const uint32_t *)app_offset;
|
||||||
void *app_entry;
|
void *app_entry;
|
||||||
uint32_t app_end_stack;
|
uint32_t app_end_stack;
|
||||||
|
|
||||||
|
#ifndef NO_VTOR
|
||||||
/* Disable interrupts */
|
/* Disable interrupts */
|
||||||
asm volatile("cpsid i");
|
asm volatile("cpsid i");
|
||||||
|
|
||||||
/* Update IV */
|
/* Update IV */
|
||||||
VTOR = ((uint32_t)app_IV);
|
VTOR = ((uint32_t)app_IV);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get stack pointer, entry point */
|
/* Get stack pointer, entry point */
|
||||||
app_end_stack = (*((uint32_t *)(app_offset)));
|
app_end_stack = (*((uint32_t *)(app_offset)));
|
||||||
|
@ -94,6 +94,9 @@ void do_boot(const uint32_t *app_offset)
|
||||||
|
|
||||||
/* Update stack pointer */
|
/* Update stack pointer */
|
||||||
asm volatile("msr msp, %0" ::"r"(app_end_stack));
|
asm volatile("msr msp, %0" ::"r"(app_end_stack));
|
||||||
|
#ifndef NO_VTOR
|
||||||
|
asm volatile("cpsie i");
|
||||||
|
#endif
|
||||||
/* Unconditionally jump to app_entry */
|
/* Unconditionally jump to app_entry */
|
||||||
asm volatile("mov pc, %0" ::"r"(app_entry));
|
asm volatile("mov pc, %0" ::"r"(app_entry));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue