Openharmony之GPU Mesa3D移植一(weston 老框架)

奶盖
发布于 2023-3-2 11:07
浏览
0收藏

本文主要介绍在OpenHarmony上,基于RK3568移植开源GPU Mesa3D图形驱动,使用的基线版本是openharmony 的RK分支+kernel4.19+Weston。

注意:weston是老版本中使用的,新版中已使用renderservice替换。

1、获取openharmony rk分支版本代码

该基线版本是RK分支的OpenHarmony版本,选用此版本的原因是,该版本使能了闭源的GPU。

创建编译openharmony的docker,安装依赖,下载源码,以及编译

创建docker:
podman run --name hm-rk -it -v /home/test/22-01-30_rk /:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.7 /bin/bash
git config --global user.name “test”
git config --global user.email “test@com.cn
git config --global credential.helper store
安装依赖:
curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo
chmod a+x /usr/local/bin/repo
apt-get update && apt-get install -y binutils git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g+±multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby libssl-dev
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
下载源码:
repo init -u https://gitee.com/openharmonyrk/manifest -b master -m rk.xml --no-repo-verify
repo sync -c
repo forall -c ‘git lfs pull’
编译:
bash build/prebuilts_download.sh
./build.sh --product-name rk3568 --ccache

编译成功,刷机后,能进入系统,但是没有图形,注意RK版本的代码本省不能进图形是正常的。

2、编译5.10内核

Mesa3D需要高版本内核支持,而RK分支使用的是4.19的内核,所以需要升级内核,当前开源鸿蒙中2022.1.10后主干代码支持kernel5.10,因此编译kernel5.10需要使用Master 1.10以后的代码版本,具体如下:

mkdir hm-master && cd hm-master
podman run --name hm-master -it -v /home/test/hm-master/:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.7 /bin/bash
git config --global user.name “test”
git config --global user.email “test@.com.cn”
git config --global credential.helper store
curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo
chmod a+x /usr/local/bin/repo
repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
repo sync -c
repo forall -c ‘git lfs pull’
bash build/prebuilts_download.sh
./build.sh --product-name rk3568 --ccache --build-target kernel

注意:文档中只有本小节,即编译510内核才需要使用主干1.10以后的代码版本,其它小节均使用的是RK分支版本代码。

1)修改DTS

修改out/kernel/src_tmp/linux-5.10/arch/arm64/boot/dts/rockchip/rk3568.dtsi适配开源panfrost,如下:

--- arch/arm64/boot/dts/rockchip/rk3568.dtsi-bak        2022-02-15 01:39:52.169152789 +0000                                                                                         
+++ arch/arm64/boot/dts/rockchip/rk3568.dtsi    2022-02-15 02:02:42.096047298 +0000  
@@ -1169,36 +1169,23 @@                                
        };          
            
        gpu: gpu@fde60000 {  
-               compatible = "arm,mali-bifrost";  
-               reg = <0x0 0xfde60000 0x0 0x4000>;  
+               compatible = "rockchip, rk3568-mali", "arm,mali-bifrost";  
+               reg = <0x0 0xfde60000 0x0 0x20000>;  
  
  
-               interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,  
+               interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,  
                             <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,  
-                            <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>;  
-               interrupt-names = "GPU", "MMU", "JOB";  
-  
-               upthreshold = <40>;  
-               downdifferential = <10>;  
-  
+                            <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;  
+               interrupt-names = "job", "mmu", "gpu";  
                clocks = <&scmi_clk 1>, <&cru CLK_GPU>;  
-               clock-names = "clk_mali", "clk_gpu";  
-               power-domains = <&power RK3568_PD_GPU>;  
-               #cooling-cells = <2>;  
+               clock-names = "core", "bus";  
                operating-points-v2 = <&gpu_opp_table>;  
  
  
+               #cooling-cells = <2>;  
+               power-domains = <&power RK3568_PD_GPU>;  
                status = "disabled";  
-               gpu_power_model: power-model {  
-                       compatible = "simple-power-model";  
-                       leakage-range= <5 15>;  
-                       ls = <(-24002) 22823 0>;  
-                       static-coefficient = <100000>;  
-                       dynamic-coefficient = <953>;  
-                       ts = <(-108890) 63610 (-1355) 20>;  
-                       thermal-zone = "gpu-thermal";  
-               };  
        };  
  
  
-       gpu_opp_table: opp-table2 {  
+       gpu_opp_table: gpu-opp-table {  
                compatible = "operating-points-v2";  
  
  
                mbist-vmin = <825000 900000 950000>;  
@@ -1227,7 +1214,7 @@  
                };  
                opp-800000000 {  
                        opp-hz = /bits/ 64 <800000000>;  
-                       opp-microvolt = <950000>;  
+                       opp-microvolt = <1000000>;  
                };  
        };  

2)修改config配置

cd out/kernel/src_tmp/linux-5.10
make menuconfig ARCH=arm64

在graphic support中启用panfrost,

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

然后在Direct Rendering Manager取消选择Ignore drm ioctl permission,然后保存退出配置。

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

保存配置,并退出。

使用新的.config配置覆盖rockchip_linux_defconfig配置,使用make-ohos.sh脚本编译时config才能生效,如下:

cp .config arch/arm64/configs/rockchip_linux_defconfig

3)修改drivers/gpu/drm/drm_ioctl.c

修改out/kernel/src_tmp/linux-5.10/drivers/gpu/drm/drm_ioctl.c搜索关键字DUMB,将0修改为DRM_RENDER_ALLOW, 如下:

--- drivers/gpu/drm/drm_ioctl.c-bak     2022-02-16 02:16:18.211452279 +0000  
+++ drivers/gpu/drm/drm_ioctl.c 2022-02-16 02:17:01.138864226 +0000  
@@ -680,9 +680,9 @@  
        DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb_ioctl, 0),  
        DRM_IOCTL_DEF(DRM_IOCTL_MODE_PAGE_FLIP, drm_mode_page_flip_ioctl, DRM_MASTER),  
        DRM_IOCTL_DEF(DRM_IOCTL_MODE_DIRTYFB, drm_mode_dirtyfb_ioctl, DRM_MASTER),  
-       DRM_IOCTL_DEF(DRM_IOCTL_MODE_CREATE_DUMB, drm_mode_create_dumb_ioctl, 0),  
-       DRM_IOCTL_DEF(DRM_IOCTL_MODE_MAP_DUMB, drm_mode_mmap_dumb_ioctl, 0),  
-       DRM_IOCTL_DEF(DRM_IOCTL_MODE_DESTROY_DUMB, drm_mode_destroy_dumb_ioctl, 0),  
+       DRM_IOCTL_DEF(DRM_IOCTL_MODE_CREATE_DUMB, drm_mode_create_dumb_ioctl, DRM_RENDER_ALLOW),                                                                                    
+       DRM_IOCTL_DEF(DRM_IOCTL_MODE_MAP_DUMB, drm_mode_mmap_dumb_ioctl, DRM_RENDER_ALLOW),                                                                                         
+       DRM_IOCTL_DEF(DRM_IOCTL_MODE_DESTROY_DUMB, drm_mode_destroy_dumb_ioctl, DRM_RENDER_ALLOW),                                                                                  
        DRM_IOCTL_DEF(DRM_IOCTL_MODE_OBJ_GETPROPERTIES, drm_mode_obj_get_properties_ioctl, 0),                                                                                      
        DRM_IOCTL_DEF(DRM_IOCTL_MODE_OBJ_SETPROPERTY, drm_mode_obj_set_property_ioctl, DRM_MASTER),                                                                                 
        DRM_IOCTL_DEF(DRM_IOCTL_MODE_CURSOR2, drm_mode_cursor2_ioctl, DRM_MASTER), 

4)编译

PRODUCT_PATH=“vendor/hihope/rk3568” ./make-ohos.sh TB-RK3568X0

5)刷机

图中所示img全部使用新版内核中编译出来的img刷机,即master部分都需要刷入编译5.10内核出来的img,

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

3、编译Buildroot

编译环境:ubuntu20.04

1)下载代码

git clone https://gitee.com/xfan1024/oh-buildroot-mesa3d -b rpi3b
cd oh-buildroot-mesa3d
apt-get install cpio ruby -y

2)修改配置

make mesa3d_rpi3b_defconfig
make menuconfig ARCH=arm64

修改如下:

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

如果需要测试glmark2,还应该选中glmaster2

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

选中glmark2,然后保存退出,重新编译

3)编译

make -j8

4)刷机测试

在system分区刷入buildroot编译出来rootfs.ext2镜像,刷机成功后,在终端运行glmark2-es2-wayland,验证内核panfrost驱动和用户态panfrost驱动是否可以正常工作,具体如下:

mkdir /tmp/xdg
export XDG_RUNTIME_DIR=/tmp/xdg
weston --tty 1 &
glmark2-es2-wayland

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区
Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

4、重新编译rk分支

1)找到编译好的二进制文件

将通过buildroot编译出来的二进制文件拷贝到rk分支的device/rockchip/hardware/gpu/中,

output/target/usr/lib/libEGL.so.1  
output/target/usr/lib/libGLESv1_CM.so.1  
output/target/usr/lib/libGLESv2.so.2  
output/target/usr/lib/libgbm.so.1  
output/target/usr/lib/libglapi.so.0  
output/build/mesa3d-21.3.3/build/src/gallium/targets/dri/libgallium_dri.so  

2)修改rk分支代码对应的编译配置项

修改device/rockchip/rk3568/BUILD.gn

import("//build/ohos.gni")  
  
print("rk3568_group in")  
group("rk3568_group") {  
  deps = [  
  "//device/rockchip/hardware/gpu:libgallium_dri"  
  ]  
}

修改device\rockchip\hardware\gpu\BUILD.gn为:

import("//build/ohos.gni")  
import("//build/ohos/ndk/ndk.gni")  
  
mesa3d_common_prebuilts = [  
  "libgbm.so.1",  
  "libEGL.so.1",  
  "libglapi.so.0",  
  "libGLESv1_CM.so.1",  
  "libGLESv2.so.2",  
]  
  
mesa3d_common_deps = []  
foreach(file, mesa3d_common_prebuilts) {  
  target = "mesa3d-common-$file"  
  ohos_prebuilt_shared_library(target) {  
    source = file  
    subsystem_name = "hdf"  
    part_name = "hdf"  
    install_enable = true  
  }  
  mesa3d_common_deps += [ ":$target" ]  
}  
  
group("mali-bifrost-g52-g2p0-wayland") {  
  deps = mesa3d_common_deps  
}  
  
ohos_prebuilt_shared_library("libgallium_dri") {  
  source = "libgallium_dri.so"  
  part_name = "rockchip_products"  
  install_enable = true  
  symlink_target_name = [  
    "panfrost_dri.so",  
    "rockchip_dri.so",  
  ]  
}  

修改third_party/weston/libweston/renderer-gl/egl-glue.c

--- libweston/renderer-gl/egl-glue.c-bak        2022-02-16 15:10:25.758230255 +0800  
+++ libweston/renderer-gl/egl-glue.c    2022-02-16 15:13:36.431391104 +0800  
@@ -662,7 +662,8 @@  
                gr->has_dmabuf_import_modifiers = true;  
        }  
  
-       if (weston_check_egl_extension(extensions, "EGL_KHR_fence_sync")) {  
+       if (weston_check_egl_extension(extensions, "EGL_KHR_fence_sync") &&  
+               weston_check_egl_extension(extensions, "EGL_ANDROID_native_fence_sync")) {                                                                                          
                gr->create_sync =  
                        (void *) eglGetProcAddress("eglCreateSyncKHR");  
                gr->destroy_sync =  

修改foundation/graphic/standard/frameworks/surface/src/producer_egl_surface.cpp

--- foundation/graphic/standard/frameworks/surface/src/producer_egl_surface.cpp-bak     2022-02-16 15:16:00.298830342 +0800                                                         
+++ foundation/graphic/standard/frameworks/surface/src/producer_egl_surface.cpp 2022-02-16 15:18:26.454451058 +0800                                                                 
@@ -307,6 +307,9 @@  
     if (CreateEglFenceFd(fd) != SURFACE_ERROR_OK) {  
         BLOGNE("CreateEglFenceFd failed.");  
         // return SURFACE_ERROR_ERROR;  
+       fd = EGL_NO_NATIVE_FENCE_FD_ANDROID;  
+       glFlush();  
+       glFinish();  
     }  
     BLOGNE("flush fence fd %{public}d.", fd);  

修改base/startup/init_lite/ueventd/etc/ueventd.config

--- base/startup/init_lite/ueventd/etc/ueventd.config-bak       2022-02-16 15:19:16.460426687 +0800                                                                                 
+++ base/startup/init_lite/ueventd/etc/ueventd.config   2022-02-16 15:19:44.243635535 +0800                                                                                         
@@ -73,4 +73,5 @@  
 /dev/rtc0 0640 1000 1000  
 /dev/tty0 0660 0 1000  
 /dev/uinput 0660 3011 3011  
-  
+/dev/dri/card1 0666 0 1003  
+/dev/dri/renderD129 0666 0 1003  

修改third_party/wayland_standard/BUILD.gn

--- ../22-01-30_rk-bak/third_party/wayland_standard/BUILD.gn    2022-01-30 15:37:09.000000000 +0800                  
+++ third_party/wayland_standard/BUILD.gn       2022-02-21 17:59:33.821781825 +0800  
@@ -181,6 +181,22 @@  
   ]  
 }  
  
+ohos_shared_library("wayland_egl") {  
+  sources = [  
+    "egl/wayland-egl.c",  
+  ]  
+  include_dirs = [  
+    "egl",  
+    "include/protocol",  
+    "src",  
+  ]  
+  public_deps = [  
+    ":wayland_core_protocol",  
+    ":wayland_version",  
+  ]  
+  part_name = "graphic_standard"  
+  subsystem_name = "graphic"  
+}  
 ohos_shared_library("libwayland_client.0") {  
   sources = [  
     "src/connection.c",  

修改third_party/weston/BUILD.gn

--- /home/test/22-01-30_rk-bak/third_party/weston/BUILD.gn  2022-01-30 15:37:09.000000000 +0800  
+++ third_party/weston/BUILD.gn 2022-02-21 17:51:04.904373460 +0800  
@@ -392,6 +392,7 @@  
     "libweston",  
     "libweston/backend-drm/auth",  
     ".",  
+    "//third_party/wayland_standard/egl",  
   ]  
  
   cflags = [  
@@ -496,6 +497,7 @@  
     "//third_party/wayland_standard:libwayland_client",  
     "//device/rockchip/hardware/gpu:mali-bifrost-g52-g2p0-wayland",  
     "//foundation/graphic/standard/frameworks/wmserver:wms_protocol",  
+    "//third_party/wayland_standard:wayland_egl",  
   ]  
  
   part_name = "graphic_standard"  

修改配置foundation/graphic/standard/frameworks/animation_server/BUILD.gn

--- a/frameworks/animation_server/BUILD.gn  
+++ b/frameworks/animation_server/BUILD.gn  
@@ -116,6 +116,7 @@ ohos_executable("animation_server") {  
     "//foundation/graphic/standard:libwmservice",  
     "//foundation/graphic/standard/utils:libgraphic_utils",  
     "//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",  
+    "//device/hihope/hardware/gpu:mali-bifrost-g52-g2p0-wayland",  
   ]  
  
   part_name = "graphic_standard"  

修改third_party/weston/weston.cfg 配置,

--- ../22-01-30_rk-bak/third_party/weston/weston.cfg    2022-01-30 15:37:09.000000000 +0800                                                                                         
+++ third_party/weston/weston.cfg       2022-02-22 09:51:33.688896864 +0800  
@@ -14,6 +14,8 @@  
                 "export XKB_CONFIG_EXTRA_PATH /etc/xkb",  
                 "mkdir /data/weston",  
                 "chmod 777 /data/weston",  
+                "chmod 777 -R /dev/dri/*",  
+                "export LIBGL_DRIVERS_PATH /system/lib",  
                 "start weston",  
                 "trigger weston_start",  
                 "sleep 2"  

3)重新编译

./build.sh --product-name rk3568 –ccache

4)刷机

System、vendor、userdata 3个分区刷入rk分支新编译出来的img,

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

刷机成功后,能正常进入系统,图形也正常启动,使用中速度明显感觉快了很多,即使输入wifi密码也能成功。

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

5、问题

1)内核编译报错:

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区
解决办法:

使用命令,

PRODUCT_PATH=“vendor/hihope/rk3568” ./make-ohos.sh TB-RK3568X0

2)内核刷机后进不了系统

把rk编译出来的img刷机后能进入系统,但是没有图形,把之前编译出来的rootfs.ext2和新编译出来的510内核boot_linux.img刷机后,串口显示如下:

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

解决办法:

有两种办法,一是把新老boot_linux.img 解压开对比

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

新老版中extlinux.conf对比发现都是类似的内容,唯一的区别就是有如TC031C的标识,串口输出中有找不到extlinux.conf.TC031C的打印

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

把old中extlinux.conf.TC031C拷贝到新版中,并复制toybrick.dtb为toybrick.dtb.TC031C

cd new
cp toybrick.dtb toybrick.dtb.TC031C
cp …/old/extlinux.conf.TC031C ./

重新刷入新的boot_linux.img,正常进入系统。

二是图中所示img全部使用新版内核中编译出来的img刷机(推荐该办法)。

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

3)编译buildroot报错

编译报如下:
Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

解决办法:

删除output目录,修改编译参数重新编译

rm -rf output/
make -j8

Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

4)编译rk报错undefined symbol: wl_egl_window_create

错误提示如下:

ld.lld: error: undefined symbol: wl_egl_window_create  
>>> referenced by simple-egl-hos.c:371 (../../third_party/weston/clients/simple-egl-hos.c:371)  
>>>               obj/third_party/weston/clients/simple-egl-hos/simple-egl-hos.o:(main)  
  
ld.lld: error: undefined symbol: wl_egl_window_destroy  
>>> referenced by simple-egl-hos.c:418 (../../third_party/weston/clients/simple-egl-hos.c:418)  
>>>               obj/third_party/weston/clients/simple-egl-hos/simple-egl-hos.o:(main)  
clang-10: error: linker command failed with exit code 1 (use -v to see invocation) 

解决办法:

在third_party/wayland_standard/BUILD.gn中新增编译wayland-egl.c

--- ../22-01-30_rk-bak/third_party/wayland_standard/BUILD.gn    2022-01-30 15:37:09.000000000 +0800                  
+++ third_party/wayland_standard/BUILD.gn       2022-02-21 17:59:33.821781825 +0800  
@@ -181,6 +181,22 @@  
   ]  
 }  
  
+ohos_shared_library("wayland_egl") {  
+  sources = [  
+    "egl/wayland-egl.c",  
+  ]  
+  include_dirs = [  
+    "egl",  
+    "include/protocol",  
+    "src",  
+  ]  
+  public_deps = [  
+    ":wayland_core_protocol",  
+    ":wayland_version",  
+  ]  
+  part_name = "graphic_standard"  
+  subsystem_name = "graphic"  
+}  
 ohos_shared_library("libwayland_client.0") {  
   sources = [  
     "src/connection.c",  

在third_party/weston/BUILD.gn中增加对应的依赖

--- /home/test/22-01-30_rk-bak/third_party/weston/BUILD.gn  2022-01-30 15:37:09.000000000 +0800  
+++ third_party/weston/BUILD.gn 2022-02-21 17:51:04.904373460 +0800  
@@ -392,6 +392,7 @@  
     "libweston",  
     "libweston/backend-drm/auth",  
     ".",  
+    "//third_party/wayland_standard/egl",  
   ]  
  
   cflags = [  
@@ -496,6 +497,7 @@  
     "//third_party/wayland_standard:libwayland_client",  
     "//device/rockchip/hardware/gpu:mali-bifrost-g52-g2p0-wayland",  
     "//foundation/graphic/standard/frameworks/wmserver:wms_protocol",  
+    "//third_party/wayland_standard:wayland_egl",  
   ]  
  
   part_name = "graphic_standard"  

5)编译rk报错undefined symbol: glEnable

错误提示如下:

[OHOS INFO] [2775/3124] ACTION //third_party/jsframework:ark_jsf(//build/toolchain/ohos:ohos_clang_arm)  
^[[91m[OHOS ERROR]^[[0m [2756/3124] LINK graphic/graphic_standard/animation_server  
^[[91m[OHOS ERROR]^[[0m FAILED: graphic/graphic_standard/animation_server exe.unstripped/graphic/graphic_standard/animation_server  
^[[91m[OHOS ERROR]^[[0m /usr/bin/env "../../build/toolchain/gcc_link_wrapper.py" --output="graphic/graphic_standard/animation_server" --strip="../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-strip" --unstripped-file="./exe.unstripped/graphic/graphic_standard/animation_server" -- ../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang++ -Wl,--fatal-warnings -Wl,--build-id=md5 -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -Wl,--no-undefined -Wl,--exclude-libs=libunwind_llvm.a -Wl,--exclude-libs=libc++_static.a -Wl,--exclude-libs=libvpx_assembly_arm.a --target=arm-linux-ohosmusl -Werror -Wl,--warn-shared-textrel -Wl,-O2 -Wl,--gc-sections -Wl,--gdb-index --sysroot=obj/third_party/musl -nostdlib -L../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/arm-linux-ohosmusl/c++ -Lobj/third_party/musl/usr/lib/arm-linux-ohosmusl -L../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/10.0.1/lib/arm-linux-ohosmusl -Wl,--warn-shared-textrel -Bdynamic -Wl,-z,nocopyreloc -pie -o "./exe.unstripped/graphic/graphic_standard/animation_server" obj/third_party/musl/usr/lib/arm-linux-ohosmusl/Scrt1.o obj/third_party/musl/usr/lib/arm-linux-ohosmusl/crti.o -Wl,--start-group  @"graphic/graphic_standard/animation_server.rsp"  -lunwind ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/10.0.1/lib/arm-linux-ohosmusl/libclang_rt.builtins.a -lc -lc++ -lc++abi -ldl -lm -Wl,--end-group  obj/third_party/musl/usr/lib/arm-linux-ohosmusl/crtn.o  
^[[91m[OHOS ERROR]^[[0m ld.lld: ^[[91merror^[[0m: undefined symbol: glEnable  
^[[91m[OHOS ERROR]^[[0m >>> referenced by rotation_animation.cpp:47 (../../foundation/graphic/standard/frameworks/animation_server/server/src/rotation_animation.cpp:47)  
^[[91m[OHOS ERROR]^[[0m >>>               obj/foundation/graphic/standard/frameworks/animation_server/server/src/animation_server/rotation_animation.o:(OHOS::RotationAnimation::Init(OHOS::RotationAnimationParam&))  
foundation/graphic/standard/frameworks/animation_server/server/src/rotation_animation.cpp:47)  
^[[91m[OHOS ERROR]^[[0m >>>               obj/foundation/graphic/standard/frameworks/animation_server/server/src/animation_server/rotation_animation.o:(OHOS::RotationAnimation::Init(OHOS::RotationAnimationParam&))  

使用nm -D 或者 objdump -tT 确定 glEnable 在哪个库文件中定义

nm -D libGLESv2.so.2 |grep glEnable
000068fc T glEnable
00006918 T glEnableVertexAttribArray
00006934 T glEnablei

然后修改配置foundation/graphic/standard/frameworks/animation_server/BUILD.gn,增加对应的依赖,

--- a/frameworks/animation_server/BUILD.gn  
+++ b/frameworks/animation_server/BUILD.gn  
@@ -116,6 +116,7 @@ ohos_executable("animation_server") {  
     "//foundation/graphic/standard:libwmservice",  
     "//foundation/graphic/standard/utils:libgraphic_utils",  
     "//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",  
+    "//device/hihope/hardware/gpu:mali-bifrost-g52-g2p0-wayland",  
   ]  
  
   part_name = "graphic_standard"  

编译成功。

6)刷机进入系统后图形起不来

在终端执行ps -ef|grep weston,如果没有weston,即weston没有起来,如下:
Openharmony之GPU Mesa3D移植一(weston 老框架)-鸿蒙开发者社区

原因则是weston.cfg配置中没有加入export LIBGL_DRIVERS_PATH /system/lib环境变量。

如果出现如下:

# ps -ef |grep weston                                                            
root           238     1 11 12:46:17 ?    00:00:22 weston -c /system/etc/weston.ini -B drm-backend.so --tty=1 --use-pixman  
root           782   286 8 12:49:47 ttyFIQ0 00:00:00 grep weston  

最终定位到third_party/weston/weston.cfg 配置问题,weston服务启动时不能添加–use-pixman参数,如果有该参数,需要删除该参数,一下是基于RK分支代码weston的修改:

--- ../22-01-30_rk-bak/third_party/weston/weston.cfg    2022-01-30 15:37:09.000000000 +0800                                                                                         
+++ third_party/weston/weston.cfg       2022-02-22 09:51:33.688896864 +0800  
@@ -14,6 +14,8 @@  
                 "export XKB_CONFIG_EXTRA_PATH /etc/xkb",  
                 "mkdir /data/weston",  
                 "chmod 777 /data/weston",  
+                "chmod 777 -R /dev/dri/*",
+                "export LIBGL_DRIVERS_PATH /system/lib",  
                 "start weston",  
                 "trigger weston_start",  
                 "sleep 2"  

文章转载自作者:易阳天

已于2023-3-2 11:07:45修改
收藏
回复
举报
回复
    相关推荐