Page 1 of 1

EVE memory allocation

Posted: Mon Aug 29, 2022 8:19 pm
by Alex Stahl
Hello,

I am new to EVE as of last week and already thoroughly appreciating its capabilities. I have a newbie question about RAM_G allocation.

I have been using Rudolph's excellent library. I had no trouble getting the EVE_Test example working with a Teensy 4.1.
Also, no trouble building a widget based UI for a project. Sliders and toggles and buttons, oh my.

Then it was time to make a custom logo graphic. My source image happened to be a small PNG.
I used EAB to convert to L8, then to a c array. Pasted this array into pic[] in tft_data, adjusted the size and added a couple padding bytes.
It worked, but the displayed bitmap was corrupted by a few lines of garbage.

Then I found a note in the programming guide, that the top 42k of RAM_G (from address 0xF5800 - 0xFFFFF) may be overwritten by a PNG decode process.
Okay, so I moved the cmd_loadimage destination pointer down to 0xF0000 (again, I'm hacking a copy of Rudolph's EVE_Test example; so this was the MEM_PIC1 define, originally 0xFA000). Now everything looks great, exactly as expected. But I chose 0xf0000 as a stab in the dark, and can only imagine I was lucky not to clobber something.

So...my question is, are there general guidelines for allocating space in RAM_G for bitmaps? Or documentation that explains more about how coprocessor commands, etc., use RAM_G space? I've played around with cmd_getptr, cmd_getprops and apilevel, and will continue experimenting.

Any pointers welcome (no pun intended)!

Thanks!

Alex

Re: EVE memory allocation

Posted: Tue Aug 30, 2022 9:03 am
by Rudolph
Thank you for your kind words.

On the top of my head I believe that CMD_LOADIMAGE is the only command that allocates memory and only for PNG.
Generally speaking I would advise against using PNG files anyways, it takes really long to decode and EVE is a bit picky about the format.

The best option so far really is ASTC from BT81x.

Edit: I ran out of time earlier. :-)
So on memory layout, there a few more restrictions and these are with alignment.
The CMD_SETFONT font metrics block needs to be aligned to 4 bytes.
The CMD_SETFONT2 font metrics block needs to be aligned to 32 bytes.
The destination address in RAM_G for CMD_FLASHREAD needs to be aligned to 4 bytes.
The pointer for CMD_ANIMSTARTRAM and CMD_ANIMFRAMERAM need to be aligned to 64 bytes.
The pointer for CMD_FONTCACHE needs to be aligned to 64 bytes.
ASTC bitmaps in RAM_G need to be aligned to 16 bytes.
Audio data needs to be aligned to 8 bytes.
And probably a few more plus data in FLASH has additional alignment requirements.

To make things easier I tend to go with full pages, so 0xnnnnn00 addresses.
Optimizing memory usage is for when you actually use most of it. :-)