Recent

Author Topic: Out of memory on a ATtiny841  (Read 853 times)

pascalbythree

  • Sr. Member
  • ****
  • Posts: 256
Out of memory on a ATtiny841
« on: November 30, 2023, 03:42:00 pm »
Out of memory on a ATtiny841 when using the www.freepascal.org compiler!

Does anybody know a exe compressor to be used for HEX files for AVR ?

Or i am i stuck to compiler parameters ?

Greets, PascalByThree, Wouter van Wegen

Laksen

  • Hero Member
  • *****
  • Posts: 755
    • J-Software
Re: Out of memory on a ATtiny841
« Reply #1 on: November 30, 2023, 05:56:10 pm »
Out of RAM or FLASH?

If RAM, reduce the amount of global variables you need
If FLASH, rewrite your code to make your generated code smaller. You might be using a lot of RTL functions that might be large (WriteLn, memory manager, etc)

You can investigate sizes of stuff with
Code: [Select]
avr-embedded-nm -Sn MyProgram.elf

TRon

  • Hero Member
  • *****
  • Posts: 2542
Re: Out of memory on a ATtiny841
« Reply #2 on: November 30, 2023, 06:13:52 pm »
Does anybody know a exe compressor to be used for HEX files for AVR ?
fwiw: solution likes that is actually making things worse because when compressed you require roughly twice the the amount of memory. First to load the compressed file into memory and the second time for the decompressed version (and the decompression code itself requires memory as well).

pascalbythree

  • Sr. Member
  • ****
  • Posts: 256
Re: Out of memory on a ATtiny841
« Reply #3 on: November 30, 2023, 06:31:20 pm »
8K Bytes flash memory,

To load a UART and a I2C stack. With a small program loop. And some procedures to store a integer in the EEPROM.

Do you think it will be sufficiant ? Maybe it is possible to tell like that ?


ccrause

  • Hero Member
  • *****
  • Posts: 863
Re: Out of memory on a ATtiny841
« Reply #4 on: November 30, 2023, 07:01:28 pm »
Does anybody know a exe compressor to be used for HEX files for AVR ?
fwiw: solution likes that is actually making things worse because when compressed you require roughly twice the the amount of memory. First to load the compressed file into memory and the second time for the decompressed version (and the decompression code itself requires memory as well).
It is even worse on Harvard architecture, instructions are only loaded from flash, so the decompressor needs to decompress to flash.  The decompressor also needs to run from flash, so it requires quote a bit of juggling of already limited flash memory.  And the flash space is already too small for the original code.  So while this is an interesting academic challenge, it would be a lot easier to just buy a controller with more flash.

ccrause

  • Hero Member
  • *****
  • Posts: 863
Re: Out of memory on a ATtiny841
« Reply #5 on: November 30, 2023, 07:16:29 pm »
8K Bytes flash memory,

To load a UART and a I2C stack. With a small program loop. And some procedures to store a integer in the EEPROM.

Do you think it will be sufficiant ? Maybe it is possible to tell like that ?
This functionality typically should fit into less than 4 kB, but it really depends on the specific code. As Laksen mentioned, do you use RTL functions to format strings, or convert text to integer or something? Or use (short)string types?  Did you enable any debug features such as range, overflow or stack checking?

Are you using the latest development (main) compiler? There are a couple of new optimizations in main that is not in the latest release version (3.2.2) - although the compiler optimizer will typically only reduce size by about 10 - 20%.

Thaddy

  • Hero Member
  • *****
  • Posts: 14393
  • Sensorship about opinions does not belong here.
Re: Out of memory on a ATtiny841
« Reply #6 on: December 01, 2023, 01:59:12 pm »
I suspect you are simply stuck, because you tried to build with sysutils, which is a no no. Same as my answer to your other question.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018