0

In CC2541 (IAR EW51/7.20) project I need to store few large const arrays (~30KB each).

I define the first array:

const uint8 demo_signal_1[30000] = {
    0X00,
    0X01,
    0X10,
    // rest of the data
};

It links in XDATA_ROM_C segment and runs just fine.

Then I add another 30KB array in another segment to overcome 32KB limitation:

const uint8 demo_signal_2[30000] = {
    0X22,
    0X33,
    0X44,
    // rest of data
}

The linker throws an error:

Error[e104]: Failed to fit all segments into specified ranges. Problem discovered in segment XDATA_ROM_C. Unable to place 96 block(s) (0xe37e byte(s) total) in 0x8000 byte(s) of memory.

Can anyone guide how to locate the second array on its own segment so linking should pass ?

I tried to follow the documentation and the forum but I seem to fail grasp something.

many thanks for any support

Thanks.


UPDATE (pretty long but please bear with me):

I played a little with segments definitions -

I've added two new (CONST)segments to the xcl file:

// Define segments for const data in flash.
// First the segment with addresses as used by the program (flash mapped as XDATA)
-P(CONST)XDATA_ROM_C=0x8000-0xFFFF
-Z(CONST)XDATA_ROM_C2=0x28000-0x2FFFF   // Added
-Z(CONST)XDATA_ROM_C3=0x38000-0x3FFFF   // Added
//

And defined the arrays to locate in these segments

// Array 1 in it own segment
const uint8 demo_signal_1[28800] @ "XDATA_ROM_C2"= {
        0X00,
        0X00,
        0X01,
        0X01,
// ...rest of initialization data
}

// Array 2 in it own segment
const uint8 demo_signal_2[28800] @ "XDATA_ROM_C3" = {
        0X00,
        0X00,
        0X02,
        0X02,
// ...rest of initialization data
}

This time it does link fine and generate the following map file

                ****************************************
                *                                      *
                *      SEGMENTS IN ADDRESS ORDER       *
                *                                      *
                ****************************************


SEGMENT              SPACE    START ADDRESS   END ADDRESS     SIZE  TYPE  ALIGN
=======              =====    =============   ===========     ====  ====  =====
INTVEC               CODE          00000000 - 00000085          86   com    0
CSTART               CODE          00000086 - 00000136          B1   rel    0
BIT_ID               CODE               00000137                     dse    0
BDATA_ID             CODE               00000137                     dse    0
IDATA_ID             CODE               00000137                     dse    0
IXDATA_ID            CODE               00000137                     dse    0
PDATA_ID             CODE               00000137                     dse    0
DATA_ID              CODE               00000137                     dse    0
XDATA_ID             CODE          00000137 - 0000057A         444   rel    0
BANK_RELAYS          CODE          0000057B - 0000151C         FA2   rel    0
RCODE                CODE          0000151D - 00001C4F         733   rel    0
CODE_N               CODE               00001C50                     dse    0
DIFUNCT              CODE               00001C50                     dse    0
NEAR_CODE            CODE          00001C50 - 00002C14         FC5   rel    2
<BANKED_CODE> 1      CODE          00002C15 - 00002C17           3   rel    0
<BANKED_CODE,CODE_C> 1
                     CODE          00002C18 - 00007FFB        53E4   rel    2
<BANKED_CODE,XDATA_ROM_C_FLASH> 1
                     CODE          00008000 - 0000FFFD        7FFE   rel    2
<BANKED_CODE> 2      CODE          00010000 - 00017FF9        7FFA   rel    0
<BANKED_CODE> 3      CODE          00018000 - 0001DE08        5E09   rel    0
BLENV_ADDRESS_SPACE
                     CODE          0003E800 - 0003F7FF        1000   rel    0
REGISTERS            DATA          00000000 - 00000007           8   rel    0
VREG                 DATA          00000008 - 00000017          10   rel    0
PSP                  DATA               00000018                     dse    0
XSP                  DATA          00000018 - 00000019           2   rel    0
DATA_I               DATA               0000001A                     dse    0
BREG                 BIT        00000020.0  -  00000020.7        8   rel    0
DATA_Z               DATA          00000021 - 00000028           8   rel    0
SFR_AN               DATA          00000080 - 00000080           1   rel    0
                     DATA          00000086 - 0000008A           5 
                     DATA          0000008C - 0000008D           2 
                     DATA          00000090 - 00000091           2 
                     DATA          00000094 - 00000097           4 
                     DATA          0000009A - 000000A9          10 
                     DATA          000000AB - 000000AF           5 
                     DATA          000000B3 - 000000B4           2 
                     DATA          000000B6 - 000000B6           1 
                     DATA          000000B8 - 000000B9           2 
                     DATA          000000BB - 000000C7           D 
                     DATA          000000C9 - 000000C9           1 
                     DATA          000000D1 - 000000DB           B 
                     DATA          000000E1 - 000000E9           9 
                     DATA          000000F1 - 000000F5           5 
                     DATA          000000F8 - 000000FA           3 
                     DATA          000000FC - 000000FF           4 
XSTACK               XDATA         00000001 - 00000280         280   rel    0
XDATA_Z              XDATA         00000281 - 00000BE4         964   rel    0
XDATA_I              XDATA         00000BE5 - 00001028         444   rel    0
<XDATA_N> 1          XDATA         00001029 - 00001C2A         C02   rel    0
XDATA_AN             XDATA         0000780E - 00007813           6   rel    0
<XDATA_ROM_C> 1      CONST         00008000 - 00008805         806   rel    2
XDATA_ROM_C2         XDATA         00028000 - 0002F07F        7080   rel    0
XDATA_ROM_C3         XDATA         00038000 - 0003F07F        7080   rel    0
IDATA_I              IDATA              00000029                     dse    0
IDATA_Z              IDATA         00000029 - 0000002A           2   rel    0
ISTACK               IDATA         00000040 - 000000FF          C0   rel    0

                ****************************************
                *                                      *
                *        END OF CROSS REFERENCE        *
                *                                      *
                ****************************************

 126 461 bytes of CODE  memory
      34 bytes of DATA  memory (+ 86 absolute )
   7 210 bytes of XDATA memory (+  6 absolute )
     194 bytes of IDATA memory
       8 bits  of BIT   memory
  59 654 bytes of CONST memory

Errors: none
Warnings: none

Two observations (scroll to the bottom of the map file):

  • The CODE size reduced by the 28803 bytes as the size of the original array located in the original segment, similarly segment size reduced by same 28803 bytes. and;
  • Newly added CONST segment (in xcl file) appear as XDATA in the map file

This all would be fine if I could download the generated binary into the chip, but when I try to 'download and debug' I receive the following message:

Fatal Error: Everything you want to place in flash memory must be placed with Xlink CODE memory segment type.

I tried to circumvent and generate intel-extended hex file to flash it standalone but the IDE returns the following error:

Error[e133]: The output format intel-extended cannot handle multiple address spaces. Use format variants (-y -O) to specify which address space is wanted

Reaching so far I tried one more thing and changed the new segments definition to (CODE) as advised by the error message.

// Define segments for const data in flash.
// First the segment with addresses as used by the program (flash mapped as XDATA)
-P(CONST)XDATA_ROM_C=0x8000-0xFFFF
-Z(CODE)XDATA_ROM_C2=0x28000-0x2FFFF    // Modified to (CODE)
-Z(CODE)XDATA_ROM_C3=0x38000-0x3FFFF    // Modified to (CODE)

Once again it links fine and the map file shows (scroll to the bottom):

                ****************************************
                *                                      *
                *      SEGMENTS IN ADDRESS ORDER       *
                *                                      *
                ****************************************


SEGMENT              SPACE    START ADDRESS   END ADDRESS     SIZE  TYPE  ALIGN
=======              =====    =============   ===========     ====  ====  =====
INTVEC               CODE          00000000 - 00000085          86   com    0
CSTART               CODE          00000086 - 00000136          B1   rel    0
DATA_ID              CODE               00000137                     dse    0
BDATA_ID             CODE               00000137                     dse    0
BIT_ID               CODE               00000137                     dse    0
IDATA_ID             CODE               00000137                     dse    0
IXDATA_ID            CODE               00000137                     dse    0
PDATA_ID             CODE               00000137                     dse    0
XDATA_ID             CODE          00000137 - 0000057A         444   rel    0
BANK_RELAYS          CODE          0000057B - 0000151C         FA2   rel    0
RCODE                CODE          0000151D - 00001C4F         733   rel    0
DIFUNCT              CODE               00001C50                     dse    0
CODE_N               CODE               00001C50                     dse    0
NEAR_CODE            CODE          00001C50 - 00002C14         FC5   rel    2
<BANKED_CODE> 1      CODE          00002C15 - 00002C17           3   rel    0
<BANKED_CODE,CODE_C> 1
                     CODE          00002C18 - 00007FFB        53E4   rel    2
<BANKED_CODE,XDATA_ROM_C_FLASH> 1
                     CODE          00008000 - 0000FFFD        7FFE   rel    2
XDATA_ROM_C2         CODE          00010000 - 0001707F        7080   rel    0
<BANKED_CODE> 2      CODE          00017080 - 00017FF3         F74   rel    0
XDATA_ROM_C3         CODE          00018000 - 0001F07F        7080   rel    0
<BANKED_CODE> 3      CODE          0001F080 - 0001FFF0         F71   rel    0
<BANKED_CODE> 4      CODE          00020000 - 00027FF9        7FFA   rel    0
<BANKED_CODE> 5      CODE          00028000 - 0002BF23        3F24   rel    0
BLENV_ADDRESS_SPACE
                     CODE          0003E800 - 0003F7FF        1000   rel    0
REGISTERS            DATA          00000000 - 00000007           8   rel    0
VREG                 DATA          00000008 - 00000017          10   rel    0
PSP                  DATA               00000018                     dse    0
XSP                  DATA          00000018 - 00000019           2   rel    0
DATA_I               DATA               0000001A                     dse    0
BREG                 BIT        00000020.0  -  00000020.7        8   rel    0
DATA_Z               DATA          00000021 - 00000028           8   rel    0
SFR_AN               DATA          00000080 - 00000080           1   rel    0
                     DATA          00000086 - 0000008A           5 
                     DATA          0000008C - 0000008D           2 
                     DATA          00000090 - 00000091           2 
                     DATA          00000094 - 00000097           4 
                     DATA          0000009A - 000000A9          10 
                     DATA          000000AB - 000000AF           5 
                     DATA          000000B3 - 000000B4           2 
                     DATA          000000B6 - 000000B6           1 
                     DATA          000000B8 - 000000B9           2 
                     DATA          000000BB - 000000C7           D 
                     DATA          000000C9 - 000000C9           1 
                     DATA          000000D1 - 000000DB           B 
                     DATA          000000E1 - 000000E9           9 
                     DATA          000000F1 - 000000F5           5 
                     DATA          000000F8 - 000000FA           3 
                     DATA          000000FC - 000000FF           4 
XSTACK               XDATA         00000001 - 00000280         280   rel    0
XDATA_Z              XDATA         00000281 - 00000BE4         964   rel    0
XDATA_I              XDATA         00000BE5 - 00001028         444   rel    0
<XDATA_N> 1          XDATA         00001029 - 00001C2A         C02   rel    0
XDATA_AN             XDATA         0000780E - 00007813           6   rel    0
<XDATA_ROM_C> 1      CONST         00008000 - 00008805         806   rel    2
IDATA_I              IDATA              00000029                     dse    0
IDATA_Z              IDATA         00000029 - 0000002A           2   rel    0
ISTACK               IDATA         00000040 - 000000FF          C0   rel    0

                ****************************************
                *                                      *
                *        END OF CROSS REFERENCE        *
                *                                      *
                ****************************************

 184 061 bytes of CODE  memory
      34 bytes of DATA  memory (+ 86 absolute )
   7 210 bytes of XDATA memory (+  6 absolute )
     194 bytes of IDATA memory
       8 bits  of BIT   memory
   2 054 bytes of CONST memory

Errors: none
Warnings: none

Voilla, CONST has shrunk and CODE expanded by exactly 57600 bytes as expected.

It even download and debug and generates hex file.

BUT when debugging the code it appears that instead of accessing 0x28000/0x38000, the memory controller access the data at 0x8000 which is the 'original' (CONST)XDATA_ROM_C segment.

To summarize:

when defining the two new segments as (CONST), the code links but can not debug nor generate hex file and
when defining the two new segments as (CODE), the code links, loads and run but the memory is not accessed correclty.

phew, this was long description. Any ideas someone ????

Note that this thread is duplicated at TI e2e forum as well here

eyalasko
  • 75
  • 6

1 Answers1

0

I have the same problem. Seems all data constants need to be in a single 32K segment that gets mapped into the Xdata region. I did a weak work around by using the -Z(CODE)XDATA_ROM_C2=0x38000-0x3FFFF declaration in your second attempt to map my 2nd array of 32K data into BANK6. In my code access routine I cheated by using the HalFlashRead routine to pull 32 bytes chunks into a local array and then index into the local array -- lots of bits missing, but the HaFlash routine expects a 2k page number, offset into page, buffer to place the data, and byte count. This is hardly a solid portable solution but allowed me to move forward. -- hope it helps or gives you more insight

rd_addr = 0x38000 + offset;
HalFlashRead((rd_addr>>0x11)&0xff), (rd_addr & 0x7ff), *ptr32bytes, 32);
realdata = ptr[0];  // offset == [0], offset+1= [1], ....