1
0
mirror of https://github.com/rfivet/stm32bringup.git synced 2024-12-17 22:36:24 -05:00

In RAM execution using all RAM when loading via SWD.

This commit is contained in:
Renaud 2021-06-18 13:24:54 +08:00
parent d2836ddd55
commit d13ec1241c
3 changed files with 36 additions and 12 deletions

View File

@ -41,23 +41,41 @@ SIZE = $(BINPFX)size
PROJECT = f030f4
# In RAM Execution
### Memory Models
# In RAM Execution, load and start by USART bootloader
# Bootloader uses first 2K of RAM, execution from bootloader
#FLASHSTART = 0x20000800
#FLASHSIZE = 2K
#RAMSTART = 0x20000000
#RAMSIZE = 2K
# In RAM Execution, load and start via SWD
# 4K RAM available, execution via SWD
#FLASHSTART = 0x20000000
#FLASHSIZE = 3K
#RAMSTART = 0x20000C00
#RAMSIZE = 1K
# In Flash Execution
# if FLASHSTART is not at beginning of FLASH: execution from bootloader
# if FLASHSTART is not at beginning of FLASH: execution via bootloader or SWD
FLASHSTART = 0x08000000
FLASHSIZE = 16K
RAMSTART = 0x20000000
RAMSIZE = 4K
# ISR vector copied and mapped to RAM if FLASHSTART != 0x08000000
ifneq ($(FLASHSTART),0x08000000)
RAMISRV := 1
ifdef FLASHSTART
ifneq ($(FLASHSTART),0x08000000)
ifeq ($(FLASHSTART),0x20000000)
# Map isr vector in RAM
RAMISRV := 1
else
# Copy and map isr vector in RAM
RAMISRV := 2
endif
endif
FNAMLOC = .$(FLASHSTART)
endif
#SRCS = boot.c
@ -90,8 +108,10 @@ WARNINGS=-pedantic -Wall -Wextra -Wstrict-prototypes -Wno-unused-parameter
CFLAGS = $(CPU) -g $(WARNINGS) -Os $(CDEFINES)
LD_SCRIPT = generic.ld
LDOPTS =--defsym FLASHSTART=$(FLASHSTART) --defsym FLASHSIZE=$(FLASHSIZE)
LDOPTS +=--defsym RAMSTART=$(RAMSTART) --defsym RAMSIZE=$(RAMSIZE)
ifdef FLASHSTART
LDOPTS =--defsym FLASHSTART=$(FLASHSTART) --defsym FLASHSIZE=$(FLASHSIZE)
LDOPTS +=--defsym RAMSTART=$(RAMSTART) --defsym RAMSIZE=$(RAMSIZE)
endif
LDOPTS +=-Map=$(subst .elf,.map,$@) -cref --print-memory-usage
comma :=,
space :=$() # one space before the comment
@ -101,7 +121,7 @@ LDFLAGS =-Wl,$(subst $(space),$(comma),$(LDOPTS))
.PHONY: clean all version
all: $(PROJECT).hex $(PROJECT).$(FLASHSTART).bin
all: $(PROJECT).hex $(PROJECT)$(FNAMLOC).bin
version:
@echo make $(MAKE_VERSION) $(MAKE_HOST)
@ -125,11 +145,13 @@ cstartup.elf: cstartup.o
$(SIZE) -G $@
$(OBJDUMP) -hS $@ > $(subst .elf,.lst,$@)
ifdef FNAMLOC
%.bin: %.elf
@echo $@
$(OBJCOPY) -O binary $< $@
endif
%.$(FLASHSTART).bin: %.elf
%$(FNAMLOC).bin: %.elf
@echo $@
$(OBJCOPY) -O binary $< $@

View File

@ -11,8 +11,10 @@
MEMORY
{
/* FLASH means code, read only data and data initialization */
FLASH (rx) : ORIGIN = FLASHSTART, LENGTH = FLASHSIZE
RAM (rwx) : ORIGIN = RAMSTART, LENGTH = RAMSIZE
FLASH (rx) : ORIGIN = DEFINED(FLASHSTART) ? FLASHSTART : 0x08000000,
LENGTH = DEFINED(FLASHSIZE) ? FLASHSIZE : 16K
RAM (rwx) : ORIGIN = DEFINED(RAMSTART) ? RAMSTART : 0x20000000,
LENGTH = DEFINED(RAMSIZE) ? RAMSIZE : 4K
}
/* Linker script to place sections and symbol values. Should be used together

View File

@ -110,7 +110,7 @@ isr_p const isr_vector[ 16 + 32] __attribute__((section(".isr_vector"))) = {
USB_Handler
} ;
#if RAMISRV
#if RAMISRV == 2
# define ISRV_SIZE (sizeof isr_vector / sizeof *isr_vector)
isr_p ram_vector[ ISRV_SIZE] __attribute__((section(".ram_vector"))) ;
#endif
@ -121,7 +121,7 @@ void Reset_Handler( void) {
const long *f ; /* from, source constant data from FLASH */
long *t ; /* to, destination in RAM */
#if RAMISRV
#if RAMISRV == 2
/* Copy isr vector to beginning of RAM */
for( unsigned i = 0 ; i < ISRV_SIZE ; i++)
ram_vector[ i] = isr_vector[ i] ;