View previous topic :: View next topic |
Author |
Message |
dgallo
Joined: 02 Dec 2009 Posts: 16
|
Posted: Mon Jan 04, 2010 6:00 pm Post subject: ERROR: Not Enough RAM |
|
|
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 |
|
|
pz Guest
|
Posted: Tue Jan 05, 2010 9:36 am Post subject: |
|
|
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
|
Posted: Tue Jan 05, 2010 11:53 am Post subject: |
|
|
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
Thanks!
Diego |
|
Back to top |
|
|
pz Guest
|
Posted: Tue Jan 05, 2010 3:36 pm Post subject: |
|
|
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
|
Posted: Wed Jan 06, 2010 11:43 am Post subject: |
|
|
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
I found the docs, thanks! |
|
Back to top |
|
|
|