LittlevGL in Atollic TrueSTUDIO for STM32

I have build up a eclipse based project for my STM32F407VG MCU with the cubemx tool and opened the project with TrueSTUDIO for STM32.

Now I try to add the littlevgl library and got some problems. I cloned the library and checked-out version v6.0.2 from github. I copied and renamed the lv_conf_template.h file next to the lvgl folder and removed the if statement at the beginning of the file. I strictly followed the instructions from the porting section on the website.

Then I added the lvgl folder to the paths and symbols properties of the eclipse based project.

After building the project I got an error.

..\Src\main.c:70:18: error: expected declaration specifiers or '...' before '&' token
 lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10);    /*Initialize the display buffer*/
                  ^
..\Src\main.c:70:29: error: expected declaration specifiers or '...' before 'buf'
 lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10);    /*Initialize the display buffer*/
                             ^~~
In file included from c:\program files (x86)\atollic\truestudio for stm32 9.2.0\armtools\arm-atollic-eabi\include\string.h:17:0,
                 from ../lvgl/src/lv_hal/../lv_misc/lv_area.h:16,
                 from ../lvgl/src/lv_hal/lv_hal_disp.h:22,
                 from ../lvgl/src/lv_hal/lv_hal.h:16,
                 from ../lvgl/lvgl.h:24,
                 from ..\Src\main.c:47:
..\Src\main.c:70:34: error: expected declaration specifiers or '...' before '(' token

It seems that the project only finds the function names in the lv_hal_disp.h header file, but not in the corresponding lv_disp.c source file. Even searching for the function name with the C/C++ search tool from TrueSTUDIO I only can find the name in the header, not in the source.

Can anyone help me on how to get the project setting working on TrueSTUDIO for STM32?
Thank your in advance.

My guess from the snippet you have shown is that you are making a call to the lv_disp_buf_init function outside the scope of running code. Try moving that call into the main function.

1 Like

Thanks a lot. That solved my problem.