Discussion

Installing mali r3p2 kernel drivers into LeMaker kernel 3.4

30 16634
kevindt  
Post Last Edited by kevindt at 2014-9-25 21:36

The GPU in the Cortex A20 chip is a dual core device, but the drivers in the current kernel only support one core.  It is possible to upgrade the kernel drivers from the existing release, but there are a significant number of changes required, in multiple files.
Siarhei Siamanshka (ssvb) successfully patched the linux 3.4 kernel for CubieBoard2, which uses the same GPU, and his commits are up on github in his repository.  He deserves credit for the great majority of the work here.

I have taken the required commits and converted them to git patches and then cleaned them up to match the current LeMaker source code on github. The two git patches are here:

https://dl.dropboxusercontent.com/u/23861053/%20git_patches.zip

To patch them into the kernel is simple.  

First clone the kernel from github:
  1. git clone https://github.com/LeMaker/linux-bananapi.git
Copy the Code
then move the patches into the linux-bananapi directory, cd into the same directory, and use git to apply them

  1. cd linux-bananapi
  2. git apply ./0001-Imported-the-original-mali-r3p2-01rel2-kernel-module.patch
  3. git apply ./0002-Sunxi-adaptation-for-mali-r3p2-01rel2-kernel-module.patch
Copy the Code
If you check drivers/gpu/, you should find the new drivers in a new folder (mali_r3p2-01rel2).  I have successfully compiled them into the kernel in a Ubuntu cross-compile environment using the modified sunxi_defconfig created by the patches and used the new drivers with mplayer.

I have also almost finished a script that will automatically create a complete armhf build chain for the bananapi on a clean install of Ubuntu Server 14-04, pull the bananapi sources from github, and then build an image with a base debian system via debootstrap, or add in mplayer and accelerated graphics with these drivers, as well as LXDE GUI desktop.  So far it is compiling images well, and mplayer works nicely with H264 HD files, but there are still a few items to tweak.
Reply 1# kevindt

Very good - are you going to post your work for newies, once its done?

Which branch do you use ssvb's kernel?

kevindt  
Hi Tony,

I have not seen that reference to Optimizing_system_performance before.  

Those commits are on ssvb's 20130912-mali-r3p2-01rel2, the commits starting 0c55865....   and 5bf1290..... are the ones you want.  They need to be reworked a bit to match your kernel source - particularly the defconfig.

Kevin.

kevindt  
Reply 2# EricaTee


I hope so, Erica, but it will really be a resource for experimenters, not a glossy finished image like those available to download.
I'm no expert either, so it took me a long time to hunt down an easy way to easily set up a cross-compile environment that most anyone can set up and use  It then can be used to build almost automatically on a basic command line-only Ubuntu server (and it is solidly based on the work of many smarter folks).   

One of the better ways to learn is to take a good script and break it down into manageable sections, to see how it all fits together.  Then you can go search on the bits that aren't obvious.

Reply 6# kevindt


    Thanks buddy.

Reply 1# kevindt

Hi Kevin,

Could you please share your script? I have applied the git patches, the new drivers get created as you stated. But then when I boot and install mali binary drivers the version detected is still the older version.


What am I doing wrong??

Post Last Edited by deales82 at 2014-9-26 18:34

Some further information, this is what I get when trying to specify the version manually.

root@BananaPi:~/sunxi-mali# make config VERSION=r3p2-01rel2 ABI=armhf EGL_TYPE=framebuffer
rm -f config.mk
make config.mk
make[1]: Entering directory `/root/sunxi-mali'
make -f Makefile.config
ABI="armhf" (Provided)
VERSION="r3p2-01rel2" (Provided)
make[2]: Entering directory `/root/sunxi-mali'
Makefile.config:57: Unknown/unhandled Mali Version "r3p2-01rel2"
Makefile.config:58: Use VERSION=(r2p4,r3p0,r3p1,r3p2-01rel1) instead
Makefile.config:59: *** Unknown/unhandled Mali Version "r3p2-01rel2".  Stop.
make[2]: Leaving directory `/root/sunxi-mali'
make[1]: *** [config.mk] Error 2
make[1]: Leaving directory `/root/sunxi-mali'
make: *** [config] Error 2
root@BananaPi:~/sunxi-mali#

And on auto detect....

root@BananaPi:~/sunxi-mali# make config
rm -f config.mk
make config.mk
make[1]: Entering directory `/root/sunxi-mali'
make -f Makefile.config
ABI="armhf" (Detected)
VERSION="r3p2-01rel1" (Detected)
EGL_TYPE="framebuffer" (Detected)
make[2]: Entering directory `/root/sunxi-mali'
echo "MALI_VERSION ?= r3p2-01rel1" > config.mk
echo "MALI_LIBS_ABI ?= armhf" >> config.mk
echo "MALI_EGL_TYPE ?= framebuffer" >> config.mk
make[2]: Leaving directory `/root/sunxi-mali'
make[1]: Leaving directory `/root/sunxi-mali'
root@BananaPi:~/sunxi-mali#
And finally below are the commands I am using to build the kernel...

git clone https://github.com/LeMaker/linux-bananapi.git
cd linux-bananapi
git apply ./0001-Imported-the-original-mali-r3p2-01rel2-kernel-module.patch
git apply ./0002-Sunxi-adaptation-for-mali-r3p2-01rel2-kernel-module.patch
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sun7i_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=output modules_install

kevindt  
Post Last Edited by kevindt at 2014-9-26 20:51

Reply 9# deales82

You should just have to use the configurations in the defconfig that is created.  The relevant section from the script for toolchain creation on a clean Ubuntu Server 14.04 is here, as well as the git download and compilation steps, and the corresponding patches from my compile machine are in this zipfile :

https://dl.dropboxusercontent.co ... %20for%20script.zip

#
# Note: This is based heavily upon a script for Cubietruck/Cubiboard2
# created by Igor Pecovnik, www.igorpecovnik.com
#
# --- Configuration -------------------------------------------------------------
#
#

RELEASE="wheezy"                                                   # wheezy
VERSION="BananaDebian 2.6 $RELEASE"                    # just name
TOOLCHAIN_CREATE="yes"                                        # yes / no
SOURCE_COMPILE="yes"                                           # yes / no
PATCH="yes"                                                            # yes / no
DEST_LANG="en_US.UTF-8"                                      # sl_SI.UTF-8, en_US.UTF-8
TZDATA="US/Pacific"                                                # Timezone
ACCESS_POINT="no"                                                # Configure for access point (yes / no)
DEST=$(pwd)/output                                                # Destination
ROOTPWD="1234"                                                    # Must be changed @first login
HOST="banana"                                                        # Hostname

#
#
# --- End -----------------------------------------------------------------------

# source is where we start the script
SRC=$(pwd)
set -e

# optimize build time with 100% CPU usage
CPUS=$(grep -c 'processor' /proc/cpuinfo)
CTHREADS="-j$(($CPUS + $CPUS/2))"
#CTHREADS="-j${CPUS}" # or not

# to display build time at the end
start=`date +%s`

# root is required ...
if [ "$UID" -ne 0 ]
  then echo "Please run as root"
  exit
fi

clear
echo "Building $VERSION."

#--------------------------------------------------------------------------------
# Downloading necessary files
#--------------------------------------------------------------------------------
if [ "$TOOLCHAIN_CREATE" = "yes" ]; then

echo "Downloading necessary files."
apt-get -qq -y install bc lzop zip binfmt-support bison build-essential ccache debootstrap flex gawk gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf lvm2 qemu-user-static u-boot-tools uuid-dev zlib1g-dev unzip libncurses5-dev pkg-config libusb-1.0-0-dev parted

#--------------------------------------------------------------------------------
# Preparing output / destination files
#--------------------------------------------------------------------------------
echo "Fetching files from Github."
mkdir -p $DEST/output

if [ -d "$DEST/u-boot-bananapi" ]
then
        cd $DEST/u-boot-bananapi ; git pull; cd $SRC
else
        git clone https://github.com/LeMaker/u-boot-bananapi.git  $DEST/u-boot-bananapi                      #Bananapi loader
fi

if [ -d "$DEST/sunxi-tools" ]
then
        cd $DEST/sunxi-tools; git pull; cd $SRC
else
        git clone https://github.com/LeMaker/sunxi-tools.git $DEST/sunxi-tools                               # Allwinner tools
fi

if [ -d "$DEST/sunxi-boards" ]
then
        cd $DEST/sunxi-boards; git pull; cd $SRC
else
        git clone https://github.com/LeMaker/sunxi-boards.git $DEST/sunxi-boards                             # Allwinner tools
fi

if [ -d "$DEST/linux-bananapi" ]
then
        cd $DEST/linux-bananapi; git pull -f; cd $SRC
else
        git clone https://github.com/LeMaker/linux-bananapi.git   $DEST/linux-bananapi                                    # Stable kernel source
fi

if [ -d "$DEST/sunxi-lirc" ]
then
        cd $DEST/sunxi-lirc; git pull -f; cd $SRC
else
        git clone https://github.com/matzrh/sunxi-lirc $DEST/sunxi-lirc                                 # Lirc RX and TX functionality for Allwinner A1X and A20 chips
fi

fi  # end of "if TOOLCHAIN_CREATE"

if [ "$SOURCE_COMPILE" = "yes" ]; then

#--------------------------------------------------------------------------------
# Patching
#--------------------------------------------------------------------------------
if [ "$PATCH" = "yes" ]; then
echo "------ Applying patches"

cd $DEST/linux-bananapi
git apply $SRC/0001-Imported-the-original-mali-r3p2-01rel2-kernel-module.patch
git apply $SRC/0003-Sunxi-adaptation-for-mali-r3p2-01rel2-kernel-module.patch

fi
#----------------------------------------------------------------------------

# Compiling everything
#--------------------------------------------------------------------------------

# boot loader

echo "------ Compiling universal boot loader"

cd $DEST/u-boot-bananapi
make clean && make $CTHREADS CROSS_COMPILE=arm-linux-gnueabihf- Bananapi_config
make $CTHREADS CROSS_COMPILE=arm-linux-gnueabihf-

echo "------ Compiling sunxi tools"

cd $DEST/sunxi-tools
make clean && make fex2bin && make bin2fex
cp fex2bin bin2fex /usr/local/bin/

echo "------ Creating script.bin"

cd $DEST/sunxi-boards/sys_config/a20/
fex2bin Bananapi.fex script.bin

echo "------ Compiling kernel"
cd $DEST/linux-bananapi
make clean
make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sun7i_defconfig
make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage modules
make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=output modules_install
make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_HDR_PATH=output/usr headers_install
cp $DEST/linux-bananapi/Module.symvers $DEST/linux-bananapi/output/usr/include

fi # end of "if SOURCE_COMPILE"

echo "------ End of kernel compilation"


I'll be happy to upload the whole script later, when it is tested and cleaned up, but if you want, I'll PM you the current working status (very much experimental).

Kevin.

You have to log in before you can reply Login | Sign Up

Points Rules