Posted by: ,

一,准备

1,x86_64位的ubuntu 12.04的系统

2,pcDuino 3A/3B/NANO

说明,在软件中#表示在x86的ubuntu里面运行的指令,$表示在pcDuino运行的指令;

二,制作从TF卡启动的系统,

把TF插入到pcDuino上面,建议选择大于8G的TF卡,执行

$board-config.sh

 

选择make_mmc_boot,大概10分钟以后你就会得到一个从TF卡启动的系统。这时候你重启系统,就是从TF卡启动,这里需要注意一下,你需要扩展一下你的系统,才能使用TF卡所有的内存。再次执行$board-config.sh 。

选择expand_rootfs之后就可以进入可用空间比较大的系统了。

二,添加Mali400驱动,

1,下载a20_kernel源码。

$git clone https://github.com/pcduino/a20-kernel

$cd a20_kernel

$make

2,由于Mali400有些库不开源,不能采用分离编译,只能在linux-sunxi里面本地编译。

$git clone  https://github.com/Pillar1989/Qt5.3.2forPcDuino3

$cp Qt5.3.2forPcDuino3/mali_r3p2-01rel2 linux-sunxi/drivers/gpu/

然后在整个源码里打上0003-Sunxi-adaptation-for-mali-r3p2-01rel2-kernel-module.patch这个补丁

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
From 5bf12905ff1faa38af4c47ff0752d3f5f12f5644 Mon Sep 17 00:00:00 2001
From: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Date: Fri, 13 Sep 2013 01:52:16 +0300
Subject: [PATCH] Sunxi adaptation for mali r3p2-01rel2 kernel module
Tested only on A10 and A20.
TODO:
- bus addresses vs. physical addresses?
- umplock?
- power management (disable clocks when idle)?
- drm upgrade (and also fix compatibility with xf86-video-modesetting)?
---
diff --git a/arch/arm/configs/sun4i_defconfig b/arch/arm/configs/sun4i_defconfig
index f0344b2..8b043aa 100644
--- a/arch/arm/configs/sun4i_defconfig
+++ b/arch/arm/configs/sun4i_defconfig
@@ -200,7 +200,10 @@ CONFIG_AUDIO_ENGINE=y
 CONFIG_PA_CONTROL=y
 CONFIG_DRM=m
 CONFIG_DRM_MALI=m
-CONFIG_MALI=m
+CONFIG_MALI400=m
+CONFIG_MALI400_DEBUG=y
+CONFIG_MALI400_UMP=y
+CONFIG_UMP=m
 CONFIG_FB=y
 CONFIG_FB_SUNXI=y
 CONFIG_FB_SUNXI_LCD=y
diff --git a/arch/arm/configs/sun7i_defconfig b/arch/arm/configs/sun7i_defconfig
index 709715e..0dc5613 100644
--- a/arch/arm/configs/sun7i_defconfig
+++ b/arch/arm/configs/sun7i_defconfig
@@ -869,9 +869,10 @@ CONFIG_DRM_I2C_CH7006=m
 CONFIG_DRM_I2C_SIL164=m
 CONFIG_DRM_MALI=m
 CONFIG_DRM_UDL=m
-CONFIG_MALI=m
+CONFIG_MALI400=m
 CONFIG_MALI400_DEBUG=y
-CONFIG_MALI400_GPU_UTILIZATION=y
+CONFIG_MALI400_UMP=y
+CONFIG_UMP=m
 CONFIG_FB=y
 CONFIG_FB_SUNXI=y
 CONFIG_FB_SUNXI_LCD=y
diff --git a/arch/arm/plat-sunxi/include/plat/irqs.h b/arch/arm/plat-sunxi/include/plat/irqs.h
index ad5e322..b501ad0 100644
--- a/arch/arm/plat-sunxi/include/plat/irqs.h
+++ b/arch/arm/plat-sunxi/include/plat/irqs.h
@@ -164,10 +164,10 @@
 #define SW_INT_IRQNO_GPU_PP0       (71 + SW_INT_START)
 #define SW_INT_IRQNO_GPU_PPMMU0        (72 + SW_INT_START)
 #define SW_INT_IRQNO_GPU_PMU       (73 + SW_INT_START)
-
-#ifdef CONFIG_ARCH_SUN7I
 #define SW_INT_IRQNO_GPU_PP1            (74 + SW_INT_START)
 #define SW_INT_IRQNO_GPU_PPMMU1         (75 + SW_INT_START)
+
+#ifdef CONFIG_ARCH_SUN7I
 #define SW_INT_IRQNO_GPU_RSV0           (76 + SW_INT_START)
 #define SW_INT_IRQNO_GPU_RSV1           (77 + SW_INT_START)
 #define SW_INT_IRQNO_GPU_RSV2           (78 + SW_INT_START)
diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile
index 83bd33d..bdf6461 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -1 +1 @@
-obj-y          += drm/ vga/ stub/ ion/ mali/
+obj-y          += drm/ vga/ stub/ ion/ mali_r3p2-01rel2/
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index e5cfd95..6ad293d 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -175,7 +175,7 @@ config DRM_VIA
 config DRM_MALI
    tristate "Mali DRM supprt"
    depends on DRM
-   depends on MALI
+   depends on MALI400
    help
      Choose this option if you have a Mali 200 or Mali 400 gpu
      If M is selected the module will be called mali_drm.
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index df63338..4825e23 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -25,7 +25,7 @@ source "drivers/gpu/stub/Kconfig"
  
 source "drivers/gpu/ion/Kconfig"
  
-source "drivers/gpu/mali/Kconfig"
+source "drivers/gpu/mali_r3p2-01rel2/Kconfig"
  
 config VGASTATE
        tristate
@@ -290,7 +290,7 @@ config FB_SUNXI_RESERVED_MEM
  
 config FB_SUNXI_UMP
    bool "Enable FB/UMP Integration"
-   depends on MALI && FB_SUNXI
+   depends on MALI400 && FB_SUNXI
    default y
  
 config FB_SUNXI_LCD
--
1.8.3.2

打完补丁以后,重新编译内核。pcDuino系列默认的framebuff都是640×480.你可以在

drivers/video/sunxi/disp/dev_fb.c

里面43行修改:

static char *screen0_output_mode=”1920x1080p50″;

这里我修改到了1080p.

3,重新编译内核

$make ARCH=arm  sun7i_defconfig

$make -j 8 uImage ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

$make -j 8 modules ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

$make -j 8 firmware_install modules_install INSTALL_MOD_PATH=../modules ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

编译结束以后,你会在arch/arm/boot/下面得到新的uImage。在 ../modules/lib/modules/下面会得到新的内核modules。

把uImage拷贝到TF卡的第一分区。把新的3.4.79的内核模块拷贝到系统的/lib/modules/下面,重启系统,这时候你会发现屏幕的字符输出变成了1080P。

$lsmod

root@ubuntu:/home/ubuntu# lsmod
Module Size Used by
sun4i_csi0 25980 0
videobuf_dma_contig 6844 1 sun4i_csi0
videobuf_core 20061 2 sun4i_csi0,videobuf_dma_contig
gc2035 16176 1
gc0308 14344 0
g_ether 57121 0
sw_usb_udc 23041 0
udc_core 7922 2 g_ether,sw_usb_udc
rt5370sta 653633 0
8188eu 496904 0
8192cu 449867 0
mali_drm 2608 1
drm 207738 2 mali_drm
mali 224755 1
disp_ump 861 0
ump 33016 6 mali,disp_ump

里面有最新的mali和disp_ump.

三,添加应用里面支持openesgl的库以及其他的软件库。

1,安装依赖软件

$sudo apt-get install libssl-dev libasound2-dev  libxcb-icccm4-dev  libxcb-xfixes0-dev libxcb-image0-dev  libxcb-keysyms1-dev libxcb-sync0-dev libxcb-render-util0-dev libxcb-randr0-dev  libx11-dev libxrender-dev  libicu-dev  libx11-xcb-dev libxext-dev git build-essential autoconf libtool automake

2,安装ump.

$git clone https://github.com/linux-sunxi/libump.git

$cd libump

$autoreconf -i
$./configure --prefix=/usr
$make
$make install
3,安装sunxi_mali

$cd Qt5.3.2forPcDuino3/sunxi_mali

$ make config VERSION=r3p2-01rel1 ABI=armhf EGL_TYPE=framebuffer
$make
$make install

$make test

Note
/* for X11 */

EGL_TYPE=x11

这时候你可以使用键盘,按住ctrl+alt+F1,这时候进入字符界面

$cd sunxi-mali/test

$./test

 

四,交叉编译qt-everywhere-opensource-src-5.3.2.

1,TF卡插入到x86的ubuntu系统里面,然后把

#mkdir rootfs

2,挂载TF卡的文件系统的到rootfs上面

#mount /dev/sdb2 rootfs

3,下载qt-everywhere-opensource-src-5.3.2

#wget http://download.qt.io/official_releases/qt/5.3/5.3.2/single/qt-everywhere-opensource-src-5.3.2.tar.xz

#tar xvf  qt-everywhere-opensource-src-5.3.2.tar.xz

#cd qt-everywhere-opensource-src-5.3.2

4,拷贝pcDuino3设备到Qt

#cp ../Qt5.3.2forPcDuino3/linux-pcDuino3-g++   qtbase/mkspecs/devices/ -rf

这里需要注意,打开linux-pcDuino3-g++ 里的

1
2
3
4
5
38 # Extra stuff (OpenGL, DirectFB, ...)
39 QMAKE_INCDIR_EGL        = /home/pillar/Qt/rootfs/usr/include/EGL
40 QMAKE_LIBDIR_EGL        = /home/pillar/Qt/rootfs/usr/lib
41 QMAKE_INCDIR_OPENGL_ES2 = /home/pillar/Qt/rootfs/usr/include/GLES2
42 QMAKE_LIBDIR_OPENGL_ES2 = /home/pillar/Qt/rootfs/usr/lib

你需要修改成自己的路径。

5,修改Qt源码的qtbase/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp

#vim qtbase/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
EGLNativeWindowType QEglFSHooks::createNativeWindow(QPlatformWindow *platformWindow,
                                                    const QSize &size,
                                                    const QSurfaceFormat &format)
{
    Q_UNUSED(platformWindow);
    Q_UNUSED(size);
    Q_UNUSED(format);
    //return 0;
    static struct mali_native_window native_window = {
        .width = (short unsigned int)size.width(),
        .height = (short unsigned int)size.height(),
    };
    return &native_window;
}

6,配置Qt

1
#./configure -opengl es2 -no-linuxfb -system-xcb -system-zlib -no-pch -eglfs -device linux-pcDuino3-g++ -device-option CROSS_COMPILE=/home/pillar/Qt/gcc-arm/bin/arm-linux-gnueabihf- -sysroot /home/pillar/Qt/rootfs -opensource -confirm-license -optimized-qmake -release -make libs -prefix /usr/local/qt5 -qreal float -v

下面是配置的结果。

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
   Configure summary
Building on:   linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for:  devices/linux-pcDuino3-g++ (arm, CPU features: neon)
Platform notes:
            - Also available for Linux: linux-kcc linux-icc linux-cxx
         
qmake vars .......... styles += mac fusion windows DEFINES += QT_NO_MTDEV DEFINES += QT_NO_LIBUDEV QMAKE_X11_PREFIX = /usr DEFINES += QT_NO_XKB QMAKE_XKB_CONFIG_ROOT = /usr/share/X11/xkb QMAKE_CFLAGS_XCB =   QMAKE_LIBS_XCB = -L/home/pillar/Qt/rootfs/usr/lib/arm-linux-gnueabihf -lxcb-sync -lxcb-xfixes -lxcb-render -lxcb-randr -lxcb-image -lxcb-shm -lxcb-keysyms -lxcb-icccm -lxcb-shape -lxcb   sql-drivers =  sql-plugins =  sqlite qmake switches .........
Build options:
  Configuration .......... accessibility alsa audio-backend c++11 clock-gettime clock-monotonic compile_examples concurrent cross_compile egl eglfs evdev eventfd freetype full-config getaddrinfo getifaddrs iconv icu inotify ipv6ifname large-config largefile medium-config minimal-config mremap nis no-harfbuzz opengl opengles2 openssl pcre png posix_fallocate qpa qpa reduce_exports release rpath shared small-config system-zlib xcb xcb-glx xcb-plugin xcb-render xcb-xlib xkbcommon-qt xlib xrender
  Build parts ............  libs
  Mode ................... release
  Using C++11 ............ yes
  Using PCH .............. no
  Target compiler supports:
    iWMMXt/Neon .......... no/auto
Qt modules and options:
  Qt D-Bus ............... no
  Qt Concurrent .......... yes
  Qt GUI ................. yes
  Qt Widgets ............. yes
  Large File ............. yes
  QML debugging .......... yes
  Use system proxies ..... no
Support enabled for:
  Accessibility .......... yes
  ALSA ................... yes
  CUPS ................... no
  Evdev .................. yes
  FontConfig ............. no
  FreeType ............... yes (bundled copy)
  Glib ................... no
  GTK theme .............. no
  HarfBuzz ............... no
  Iconv .................. yes
  ICU .................... yes
  Image formats:
    GIF .................. yes (plugin, using bundled copy)
    JPEG ................. yes (plugin, using bundled copy)
    PNG .................. yes (in QtGui, using bundled copy)
  journald ............... no
  mtdev .................. no
  Networking:
    getaddrinfo .......... yes
    getifaddrs ........... yes
    IPv6 ifname .......... yes
    OpenSSL .............. yes (loading libraries at run-time)
  NIS .................... yes
  OpenGL / OpenVG:
    EGL .................. yes
    OpenGL ............... yes (OpenGL ES 2.x)
    OpenVG ............... no
  PCRE ................... yes (bundled copy)
  pkg-config ............. yes
  PulseAudio ............. no
  QPA backends:
    DirectFB ............. no
    EGLFS ................ yes
    KMS .................. no
    LinuxFB .............. no
    XCB .................. yes (system library)
      EGL on X ........... no
      GLX ................ yes
      MIT-SHM ............ yes
      Xcb-Xlib ........... yes
      Xcursor ............ yes (loaded at runtime)
      Xfixes ............. yes (loaded at runtime)
      Xi ................. yes (loaded at runtime)
      Xi2 ................ no
      Xinerama ........... yes (loaded at runtime)
      Xrandr ............. yes (loaded at runtime)
      Xrender ............ yes
      XKB ................ no
      XShape ............. yes
      XSync .............. yes
      XVideo ............. yes
  Session management ..... yes
  SQL drivers:
    DB2 .................. no
    InterBase ............ no
    MySQL ................ no
    OCI .................. no
    ODBC ................. no
    PostgreSQL ........... no
    SQLite 2 ............. no
    SQLite ............... yes (plugin, using bundled copy)
    TDS .................. no
  udev ................... no
  xkbcommon .............. yes (bundled copy, XKB config root: /usr/share/X11/xkb)
  zlib ................... yes (system library)
NOTE: libxkbcommon and libxkbcommon-x11 0.4.1 or higher not found on the system, will use
the bundled version from 3rd party directory.
Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /usr/local/qt5
Prior to reconfiguration, make sure you remove any leftovers from
the previous build.

#make -j 8

#sudo make install

我用四核的电脑,编译大概2个小时。

编译结束以后,相关的库都会安装到TF卡rootfs的/usr/local/qt5,而相应的开发工具都会按照到本地的/usr/local/qt5。

五,编译应用。

这里我选择比较经典的。Qt5_CinematicExperience

#cd Qt5.3.2forPcDuino3/Qt5_CinematicExperience_1.1

# export PATH=/usr/local/qt5/bin:$PATH

#qmake

#make

编译结束以后把整个工程都拷贝到板子上面。然后在字符界面下面执行

$./Qt5_CinematicExperience -platform eglfs