There are some Hardfault in running examples

I am new to this library and have spent 2 days to port library and came across some problems and now I wanted to design my GUI so I tested every example first with my LCD to know my component first. however some of example presented in document page either not working correctly or have hardfault problem.

My hardware is STM32f103rbt6 64K Ram 256K flash on nucleo board
my software is keil V5 using cubemx
my lcd is 240*320 2.8inch tft 8-bit interface 4bit command

examples not work correctly
Keyboard shows but freezes by pressing any key
matrix button does not fit page properly
image example complian about cogwheel image file

examples with hardfault

That’s in the lv_examples repository (rework branch).

some of example presented in document page either not working correctly or have hardfault problem.

Have you tried them in the PC simulator? Do they crash there? Have you debugged to see where the hardfault occurs?

I am not using PC simulator.
I tested in Keil Debugger in Stm32 in realmicrocontroller
how deeply you need to know where code goes to Hard fault

I checked table example and it goes to hard fault in lv_task_handler

I went into function

/*Tasks with higher priority then the interrupted shall be run in every case*/
            else if(task_interrupter) {
                if(((lv_task_t *)LV_GC_ROOT(_lv_task_act))->prio > task_interrupter->prio) {
                    if(lv_task_exec(LV_GC_ROOT(_lv_task_act))) {
                        task_interrupter =
                            LV_GC_ROOT(_lv_task_act); /*Check all tasks again from the highest priority */
                        end_flag = false;

this part runs ok for the first time but in second time in the line

goes to hardfault
I went into function

in line

if(task->task_cb) task->task_cb(task);

there is a problem

Test if the exact same code works in the PC simulator. If it does, then it is probably an issue with your specific platform, and not LittlevGL itself.

Maybe you have a stack overflow problem?

I checked table example with simulator and It crashed but I checked that two variable been modified from static to normal function vars.
static lv_style_t style_cell1;
static lv_style_t style_cell2;
and this was culprit. If you can explain it that would be great so I learn about it

all other examples works when I increase LV_MEM_SIZE from 2 k to 3k

2-3 kilobytes is not enough memory for any real use of the library. It needs to be at least 16 kilobytes.

The lv_style_t object can’t go out of scope while LittlevGL is running. If it’s a normal function variable then it goes out of scope when the function returns, but LittlevGL keeps running.

By making it static you keep it around for the lifetime of the program.

1 Like