Fix Linker bug copy ROM to RAM & exec from RAM (need more test).
This commit is contained in:
parent
da27adcf1c
commit
c65ca01044
@ -28,7 +28,8 @@ MEMORY
|
|||||||
/* rom is really the shadow region that points to SPI flash or elsewhere */
|
/* rom is really the shadow region that points to SPI flash or elsewhere */
|
||||||
rom (rx) : ORIGIN = 0x00000000, LENGTH = 1M
|
rom (rx) : ORIGIN = 0x00000000, LENGTH = 1M
|
||||||
ram (rwx) : ORIGIN = 0x10000000, LENGTH = 128K
|
ram (rwx) : ORIGIN = 0x10000000, LENGTH = 128K
|
||||||
/* there are some additional RAM regions */
|
/* there are some additional RAM regions for data */
|
||||||
|
ram_data (rw) : ORIGIN = 0x10080000, LENGTH = 72K
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Include the common ld script. */
|
/* Include the common ld script. */
|
||||||
|
@ -25,7 +25,7 @@ PREFIX ?= arm-none-eabi
|
|||||||
#PREFIX ?= arm-elf
|
#PREFIX ?= arm-elf
|
||||||
CC = $(PREFIX)-gcc
|
CC = $(PREFIX)-gcc
|
||||||
AR = $(PREFIX)-ar
|
AR = $(PREFIX)-ar
|
||||||
CFLAGS = -O2 -g -Wall -Wextra -I../../include -fno-common \
|
CFLAGS = -O2 -g3 -Wall -Wextra -I../../include -fno-common \
|
||||||
-mcpu=cortex-m4 -mthumb -Wstrict-prototypes \
|
-mcpu=cortex-m4 -mthumb -Wstrict-prototypes \
|
||||||
-ffunction-sections -fdata-sections -MD \
|
-ffunction-sections -fdata-sections -MD \
|
||||||
-mfloat-abi=hard -mfpu=fpv4-sp-d16
|
-mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||||
|
@ -56,26 +56,26 @@ SECTIONS
|
|||||||
_etext_ram = . + ORIGIN(ram);
|
_etext_ram = . + ORIGIN(ram);
|
||||||
_etext_rom = . + ORIGIN(rom_flash);
|
_etext_rom = . + ORIGIN(rom_flash);
|
||||||
|
|
||||||
. = ORIGIN(ram);
|
|
||||||
|
|
||||||
.data : {
|
.data : {
|
||||||
_data = .;
|
_data = .;
|
||||||
*(.data*) /* Read-write initialized data */
|
*(.data*) /* Read-write initialized data */
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
_edata = .;
|
_edata = .;
|
||||||
} >ram AT >rom
|
} >ram_data AT >rom
|
||||||
|
|
||||||
.bss : {
|
.bss : {
|
||||||
|
. = _edata;
|
||||||
*(.bss*) /* Read-write zero initialized data */
|
*(.bss*) /* Read-write zero initialized data */
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
_ebss = .;
|
_ebss = .;
|
||||||
} >ram
|
} >ram_data
|
||||||
|
|
||||||
/* exception unwind data - required due to libgcc.a issuing /0 exceptions */
|
/* exception unwind data - required due to libgcc.a issuing /0 exceptions */
|
||||||
.ARM.extab : {
|
.ARM.extab : {
|
||||||
|
. = _ebss;
|
||||||
*(.ARM.extab*)
|
*(.ARM.extab*)
|
||||||
} >ram
|
} >ram_data
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The .eh_frame section appears to be used for C++ exception handling.
|
* The .eh_frame section appears to be used for C++ exception handling.
|
||||||
|
@ -171,6 +171,9 @@ void reset_handler(void)
|
|||||||
if( (&_etext_ram-&_text_ram) > 0 )
|
if( (&_etext_ram-&_text_ram) > 0 )
|
||||||
{
|
{
|
||||||
src = &_etext_rom-(&_etext_ram-&_text_ram);
|
src = &_etext_rom-(&_etext_ram-&_text_ram);
|
||||||
|
/* Change Shadow memory to ROM (for Debug Purpose in case Boot has not set correctly the M4MEMMAP because of debug) */
|
||||||
|
CREG_M4MEMMAP = (unsigned long)src;
|
||||||
|
|
||||||
for(dest = &_text_ram; dest < &_etext_ram; )
|
for(dest = &_text_ram; dest < &_etext_ram; )
|
||||||
{
|
{
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user