Thank you for answering!
Currently I try to set up an example to get a running linker-script:
In main.c intiates a gpio-port and catches the MC a loop:
1 | while(1)
|
2 | {
|
3 | delay();
|
4 | toggle_io();
|
5 | }
|
The function "toggle_io" is in an different file for the code which
should be executed from a ram-location. In my example the function just
toggles the gpio-port.
My problem is the linker-script.
Normaly the script looks like this (in CooCox):
1 | OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
2 | SEARCH_DIR(.)
|
3 | INCLUDE "memory.ld"
|
4 |
|
5 | /* Section Definitions */
|
6 | SECTIONS
|
7 | {
|
8 |
|
9 | .text :
|
10 | {
|
11 | KEEP(*(.isr_vector .isr_vector.*))
|
12 | *(.text .text.* .gnu.linkonce.t.*)
|
13 | *(.glue_7t) *(.glue_7)
|
14 | *(.rodata .rodata* .gnu.linkonce.r.*)
|
15 | } > rom */
|
16 |
|
17 |
|
18 |
|
19 | .ARM.extab :
|
20 | { ...
|
21 |
|
22 | ...
|
23 | ...
|
24 | }
|
In my first attemp I divided the .text section in two part (without any
further changes) and inserted my .boot-section between the isr-vectors
and the user-code-section .
Currently I havn't implemented a loader-function, I only wanted to see,
if the MC jumps to a ram-location.
It didn't! The toggle-fuction was executed from a flash-location, so
the programm was able to run.
I assume, that the toggle-function is linked a second time in the second
part of the .text-section, so I tried to link the other .o-files
manually.
After that I got an elf-file with 32KB large .text-section, that is even
not able to init the gpio-port.
Now I'm confused...
Whats wrong with this code?
1 | SECTIONS
|
2 | {
|
3 | .text :
|
4 | {
|
5 | KEEP(*(.isr_vector .isr_vector.*)) /* keep interrupt vector at default position */
|
6 | } >rom
|
7 |
|
8 | .boot : /* create boot-section between isr-vectors and user code*/
|
9 | AT (0x20000000) /* relocate to ram begin */
|
10 | {
|
11 | _sram_code = . ; /* save start adress of code */
|
12 | ..\obj\boot.o *(.text); /* link code to ram-position*/
|
13 | _eram_code = . ; /* save end adress of code*/
|
14 | } > rom
|
15 |
|
16 | /* first try */
|
17 | /* .text :
|
18 | {
|
19 | *(.text .text.* .gnu.linkonce.t.*)
|
20 | *(.glue_7t) *(.glue_7)
|
21 | *(.rodata .rodata* .gnu.linkonce.r.*)
|
22 | } > rom */
|
23 | /* end first try*/
|
24 |
|
25 | /* second try: */
|
26 | .text :
|
27 | {
|
28 | ..\obj\main.o *(.text);
|
29 | ..\obj\stm32f4xx_gpio.o *(.text);
|
30 | ..\obj\startup_stm32f4xx.o *(.text);
|
31 | ..\obj\stm32f4xx_rcc.o *(.text);
|
32 | ..\obj\system_stm32f4xx.o *(.text);
|
33 |
|
34 | *(.glue_7t) *(.glue_7)
|
35 | *(.rodata .rodata* .gnu.linkonce.r.*)
|
36 | } > rom
|
37 | /* end second try*/
|
38 |
|
39 | .ARM.extab :
|
40 | {...
|
41 | ...
|