No text on buttons/labels

Well not entirely,

I still don’t have any text on my labels.
If I take this sample Label (lv_label) — LVGL documentation, I end with a white screen and no text.

So, the current status is that lv_display_task() as well as lv_timer_task() are working as intended. However the text rendering still fails somehow. Any suggestions for this?

Hi @theprogram01 ,

Oh dear… I’m sorry I am just a user of (and occasional contributor to) LVGL like you and have a day job also, today I am somewhat busier than usual, hence my long time reply…

Are you able to see the entire contents of your static lv_disp_drv_t disp_drv structure from your debugging environment… I am essentially doing things the same way in my platform but I have a double buffer.

Here is a screenshot of my driver structure:

Just for comparison…

Kind Regards,

Pete

Hi @pete-pjb,

Thanks for the update.

Unfortunately my environment does not have support for that kind of debugging.

For now I am filling the code with LV_LOG_TRACE(""); calls. This way I hope to figure out why the library won’t draw any text.

Any issues I find while debugging I’ll (probably) post here and once I have confirmed them I’ll make them into issues on GitHub.

Hi @theprogram01 ,

I would certain make sure you check the value of direct_mode and/or add this line to your initialisation:

disp_drv.direct_mode = 1;

Kind Regards,

Pete

Hi @pete-pjb,

The direct_mode flag is indeed on. So that should work just fine.

So far I think I found the line that causes my text to disappear.

If I add some debugging before this line I get the following result

[Trace]  (5.438, +2)   lv_font_get_glyph_dsc: Begin for font at 0xa0030ac8, letter index 111   (in lv_font.c line #68)
[Trace]  (5.440, +2)   lv_draw_letter: Begin   (in lv_draw_label.c line #368)
[Trace]  (5.442, +2)   lv_draw_sw_letter: Begin for letter o with value 111   (in lv_draw_sw_letter.c line #98)
[Trace]  (5.442, +0)   lv_font_get_glyph_dsc: Begin for font at 0xa0030ac8, letter index 111   (in lv_font.c line #68)
[Trace]  (5.445, +3)   lv_draw_sw_letter: Got bounding box g_ret=1, height=0, width=0   (in lv_draw_sw_letter.c line #130)
[Trace]  (5.447, +2)   lv_draw_letter: Finish   (in lv_draw_label.c line #370)

So LVGL is unable to grab the correct size from the stored letter table. If I look in the .map file I can find that the index is correctly resolved for my font.

 .rodata        0xa0030ac8     0x3540 lib/liblvgl.a(lv_font_montserrat_14.c.obj)
                0xa0030ac8                lv_font_montserrat_14

If I now drop the .elf in ghidra everything seems to be correctly compiled. (Ghidra also recognizes the table.)

Anyway, that was the update so far, next plan: Call lv_font_get_glyph_dsc directly and add some more debugging there. (If I don’t call it directly the logging takes way too long).

But that is something for tomorrow.

Hi @theprogram01 ,

I think you are the victim of memory corruption here looking at your results. The draw routines of LVGL are pretty mature and normally stable these days… My own projects would fail badly if there were bugs at this level in LVGL…

I think you would be best to spend your time making sure you have sufficient stack allocated both for your system and each task as well as checking the heap configuration for the system and LVGL.

I have just found your email in my junk! Sorry.

I have to pop out for an hour or so and will take a closer look on my return.

Kind Regards,

Pete

Ok, I think I found what went wrong.

So in lv_font_fmt_txt.c we have the following lines.

Somehow the optimizer just “assumes” the letter is ‘\t’ and leaves me with a space. I run the optimizer in -Os (size) mode. Setting the optimizer to -O0 (zero) mode will cause the code to just run fine. An alternative is to comment out these 4 lines.

Since these kinds of claims require some sort of evidence, I updated get_glyph_dsc_id

static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter)
{
    LV_LOG_USER("Begin with font %p and letter %d", font, letter);
    if(letter == '\0') return 0;

    lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)font->dsc;

So, with the optimizer in -Os mode we get the following lines at the end (note: the 2nd call is the 2nd time this method is called in lv_font_get_glyph_dsc_fmt_txt().)

[User]  (12.685, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 32   (in lv_font_fmt_txt.c line #211)
[User]  (12.687, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 109   (in lv_font_fmt_txt.c line #211)
[User]  (12.689, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 32   (in lv_font_fmt_txt.c line #211)
[User]  (12.691, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 97   (in lv_font_fmt_txt.c line #211)
[User]  (12.693, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 32   (in lv_font_fmt_txt.c line #211)
[User]  (12.694, +1)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 116   (in lv_font_fmt_txt.c line #211)
[User]  (12.696, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 32   (in lv_font_fmt_txt.c line #211)
[User]  (12.698, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 105   (in lv_font_fmt_txt.c line #211)
[User]  (12.700, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 32   (in lv_font_fmt_txt.c line #211)
[User]  (12.702, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 99   (in lv_font_fmt_txt.c line #211)
[User]  (12.705, +3)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 32   (in lv_font_fmt_txt.c line #211)
[User]  (12.705, +0)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 97   (in lv_font_fmt_txt.c line #211)
[User]  (12.708, +3)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 32   (in lv_font_fmt_txt.c line #211)
[User]  (12.710, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 108   (in lv_font_fmt_txt.c line #211)
[User]  (12.712, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 32   (in lv_font_fmt_txt.c line #211)
[User]  (12.714, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 108   (in lv_font_fmt_txt.c line #211)
[User]  (12.716, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 32   (in lv_font_fmt_txt.c line #211)
[User]  (12.716, +0)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 121   (in lv_font_fmt_txt.c line #211)
[User]  (12.718, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 32   (in lv_font_fmt_txt.c line #211)
[User]  (12.720, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 46   (in lv_font_fmt_txt.c line #211)
[User]  (12.723, +3)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 32   (in lv_font_fmt_txt.c line #211)
[User]  (12.725, +2)   get_glyph_dsc_id: Begin with font 0xa0026ba0 and letter 0   (in lv_font_fmt_txt.c line #211)

Now with the if(unicode_letter == '\t') section disabled

[User]  (13.432, +1)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 109   (in lv_font_fmt_txt.c line #211)
[User]  (13.433, +1)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 109   (in lv_font_fmt_txt.c line #211)
[User]  (13.435, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 97   (in lv_font_fmt_txt.c line #211)
[User]  (13.437, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 97   (in lv_font_fmt_txt.c line #211)
[User]  (13.439, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 116   (in lv_font_fmt_txt.c line #211)
[User]  (13.441, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 116   (in lv_font_fmt_txt.c line #211)
[User]  (13.442, +1)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 105   (in lv_font_fmt_txt.c line #211)
[User]  (13.444, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 105   (in lv_font_fmt_txt.c line #211)
[User]  (13.446, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 99   (in lv_font_fmt_txt.c line #211)
[User]  (13.448, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 99   (in lv_font_fmt_txt.c line #211)
[User]  (13.450, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 97   (in lv_font_fmt_txt.c line #211)
[User]  (13.452, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 97   (in lv_font_fmt_txt.c line #211)
[User]  (13.453, +1)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 108   (in lv_font_fmt_txt.c line #211)
[User]  (13.455, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 108   (in lv_font_fmt_txt.c line #211)
[User]  (13.457, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 108   (in lv_font_fmt_txt.c line #211)
[User]  (13.460, +3)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 108   (in lv_font_fmt_txt.c line #211)
[User]  (13.462, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 121   (in lv_font_fmt_txt.c line #211)
[User]  (13.464, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 121   (in lv_font_fmt_txt.c line #211)
[User]  (13.464, +0)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 46   (in lv_font_fmt_txt.c line #211)
[User]  (13.467, +3)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 46   (in lv_font_fmt_txt.c line #211)
[User]  (13.469, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 0   (in lv_font_fmt_txt.c line #211)

And finally the optimizer set to -O0

[User]  (13.432, +1)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 109   (in lv_font_fmt_txt.c line #211)
[User]  (13.433, +1)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 109   (in lv_font_fmt_txt.c line #211)
[User]  (13.435, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 97   (in lv_font_fmt_txt.c line #211)
[User]  (13.437, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 97   (in lv_font_fmt_txt.c line #211)
[User]  (13.439, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 116   (in lv_font_fmt_txt.c line #211)
[User]  (13.441, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 116   (in lv_font_fmt_txt.c line #211)
[User]  (13.442, +1)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 105   (in lv_font_fmt_txt.c line #211)
[User]  (13.444, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 105   (in lv_font_fmt_txt.c line #211)
[User]  (13.446, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 99   (in lv_font_fmt_txt.c line #211)
[User]  (13.448, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 99   (in lv_font_fmt_txt.c line #211)
[User]  (13.450, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 97   (in lv_font_fmt_txt.c line #211)
[User]  (13.452, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 97   (in lv_font_fmt_txt.c line #211)
[User]  (13.453, +1)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 108   (in lv_font_fmt_txt.c line #211)
[User]  (13.455, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 108   (in lv_font_fmt_txt.c line #211)
[User]  (13.457, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 108   (in lv_font_fmt_txt.c line #211)
[User]  (13.460, +3)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 108   (in lv_font_fmt_txt.c line #211)
[User]  (13.462, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 121   (in lv_font_fmt_txt.c line #211)
[User]  (13.464, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 121   (in lv_font_fmt_txt.c line #211)
[User]  (13.464, +0)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 46   (in lv_font_fmt_txt.c line #211)
[User]  (13.467, +3)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 46   (in lv_font_fmt_txt.c line #211)
[User]  (13.469, +2)   get_glyph_dsc_id: Begin with font 0xa0026b7c and letter 0   (in lv_font_fmt_txt.c line #211)

As a test I updated lv_font_get_glyph_dsc_fmt_txt() to the following.

bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter,
                                   uint32_t unicode_letter_next)
{
    volatile uint32_t temp_unicode_letter = unicode_letter;
    volatile bool is_tab = false;
    if(temp_unicode_letter == '\t') {
        unicode_letter = ' ';
        is_tab = true;
    }
    lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)font->dsc;

This also seems to work with -Os.

Hi @theprogram01 ,

That is some serious debugging!

I can’t say I have come across anything like this before.
I am going to check the -Os flag on my own platform to see if this a general ‘GCC’ issue.

I do remember seeing this the other day, which is quite similar…

I’ll let know what I find.

Kind Regards,

Pete

Hi @theprogram01

It seems on the ‘GCC’ based toolchain I am using this issue does not exist when building LVGL with the -Os flag. (I am using ARM Cortex-A9 cores)

I am now not sure what we should do about it, do you consider this to be an issue with the compiler you are using?

Kind Regards,

Pete

Hi @pete-pjb,

In my toolchain it is a really plausible option that my compiler version has some issues. If I do a --version i get this.

arm-none-eabi-gcc.exe (Sourcery CodeBench Lite 2013.05-23) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

So the compiler is about 10 years old…

Maybe we should request an update for it. :wink:

Anyway, I am going to create an issue on GitHub and see what comes of it.

Edit: issue created Optimizer prevents font rendering · Issue #4370 · lvgl/lvgl · GitHub

Thanks for your help.

I’ve review and updated the links. Thank you for pointing it out.