Skip to main content
suyongyao
Associate III
September 15, 2008
Question

Data/SRAM Segment problem help~~

  • September 15, 2008
  • 13 replies
  • 2381 views
Posted on September 15, 2008 at 06:15

Data/SRAM Segment problem help~~

    This topic has been closed for replies.

    13 replies

    suyongyao
    suyongyaoAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:44

    Hi All,

    I'm using STM32F103RBT6 mcu, which is 128kbytes of flash memory and 20kbytes of RAM. I do not know how to resolve this error when I compile my program by IAR. It says:

    Error[e16]: Segment DATA_Z (size: 0x69dd align: 0x2) is too long for segment definition. At

    least 0x19dd more bytes needed. The problem occurred while processing the segment

    placement command ''-Z(DATA)DATA_I,DATA_Z,DATA_N=RAMSTART-RAMEND'',

    where at the moment of placement the available memory ranges were

    ''CODE:20000000-20004fff''

    Reserved ranges relevant to this placement:

    20000000-20004fff DATA_I

    Below is part of my program, please help me.

    float Q[3][3];

    float c[3];

    float J[72][3];

    float g[72];

    float z[3];

    float lambda[72];

    float Cstrain[72];

    float Mmat[3][3], dmat[3];

    float dz[3], dlam[72], c2[3], bfs[72];

    float QO[75][75], PO[75];

    main()

    {

    ...

    ...

    }

    There are 27828bytes of the variable, which is still less than 128kbytes. What is the problem? Can anyone help me? Thank you.

    suyongyao
    suyongyaoAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:44

    Quote:

    On 10-09-2008 at 14:27, Anonymous wrote:

    Check the size of BSS section. This size should be bigger than size of your variables.

    [ This message was edited by: jaroslaw.oska on 10-09-2008 14:27 ]

    Hi jaroslaw.oska,

    Thank you for quick reply. May I know what is BSS?

    Yong Yao

    jaroslaw2
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:44

    Check the size of BSS section. This size should be bigger than size of your variables.

    [ This message was edited by: jaroslaw.oska on 10-09-2008 14:27 ]

    jj_it
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:44

    Analysis:

    1) Have you a free (KS) or paid version of IAR? If you have any code you will surely overflow the 32KB ''free'' limit. Of course float ''eats'' memory.

    2) Have you updated to IAR Ver 5.2?

    3) Is your STM32 micro version ''Y?''

    jaroslaw2
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:44

    Quote:

    Hi jaroslaw.oska,

    Thank you for quick reply. May I know what is BSS?

    Yong Yao

    Firstly, global variables stays in RAM and ivanov-i is right should check if your variables have smaller size than RAM size.

    Second, BSS section holds all uninicjalized global variables.

    ivanov-i
    Associate
    May 17, 2011
    Posted on May 17, 2011 at 12:44

    The message simply means that you can not fit 27828 bytes into 20K :) . All variables are located in RAM.

    You should either use a chip with bigger RAM (C, D, E), or allocate less variables in your program.

    suyongyao
    suyongyaoAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:44

    Quote:

    On 10-09-2008 at 13:52, Anonymous wrote:

    Analysis:

    1) Have you a free (KS) or paid version of IAR? If you have any code you will surely overflow the 32KB ''free'' limit. Of course float ''eats'' memory.

    2) Have you updated to IAR Ver 5.2?

    3) Is your STM32 micro version ''Y?''

    hi,

    1. I have both eval n kickstart version installed in my computer. Not sure if the KS version has overwrite and limited to 32k code size. I will investigate on this.

    2. I'm still using version 4.42a because my KickStart board is a older version (i do not have the box that label the version of the board now), and i believe the firmware library is specially written for the board version. That's y i remain using tat.

    3. May I know how to check the STM32 micro version?

    [ This message was edited by: suyongyao on 10-09-2008 16:46 ]

    suyongyao
    suyongyaoAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:44

    Quote:

    On 10-09-2008 at 17:47, Anonymous wrote:

    Quote:

    Hi jaroslaw.oska,

    Thank you for quick reply. May I know what is BSS?

    Yong Yao

    Firstly, global variables stays in RAM and ivanov-i is right should check if your variables have smaller size than RAM size.

    Second, BSS section holds all uninicjalized global variables.

    Hi Jaroslaw.oska,

    Sorry but I still dont understand what is BSS?

    [ This message was edited by: suyongyao on 11-09-2008 06:32 ]

    lanchon
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:44

    > You should either use a chip with bigger RAM (C, D, E), or allocate less variables in your program.

    if you are using enough constants (like look-up tables) you could move them to flash. note that you need to reserve stack space and maybe also heap space.

    jaroslaw2
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:44

    Hi,

    You've asked me what the BSS section is. Explanation will be too long to present it on forum. Please read about the linker.

    What I can tell you is that if you have RAM memory e.g. 20kB, this 20kB is divided in to sections. Compiler has to know to what range of addresses it can place the variables and stack.

    Example.

    Place .stack form 0-10kB and .bss form 10kB-20kB.

    What is important. When you declare variable before main and did not initialize by eg. zero it will be in .bss section.

    Code:

    int i;

    main(){

    }

    The pointer of i will point the address of (0x200000 + 10KB) which is first byte of .bss section.

    I hope it will give you first step to learn about linker.

    This was just an example don't take it seriously try to find *.ld file and read.