打印
[应用相关]

移植LVGL9到STM32MP

[复制链接]
26|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wowu|  楼主 | 2024-12-19 14:22 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
下载源代码
git clone https://github.com/lvgl/lv_port_linux.git
cd lv_port_linux_frame_buffer/
git submodule update --init --recursive
cd lv_port_linux



加载STM32 MPU SDK
source $HOME/STM32MPU_workspace/Developer-Package/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi


修改CMakeLists.txt如下:
cmake_minimum_required(VERSION 3.10)
project(lvgl)

# 设置交叉编译
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
# 这里指定的路径必须是使用的交叉编译器的绝对路径
set(CMAKE_C_COMPILER /home/dx/STM32MPU_workspace/Developer-Package/SDK/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /home/dx/STM32MPU_workspace/Developer-Package/SDK/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++)

set(CMAKE_C_STANDARD 99)#C99 # lvgl officially support C99 and above
set(CMAKE_CXX_STANDARD 17)#C17
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

add_subdirectory(lvgl)
target_include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR})

add_executable(main main.c mouse_cursor_icon.c)

# 注释掉这行,如果要使用DRM驱动,则需要放开这行
#include(${CMAKE_CURRENT_LIST_DIR}/lvgl/tests/FindLibDRM.cmake)
#include_directories(${Libdrm_INCLUDE_DIRS})

# 注释掉下面三个,这个是在PC端使用的
#find_package(SDL2)
#find_package(SDL2_image)
#include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS})

target_link_libraries(main lvgl lvgl::examples lvgl::demos lvgl::thorvg ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${Libdrm_LIBRARIES} m pthread)
add_custom_target (run COMMAND ${EXECUTABLE_OUTPUT_PATH}/main DEPENDS main)




使用DRM驱动的话有些设备使用上述CMakeLists.txt即使把DRM驱动注释放开可能还是会编译报错,可尝试修改如下
cmake_minimum_required(VERSION 3.10)
project(lvgl)

# 设置交叉编译
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
# 这里指定的路径必须是绝对路径
set(CMAKE_C_COMPILER /home/dx/STM32MPU_workspace/Developer-Package/SDK/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /home/dx/STM32MPU_workspace/Developer-Package/SDK/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++)

set(CMAKE_C_STANDARD 99)#C99 # lvgl officially support C99 and above
set(CMAKE_CXX_STANDARD 17)#C17
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

add_subdirectory(lvgl)
add_executable(main main.c mouse_cursor_icon.c)

find_package(PkgConfig REQUIRED) # We use the platform independent pkg-config to find all the libs
pkg_check_modules(LIBDRM REQUIRED libdrm)
#pkg_check_modules(SDL2 REQUIRED sdl2)
#pkg_check_modules(SDL2_image REQUIRED SDL2_image)

target_include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR})
#target_include_directories(lvgl PRIVATE ${SDL2_INCLUDE_DIRS})
#target_include_directories(lvgl PRIVATE ${SDL2_IMAGE_INCLUDE_DIRS})
target_include_directories(lvgl PRIVATE ${LIBDRM_INCLUDE_DIRS})

target_link_libraries(main PRIVATE lvgl) # Add '-static' if you want a standalone binary
target_link_libraries(main PRIVATE lvgl::examples)
target_link_libraries(main PRIVATE lvgl::demos)
target_link_libraries(main PRIVATE lvgl::thorvg)
#target_link_libraries(main PRIVATE ${SDL2_LIBRARIES})
#target_link_libraries(main PRIVATE ${SDL2_IMAGE_LIBRARIES})
target_link_libraries(main PRIVATE ${LIBDRM_LIBRARIES})
target_link_libraries(main PRIVATE m)
target_link_libraries(main PRIVATE pthread)

add_custom_target(run COMMAND ${EXECUTABLE_OUTPUT_PATH}/main DEPENDS main)




编译
mkdir build
cd build
cmake ..
make


生成文件在bin文件夹下,拷贝到板子上运行即可
————————————————

                            版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/D_dx1/article/details/144466116

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

98

主题

4121

帖子

1

粉丝