Skip to content

Commit 34a8ae4

Browse files
committed
Added NO_VTOR to disable interrupt table relocation
1 parent 4dbffd1 commit 34a8ae4

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ BOOT0_OFFSET?=0x20000
1010
SIGN?=ED25519
1111
TARGET?=stm32f4
1212
DEBUG?=0
13+
VTOR?=1
1314

1415
LSCRIPT:=hal/$(TARGET).ld
1516

@@ -49,14 +50,16 @@ ifeq ($(SIGN),EC256)
4950
CFLAGS+=-DBOOT_SIGN_EC256
5051
endif
5152

52-
53-
5453
ifeq ($(DEBUG),1)
5554
CFLAGS+=-O0 -g -ggdb3 -DDEBUG=1
5655
else
5756
CFLAGS+=-Os
5857
endif
5958

59+
ifeq ($(VTOR),0)
60+
CFLAGS+=-DNO_VTOR
61+
endif
62+
6063

6164

6265
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
6871
$(OBJCOPY) -O binary $^ $@
6972
$(SIZE) wolfboot.elf
7073

74+
wolfboot.hex: wolfboot.elf
75+
$(OBJCOPY) -O ihex $^ $@
76+
7177
align: wolfboot-align.bin
7278

7379
wolfboot-align.bin: wolfboot.elf
@@ -103,7 +109,7 @@ keys: ed25519.der
103109

104110

105111
clean:
106-
rm -f *.bin *.elf $(OBJS) wolfboot.map *.bin
112+
rm -f *.bin *.elf $(OBJS) wolfboot.map *.bin *.hex
107113
make -C test-app clean
108114

109115
distclean: clean

hal/nrf52.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MEMORY
22
{
3-
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x001FFE0
4-
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000
3+
FLASH (rx) : ORIGIN = 0x0001f000, LENGTH = 0x0010000
4+
RAM (rwx) : ORIGIN = 0x20002800, LENGTH = 0xD800
55
}
66

77
SECTIONS

src/startup_bl.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "bootutil/image.h"
2222
#include "bootutil/bootutil.h"
2323
#include <stdint.h>
24-
#define BOOTLOADER
2524
extern unsigned int _stored_data;
2625
extern unsigned int _start_data;
2726
extern unsigned int _end_data;
@@ -61,13 +60,12 @@ void isr_fault(void)
6160

6261
void isr_empty(void)
6362
{
64-
/* Ignore the event and continue */
63+
/* Ignore unmapped event and continue */
6564
}
6665

67-
6866
#define VTOR (*(volatile uint32_t *)(0xE000ED08))
6967

70-
/* This is the main program loop for the bootloader.
68+
/* This is the main loop for the bootloader.
7169
*
7270
* It performs the following actions:
7371
* - globally disable interrutps
@@ -82,18 +80,23 @@ void do_boot(const uint32_t *app_offset)
8280
const uint32_t * const app_IV = (const uint32_t *)app_offset;
8381
void *app_entry;
8482
uint32_t app_end_stack;
83+
84+
#ifndef NO_VTOR
8585
/* Disable interrupts */
8686
asm volatile("cpsid i");
87-
8887
/* Update IV */
8988
VTOR = ((uint32_t)app_IV);
89+
#endif
9090

9191
/* Get stack pointer, entry point */
9292
app_end_stack = (*((uint32_t *)(app_offset)));
9393
app_entry = (void *)(*((uint32_t *)(app_offset + 1)));
9494

9595
/* Update stack pointer */
9696
asm volatile("msr msp, %0" ::"r"(app_end_stack));
97+
#ifndef NO_VTOR
98+
asm volatile("cpsie i");
99+
#endif
97100
/* Unconditionally jump to app_entry */
98101
asm volatile("mov pc, %0" ::"r"(app_entry));
99102
}

0 commit comments

Comments
 (0)