mirror of
https://github.com/rfivet/stm32bringup.git
synced 2024-12-18 06:46:23 -05:00
In RAM execution using all RAM when loading via SWD.
This commit is contained in:
parent
d2836ddd55
commit
d13ec1241c
38
Makefile
38
Makefile
@ -41,23 +41,41 @@ SIZE = $(BINPFX)size
|
|||||||
|
|
||||||
PROJECT = f030f4
|
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
|
# Bootloader uses first 2K of RAM, execution from bootloader
|
||||||
#FLASHSTART = 0x20000800
|
#FLASHSTART = 0x20000800
|
||||||
#FLASHSIZE = 2K
|
#FLASHSIZE = 2K
|
||||||
#RAMSTART = 0x20000000
|
#RAMSTART = 0x20000000
|
||||||
#RAMSIZE = 2K
|
#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
|
# 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
|
FLASHSTART = 0x08000000
|
||||||
FLASHSIZE = 16K
|
FLASHSIZE = 16K
|
||||||
RAMSTART = 0x20000000
|
RAMSTART = 0x20000000
|
||||||
RAMSIZE = 4K
|
RAMSIZE = 4K
|
||||||
|
|
||||||
# ISR vector copied and mapped to RAM if FLASHSTART != 0x08000000
|
# ISR vector copied and mapped to RAM if FLASHSTART != 0x08000000
|
||||||
ifneq ($(FLASHSTART),0x08000000)
|
ifdef FLASHSTART
|
||||||
RAMISRV := 1
|
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
|
endif
|
||||||
|
|
||||||
#SRCS = boot.c
|
#SRCS = boot.c
|
||||||
@ -90,8 +108,10 @@ WARNINGS=-pedantic -Wall -Wextra -Wstrict-prototypes -Wno-unused-parameter
|
|||||||
CFLAGS = $(CPU) -g $(WARNINGS) -Os $(CDEFINES)
|
CFLAGS = $(CPU) -g $(WARNINGS) -Os $(CDEFINES)
|
||||||
|
|
||||||
LD_SCRIPT = generic.ld
|
LD_SCRIPT = generic.ld
|
||||||
LDOPTS =--defsym FLASHSTART=$(FLASHSTART) --defsym FLASHSIZE=$(FLASHSIZE)
|
ifdef FLASHSTART
|
||||||
LDOPTS +=--defsym RAMSTART=$(RAMSTART) --defsym RAMSIZE=$(RAMSIZE)
|
LDOPTS =--defsym FLASHSTART=$(FLASHSTART) --defsym FLASHSIZE=$(FLASHSIZE)
|
||||||
|
LDOPTS +=--defsym RAMSTART=$(RAMSTART) --defsym RAMSIZE=$(RAMSIZE)
|
||||||
|
endif
|
||||||
LDOPTS +=-Map=$(subst .elf,.map,$@) -cref --print-memory-usage
|
LDOPTS +=-Map=$(subst .elf,.map,$@) -cref --print-memory-usage
|
||||||
comma :=,
|
comma :=,
|
||||||
space :=$() # one space before the comment
|
space :=$() # one space before the comment
|
||||||
@ -101,7 +121,7 @@ LDFLAGS =-Wl,$(subst $(space),$(comma),$(LDOPTS))
|
|||||||
|
|
||||||
.PHONY: clean all version
|
.PHONY: clean all version
|
||||||
|
|
||||||
all: $(PROJECT).hex $(PROJECT).$(FLASHSTART).bin
|
all: $(PROJECT).hex $(PROJECT)$(FNAMLOC).bin
|
||||||
|
|
||||||
version:
|
version:
|
||||||
@echo make $(MAKE_VERSION) $(MAKE_HOST)
|
@echo make $(MAKE_VERSION) $(MAKE_HOST)
|
||||||
@ -125,11 +145,13 @@ cstartup.elf: cstartup.o
|
|||||||
$(SIZE) -G $@
|
$(SIZE) -G $@
|
||||||
$(OBJDUMP) -hS $@ > $(subst .elf,.lst,$@)
|
$(OBJDUMP) -hS $@ > $(subst .elf,.lst,$@)
|
||||||
|
|
||||||
|
ifdef FNAMLOC
|
||||||
%.bin: %.elf
|
%.bin: %.elf
|
||||||
@echo $@
|
@echo $@
|
||||||
$(OBJCOPY) -O binary $< $@
|
$(OBJCOPY) -O binary $< $@
|
||||||
|
endif
|
||||||
|
|
||||||
%.$(FLASHSTART).bin: %.elf
|
%$(FNAMLOC).bin: %.elf
|
||||||
@echo $@
|
@echo $@
|
||||||
$(OBJCOPY) -O binary $< $@
|
$(OBJCOPY) -O binary $< $@
|
||||||
|
|
||||||
|
@ -11,8 +11,10 @@
|
|||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
/* FLASH means code, read only data and data initialization */
|
/* FLASH means code, read only data and data initialization */
|
||||||
FLASH (rx) : ORIGIN = FLASHSTART, LENGTH = FLASHSIZE
|
FLASH (rx) : ORIGIN = DEFINED(FLASHSTART) ? FLASHSTART : 0x08000000,
|
||||||
RAM (rwx) : ORIGIN = RAMSTART, LENGTH = RAMSIZE
|
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
|
/* Linker script to place sections and symbol values. Should be used together
|
||||||
|
@ -110,7 +110,7 @@ isr_p const isr_vector[ 16 + 32] __attribute__((section(".isr_vector"))) = {
|
|||||||
USB_Handler
|
USB_Handler
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#if RAMISRV
|
#if RAMISRV == 2
|
||||||
# define ISRV_SIZE (sizeof isr_vector / sizeof *isr_vector)
|
# define ISRV_SIZE (sizeof isr_vector / sizeof *isr_vector)
|
||||||
isr_p ram_vector[ ISRV_SIZE] __attribute__((section(".ram_vector"))) ;
|
isr_p ram_vector[ ISRV_SIZE] __attribute__((section(".ram_vector"))) ;
|
||||||
#endif
|
#endif
|
||||||
@ -121,7 +121,7 @@ void Reset_Handler( void) {
|
|||||||
const long *f ; /* from, source constant data from FLASH */
|
const long *f ; /* from, source constant data from FLASH */
|
||||||
long *t ; /* to, destination in RAM */
|
long *t ; /* to, destination in RAM */
|
||||||
|
|
||||||
#if RAMISRV
|
#if RAMISRV == 2
|
||||||
/* Copy isr vector to beginning of RAM */
|
/* Copy isr vector to beginning of RAM */
|
||||||
for( unsigned i = 0 ; i < ISRV_SIZE ; i++)
|
for( unsigned i = 0 ; i < ISRV_SIZE ; i++)
|
||||||
ram_vector[ i] = isr_vector[ i] ;
|
ram_vector[ i] = isr_vector[ i] ;
|
||||||
|
Loading…
Reference in New Issue
Block a user