[BitCloud] Size ROM + RAM

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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:
https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=833045

		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:

13072 + 236 = 13,308

The (static) RAM usage is the .data + .bss:

236 + 65296 = 65532

I have for example :

   text       data        bss        dec        hex    
 113092       4226       7516     124834      1e7a2    

So in my case :

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 !

Last Edited: Fri. Oct 16, 2015 - 02:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl,

Thnx for answer! It's much clear to me now.

Regards!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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:

#include 

volatile int32_t i;
volatile int16_t b = 42;

int main(void)
{
	while(1);
	return 0;
}

and get

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?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This application is compiled using standard liker script, it is fine.

I was referring to this:

code : 4226 + 113092 = 117318
ram : 4226 + 7516 = 11742 

This looks more like BitCloud image target size. And correct calculation in this case:

ram : 4226 + 7516 - 4096 = 7646 

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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...

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On .elf as well. BitCloud linker scripts have this section in them:

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).

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi again !

Little investigation... concerning RAM.

Parameters for standard security:

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:

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 !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You may start loosing some frames for a heavily loaded network.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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 !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is no connection at all. CS_APS_DATA_REQ_BUFFERS_AMOUNT only sets how many APS_DataReq() requests will be handled at once.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.