rtems, lvgl,

Embedded GUI application on RTEMS using LittlevGL

Vijay K. Banerjee (thelunatic) Vijay K. Banerjee (thelunatic) Sep 27, 2019 · 3 mins read
Embedded GUI application on RTEMS using LittlevGL
Share this

LittlevGL is a graphics library targetted to embedded systems with limited resources. I learnt about littlevGL (lvgl) during my search for a graphics library that will be suitable for a GUI app directly using the framebuffer.

RTEMS-littlevGL

To port lvgl to rtems rtems-littlevgl package was developed using the waf build system to create a liblvgl.a library that can be linked with rtems apps.

We’re going to walk through an example GUI app that I built on Beaglebone black target using rtems-libbsd. First we’ll clone the rtems-littlevgl package.

1
2
3
git clone git://git.rtems.org/packages/rtems-littlevgl.git
git submodule init
git submodule update

Time to waf it! Run waf from the root of the rtems-littlevgl tree and all the files will be built as required.

1
2
./waf configure --prefix=<YOUR_RTEMS_PREFIX> --rtems-bsps=arm/beagleboneblack
./waf build install

If we don’t already have it, we’ll also have to install rtems-libbsd. There are two ways of doing that:

  • We can clone rtems-libbsd and waf it.
  • We can use the RTEMS Source Builder (RSB) to build it.

Here we’ll use the second option and build it like this:

1
2
cd rsb/rtems
../source-builder/sb-set-builder --prefix=$RTEMS_PREFIX 5/rtems-libbsd

An example application

lvgl sample app
lvgl sample app

We’ll go through an example application that uses lvgl to output a nice hello world image on the screen. This example has been added to the rtems-examples repository and can be found here.

Since RTEMS currently supports the BBB framebuffer through libbsd, the FreeBSD fb port is necessary. The FreeBSD fb is enable in the rtems-littlevgl by default. To edit the default configurations, we’ll have to edit the lv_conf.h and lv_drv_conf.h files in the rtems-littlevgl directory.

Below is the part of Init function that prints the hello world label:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
	static lv_color_t buf[LV_HOR_RES_MAX*10];
	static lv_disp_buf_t disp_buf;

	/* First the rtems_bsd needs to be initialized */
	sc = rtems_bsd_initialize();
	assert(sc == RTEMS_SUCCESSFUL);

	/*lv_init and fbdev_init initializes the lvgl and framebuffer respectively
	*/
	lv_init();

	fbdev_init();

	lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX*10);

	/* Initialize and register a display driver with the fbdev_flush function.
	 * Note that this function is already provided with lv_drivers and no need
	 * to define it again.
	 */

	lv_disp_drv_t disp_drv;
	lv_disp_drv_init(&disp_drv);
	disp_drv.buffer = &disp_buf;
	disp_drv.flush_cb = fbdev_flush;
	lv_disp_drv_register(&disp_drv);

	/* Create the Hello world lable */
	lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
	lv_label_set_text(label, "Hello world!");
	lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);

	lv_tick_inc(5);
	/* This handler runs the lvgl task and is necessary to call */
	lv_task_handler();

Summary

In this blog I discussed about the rtems-littlevgl package and explained an example app using littlevlg. Hope this was helpful in getting you started with littlevgl GUI applications on RTEMS.

For further reading, please refer to the RTEMS and lvgl documentations.

Thank you for stopping by and happy hacking ;-)