This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Use internal flash to store long data-cc2541

Other Parts Discussed in Thread: CC2541

Hi all,

I want to use internal flash to store data which is around 80Kbytes long. I am using an uint8 array in which i am storing my data. I get following error when i increase the length of array by around 1-2Kbytes.

Error[e16]: Segment XDATA_I (size: 0x1547 align: 0) is too long for segment definition. At least 0xb8f more bytes needed. The problem occurred while processing the segment placement command "-Z(XDATA)XDATA_Z,XDATA_I=_XDATA_START-_XDATA_END", where at the moment of placement the available memory ranges  
were "XDATA:1548-1eff"
   Reserved ranges relevant to this placement:
   XDATA:1-280          XSTACK
   XDATA:281-1eff       XDATA_Z
   BIT:0-7              BREG
   BIT:80-97            SFR_AN
   BIT:a0-af            SFR_AN
   BIT:b8-c7            SFR_AN
   BIT:d8-df            SFR_AN
   BIT:f8-ff            SFR_AN
Error while running Linker

If i reduce the array size by 1-2Kbytes then i get following used space

116 276 bytes of CODE  memory
      34 bytes of DATA  memory (+ 88 absolute )
   7 886 bytes of XDATA memory
     194 bytes of IDATA memory
       8 bits  of BIT   memory
     638 bytes of CONST memory

my cc2541 flash size is 256Kbytes. If i calculate the above used space then it comes to be around 120Kbytes. My question is how adding 2-3 Kbytes data lead to above error? How can i store my required 80Kbytes data in internal flash?

Thanks

  • Hi,

    It seems you are trying to place the array in RAM (xdata). If you put 'const' before the array declaration it should be placed in flash instead.

    BR,
    Aslak
  • Hi Aslak,
    Thanks for your response.
    Ya. You were correct. I hadn't added const keyword. Now i had added const keyword and able to store around 28Kbytes data but if i tried to add more around 20Kbytes data with const keyword then i was getting following error.

    Error[e104]: Failed to fit all segments into specified ranges. Problem discovered in segment XDATA_ROM_C. Unable to place 100 block(s) (0xc41c byte(s) total) in
    0x8000 byte(s) of memory. The problem occurred while processing the segment placement command "-P(CONST)XDATA_ROM_C=0x8000-0xFFFF", where at the
    moment of placement the available memory ranges were "XDATA:8000-ffff"
    Error while running Linker

    Below is the memory used when i am not getting any compile error. Can you please tell how much more data i will be able to store more?

    143 579 bytes of CODE memory
    34 bytes of DATA memory (+ 88 absolute )
    6 542 bytes of XDATA memory
    194 bytes of IDATA memory
    8 bits of BIT memory
    29 495 bytes of CONST memory
    If i calculate used memory then it will come around 175-180Kbytes but why i am not able to add extra 20Kbytes data? Or do i need to store somewhere else? Please guide.
    thanks
  • Hi,

    This has to do with the flash banking system used in the 8051. One bank is configured to be accessed just like RAM although it is flash. Each bank is only 32kB. Const data is put into the segment called 'XDATA_ROM_C' meaning read only constant data mapped to XDATA.

    If you want to record more, you will need to modify the linker file so that one or two or more banks are not used by IAR, and then manually take control of these pages/banks using HalFlashRead/HalFlashWrite. You can then not access/read the arrays in the same manner as a const array.

    Best regards,
    Aslak
  • Ya, i got that i can't store more than 32kB in one bank and so i was getting previous error.
    Can you please be more specific what do you mean by "You can then not access/read the arrays in the same manner as a const array."?
    Can you please give a reference manual where i can get details about accessing different banks in flash? I have not worked with HalFlashRead & HalFlashWrite yet and hence not able to get more. I also don't know how to modify linker file as you have mentioned.
    thanks