Skip to content

Sketches (or libraries) with Large static data, do not load on Zephyr #173

@KurtE

Description

@KurtE

Describe the bug
I ported over a version of the ST77xx library that we have for Teensy boards over to run on Zephyr.
And in this case, If I try to run one of our tests which displays several different fonts on the display like an
ST7796. However when I try to use my full test sketch (ILI_ADA_FontTest4), it would build and appear to program it, but then fails to load:
Earlier I stripped it down to use very few of our fonts and also modified one of the font files to reduce the number of font sizes it
supported.

Today with the new release, decided to try it again and add one more font file, and again it failed to load:

Build output:

Sketch uses 254292 bytes (32%) of program storage space. Maximum is 786432 bytes.
Global variables use 4068 bytes (0%) of dynamic memory, leaving 519556 bytes for local variables. Maximum is 523624 bytes.
Performing 1200-bps touch reset on serial port COM7
Waiting for upload port...

Serial monitor window:

uart:~$
*** Booting Zephyr OS build v4.2.0-21-g277ebb69af4a ***
[00:00:00.594,000] <err> llext: Failed allocating 262144 bytes 262144-aligned for region 2
[00:00:00.605,000] <err> llext: Failed to copy regions, ret -12
Failed to load sketch, rc -12

Target board + cli verbose compilation output
I built on Portenta H7 with current zephyr sources.

Optional: attach the sketch
Sketch is up on my github project:
https://github.com/KurtE/Arduino_GIGA-stuff/tree/main/libraries/ST77XX_zephyr

I modified it to optionally add one more font:

#include <elapsedMillis.h>

#include <Adafruit_GFX.h>

#include <ST77XX_zephyr.h>

#include "ST77XX_zephyr_font_Arial.h"
//#include "font_ArialBold.h"
//#include "font_ComicSansMS.h"
#define USE_OPENSANS
#ifdef USE_OPENSANS
#include "font_OpenSans.h"
#endif
//#include "font_DroidSans.h"
//#include "font_Michroma.h"
//#include "font_Crystal.h"
//#include "font_ChanceryItalic.h"

And added it to the table:

const ili_fonts_test_t font_test_list[] = {
  {&Arial_12, nullptr,  "Arial_12", ST77XX_WHITE, ST77XX_WHITE},
//  {&Arial_12_Bold, nullptr,  "ArialBold 12", ST77XX_YELLOW, ST77XX_YELLOW},
//  {&ComicSansMS_12, nullptr,  "ComicSansMS 12", ST77XX_GREEN, ST77XX_GREEN},
//  {&DroidSans_12, nullptr,  "DroidSans_12", ST77XX_WHITE, ST77XX_WHITE},
//  {&Michroma_12, nullptr,  "Michroma_12", ST77XX_YELLOW, ST77XX_YELLOW},
//  {&Crystal_16_Italic, nullptr,  "CRYSTAL_16", ST77XX_BLACK, ST77XX_YELLOW},
//  {&Chancery_16_Italic, nullptr,  "Chancery_16_Italic", ST77XX_GREEN, ST77XX_GREEN},
#ifdef USE_OPENSANS
  {&OpenSans16, nullptr,  "OpenSans 16", ST77XX_RED, ST77XX_YELLOW},
#endif
  {nullptr, &FreeMono9pt7b,  "GFX FreeMono9pt7b", ST77XX_WHITE, ST77XX_WHITE},
  {nullptr, &FreeMono9pt7b,  "GFX FreeMono9pt7b", ST77XX_RED, ST77XX_YELLOW},
  {nullptr, &FreeSerif9pt7b,  "GFX FreeSerif9pt7b", ST77XX_WHITE, ST77XX_WHITE},
  {nullptr, &FreeSerif9pt7b,  "GFX FreeSerif9pt7b", ST77XX_RED, ST77XX_YELLOW},

} ;

As you can see on other platforms I am using several more fonts.

extern const ILI9341_t3_font_t Arial_8;
extern const ILI9341_t3_font_t Arial_9;
extern const ILI9341_t3_font_t Arial_10;
extern const ILI9341_t3_font_t Arial_11;
extern const ILI9341_t3_font_t Arial_12;
extern const ILI9341_t3_font_t Arial_13;
extern const ILI9341_t3_font_t Arial_14;
extern const ILI9341_t3_font_t Arial_16;
extern const ILI9341_t3_font_t Arial_18;
#ifdef INCLUDE_LARGER_ARIAL
extern const ILI9341_t3_font_t Arial_20;
extern const ILI9341_t3_font_t Arial_24;
extern const ILI9341_t3_font_t Arial_28;
extern const ILI9341_t3_font_t Arial_32;
extern const ILI9341_t3_font_t Arial_40;
extern const ILI9341_t3_font_t Arial_48;
extern const ILI9341_t3_font_t Arial_60;
extern const ILI9341_t3_font_t Arial_72;
extern const ILI9341_t3_font_t Arial_96;
#endif

Each of these fonts: take up a lot of room, like the smallest of these:

static const unsigned char Arial_8_data[] = {
0x00,0x00,0x18,0x03,0x00,0x16,0x44,0x06,0x62,0xA4,
0xD0,0x0B,0x00,0x34,0x15,0xF8,0x53,0xF1,0x40,0x0B,
0x27,0xB1,0xCA,0xA8,0x74,0x15,0x53,0x84,0x13,0x00,
0x51,0x89,0x12,0x83,0x40,0x16,0x81,0x48,0x8C,0x0D,
0x00,0x38,0xC8,0x48,0x61,0x44,0x68,0x8E,0x80,0x02,
0x62,0x94,0xC0,0x07,0x47,0x20,0x96,0x42,0x10,0x07,
0x47,0x22,0x16,0x12,0x40,0x06,0x82,0x21,0x39,0x28,
0x0A,0xA0,0xB4,0x11,0xF8,0x20,0x02,0x6F,0x1C,0xC0,
0x06,0x21,0x23,0x80,0x02,0x28,0x1A,0x07,0x00,0x1C,
0x1A,0x51,0x00,0x0B,0x00,0x31,0xD9,0x13,0x80,0x07,
0x00,0x30,0x9A,0xD9,0x0B,0x00,0x31,0xC8,0xC0,0x42,
0x10,0x87,0xC0,0x0B,0x00,0x31,0xC8,0x82,0x34,0x05,
0x13,0x80,0x0B,0x00,0x30,0x43,0x42,0x92,0x7E,0x04,
0x0B,0x00,0x31,0xE4,0x20,0xF4,0x05,0x13,0x80,0x0B,
0x00,0x31,0xC8,0xA0,0xF4,0xC4,0xE0,0x0B,0x00,0x33,
0xF0,0x28,0x24,0xA0,0x0B,0x00,0x31,0xD1,0x13,0xA6,
0x27,0x00,0x0B,0x00,0x31,0xD3,0x13,0xC1,0x44,0xE0,
0x02,0xC0,0x1B,0x44,0x03,0x07,0x1B,0x49,0x80,0x0A,
0xA0,0xB0,0x27,0x20,0x70,0x20,0x0A,0x61,0x33,0xE0,
0x3E,0x0A,0xA0,0xB2,0x07,0x02,0x72,0x00,0x0B,0x00,
0x31,0xC8,0x82,0x14,0x10,0x01,0x00,0x15,0x47,0x58,
0x7C,0x30,0x44,0xD5,0x26,0xC5,0x12,0xA6,0x93,0x61,
0x01,0x1F,0xC0,0x0F,0x00,0x40,0x44,0x94,0x22,0x3E,
0x88,0x20,0x0D,0x00,0x3B,0xE8,0x85,0xFC,0xC2,0xF8,
0x0D,0x00,0x38,0xE2,0x35,0x01,0x11,0xC0,0x0D,0x00,
0x3B,0xC4,0x55,0x0A,0x27,0x80,0x0B,0x00,0x33,0xF1,
0x07,0xE6,0x0F,0x80,0x0B,0x00,0x33,0xF1,0x07,0xAA,
0x00,0x0F,0x00,0x40,0xE1,0x12,0x0A,0x02,0x3A,0x09,
0x10,0xE0,0x0D,0x00,0x3C,0xC2,0xFE,0xA1,0x03,0x00,
0x16,0xD0,0x09,0x00,0x2D,0x8C,0x49,0x80,0x0D,0x00,
0x3A,0x14,0x49,0x16,0x34,0x88,0x90,0x80,0x0B,0x00,
0x36,0xC1,0xF0,0x0F,0x00,0x42,0x0C,0x63,0x9A,0xB1,
0x24,0x0D,0x00,0x3A,0x16,0x31,0x4C,0x4A,0x8D,0x08,
0x0F,0x00,0x40,0xE1,0x15,0x41,0x22,0x1C,0x0B,0x00,
0x33,0xD3,0x17,0xA6,0x00,0x0F,0x00,0x40,0xE1,0x14,
0xC1,0x4D,0x22,0x1F,0x0D,0x00,0x3B,0xE8,0x85,0xF2,
0x48,0x89,0x08,0x0D,0x00,0x39,0xE4,0x28,0x0C,0x06,
0x02,0x84,0xF0,0x0B,0x00,0x33,0xFA,0x40,0x0D,0x00,
0x3E,0xC2,0x78,0x0F,0x00,0x44,0x41,0x84,0x50,0x52,
0x04,0x00,0x17,0x18,0x52,0x10,0xA2,0x8C,0x25,0x28,
0x51,0x50,0x41,0x00,0x0D,0x00,0x3A,0x18,0x4A,0x0C,
0x84,0x90,0x80,0x0F,0x00,0x42,0x0C,0x22,0x14,0xA1,
0x00,0x0D,0x00,0x39,0xF0,0x50,0x24,0x10,0x41,0xF8,
0x05,0x47,0x1B,0xD9,0x30,0x07,0x00,0x1C,0x4A,0x50,
0x40,0x05,0x47,0x1B,0xD4,0xB0,0x0A,0x82,0x28,0x90,
0xA4,0x40,0x0C,0x27,0x33,0xF0,0x04,0x43,0x22,0x20,
0x0A,0xC0,0x31,0xC8,0x9E,0x8A,0x6E,0x80,0x0B,0x00,
0x34,0x41,0x66,0x62,0x2C,0xAC,0x0A,0xC0,0x31,0xC8,
0xC4,0x11,0x38,0x0B,0x00,0x34,0x04,0xD4,0xE2,0x29,
0x9A,0x0A,0xC0,0x31,0xC8,0xBE,0x82,0x27,0x00,0x07,
0x00,0x20,0x93,0xDA,0x0B,0x07,0x31,0xA9,0xC4,0x53,
0x34,0x17,0x80,0x0B,0x00,0x34,0x41,0x66,0x6A,0x20,
0x03,0x00,0x12,0x64,0x05,0x5F,0x11,0x1A,0xA0,0x09,
0x00,0x2C,0x42,0x54,0xC7,0x29,0x20,0x03,0x00,0x16,
0xD0,0x0E,0xC0,0x42,0xF3,0x4D,0x49,0x0A,0xC0,0x33,
0xD7,0x10,0x0A,0xC0,0x31,0xD5,0x13,0x80,0x0B,0x07,
0x32,0xCC,0xC4,0x59,0x5A,0x20,0x0B,0x07,0x31,0xA9,
0xC4,0x53,0x36,0x02,0x06,0xC0,0x22,0xB5,0x40,0x0A,
0xC0,0x31,0xC8,0x98,0x12,0x27,0x00,0x07,0x18,0x1C,
0x27,0xA4,0x60,0x0A,0xC0,0x35,0x45,0x33,0x40,0x0A,
0xC0,0x34,0x46,0x15,0x04,0x12,0xC0,0x52,0x22,0x94,
0xC2,0xAA,0x08,0x80,0x0A,0xC0,0x32,0x25,0x41,0x0A,
0x44,0x0B,0x07,0x34,0x46,0x15,0x24,0x20,0x0A,0xC0,
0x33,0xE1,0x41,0x08,0x7C,0x07,0x47,0x20,0xCA,0x4A,
0x42,0x03,0x47,0x16,0xE6,0x07,0x4F,0x22,0x4A,0x1A,
0x48,0x0A,0x42,0x33,0xAB,0x00,};
/* font data size: 656 bytes */

static const unsigned char Arial_8_index[] = {
0x00,0x00,0x30,0x1C,
0x0B,0x04,0xC1,0xC0,0x9C,0x31,0x0D,0x43,0xB1,0x04,
0x46,0x13,0x05,0x01,0x50,0x57,0x17,0x46,0x31,0xA0,
0x71,0x1E,0x88,0x22,0x2C,0x93,0x26,0x8A,0x22,0xA8,
0xAE,0x2C,0xCB,0xA2,0xFC,0xC6,0x33,0xCD,0xF3,0xA0,
0xF0,0x3E,0x10,0x04,0x21,0x0F,0x46,0x92,0x04,0x91,
0x2A,0x4D,0x13,0x95,0x05,0x4A,0x54,0x95,0x95,0x89,
0x6B,0x5D,0x57,0xA5,0xFD,0x88,0x65,0x19,0xD6,0x95,
0xAE,0x6C,0xDB,0x96,0xF9,0xC4,0x72,0x1C,0xC7,0x51,
0xDC,0x78,0xDE,0xB7,0xCD,0xF8,0x80,0x60,0x88,0x32,
0x11,0x86,0x61,0xD8,0x8E,0x28,0x8B,0xA3,0x68,0xFA,
0x43,0x92,0xE5,0x19,0x5E,0x5D,0x99,0xA6,0xD9,0xD2,
0x7B,0xA0,0x68,0x5A,0x2C,
};
/* font index size: 119 bytes */

const ILI9341_t3_font_t Arial_8 = {
	Arial_8_index,
	0,
	Arial_8_data,
	1,
	0,
	32,
	126,
	0,
	0,
	10,
	4,
	4,
	2,
	4,
	4,
	11,
	8
};

In this case: 771+119+header or about 1000 bytes. The largest one Arial96 takes a lot more:
40352+190...

On the other boards, OSs... as the data is marked static const and in the case of Teensy also PROGMEM, this data typically resides in
flash memory and does not get copied into into the ITCM or DTCM ...

I believe on Zephyr all of this is supposed to fit into the LTEXT area? Or is there some way to say leave in unused area of flash?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions