Anlegen einer neuen section im RAM

#3043010
Lesenswert?

Hallo,

ich versuche gerade eine internal SRAM Section anzulegen.
Es geht um ein kleines Test-Program mit main & einer Struktur
1
typedef struct
2
{
3
 int aFlag;
4
 int bFlag;
5
 int cFlag;
6
} SharedData;
7

8
SharedData g_sharedData  __attribute__((section(".shareddata")));
9

10
void main( void )
11
{
12
 g_sharedData.aFlag = 100;
13
 g_sharedData.bFlag = 100;
14
 g_sharedData.cFlag = 100;
15
}

Eckdaten:
- uC ATxmega256:
RAM byte addresses:
- IO Register byte address  0x0000 ... 0x0FFF
- mapped Eeprom byte address 0x1000 ... 0x1FFF
- internal SRAM byte address 0x2000 ... 0x5FFF (RAMEND with byte address 
=0x5FFF)
- Harvard Architecture offset: 0x800000

Auszug aus dem angepassten linker file:
1
MEMORY
2
{
3
  text   (rx)   : ORIGIN = 0x000000, LENGTH = 0xffff
4
  shareddata   (rw!x) : ORIGIN = 0x802000, LENGTH = 0x0200 /* 512 Bytes */
5
  data   (rw!x) : ORIGIN = 0x802200, LENGTH = 0xfda0 /* 0xffa0 - 0x200 */
6
 /* data   (rw!x) : ORIGIN = 0x802000, LENGTH = 0xffa0 */
7
  eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
8
  fuse      (rw!x) : ORIGIN = 0x820000, LENGTH = 1K
9
  lock      (rw!x) : ORIGIN = 0x830000, LENGTH = 1K
10
  signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K
11
}
12
SECTIONS
13
{
14
...
15

16
  .text   :
17
  {
18
    *(.vectors)
19
    KEEP(*(.vectors))
20
    /* For data that needs to reside in the lower 64k of progmem.  */
21
    *(.progmem.gcc*)
22
    *(.progmem*)
23
    . = ALIGN(2);
24
   
25
   ...
26
   }  > text
27
  .shareddata  : 
28
  {
29
     PROVIDE (__shareddata_start = .) ;
30
    *(.shareddata*)
31
     PROVIDE (__shareddata_end = .) ;
32
  }  > shareddata
33
  .data  :   AT (ADDR (.text) + SIZEOF (.text)) 
34
  {
35
     PROVIDE (__data_start = .) ;
36
    *(.data)
37
    *(.data*)
38
    *(.rodata)  /* We need to include .rodata here if gcc is used */
39
    *(.rodata*) /* with -fdata-sections.  */
40
    *(.gnu.linkonce.d*)
41
    . = ALIGN(2);
42
     _edata = . ;
43
     PROVIDE (__data_end = .) ;
44
  }  > data
45

46
...
47
}

Auszug aus dem map file:
1
Memory Configuration
2

3
Name             Origin             Length             Attributes
4
text             0x00030000         0x0000ffff         xr
5
shareddata       0x00802000         0x00000200         rw !x
6
data             0x00802200         0x0000fda0         rw !x
7
eeprom           0x00810000         0x00010000         rw !x
8
fuse             0x00820000         0x00000400         rw !x
9
lock             0x00830000         0x00000400         rw !x
10
signature        0x00840000         0x00000400         rw !x
11
*default*        0x00000000         0xffffffff
Auszug aus dem lss file:
1
Sections:
2
Idx Name          Size      VMA       LMA       File off  Algn
3
  0 .text         0000042a  00030000  00030000  00000094  2**1
4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
5
  1 .data         00000076  00802200  00802200  000004c0  2**0
6
                  CONTENTS, ALLOC, LOAD, DATA
7
  2 .shareddata   00000002  00802000  00802000  000004be  2**0
8
                  CONTENTS, ALLOC, LOAD, DATA
9
  3 .bss          00000004  00802276  00802276  00000536  2**0
10
                  ALLOC
11
  4 .stab         000006e4  00000000  00000000  00000538  2**2
12
                  CONTENTS, READONLY, DEBUGGING
13
  5 .stabstr      00000090  00000000  00000000  00000c1c  2**0
14
                  CONTENTS, READONLY, DEBUGGING
15
  6 .debug_aranges 00000060  00000000  00000000  00000cac  2**0
16
                  CONTENTS, READONLY, DEBUGGING
17
  7 .debug_pubnames 000000d4  00000000  00000000  00000d0c  2**0
18
                  CONTENTS, READONLY, DEBUGGING
19
  8 .debug_info   00000e31  00000000  00000000  00000de0  2**0
20
                  CONTENTS, READONLY, DEBUGGING
21
  9 .debug_abbrev 00000425  00000000  00000000  00001c11  2**0
22
                  CONTENTS, READONLY, DEBUGGING
23
 10 .debug_line   0000073e  00000000  00000000  00002036  2**0
24
                  CONTENTS, READONLY, DEBUGGING
25
 11 .debug_frame  000000c0  00000000  00000000  00002774  2**2
26
                  CONTENTS, READONLY, DEBUGGING
27
 12 .debug_str    0000095f  00000000  00000000  00002834  2**0
28
                  CONTENTS, READONLY, DEBUGGING
29
 13 .debug_loc    00000093  00000000  00000000  00003193  2**0
30
                  CONTENTS, READONLY, DEBUGGING
31
 14 .debug_pubtypes 000001d4  00000000  00000000  00003226  2**0
32
                  CONTENTS, READONLY, DEBUGGING

Kompilieren lässt es sich. Sobald ich jedoch die SW flashen will (aus 
dem WinAvr Studio 5.1) bekomme ich folgende Fehlermeldung:
"Some sections of the file provided does not fit within in the device 
memory"
Woran liegt es?

Danke im Voraus für Eure Hilfe.
#3046704
Lesenswert?

Muss ".shareddata" beim Start initialisiert werden? So wie Du es 
geschrieben hast müsste der Programmer den RAM programmieren - was 
natürlich wenig sinnvoll erscheint.

Wenn es nicht initialisiert werden muss:
1
.shareddata (NOLOAD) : 
2
  {
3
     PROVIDE (__shareddata_start = .) ;
4
    *(.shareddata*)
5
     PROVIDE (__shareddata_end = .) ;
6
  }  > shareddata

Anderenfalls muss man wie bei .data dafür sorgen dass die Initialdaten 
im Flash landen.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren