From BananaPro/Pi
Jump to: navigation, search


The Mali series of Graphics Processing Units (GPUs) are semiconductor intellectual property cores produced by ARM Holdings for licensing in various ASIC (Application-specific integrated circuit) designs by ARM partners. The core is mainly developed by ARM Norway, at the former Falanx company site. Like other embedded IP cores for 3D support, the Mali GPU does not feature display controllers driving monitors (such as the combination often found in common video cards). Instead it is a pure 3D engine that renders graphics into memory and hands the rendered image over to another core that handles the display.


Step 1:Install the package
Install the package below:

sudo apt-get update
sudo apt-get install git build-essential make gcc autoconf libtool debhelper \
dh-autoreconf pkg-config automake xutils-dev libx11-dev libxext-dev libdrm-dev \
x11proto-dri2-dev libxfixes-dev xorg-dev libltdl-dev mesa-utils

Step 2:Get git repositories
Download the git repositories below:

mkdir ~/hw_accleration
cd ~/hw_accleration
git clone
git clone
git clone
git clone

You can replace the hw_acclertion to your own directory.

Step 3:Check driver modules
Before we build the four packages, we’d better ensure the driver modules “mali”, “mali_drm”, “ump” has been loaded. We can add the below lines into /etc/modules


step 4:Install libdri1
Libdri2 is needed by sunxi-mali build process when we use X11 version sunxi-mali (if use framebuffer version, we do not need libdri2).

cd ~/hw_accleration
cd libdri2
./configure --prefix=/usr
sudo make install
sudo ldconfig

step 5:Install libump
Build libump,libump is the unified memory provider user-space library.There are two ways to install libump.
You can directly install it like below, this will install all the ump libraries into the system :

cd ~/hw_accleration
cd libump
autoreconf -i
make install
sudo ldconfig

If you do not want to install the libump directly and also want to install it in other machine conveniently, you can use deb package method:

cd ~/hw_accleration
cd libump
dpkg-buildpackage -b
sudo dpkg -i ../libump_3.0-0sunxi1_armhf.deb
sudo dpkg -i ../libump-dev_3.0-0sunxi1_armhf.deb
sudo ldconfig

step 6:Build sunxi-mali
Because the gle.h and gl2ext.h in sunxi-mali repositories is too old, we need replace them with new ones.The files path is located at:
/sunxi-mali/include/GLES2/ gl2ext.h
/sunxi-mali/include/GLES2/ gl2ext.h
Compile sumxi-mali:

cd ~/hw_accleration
cd sunxi-mali
git submodule init
git submodule update

For X11 version:

make config
sudo make install

For framebuffer version:

make config ABI=armhf VERSION=r3p0 EGL_TYPE=framebuffer
sudo make install

step 7:Install fbturbo
If we want to a GLES capable Xsevers, the we need to install the fbturbo driver.

cd ~/hw_accleration
cd xf86-video-fbturbo
autoreconf -v -i
./configure --prefix=/usr
sudo make install

Make a xorg.conf file to make the Xservers work with fbturbo, make a new file:

Section "Screen"
        Identifier        "My Screen"
        Device          "Allwinner A10/A13 FBDEV"
        Monitor         "My Monitor"
Section "Device"
        Identifier        "Allwinner A10/A13 FBDEV"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb0"
        Option          "SwapbuffersWait" "true"
        Option          "AccelMethod" "G2D"
Section "Monitor"
        Identifier        "My Monitor"
        Option          "DPMS" "false"

Step 8:Edit 50-mali.rules
The default permissions of /dev/ump and /dev/mali make these unusable for normal users. Add a file to /etc/udev/rules.d/, perhaps called 50-mali.rules, with the following content:

KERNEL=="mali", MODE="0660", GROUP="video"
KERNEL=="ump", MODE="0660", GROUP="video"
KERNEL=="disp", MODE="0660", GROUP="video"
KERNEL=="g2d", MODE="0660", GROUP="video"
KERNEL=="fb*", MODE="0660", GROUP="video"
KERNEL=="cedar_dev", MODE="0660", GROUP="video"

Add then add your user account into the video group:

sudo usermod -aG video $USER

Step 9:Test
After all the steps in last section, you need reboot the system.
And then first to check the fbturbo loaded right:

grep -i fbturbo /var/log/Xorg.0.log

And the output should be like these:
Gpu mali.jpg
Secondly, test the sunxi-mali:

cd ~/hw_accleration
cd sunxi-mali

For X11:

cd test
cc -Wall -o test test.c -lEGL -lGLESv2 -lX11

For framebuffer:

make test

You will see.And you should be able to see a smoothed triangle, either written out to the top left corner of the framebuffer, or in an X window. The console will tell you which renderer is being used:

GL Vendor: "ARM"
GL Renderer: "Mali-400 MP"
GL Version: "OpenGL ES 2.0"

Gpu mali result.jpg

See Also