10" TFT Display - Want to Move Fonts to Flash Memory

DJETH

Active member
I am working on the 10" display with a Teensy 4.1 with added 8MB PSRAM and 256MB Flash mem. On one of the screens I want to add a clock using either ComicSansMS_72 or 96 Fonts however I am getting an "error Program exceeds memory space" I also get this when I try to use the larger fonts or several different sizes. I would like to move the fonts to the Flash Memory.

Code:
Memory Usage on Teensy 4.1:
  FLASH: code:402832, data:5929992, headers:8804   free for files:1784836
   RAM1: variables:98528, code:394184, padding:31800   free for local variables:-224
   RAM2: variables:12416  free for malloc/new:511872
 EXTRAM: variables:3200
Error program exceeds memory space
Multiple libraries were found for "ILI9341_fonts.h"
  Used: C:\Users\sirhu\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.59.0\libraries\ILI9488_t3
  Not used: C:\Users\sirhu\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.59.0\libraries\ST7735_t3
  Not used: C:\Users\sirhu\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.59.0\libraries\RA8875
exit status 0xffffffff

Compilation error: exit status 0xffffffff

Ignore The error/warning "Multiple libraries were found for "ILI9341_fonts.h"" it appears that their are multiple libraries in the Teensy Package. I get this anytime I get any error but goes away If I don't have any errors.

In the "ili9488_t3_font_ComicSansMS.c" in the Teensy 1.59.0 package Library in the ILI9488_t3 folder I tried adding PROGMEM to the lines that have:

Code:
static const unsigned char ComicSansMS_96_data[] = {
0x00,0x00,0x00,0x00,0x28,0x03,0x9B,0x08,0xFC,0x20,
0x03,0xF1,0x03,0xFF,0x69,0xFF,0xFA,0x7F,0xFE,0x9F,
NOTE:Just a few lines of the ~5000 lines of hex data

Before "static" after "[]" and a couple of other places... Also in the "font_ComicSansMS.h" file. Nothing worked. So if its not apparent... I have no idea what I'm doing. I'm not even sure you can move library data to the Flash memory.

Any help would be appreciated,
DJETH
 
Are you sure you're applying it to a font that the program is currently using? If the data isn't referenced then it will already be dropped at the linking stage and changing its location won't make any difference.
 
Jmarsh,
I am using:
ComicSansMS_14
ComicSansMS_16
ComicSansMS_18
ComicSansMS_24
and I ma trying to use:
ComicSansMS_40
ComicSansMS_96

I tied adding PROGMEM to all of the font sizes at once. Your question
"Are you sure you're applying it to a font that the program is currently using?" brought on another question... what if the compiler is NOT using the file I think it is SUPPOSED to be using and... I moved the file out of the Teensy library folder and it did not effect my compile... which it should have given me an error and it didn't. I am currently looking for the files the compiler is using and will get back...
 
OK... I went ahead and copied the ComicSansMS Font files (3 of them), Renamed the files, Arrays, and the constructors so there is no conflict or duplicates. So now I am sure which files the compiler is using. It compiled ok and the display works correctly with the smaller fonts.

I added the PROGMEM to the data and index arrays to ALL font sizes in the "ili9488_t3_font_ComicSansMS.c" file (which I renamed DJETH_font_ComicSansMS.c. To be clear... The code compiles and works on the display BUT adding the PROGMEM to try to get the arrays to load in the Flash Memory gives me the error below. I am using the "DJETH_ComicSansMS_18 font" in my sketch. The error below is only one of the errors sets. The other errors are for each size of the font.


Code:
d:\Documents\Arduino\libraries\DJETH_RA8876-GT9271\DJETH_font_ComicSansMS.c:1260:57: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PROGMEM'
 1260 | static const unsigned char DJETH_ComicSansMS_18_data[] PROGMEM = {
      |                                                         ^~~~~~~
d:\Documents\Arduino\libraries\DJETH_RA8876-GT9271\DJETH_font_ComicSansMS.c:1480:58: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PROGMEM'
 1480 | static const unsigned char DJETH_ComicSansMS_18_index[] PROGMEM = {
      |                                                          ^~~~~~~
d:\Documents\Arduino\libraries\DJETH_RA8876-GT9271\DJETH_font_ComicSansMS.c:1500:9: error: 'DJETH_ComicSansMS_18_index' undeclared here (not in a function); did you mean 'DJETH_ComicSansMS_18'?
 1500 |         DJETH_ComicSansMS_18_index,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         DJETH_ComicSansMS_18
d:\Documents\Arduino\libraries\DJETH_RA8876-GT9271\DJETH_font_ComicSansMS.c:1502:9: error: 'DJETH_ComicSansMS_18_data' undeclared here (not in a function); did you mean 'DJETH_ComicSansMS_18'?
 1502 |         DJETH_ComicSansMS_18_data,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |         DJETH_ComicSansMS_18
 
This compiles and works for me
Code:
PROGMEM static const unsigned char LiberationSansSchmick12_data[] = {
 
Make sure there is something like #include <Arduino.h> at the top of the file to provide the definition of PROGMEM.
 
I am not sure if this is what you are running into. But when you include a library with the Arduino setup, the link phase will include all of the object files out of that library, and I would see that all of them were included into the binary.

However if you change/add library.properties file and have a line it like:
Code:
dot_a_linkage=true
The build process will create an archive file (.a) from that library and the link phase will include that archive, and only objects that contain things in it that are referenced by something will be included into the object.
Note: The ILI9341_t3n library has this in it, as does the ILI9341_fonts...
 
First off I would like to thank PJRC and the people on this Forum for the help they provide. I have no way to express the gratitude I have in words...

thebigg and jmarsh are both correct in resolving the problem. I first added the PROGMEM to the front of the line and compiled and got this error.
Code:
d:\Documents\Arduino\libraries\Daniel_RA8876-GT9271\Daniel_font_ComicSansMS.c:1260:8: error: expected ';' before 'static'
 1260 | PROGMEM static const unsigned char Daniel_ComicSansMS_18_data[] = {
      |        ^~~~~~~
      |        ;
d:\Documents\Arduino\libraries\Daniel_RA8876-GT9271\Daniel_font_ComicSansMS.c:1480:8: error: expected ';' before 'static'
 1480 | PROGMEM static const unsigned char Daniel_ComicSansMS_18_index[] = {
      |        ^~~~~~~
      |        ;

I then added "#include <Arduino.h>" to the top of the .c file and it compiled correctly. I then changed my font size for the clock to 96 and it works great. My Ram1: free for local variables is now over 18000.

KurtE,
I only understand a little bit of what you said. or at least I think i do... if a library has "dot_a_linkage=true" then ONLY what is actually needed is used. Only the font arrays that are used in the sketch are installed not all the arrays... Hopefully I'm close? Also goes for libraires that link to other libraires if the code in them is not used then it is not loaded into the actual microcontroller.

One Note... after moving and doing the renaming of the font libraries and associated I no longer get the warning for multiple libraries. I can also modify these libraires without worrying I may affect another sketch that used the same libraries.

Again... Thanks for the support. This is a great microcontroller
DJETH
 

Attachments

  • 1000007627.jpg
    1000007627.jpg
    274.5 KB · Views: 15
Back
Top