您尚未登录。

楼主 #1 2020-02-08 21:33:11

达克罗德
会员
注册时间: 2018-04-10
已发帖子: 1,138
积分: 1090.5

A33主线Linux跑起OpenGL/ES

A33的GPU有两个方向,开源的Lima和非开源的全志OpenGL库
Lima+Mesa3D
LIMA只需要在内核选上LIMA和SUN4I的DRM驱动即可
Mesa3D可以在buildroot选上
不过最后我运行mesa的demo直接出错也找不到问题就放弃了,不知道是哪里的问题,网上教程太少不会玩。

这时候我切到第二个方案:
其实教程就是 https://github.com/mripard/sunxi-mali

但是这里有个坑(我选的fbdev的库),导致一运行malitest就出错(malitest可以自己编一个 https://github.com/linux-sunxi/sunxi-mali/tree/master/test

查资料得到了信息
1. Must enable DRM_FBDEV_LEAK_PHYS_SMEM from kernel
2. set drm_leak_fbdev_smem on compile time (for some reason, passing in command line did not help) in drm_fb_helper.c
3. use latest r8p1

这回终于跑起来了

malitest和QT的OpenGL例子都运行正常

对了,最好在buildroot里选上sunxi-mali-mainline,这样它会自动给你生成一个启动时加载mali.ko的脚本。
当然,自己modprobe也是可以的

[    2.290176] mali: loading out-of-tree module taints kernel.
[    2.303401] using random self ethernet address
[    2.310432] Allwinner sunXi mali glue initialized
[    2.310892] using random host ethernet address
[    2.319040] Mali: 
[    2.319045] Found Mali GPU Mali-400 MP r1p1
[    2.325812] using random self ethernet address
[    2.344761] using random host ethernet address
[    2.352326] usb0: HOST MAC 3a:7e:4f:95:4b:5d
[    2.359199] usb0: MAC f6:29:20:a6:b8:86
[    2.365680] g_ffs gadget: g_ffs ready
[    2.386332] Mali: 
[    2.386337] 2+0 PP cores initialized
[    2.396969] Mali: 
[    2.396971] Mali device driver loaded

运行malitest的结果,可以验证是否正确

EGL Version: "1.4 Linux-r8p1-00rel0"
EGL Vendor: "ARM"
EGL Extensions: "EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_reusable_sync EGL_KHR_fence_sync EGL_KHR_lock_surface EGL_KHR_lock_surface2 EGL_EXT_create_context_robustness EGL_ANDROID_blob_cache EGL_KHR_create_context EGL_KHR_partial_update EGL_KHR_create_context_no_error "
Surface size: 1024x600
GL Vendor: "ARM"
GL Renderer: "Mali-400 MP"
GL Version: "OpenGL ES 2.0 "mali450-r5p1-01rel0-lollipop-233-g52c929d""
GL Extensions: "GL_OES_texture_npot GL_OES_vertex_array_object GL_OES_compressed_ETC1_RGB8_texture GL_EXT_compressed_ETC1_RGB8_sub_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_depth24 GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth_texture GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 GL_OES_vertex_half_float GL_EXT_blend_minmax GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_rgb8_rgba8 GL_EXT_multisampled_render_to_texture GL_EXT_discard_framebuffer GL_OES_get_program_binary GL_ARM_mali_program_binary GL_EXT_shader_texture_lod GL_EXT_robustness GL_OES_depth_texture_cube_map GL_KHR_debug GL_ARM_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch_depth_stencil GL_OES_mapbuffer GL_KHR_no_error"

这里有点比较老的介绍,虽然过时了,但是比较系统
https://linux-sunxi.org/Mali_binary_driver

最近编辑记录 达克罗德 (2020-02-08 21:59:12)

离线

楼主 #2 2020-02-08 21:37:17

达克罗德
会员
注册时间: 2018-04-10
已发帖子: 1,138
积分: 1090.5

Re: A33主线Linux跑起OpenGL/ES

主线uboot和内核的配置可以参见另一个帖子
全志A33 主线u-boot/Linux入坑记录 https://whycan.cn/t_3643.html

最近编辑记录 达克罗德 (2020-02-08 21:37:41)

离线

#3 2020-02-08 21:40:09

晕哥
管理员
注册时间: 2017-09-06
已发帖子: 9,336
积分: 9202

离线

#4 2020-02-09 14:48:01

微凉VeiLiang
会员
所在地: 深圳
注册时间: 2018-10-28
已发帖子: 620
积分: 520
个人网站

Re: A33主线Linux跑起OpenGL/ES

厉害了,感谢分享

离线

#5 2020-02-09 14:57:12

sea18c
会员
注册时间: 2019-08-05
已发帖子: 230
积分: 222.5

Re: A33主线Linux跑起OpenGL/ES

玩的东西越来越多了

离线

#6 2020-02-09 20:41:00

sinlinx
会员
注册时间: 2020-02-07
已发帖子: 5
积分: 5

Re: A33主线Linux跑起OpenGL/ES

感谢楼主分享

离线

#7 2020-03-13 08:01:43

KevinS
会员
注册时间: 2020-01-18
已发帖子: 23
积分: 18

Re: A33主线Linux跑起OpenGL/ES

达克罗德 说:

A33的GPU有两个方向,开源的Lima和非开源的全志OpenGL库
Lima+Mesa3D
LIMA只需要在内核选上LIMA和SUN4I的DRM驱动即可
Mesa3D可以在buildroot选上
不过最后我运行mesa的demo直接出错也找不到问题就放弃了,不知道是哪里的问题,网上教程太少不会玩。

这时候我切到第二个方案:
其实教程就是https://github.com/mripard/sunxi-mali

但是这里有个坑(我选的fbdev的库),导致一运行malitest就出错(malitest可以自己编一个https://github.com/linux-sunxi/sunxi-mali/tree/master/test)

查资料得到了信息
1. Must enable DRM_FBDEV_LEAK_PHYS_SMEM from kernel
2. set drm_leak_fbdev_smem on compile time (for some reason, passing in command line did not help) in drm_fb_helper.c
3. use latest r8p1

这回终于跑起来了

malitest和QT的OpenGL例子都运行正常

对了,最好在buildroot里选上sunxi-mali-mainline,这样它会自动给你生成一个启动时加载mali.ko的脚本。
当然,自己modprobe也是可以的


运行malitest的结果,可以验证是否正确

这里有点比较老的介绍,虽然过时了,但是比较系统
https://linux-sunxi.org/Mali_binary_driver


我这边运行 test 程序直接出现 Error: eglCreateWindowSurface failed: 0x00003003
查询错误码 是 EGL_BAD_ALLOC, 用的r8p1 fbdev ,你又遇到这个问题吗?

离线

楼主 #8 2020-03-13 08:10:09

达克罗德
会员
注册时间: 2018-04-10
已发帖子: 1,138
积分: 1090.5

Re: A33主线Linux跑起OpenGL/ES

我这边运行 test 程序直接出现 Error: eglCreateWindowSurface failed: 0x00003003
查询错误码 是 EGL_BAD_ALLOC, 用的r8p1 fbdev ,你又遇到这个问题吗?

我也是遇到这个问题
2. set drm_leak_fbdev_smem on compile time (for some reason, passing in command line did not help) in drm_fb_helper.c
这个改了吗?我改了这个就好
另外记得把drm的Framebuffer设成200既2倍大小
还有如果有其它程序用fb比如xserver,要先关掉

离线

#9 2020-03-13 10:25:49

KevinS
会员
注册时间: 2020-01-18
已发帖子: 23
积分: 18

Re: A33主线Linux跑起OpenGL/ES

达克罗德 说:

我也是遇到这个问题
2. set drm_leak_fbdev_smem on compile time (for some reason, passing in command line did not help) in drm_fb_helper.c
这个改了吗?我改了这个就好
另外记得把drm的Framebuffer设成200既2倍大小
还有如果有其它程序用fb比如xserver,要先关掉

这两个选项都打开,然后 OVERALLOC设成300,问题依旧
网上查了好久都没有解决

原来用的5.5.5的内核,现在在编译4.19的lts版本再试试

离线

#10 2020-03-13 11:04:08

KevinS
会员
注册时间: 2020-01-18
已发帖子: 23
积分: 18

Re: A33主线Linux跑起OpenGL/ES

换成4.19的内核也不行,现在的问题是 不管overalloc更改成200,还是300,系统中的y_virtual 都是600

# ./egl_test 
EGL Version: "1.4 Linux-r8p1-00rel0"
EGL Vendor: "ARM"
EGL Extensions: "EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_reusable_sync EGL_KHR_fence_sync EGL_KHR_lock_surface EGL_KHR_lock_surface2 EGL_EXT_create_context_robustness EGL_ANDROID_blob_cache EGL_KHR_create_context EGL_KHR_partial_update EGL_KHR_create_context_no_error "
The mem is :2457600
The line_length is :4096
The xres is :1024
The yres is :600
The xres_v is :1024
The yres_v is :600
bits_per_pixel is :32
Error: eglCreateWindowSurface failed: 0x00003003

见了鬼了

离线

楼主 #11 2020-03-13 12:18:34

达克罗德
会员
注册时间: 2018-04-10
已发帖子: 1,138
积分: 1090.5

Re: A33主线Linux跑起OpenGL/ES

virtual应该翻倍才对

离线

楼主 #12 2020-03-13 12:26:45

达克罗德
会员
注册时间: 2018-04-10
已发帖子: 1,138
积分: 1090.5

Re: A33主线Linux跑起OpenGL/ES

你的fb是simplefb还是drm生成的fb?我是用sun4i drm。只有drm的fb可以设置大小

离线

#13 2020-03-13 13:28:45

Jmhh247
会员
注册时间: 2018-12-21
已发帖子: 262
积分: 262

Re: A33主线Linux跑起OpenGL/ES

你的驱动不支持双缓冲。

The mem is :2457600 = 600 * 4096,显存明显只一个帧缓冲大小。

必须大于双缓冲以上的显存,y_virtual 才能翻倍。





KevinS 说:

换成4.19的内核也不行,现在的问题是 不管overalloc更改成200,还是300,系统中的y_virtual 都是600

# ./egl_test 
EGL Version: "1.4 Linux-r8p1-00rel0"
EGL Vendor: "ARM"
EGL Extensions: "EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_reusable_sync EGL_KHR_fence_sync EGL_KHR_lock_surface EGL_KHR_lock_surface2 EGL_EXT_create_context_robustness EGL_ANDROID_blob_cache EGL_KHR_create_context EGL_KHR_partial_update EGL_KHR_create_context_no_error "
The mem is :2457600
The line_length is :4096
The xres is :1024
The yres is :600
The xres_v is :1024
The yres_v is :600
bits_per_pixel is :32
Error: eglCreateWindowSurface failed: 0x00003003

见了鬼了

离线

#14 2020-03-13 15:23:53

KevinS
会员
注册时间: 2020-01-18
已发帖子: 23
积分: 18

Re: A33主线Linux跑起OpenGL/ES

用drm 的fb后可以有 双缓冲了,但是现在程序又死在 eglSwapBuffers中了,直接不返回了

离线

#15 2020-03-14 19:31:13

KevinS
会员
注册时间: 2020-01-18
已发帖子: 23
积分: 18

Re: A33主线Linux跑起OpenGL/ES

NND, 终于跑起来了, 4.19.5内核外加补丁

离线

楼主 #16 2020-03-14 19:58:20

达克罗德
会员
注册时间: 2018-04-10
已发帖子: 1,138
积分: 1090.5

Re: A33主线Linux跑起OpenGL/ES

KevinS 说:

NND, 终于跑起来了, 4.19.5内核外加补丁

按理5.5不需要补丁,我没有打补丁

离线

#17 2020-03-14 21:52:53

KevinS
会员
注册时间: 2020-01-18
已发帖子: 23
积分: 18

Re: A33主线Linux跑起OpenGL/ES

我是直接用buildroot编译的,选择了mali-driver,选的5.5.5的内核,全自动完成,烧录后运行就直接死掉,串口都不响应了,只能硬重启
你是这样的吗?你是怎么编译的?

离线

楼主 #18 2020-03-15 00:04:39

达克罗德
会员
注册时间: 2018-04-10
已发帖子: 1,138
积分: 1090.5

Re: A33主线Linux跑起OpenGL/ES

KevinS 说:

我是直接用buildroot编译的,选择了mali-driver,选的5.5.5的内核,全自动完成,烧录后运行就直接死掉,串口都不响应了,只能硬重启
你是这样的吗?你是怎么编译的?

我是用的 https://github.com/mripard/sunxi-mali
这里面的驱动编的mali.ko

离线

#19 2020-03-15 16:45:34

KevinS
会员
注册时间: 2020-01-18
已发帖子: 23
积分: 18

Re: A33主线Linux跑起OpenGL/ES

达克罗德 说:

我是用的https://github.com/mripard/sunxi-mali
这里面的驱动编的mali.ko

buildroot也是用的这个地址的驱动编译的,你编译的时候有没有手动打补丁,还是直接用里面的build.sh编译的?

离线

楼主 #20 2020-03-15 18:18:53

达克罗德
会员
注册时间: 2018-04-10
已发帖子: 1,138
积分: 1090.5

Re: A33主线Linux跑起OpenGL/ES

KevinS 说:

buildroot也是用的这个地址的驱动编译的,你编译的时候有没有手动打补丁,还是直接用里面的build.sh编译的?

没有手动打补丁,也许build.sh打了补丁。。不知道buildroot是不是完全等效这个

离线

#21 2020-03-16 10:30:07

KevinS
会员
注册时间: 2020-01-18
已发帖子: 23
积分: 18

Re: A33主线Linux跑起OpenGL/ES

有重新编译了一遍5.3.6, 这次手动编译mali驱动,加载进去,运行测试程序还是死机

离线

楼主 #22 2020-03-16 11:11:57

达克罗德
会员
注册时间: 2018-04-10
已发帖子: 1,138
积分: 1090.5

Re: A33主线Linux跑起OpenGL/ES

KevinS 说:

有重新编译了一遍5.3.6, 这次手动编译mali驱动,加载进去,运行测试程序还是死机

drm_fb_helper.c改了吗?

离线

#23 2020-03-16 11:29:27

KevinS
会员
注册时间: 2020-01-18
已发帖子: 23
积分: 18

Re: A33主线Linux跑起OpenGL/ES

下载的那个4.19.5的patch,里面的drm_fb_helper.c的patch用不了吧?
4.19的drm_fb_helper.c 有3000多行
5.x的drm_fb_helper.c才2000多行,patch没法打啊

离线

#24 2020-03-16 11:35:32

KevinS
会员
注册时间: 2020-01-18
已发帖子: 23
积分: 18

Re: A33主线Linux跑起OpenGL/ES

5.x的源码是打过补丁的

离线

#25 2020-03-16 11:37:26

KevinS
会员
注册时间: 2020-01-18
已发帖子: 23
积分: 18

Re: A33主线Linux跑起OpenGL/ES

达克罗德 说:

drm_fb_helper.c改了吗?

能不能把你的具体编译流程说一下,我这边除了用4.19.5然后手动打网上的patch外,其他还没有成功过

离线

楼主 #26 2020-03-16 14:35:11

达克罗德
会员
注册时间: 2018-04-10
已发帖子: 1,138
积分: 1090.5

Re: A33主线Linux跑起OpenGL/ES

KevinS 说:

能不能把你的具体编译流程说一下,我这边除了用4.19.5然后手动打网上的patch外,其他还没有成功过

#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
static bool drm_leak_fbdev_smem = true;
module_param_unsafe(drm_leak_fbdev_smem, bool, 0600);
MODULE_PARM_DESC(drm_leak_fbdev_smem,
		 "Allow unsafe leaking fbdev physical smem address [default=false]");
#endif

我记得有人说4.x之后需要这样改动:
config打开CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM
然后在drm_fb_helper.c中drm_leak_fbdev_smem设置true;
其他就是按照那个github说明编maili.ko

离线

#27 2020-06-09 09:22:57

skliu
会员
注册时间: 2020-06-07
已发帖子: 54
积分: 23

Re: A33主线Linux跑起OpenGL/ES

楼主大侠,能出一个新手教程吗? A33也想跑Linux+qt+opengl。 感谢。

离线

#28 2020-08-28 09:39:50

明月照我沟渠
会员
注册时间: 2020-07-09
已发帖子: 120
积分: 114

Re: A33主线Linux跑起OpenGL/ES

skliu 说:

楼主大侠,能出一个新手教程吗? A33也想跑Linux+qt+opengl。 感谢。

+1

离线

#29 2020-08-28 19:43:18

jkl
会员
注册时间: 2019-11-18
已发帖子: 260
积分: 148.5

Re: A33主线Linux跑起OpenGL/ES

明月照我沟渠 说:

+1

+1

离线

#30 2020-10-22 16:46:26

孤星泪
会员
注册时间: 2020-03-18
已发帖子: 235
积分: 231

Re: A33主线Linux跑起OpenGL/ES

感谢楼主分享,可惜linux4.20里面没有lima,玩不起来,等有空再整 linux5.9试一试。

离线

#31 2020-11-02 17:22:43

ubuntu
会员
注册时间: 2020-03-30
已发帖子: 270
积分: 248

Re: A33主线Linux跑起OpenGL/ES

../src/mesa/tnl/t_vb_lighttmp.h:508:16: warning: 'base[0][3]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   Fcolor[j][3] = base[0][3];
                ^
In file included from ../src/mesa/tnl/t_vb_light.c:29:0:
../src/mesa/main/macros.h:264:13: warning: 'base[0][2]' may be used uninitialized in this function [-Wmaybe-uninitialized]
    (DST)[2] = (SRC)[2];             \
             ^
In file included from ../src/mesa/tnl/t_vb_light.c:303:0:
../src/mesa/tnl/t_vb_lighttmp.h:429:12: note: 'base[0][2]' was declared here
    GLfloat base[2][4];
            ^
In file included from ../src/mesa/tnl/t_vb_light.c:29:0:
../src/mesa/main/macros.h:263:13: warning: 'base[0][1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
    (DST)[1] = (SRC)[1];             \
             ^
In file included from ../src/mesa/tnl/t_vb_light.c:303:0:
../src/mesa/tnl/t_vb_lighttmp.h:429:12: note: 'base[0][1]' was declared here
    GLfloat base[2][4];
            ^
In file included from ../src/mesa/tnl/t_vb_light.c:29:0:
../src/mesa/main/macros.h:262:13: warning: 'base[0][0]' may be used uninitialized in this function [-Wmaybe-uninitialized]
    (DST)[0] = (SRC)[0];             \
             ^
In file included from ../src/mesa/tnl/t_vb_light.c:303:0:
../src/mesa/tnl/t_vb_lighttmp.h:429:12: note: 'base[0][0]' was declared here
    GLfloat base[2][4];
            ^
[598/690] Compiling C object 'src/mesa/bbe4a73@@mesa_classic@sta/drivers_common_meta.c.o'.
In file included from ../src/mesa/drivers/common/meta.c:91:0:
../src/compiler/nir/nir.h:2463:1: warning: '__returns_nonnull__' attribute directive ignored [-Wattributes]
 {
 ^
../src/compiler/nir/nir.h:2469:1: warning: '__returns_nonnull__' attribute directive ignored [-Wattributes]
 {
 ^
[670/690] Linking target src/mesa/drivers/dri/libmesa_dri_drivers.so.
FAILED: src/mesa/drivers/dri/libmesa_dri_drivers.so
/opt/buildroot-2020.02.3/output/host/bin/arm-none-linux-gnueabi-g++  -o src/mesa/drivers/dri/libmesa_dri_drivers.so  -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,libmesa_dri_drivers.so -Wl,--whole-archive src/mesa/drivers/dri/swrast/libswrast_dri.a src/mesa/drivers/dri/radeon/libr100.a src/mesa/drivers/dri/nouveau/libnouveau_vieux.a -Wl,--no-whole-archive src/mesa/drivers/dri/common/libmegadriver_stub.a src/mesa/drivers/dri/common/libdricommon.a src/mapi/shared-glapi/libglapi.so.0.0.0 src/mesa/libmesa_classic.a src/compiler/glsl/libglsl.a src/compiler/glsl/glcpp/libglcpp.a src/util/libmesa_util.a src/compiler/nir/libnir.a src/compiler/libcompiler.a src/util/libxmlconfig.a -Wl,--build-id=sha1 -Wl,-Bsymbolic -Wl,--gc-sections /opt/buildroot-2020.02.3/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/lib/libdrm.so -lm -pthread -ldl /opt/buildroot-2020.02.3/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/lib/libexpat.so /opt/buildroot-2020.02.3/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/lib/libz.so /opt/buildroot-2020.02.3/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/lib/libdrm_radeon.so /opt/buildroot-2020.02.3/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/lib/libdrm_nouveau.so -Wl,--end-group '-Wl,-rpath,$ORIGIN/common:$ORIGIN/../../../mapi/shared-glapi:$ORIGIN/../..:$ORIGIN/../../../compiler/glsl:$ORIGIN/../../../compiler/glsl/glcpp:$ORIGIN/../../../util:$ORIGIN/../../../compiler/nir:$ORIGIN/../../../compiler' -Wl,-rpath-link,/opt/buildroot-2020.02.3/output/build/mesa3d-19.3.4/build/src/mesa/drivers/dri/common -Wl,-rpath-link,/opt/buildroot-2020.02.3/output/build/mesa3d-19.3.4/build/src/mapi/shared-glapi -Wl,-rpath-link,/opt/buildroot-2020.02.3/output/build/mesa3d-19.3.4/build/src/mesa -Wl,-rpath-link,/opt/buildroot-2020.02.3/output/build/mesa3d-19.3.4/build/src/compiler/glsl -Wl,-rpath-link,/opt/buildroot-2020.02.3/output/build/mesa3d-19.3.4/build/src/compiler/glsl/glcpp -Wl,-rpath-link,/opt/buildroot-2020.02.3/output/build/mesa3d-19.3.4/build/src/util -Wl,-rpath-link,/opt/buildroot-2020.02.3/output/build/mesa3d-19.3.4/build/src/compiler/nir -Wl,-rpath-link,/opt/buildroot-2020.02.3/output/build/mesa3d-19.3.4/build/src/compiler
src/mesa/drivers/dri/common/libmegadriver_stub.a(megadriver_stub.c.o): In function `megadriver_stub_init':
megadriver_stub.c:(.text.startup+0x20): undefined reference to `dladdr'
megadriver_stub.c:(.text.startup+0xb8): undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
[674/690] Compiling C object 'src/egl/cb1d4f8@@EGL@sha/main_eglapi.c.o'.
ninja: build stopped: subcommand failed.
package/pkg-generic.mk:266: recipe for target '/opt/buildroot-2020.02.3/output/build/mesa3d-19.3.4/.stamp_built' failed
make[1]: *** [/opt/buildroot-2020.02.3/output/build/mesa3d-19.3.4/.stamp_built] Error 1
Makefile:84: recipe for target '_all' failed
make: *** [_all] Error 2
$
$

弄了一下午,终于解决这个编译错误了

https://git.busybox.net/buildroot/commit/?id=d3f576d2f37a05275c0d25f855dc24935ff5de5c

修改: ./output/build/mesa3d-19.3.4/src/mesa/drivers/dri/meson.build

libmegadriver_stub, libdricommon, libglapi,

改为:
libdricommon, libmegadriver_stub, libglapi,

即交换编译顺序.

离线

#32 2020-12-04 08:53:53

墙角的万用表
会员
注册时间: 2020-12-03
已发帖子: 5
积分: 3.5

离线

#33 2020-12-04 09:02:22

墙角的万用表
会员
注册时间: 2020-12-03
已发帖子: 5
积分: 3.5

Re: A33主线Linux跑起OpenGL/ES

刚刚又翻了一下 buildroot 源码, 原来buildroot在2018年版本已经加入了:

https://github.com/buildroot/buildroot/tree/master/package/sunxi-mali-mainline-driver

这样不不需要自己费事手动加入代码了。

离线

#34 2020-12-10 23:26:10

uuid
会员
注册时间: 2020-12-08
已发帖子: 45
积分: 31

Re: A33主线Linux跑起OpenGL/ES

Egl-example_output.png

https://wiki.maemo.org/SimpleGL_example


/* Created by exoticorn ( http://talk.maemo.org/showthread.php?t=37356 )
 * edited and commented by André Bergner [endboss]
 *
 * libraries needed:   libx11-dev, libgles2-dev
 *
 * compile with:   g++  -lX11 -lEGL -lGLESv2  egl-example.cpp
 */
 
#include  <iostream>
#include  <cstdlib>
#include  <cstring>
using namespace std;
 
#include  <cmath>
#include  <sys/time.h>
 
#include  <X11/Xlib.h>
#include  <X11/Xatom.h>
#include  <X11/Xutil.h>
 
#include  <GLES2/gl2.h>
#include  <EGL/egl.h>
 
 
 
const char vertex_src [] =
"                                        \
   attribute vec4        position;       \
   varying mediump vec2  pos;            \
   uniform vec4          offset;         \
                                         \
   void main()                           \
   {                                     \
      gl_Position = position + offset;   \
      pos = position.xy;                 \
   }                                     \
";
 
 
const char fragment_src [] =
"                                                      \
   varying mediump vec2    pos;                        \
   uniform mediump float   phase;                      \
                                                       \
   void  main()                                        \
   {                                                   \
      gl_FragColor  =  vec4( 1., 0.9, 0.7, 1.0 ) *     \
        cos( 30.*sqrt(pos.x*pos.x + 1.5*pos.y*pos.y)   \
             + atan(pos.y,pos.x) - phase );            \
   }                                                   \
";
//  some more formulas to play with...
//      cos( 20.*(pos.x*pos.x + pos.y*pos.y) - phase );
//      cos( 20.*sqrt(pos.x*pos.x + pos.y*pos.y) + atan(pos.y,pos.x) - phase );
//      cos( 30.*sqrt(pos.x*pos.x + 1.5*pos.y*pos.y - 1.8*pos.x*pos.y*pos.y)
//            + atan(pos.y,pos.x) - phase );
 
 
void
print_shader_info_log (
   GLuint  shader      // handle to the shader
)
{
   GLint  length;
 
   glGetShaderiv ( shader , GL_INFO_LOG_LENGTH , &length );
 
   if ( length ) {
      char* buffer  =  new char [ length ];
      glGetShaderInfoLog ( shader , length , NULL , buffer );
      cout << "shader info: " <<  buffer << flush;
      delete [] buffer;
 
      GLint success;
      glGetShaderiv( shader, GL_COMPILE_STATUS, &success );
      if ( success != GL_TRUE )   exit ( 1 );
   }
}
 
 
GLuint
load_shader (
   const char  *shader_source,
   GLenum       type
)
{
   GLuint  shader = glCreateShader( type );
 
   glShaderSource  ( shader , 1 , &shader_source , NULL );
   glCompileShader ( shader );
 
   print_shader_info_log ( shader );
 
   return shader;
}
 
 
Display    *x_display;
Window      win;
EGLDisplay  egl_display;
EGLContext  egl_context;
EGLSurface  egl_surface;
 
GLfloat
   norm_x    =  0.0,
   norm_y    =  0.0,
   offset_x  =  0.0,
   offset_y  =  0.0,
   p1_pos_x  =  0.0,
   p1_pos_y  =  0.0;
 
GLint
   phase_loc,
   offset_loc,
   position_loc;
 
 
bool        update_pos = false;
 
const float vertexArray[] = {
   0.0,  0.5,  0.0,
  -0.5,  0.0,  0.0,
   0.0, -0.5,  0.0,
   0.5,  0.0,  0.0,
   0.0,  0.5,  0.0 
};
 
 
void  render()
{
   static float  phase = 0;
   static int    donesetup = 0;
 
   static XWindowAttributes gwa;
 
   //// draw
 
   if ( !donesetup ) {
      XWindowAttributes  gwa;
      XGetWindowAttributes ( x_display , win , &gwa );
      glViewport ( 0 , 0 , gwa.width , gwa.height );
      glClearColor ( 0.08 , 0.06 , 0.07 , 1.);    // background color
      donesetup = 1;
   }
   glClear ( GL_COLOR_BUFFER_BIT );
 
   glUniform1f ( phase_loc , phase );  // write the value of phase to the shaders phase
   phase  =  fmodf ( phase + 0.5f , 2.f * 3.141f );    // and update the local variable
 
   if ( update_pos ) {  // if the position of the texture has changed due to user action
      GLfloat old_offset_x  =  offset_x;
      GLfloat old_offset_y  =  offset_y;
 
      offset_x  =  norm_x - p1_pos_x;
      offset_y  =  norm_y - p1_pos_y;
 
      p1_pos_x  =  norm_x;
      p1_pos_y  =  norm_y;
 
      offset_x  +=  old_offset_x;
      offset_y  +=  old_offset_y;
 
      update_pos = false;
   }
 
   glUniform4f ( offset_loc  ,  offset_x , offset_y , 0.0 , 0.0 );
 
   glVertexAttribPointer ( position_loc, 3, GL_FLOAT, false, 0, vertexArray );
   glEnableVertexAttribArray ( position_loc );
   glDrawArrays ( GL_TRIANGLE_STRIP, 0, 5 );
 
   eglSwapBuffers ( egl_display, egl_surface );  // get the rendered buffer to the screen
}
 
 
////////////////////////////////////////////////////////////////////////////////////////////
 
 
int  main()
{
   ///////  the X11 part  //////////////////////////////////////////////////////////////////
   // in the first part the program opens a connection to the X11 window manager
   //
 
   x_display = XOpenDisplay ( NULL );   // open the standard display (the primary screen)
   if ( x_display == NULL ) {
      cerr << "cannot connect to X server" << endl;
      return 1;
   }
 
   Window root  =  DefaultRootWindow( x_display );   // get the root window (usually the whole screen)
 
   XSetWindowAttributes  swa;
   swa.event_mask  =  ExposureMask | PointerMotionMask | KeyPressMask;
 
   win  =  XCreateWindow (   // create a window with the provided parameters
              x_display, root,
              0, 0, 800, 480,   0,
              CopyFromParent, InputOutput,
              CopyFromParent, CWEventMask,
              &swa );
 
   XSetWindowAttributes  xattr;
   Atom  atom;
   int   one = 1;
 
   xattr.override_redirect = False;
   XChangeWindowAttributes ( x_display, win, CWOverrideRedirect, &xattr );
 
   atom = XInternAtom ( x_display, "_NET_WM_STATE_FULLSCREEN", True );
   XChangeProperty (
      x_display, win,
      XInternAtom ( x_display, "_NET_WM_STATE", True ),
      XA_ATOM,  32,  PropModeReplace,
      (unsigned char*) &atom,  1 );
 
   XChangeProperty (
      x_display, win,
      XInternAtom ( x_display, "_HILDON_NON_COMPOSITED_WINDOW", False ),
      XA_INTEGER,  32,  PropModeReplace,
      (unsigned char*) &one,  1);
 
   XWMHints hints;
   hints.input = True;
   hints.flags = InputHint;
   XSetWMHints(x_display, win, &hints);
 
   XMapWindow ( x_display , win );             // make the window visible on the screen
   XStoreName ( x_display , win , "GL test" ); // give the window a name
 
   //// get identifiers for the provided atom name strings
   Atom wm_state   = XInternAtom ( x_display, "_NET_WM_STATE", False );
   Atom fullscreen = XInternAtom ( x_display, "_NET_WM_STATE_FULLSCREEN", False );
 
   XEvent xev;
   memset ( &xev, 0, sizeof(xev) );
 
   xev.type                 = ClientMessage;
   xev.xclient.window       = win;
   xev.xclient.message_type = wm_state;
   xev.xclient.format       = 32;
   xev.xclient.data.l[0]    = 1;
   xev.xclient.data.l[1]    = fullscreen;
   XSendEvent (                // send an event mask to the X-server
      x_display,
      DefaultRootWindow ( x_display ),
      False,
      SubstructureNotifyMask,
      &xev );
 
 
   ///////  the egl part  //////////////////////////////////////////////////////////////////
   //  egl provides an interface to connect the graphics related functionality of openGL ES
   //  with the windowing interface and functionality of the native operation system (X11
   //  in our case.
 
   egl_display  =  eglGetDisplay( (EGLNativeDisplayType) x_display );
   if ( egl_display == EGL_NO_DISPLAY ) {
      cerr << "Got no EGL display." << endl;
      return 1;
   }
 
   if ( !eglInitialize( egl_display, NULL, NULL ) ) {
      cerr << "Unable to initialize EGL" << endl;
      return 1;
   }
 
   EGLint attr[] = {       // some attributes to set up our egl-interface
      EGL_BUFFER_SIZE, 16,
      EGL_RENDERABLE_TYPE,
      EGL_OPENGL_ES2_BIT,
      EGL_NONE
   };
 
   EGLConfig  ecfg;
   EGLint     num_config;
   if ( !eglChooseConfig( egl_display, attr, &ecfg, 1, &num_config ) ) {
      cerr << "Failed to choose config (eglError: " << eglGetError() << ")" << endl;
      return 1;
   }
 
   if ( num_config != 1 ) {
      cerr << "Didn't get exactly one config, but " << num_config << endl;
      return 1;
   }
 
   egl_surface = eglCreateWindowSurface ( egl_display, ecfg, win, NULL );
   if ( egl_surface == EGL_NO_SURFACE ) {
      cerr << "Unable to create EGL surface (eglError: " << eglGetError() << ")" << endl;
      return 1;
   }
 
   //// egl-contexts collect all state descriptions needed required for operation
   EGLint ctxattr[] = {
      EGL_CONTEXT_CLIENT_VERSION, 2,
      EGL_NONE
   };
   egl_context = eglCreateContext ( egl_display, ecfg, EGL_NO_CONTEXT, ctxattr );
   if ( egl_context == EGL_NO_CONTEXT ) {
      cerr << "Unable to create EGL context (eglError: " << eglGetError() << ")" << endl;
      return 1;
   }
 
   //// associate the egl-context with the egl-surface
   eglMakeCurrent( egl_display, egl_surface, egl_surface, egl_context );
 
 
   ///////  the openGL part  ///////////////////////////////////////////////////////////////
 
   GLuint vertexShader   = load_shader ( vertex_src , GL_VERTEX_SHADER  );     // load vertex shader
   GLuint fragmentShader = load_shader ( fragment_src , GL_FRAGMENT_SHADER );  // load fragment shader
 
   GLuint shaderProgram  = glCreateProgram ();                 // create program object
   glAttachShader ( shaderProgram, vertexShader );             // and attach both...
   glAttachShader ( shaderProgram, fragmentShader );           // ... shaders to it
 
   glLinkProgram ( shaderProgram );    // link the program
   glUseProgram  ( shaderProgram );    // and select it for usage
 
   //// now get the locations (kind of handle) of the shaders variables
   position_loc  = glGetAttribLocation  ( shaderProgram , "position" );
   phase_loc     = glGetUniformLocation ( shaderProgram , "phase"    );
   offset_loc    = glGetUniformLocation ( shaderProgram , "offset"   );
   if ( position_loc < 0  ||  phase_loc < 0  ||  offset_loc < 0 ) {
      cerr << "Unable to get uniform location" << endl;
      return 1;
   }
 
 
   const float
      window_width  = 800.0,
      window_height = 480.0;
 
   //// this is needed for time measuring  -->  frames per second
   struct  timezone  tz;
   timeval  t1, t2;
   gettimeofday ( &t1 , &tz );
   int  num_frames = 0;
 
   bool quit = false;
   while ( !quit ) {    // the main loop
 
      while ( XPending ( x_display ) ) {   // check for events from the x-server
 
         XEvent  xev;
         XNextEvent( x_display, &xev );
 
         if ( xev.type == MotionNotify ) {  // if mouse has moved
//            cout << "move to: << xev.xmotion.x << "," << xev.xmotion.y << endl;
            GLfloat window_y  =  (window_height - xev.xmotion.y) - window_height / 2.0;
            norm_y            =  window_y / (window_height / 2.0);
            GLfloat window_x  =  xev.xmotion.x - window_width / 2.0;
            norm_x            =  window_x / (window_width / 2.0);
            update_pos = true;
         }
 
         if ( xev.type == KeyPress )   quit = true;
      }
 
      render();   // now we finally put something on the screen
 
      if ( ++num_frames % 100 == 0 ) {
         gettimeofday( &t2, &tz );
         float dt  =  t2.tv_sec - t1.tv_sec + (t2.tv_usec - t1.tv_usec) * 1e-6;
         cout << "fps: " << num_frames / dt << endl;
         num_frames = 0;
         t1 = t2;
      }
//      usleep( 1000*10 );
   }
 
 
   ////  cleaning up...
   eglDestroyContext ( egl_display, egl_context );
   eglDestroySurface ( egl_display, egl_surface );
   eglTerminate      ( egl_display );
   XDestroyWindow    ( x_display, win );
   XCloseDisplay     ( x_display );
 
   return 0;
}

编译指令:
g++ -o test4 test4.c  -lX11 -lGL -lEGL

离线

#35 2020-12-11 15:09:56

拉轰的脚踏车
会员
注册时间: 2020-03-20
已发帖子: 288
积分: 222

Re: A33主线Linux跑起OpenGL/ES

https://bootlin.com/blog/more-opengl-binaries-for-the-mali-support-on-allwinner-platforms-with-mainline-linux/

这些二进制Blob非常有用,因为它们允许今天在Allwinner平台上具有完全正常的OpenGL加速:
作为稳定性测试,我们最近在Allwinner A33平台上运行了一个Qt5应用程序,
在Allwinner A33平台上进行OpenGL渲染24H*7,持续了1.5个月。
当然,从长远来看,我们将跟踪Lima项目的进度,
该项目将提供一个完全免费的开源解决方案,
以在Allwinner平台上提供OpenGL加速。




看来,还是挺稳定的

离线

#36 2021-02-06 02:42:03

qinxiongxu
会员
注册时间: 2018-12-13
已发帖子: 88
积分: 75.5

Re: A33主线Linux跑起OpenGL/ES

请问下是否只需要加载mali.ko就可以了,还需要ump.ko等其他的ko吗?

离线

#37 2021-02-06 09:38:27

hxhlb
会员
注册时间: 2019-11-11
已发帖子: 27
积分: 27

Re: A33主线Linux跑起OpenGL/ES

求助啊,在第一步uboot就卡住了。
fel执行spl-uboot后,检测不到内存卡,mmcinfo会报一个错误:

=> mmcinfo
Card did not respond to voltage select!

完整的uboot启动输出(其实也没多少):

HELLO! BOOT0 is starting!
boot0 version : 3.1.0
reg_addr 0x01f00100 =0x00000000
reg_addr 0x01f00104 =0x00000000
reg_addr 0x01f00108 =0x5aa5a55a
reg_addr 0x01f0010c =0x00000000
reg_addr 0x01f00110 =0x00000000
reg_addr 0x01f00114 =0x00000000
eraly jump fel

U-Boot SPL 2019.01-rc3-g829407b58f-dirty (Feb 05 2021 - 19:01:12 +0800)
DRAM: 1024 MiB
Trying to boot from FEL


U-Boot 2019.01-rc3-g829407b58f-dirty (Feb 05 2021 - 19:01:12 +0800) Allwinner Technology

CPU:   Allwinner A33 (SUN8I 1667)
Model: Sinlinx SinA33
DRAM:  1 GiB
MMC:   MMC0: 01c20060 = 0x1004140, 01c20088 = 0x0, 01c202c0 = 0x1004140
MMC1: 01c20060 = 0x1004340, 01c2008c = 0x0, 01c202c0 = 0x1004340
Device 'mmc@1c11000': seq 1 is in use by 'mmc@1c10000'
MMC2: 01c20060 = 0x1004740, 01c20090 = 0x0, 01c202c0 = 0x1004740
mmc@1c0f000: 0, mmc@1c10000: 2, mmc@1c11000: 1
Loading Environment from FAT... Card did not respond to voltage select!
Setting up a 1024x600 lcd console (overscan 0x0)
In:    serial
Out:   vga
Err:   vga
Allwinner mUSB OTG (Peripheral)
Net:   
Warning: usb_ether using MAC address from ROM
eth0: usb_ether
starting USB...
USB0:   USB EHCI 1.00
USB1:   USB OHCI 1.0
scanning bus 0 for devices... 2 USB Device(s) found
scanning bus 1 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0 
=> mmcinfo
Card did not respond to voltage select!
=> 

换个最新版的uboot,发现和 https://whycan.com/t_3633.html 帖子中的流氓兔遇到的问题是一样的,但是我降频了,串口也改了(可能没改对吧)依然不行。
特来求助一下。

离线

#38 2021-02-06 09:58:28

拉轰的脚踏车
会员
注册时间: 2020-03-20
已发帖子: 288
积分: 222

Re: A33主线Linux跑起OpenGL/ES

这个坑前辈们已经踩过一次了:


全志A33 主线u-boot/Linux入坑记录
http://whycan.com/t_3643.html#p33344
(出处:哇酷开发者社区)

离线

#39 2021-02-06 10:26:45

hxhlb
会员
注册时间: 2019-11-11
已发帖子: 27
积分: 27

Re: A33主线Linux跑起OpenGL/ES

拉轰的脚踏车 说:

这个坑前辈们已经踩过一次了:


全志A33 主线u-boot/Linux入坑记录
http://whycan.com/t_3643.html#p33344
(出处:哇酷开发者社区)

我已经改过了,依然不行,很惆怅。我这个板子的引脚是匹配的,但是无论有没有引脚检测,都不能行。

离线

#40 2021-02-06 15:21:41

sea18c
会员
注册时间: 2019-08-05
已发帖子: 230
积分: 222.5

Re: A33主线Linux跑起OpenGL/ES

你用mmclist 看看是挂在那个MMC上

离线

#41 2021-02-06 15:22:52

sea18c
会员
注册时间: 2019-08-05
已发帖子: 230
积分: 222.5

Re: A33主线Linux跑起OpenGL/ES

你要用mmc dev X   切换才能使用mmc info 查到TF信息吧

离线

#42 2024-06-17 16:27:06

wangjun110
会员
注册时间: 2020-07-03
已发帖子: 11
积分: 7

Re: A33主线Linux跑起OpenGL/ES

楼主,请问一下,在编译应用程序的时候-lX11,这个libx11.so的库在哪里有提供呢?

离线

#43 2024-06-19 17:10:46

晕哥
管理员
注册时间: 2017-09-06
已发帖子: 9,336
积分: 9202

Re: A33主线Linux跑起OpenGL/ES

wangjun110 说:

楼主,请问一下,在编译应用程序的时候-lX11,这个libx11.so的库在哪里有提供呢?

应该在 buildroot 有这个package





离线

#44 2024-07-20 20:31:02

joeydeng
会员
注册时间: 2022-09-12
已发帖子: 9
积分: 99

Re: A33主线Linux跑起OpenGL/ES

KevinS 说:

NND, 终于跑起来了, 4.19.5内核外加补丁

请问是加的哪一个补丁呢?

在我这边手动insmod mali.ko后输出如下,看起来是和楼主一样是正常的,我的kernel版本是mainline 4.19.315

[   87.506758] Allwinner sunXi mali glue initialized
[   87.507330] Mali:
[   87.507336] Found Mali GPU Mali-400 MP r1p1
[   87.510612] Mali:
[   87.510623] 2+0 PP cores initialized
[   87.511784] Mali:
[   87.511790] Mali device driver loaded


运行qt程序报错0x3003
root@hyiot-shp-a:~# QT_QPA_EGLFS_PHYSICAL_WIDTH=720 QT_QPA_EGLFS_PHYSICAL_HEIGHT=1440 QT_QPA_EGLFS_INTEGRATION=none ./2dpainting
EGL Error : Could not create the egl surface: error = 0x3003

Aborted

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn