| Author |
Message |
|
|
Posted: May 16, 2012 - 12:30 PM |
|

Joined: May 25, 2011
Posts: 85
|
|
Hi !
Seems that I'm pretty much out of RAM, I have error :
.bss is not within region data
.noinit is not within region data
What I don't understand is calculation of ROM + RAM.
Here form other post:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=833045
Code:
Finished building target: CCPro_Bootloader.elf
AVR Memory Usage
----------------
text data bss dec hex filename
13072 236 65296 78604 1330c CCPro_Bootloader.elf
Done executing task "RunAvrGcc32".
Done building target "CoreBuild" in project "CCPro_Bootloader.avrgccproj".
clawson wrote:
The code flash has both .text and a copy of the .data initialisers so from that picture the code size is:
Code:
13072 + 236 = 13,308
The (static) RAM usage is the .data + .bss:
Code:
236 + 65296 = 65532
I have for example :
Code:
text data bss dec hex
113092 4226 7516 124834 1e7a2
So in my case :
Code:
code : 4226 + 113092 = 117318
ram : 4226 + 7516 = 11742
Code is OK, but RAM ??
ATmega1281 has 8K RAM.
Can anyone explain this to me?
Thnx, very much ! |
|
|
| |
|
|
|
|
|
Posted: May 16, 2012 - 02:08 PM |
|


Joined: Mar 27, 2002
Posts: 18595
Location: Lund, Sweden
|
|
What do you want an explanation of?
Yes, it seems correct that you are consuming over 8 K of RAM (for static allocations alone - add to that the run-time consumption for automatics (stack usage) and dynamics (i.e. allocated with malloc()).
Or do you need an explanation why e.g. data is aded to both flash and RAM? It goes like this: "data" contains initialized variables. So, the initialization values needs to be in non-volatile memory which is flash. But then, since they are variables, there has to be space allocated for them in RAM. So initialized (statically allocated) variables crave memory in both flash and RAM.
Non-initialized (statically allocated) variables craves only RAM space. The compiler knows that all such variables should be set to zero on program start, and does this with a call to memset() or similar. This is the "bss" segment, added only to RAM sage.
(Finally "text" is the executable code, added only to flash).
You might find more on this in the avrlibc documentation. |
|
|
| |
|
|
|
|
|
Posted: May 16, 2012 - 02:44 PM |
|

Joined: May 25, 2011
Posts: 85
|
|
JohanEkdahl,
Thnx for answer! It's much clear to me now.
Regards! |
|
|
| |
|
|
|
|
|
Posted: May 16, 2012 - 04:04 PM |
|


Joined: Apr 15, 2009
Posts: 4870
Location: San Jose, CA
|
|
| Keep in mind that default linker script allocates and initializes 4096 bytes of EEPROM memory, they count towards .data section, but the are not present in the final image. So for data you really have 4226 - 4096 = 130 bytes. It is annoying, but this is how avr-size works. |
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|
Posted: May 17, 2012 - 08:43 AM |
|


Joined: Mar 27, 2002
Posts: 18595
Location: Lund, Sweden
|
|
|
Quote:
So for data you really have 4226 - 4096 = 130 bytes. It is annoying, but this is how avr-size works.
I lost you there, Alex.
I built this:
Code:
#include <avr/io.h>
volatile int32_t i;
volatile int16_t b = 42;
int main(void)
{
while(1);
return 0;
}
and get
Code:
C:\Users\johan\Documents\AVR\Null app>avr-size NullApp.elf
text data bss dec hex filename
114 2 4 120 78 NullApp.elf
What am I missing? |
|
|
| |
|
|
|
|
|
Posted: May 17, 2012 - 04:05 PM |
|


Joined: Apr 15, 2009
Posts: 4870
Location: San Jose, CA
|
|
This application is compiled using standard liker script, it is fine.
I was referring to this:
Code:
code : 4226 + 113092 = 117318
ram : 4226 + 7516 = 11742
This looks more like BitCloud image target size. And correct calculation in this case:
Code:
ram : 4226 + 7516 - 4096 = 7646
|
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|
Posted: May 17, 2012 - 04:39 PM |
|


Joined: Mar 27, 2002
Posts: 18595
Location: Lund, Sweden
|
|
Got it now, Alex. It's when you run avr-size on a hex file, right? Never done that - wouldn't even think of it as it seems to make little sense for exactly the reasons spelled out in the other thread that the OP linked to above.
Sorry for any confusion caused... |
|
|
| |
|
|
|
|
|
Posted: May 17, 2012 - 04:43 PM |
|


Joined: Apr 15, 2009
Posts: 4870
Location: San Jose, CA
|
|
On .elf as well. BitCloud linker scripts have this section in them:
Code:
MEMORY
{
......
eeprom (rw!x) : ORIGIN = 0x00810000, LENGTH = 4K
}
......
.eeprom :
{
FILL(0xff)
BYTE(0xff)
. = . + LENGTH(eeprom)-1;
} > eeprom
This creates EEPROM section filled with 0xff, but avr-size counts this towards .data section (because technically it is initialized data). |
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|
Posted: May 31, 2012 - 12:34 PM |
|

Joined: May 25, 2011
Posts: 85
|
|
Hi again !
Little investigation... concerning RAM.
Parameters for standard security:
Code:
CS_NWK_BUFFERS_AMOUNT 219 × p (p=4)
CS_APS_DATA_REQ_BUFFERS_AMOUNT 102 × p (p=3)
CS_APS_ACK_FRAME_BUFFERS_AMOUNT 53 × p (p=2)
In brackets are default values.
Can I lower them down to:
Code:
CS_NWK_BUFFERS_AMOUNT 219 × p (p=2)
CS_APS_DATA_REQ_BUFFERS_AMOUNT 102 × p (p=2)
CS_APS_ACK_FRAME_BUFFERS_AMOUNT 53 × p (p=2)
I save 540 bytes of RAM.
What are consequences doing so?
Thnx very much ! |
|
|
| |
|
|
|
|
|
Posted: May 31, 2012 - 04:47 PM |
|


Joined: Apr 15, 2009
Posts: 4870
Location: San Jose, CA
|
|
| You may start loosing some frames for a heavily loaded network. |
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|
Posted: May 31, 2012 - 04:48 PM |
|


Joined: Apr 15, 2009
Posts: 4870
Location: San Jose, CA
|
|
| You can set CS_APS_DATA_REQ_BUFFERS_AMOUNT to 1 if you don't plan to issue more than one APS_DataReq() at the same tome. |
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|
Posted: May 31, 2012 - 05:51 PM |
|

Joined: May 25, 2011
Posts: 85
|
|
|
alexru wrote:
You can set CS_APS_DATA_REQ_BUFFERS_AMOUNT to 1 if you don't plan to issue more than one APS_DataReq() at the same tome.
Thanks Alexru !
One quick question:
what's connection between CS_APS_DATA_REQ_BUFFERS_AMOUNT and fragmentation?
I never used fragmentation, but I suppose that I must have CS_APS_DATA_REQ_BUFFERS_AMOUNT set to more then 1 or at least to number of fragments.
Thnx again ! |
|
|
| |
|
|
|
|
|
Posted: May 31, 2012 - 06:01 PM |
|


Joined: Apr 15, 2009
Posts: 4870
Location: San Jose, CA
|
|
| There is no connection at all. CS_APS_DATA_REQ_BUFFERS_AMOUNT only sets how many APS_DataReq() requests will be handled at once. |
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|