Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to transplant LittlevGL on rt-thread with raspberry pie 3b

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the raspberry pie 3b how to transplant LittlevGL on rt-thread, the article is very detailed, has a certain reference value, interested friends must read!

Raspberry pie 3b transplants LittlevGL on rt-thread

1. An overview of this article

This paper mainly describes the transplantation of lvgl on rt-thread aiming at raspberry pie 3b. The process of porting lvgl to rtt is realized in the simplest way. Just add a few files and you can use the latest version of the LittlevGL graphics library.

This article can also be tested on raspi qemu, you can learn the development of LittlevGL and rt-thread without the actual hardware development board.

two。 Resource preparation

Hardware resources:

Raspberry pie 3b+hdmi screen

Or use the qemu of raspberry pie to simulate. Related articles can follow my official Wechat account and teach you how to build rtt environment and qemu environment for raspberry pie. There will be no more narration here.

Software resources:

Get the source code for rtt:

Https://github.com/RT-Thread/rt-thread

Enter the bsp directory related to raspberry pie 3b

Rt-thread/bsp/raspberry-pi/raspi3-64 /

Then get the source code of lvgl

Https://github.com/littlevgl/lvgl

3. Hands-on experience

Step 1: download the source code

Https://github.com/bigmagic123/lvgl

Here is the fork on the original lvgl project, only a few files have been added, and how to modify it is described in detail later.

Put it under the rt-thread/bsp/raspberry-pi/raspi3-64/applications folder:

Where lv_conf.h is in the lvgl/lv_rtt_port folder directory

Step 2: rtt configuration using lvgl

Enter scons-- menuconfig in rt-thread/bsp/raspberry-pi/raspi3-64. Or enter menuconfig directly in the env tool.

Step 3: compile

Type scons in the console to start compilation.

CC build/kernel/src/scheduler.o

CC build/kernel/src/signal.o

CC build/kernel/src/thread.o

CC build/kernel/src/timer.o

LINK rtthread.elf

Aarch74-elf-objcopy-O binary rtthread.elf kernel8.img

Aarch74-elf-size rtthread.elf

Text data bss dec hex filename

308672 3856 95872 408400 63b50 rtthread.elf

Scons: done building targets.

Put the generated kernel8.img into the SD card of raspberry pie 3b, and enter test_lvgl in the serial console to see the screen.

The effect on the display screen is as follows:

See more clearly with a big screen

Of course, if you don't have raspberry pie hardware on hand, you can also experience it through qemu. First, you need to install the latest version of qemu. Just create the following running script.

If [!-f "sd.bin"]; then

Dd if=/dev/zero of=sd.bin bs=1024 count=65536

Fi

Qemu-system-aarch74-M raspi3-kernel kernel8.img-serial null-serial stdio-sd sd.bin-monitor pty

The execution effect is as follows

Seamless docking between 4.rt-thread and lvgl

This step is critical, how to seamlessly dock with as few modifications as possible, which requires an understanding of the driver framework model of lvgl and rtt.

First of all, rtt is compiled by SCons, while LittlevGL is compiled by makefile. Just add a few Sconscript scripts here.

Under the lvgl project, add the following Sconscript script

# RT-Thread building script for bridge

Import os

From building import *

Cwd = GetCurrentDir ()

Objs = []

List = os.listdir (cwd)

If GetDepend ('RT_USING_LVGL'):

For d in list:

Path = os.path.join (cwd, d)

If os.path.isfile (os.path.join (path, 'SConscript')):

Objs = objs + SConscript (os.path.join (d, 'SConscript'))

Return ('objs')

The above means to find the subdirectory under this directory and find the SConscript script.

Then add the above script to lvgl/src as well.

Then add the following script under lv_core, lv_draw, lv_font, lv_hal, lv_misc, lv_objx, lv_themes under the lvgl/ SRC subdirectory

From building import *

Cwd = GetCurrentDir ()

Src = Glob ('* .c') + Glob ('* .cpp') + Glob ('* .a')

CPPPATH = [cwd, str (Dir ('#'))]

Group = DefineGroup ('lv_hal', src, depend = ['], CPPPATH = CPPPATH)

Return ('group')

The meaning of this script is to compile all the files in that directory. This allows you to compile lvgl using scons.

Then write the docking driver, in order not to modify too much lvgl-related things, I set up a lv_rtt_port directory, specifically docking lvgl.

Lv_conf.h is the modified version of lv_conf_template.h under the lvgl project, which mainly modifies the width and height of the screen, as well as BPP.

Lv_port_rtt.c is the implementation of the lcd driver framework of rtt and the docking part of lvgl.

Sysmon.c is the demo program of https://github.com/littlevgl/lv_examples, under the lv_apps directory.

Rtt_lvgl_test.c is a program implemented on rtt to test lvgl, starting a gui thread.

Just finish this part.

In addition, there is only one change in rtt, that is, the driver of docking tick.

Void rt_hw_timer_isr (int vector, void * parameter)

{

# ifdef BSP_USING_CORETIMER

Rt_hw_set_gtimer_val (timerStep)

# else

ARM_TIMER_IRQCLR = 0

# endif

# ifdef RT_USING_LVGL

Lv_tick_inc (1)

# endif

Rt_tick_increase ()

}

Here is the hardware timer, where each tick generates an interrupt, and since no other timers are currently used, the same tick is used here as the operating system. It can also be implemented with a stand-alone tick or a software timer.

After these operations are complete, lvgl is ready to run on rtt.

The above is all the content of the article "how to transplant LittlevGL on rt-thread with raspberry pie 3b". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report