Forum: Compiler & IDEs ARM GCC Linker File: Aufteilung von .text auf mehrere FLASH-Bereiche


von Alexander I. (daedalus)


Lesenswert?

Hallo,
ich verwendet GCC für ARM v4.9 und habe einen Cortex M0. Leider hat der 
Kerle nur 8KB FLASH. Selbiges ist auch noch in 2 Teile zerlegt:
1
MEMORY
2
{
3
  FLASH (rx)      : ORIGIN = 0x00000000, LENGTH = 1K
4
  FLASH2(rx)      : ORIGIN = 0x00000410, LENGTH = 0x1BF0
5
  SRAM(xrw)       : ORIGIN = 0x1FFFFF00, LENGTH = 0x400
6
}
7
8
// (...)
9
10
   /* The startup code goes first into FLASH */
11
  .isr_vector :
12
  {
13
    . = ALIGN(4);
14
    KEEP(*(.isr_vector)) /* Startup code */
15
    . = ALIGN(4);
16
  } >FLASH
17
18
  /* The program code and other data goes into FLASH */
19
  .text :
20
  {
21
    . = ALIGN(4);
22
    *(.text)           /* .text sections (code) */
23
    *(.text*)          /* .text* sections (code) */
24
    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
25
    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
26
    *(.glue_7)         /* glue arm to thumb code */
27
    *(.glue_7t)        /* glue thumb to arm code */
28
  *(.eh_frame)
29
30
    . = ALIGN(0x4);
31
    /* These are for static constructors and destructors under ELF */
32
    KEEP (*crtbegin.o(.ctors))
33
    KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
34
    KEEP (*(SORT(.ctors.*)))
35
    KEEP (*crtend.o(.ctors))
36
    KEEP (*crtbegin.o(.dtors))
37
    KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
38
    KEEP (*(SORT(.dtors.*)))
39
    KEEP (*crtend.o(.dtors))
40
    *(.rodata .rodata.* .gnu.linkonce.r.*)
41
42
    KEEP (*(.init))
43
    KEEP (*(.fini))
44
45
    . = ALIGN(4);
46
    _etext = .;        /* define a global symbols at end of code */
47
  } >FLASH2
Bisher hab ich alles in FLASH2 platziert bekommen, doch nun muß ich 
FLASH anzapfen, weil nicht mehr alles in FLASH2 passt. Bisher liegt dort 
nur der Startup-Code, der größte Teil ist ungenutzt. In der Lücke 
zwischen FLASH + FLASH2 sind übrigens irgendwelche Magic-Bytes, die ich 
nicht so ohne Weiteres beschreiben darf (Ausleseschutz, Debug-Disable, 
usw.)

- Wie muss ein Linkerskript aussehen, dass Folgendes macht: "Fülle alles 
in FLASH2 und wenn's nicht reicht platziere den Rest in FLASH"?
- Kann man das irgendwie automatisiert auf FLASH+FLASH2 verteilen?
- Oder muss ich explizit einzelne o-Files in FLASH platzieren?
- Könnte man die beiden FLASH-Sectionen zusammenfassen und irgendwie 
sicherstellen, dass im Magic-Byte-Bereich nichts platziert wird?

Vielen Dank!

: Verschoben durch Admin
von S. R. (svenska)


Lesenswert?

Eine Automatik kenne ich nicht.

Lege eine Section an, die ebenfalls in FLASH liegt und lege dann deine 
Arrays oder so von Hand in diese Section, dann sollte das passen.

von Alexander I. (daedalus)


Lesenswert?

Schade, hätte gedacht hier würde LD ein bisschen mehr Möglichkeiten 
bieten.

Ich habe nun händisch einige Teile in FLASH verschoben und die 
"Partition" bis auf 20 Bytes ausgenutzt. Passt für mich so.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.