bladox.com Forum Index bladox.com
Turbo SIM Toolkit Adapter Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ERROR: Not Enough RAM

 
Post new topic   Reply to topic    bladox.com Forum Index -> Development
View previous topic :: View next topic  
Author Message
dgallo



Joined: 02 Dec 2009
Posts: 16

PostPosted: Mon Jan 04, 2010 6:00 pm    Post subject: ERROR: Not Enough RAM Reply with quote

Hi guys,

I'm trying to compile/install some app in the TSIM, but I'm getting the following error when trying to upload to TSIM:

Code:

SIM mode initialized, sim.trb
SIM_ATR: 3B 9D 94 80 1F C7 80 73 1A 21 1B 63 AF 0C A7 83


ERROR: Not Enough RAM

When compiling the app, everything runs smooth and it informs "Size PROGMEM: 6842 RAM: 282".

Anyone has any ideas of what could be wrong? How is this 282bytes of RAM calculated? Is really 282bytes of RAM too much for a TSIM app?

Thanks!
Diego
Back to top
View user's profile Send private message
pz
Guest





PostPosted: Tue Jan 05, 2010 9:36 am    Post subject: Reply with quote

Yes, 282 global vars is awfully a lot. This goes into global RAM where is only about 60? bytes free for all apps. You should use malloc and keep all your RAM needs in some structure. Then you need global only 2 bytes - pointer on your structure. Malloc it in e.g. ACTION_INIT or when needed. Look at wallet.c example - Glob_mem.
Back to top
dgallo



Joined: 02 Dec 2009
Posts: 16

PostPosted: Tue Jan 05, 2010 11:53 am    Post subject: Reply with quote

Thanks for the fast reply pz!

I found out that my error was more "basic" than that... I was trying to use some optimized C code of Skipjack block cipher, that declares a table (an array of bytes) with 256 bytes as a way to optimize some calculations...

My mistake was to just declare the variable, without the "suffix" PROGMEM to indicate that this variable should be on EEPROM instead of RAM... (that is what PROGMEM does I suppose, right?!)

Just in case anyone else happen to make the same mistake, I had declared the variable like:

Code:
static byte fTable[256] = {<256 bytes>};

instead of:

Code:
static byte PROGMEM fTable[256] = {<256 bytes>};

(*byte defined as unsigned char)

Anyway, thanks for pointing the Glob_mem struct from wallet. I'm sure it will be useful in the near future Wink

Thanks!
Diego
Back to top
View user's profile Send private message
pz
Guest





PostPosted: Tue Jan 05, 2010 3:36 pm    Post subject: Reply with quote

dgallo wrote:
Thanks for the fast reply pz!

I found out that my error was more "basic" than that... I was trying to use some optimized C code of Skipjack block cipher, that declares a table (an array of bytes) with 256 bytes as a way to optimize some calculations...

My mistake was to just declare the variable, without the "suffix" PROGMEM to indicate that this variable should be on EEPROM instead of RAM... (that is what PROGMEM does I suppose, right?!)


PROGMEM tells compiler to place it in program memory = flash, not EEPROM. There is chapter on memory organization in devel docs.
Back to top
dgallo



Joined: 02 Dec 2009
Posts: 16

PostPosted: Wed Jan 06, 2010 11:43 am    Post subject: Reply with quote

pz wrote:

PROGMEM tells compiler to place it in program memory = flash, not EEPROM. There is chapter on memory organization in devel docs.

My mistake again Wink
I found the docs, thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bladox.com Forum Index -> Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group