Compiling a compatible U-boot and Linux Kernel for Banana Pi

15 17467
Post Last Edited by db260179 at 2014-6-17 14:02

Hi All,

Thought I would share my success in getting a personal linux kernel and u-boot built for the banana pi.

Starting off: (from an X86 pc ubuntu 12.04 with cross compiler tools for arm)
Native on bananapi is ok as well.

Download - http://multiupload.biz/smfidp2u0 ... Upload.biz.zip.html

u-boot from sunxi plus patch: (http://linux-sunxi.org/U-Boot) - you will need gcc arm installed if cross compiling!

1. Make a local folder and call it 'bananapi-uboot' , extract the zip from link above, then  cd into that directory
2. git clone https://github.com/linux-sunxi/u-boot-sunxi.git
3. cd u-boot-sunxi
4. patch -p1 < ../bpi-uboot.patch - this will patch the current u-boot to support the bananapi board fully (activate gmac and set name for Bananapi)
5. Set config for bananapi - make -j2 'BananaPi_config' CROSS_COMPILE=arm-linux-gnueabihf-
6. Start build for u-boot - make -j2 CROSS_COMPILE=arm-linux-gnueabihf-
Remove CROSS_COMPILE=arm-linux-gnueabihf- if building on bananapi natively.

Once built you will have a u-boot compatible (u-boot-sunxi-with-spl.bin) to apply to the SD card, as follows:
From a linux terminal:
sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8

Change /dev/mmcblk0 to your sd card reader

Put SD card into bananapi, ideally having a USB TTL serial lead will help showing the new u-boot features!

The u-boot patch adds a GMAC regulator support that the bananapi needs to activate the GMAC mii and phy, otherwise the kernel driver needs to be hacked to do the same thing. Also the latest u-boot from sunxi adds mac address assignment from the chipid - so no random mac addresses!

The GMAC will only work at 100mbps at the moment, 1gb has high packet loss - looking at the issue

ethtool -s eth0 speed 100 duplex full

Compiling the linux kernel - 3.4.93


1. Make a second directory called 'bananapi-kernel', extract the 'sunxi-93.patch' to that directory.
2. Download the standard kernel from kernel.org - wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.4.93.tar.gz
3. Extract downloaded archive - tar xzvf linux-3.4.93.tar.gz, cd into directory
4. Run patch -p1 < ../sunxi-93.patch
5. This is now a bananapi compatible linux kernel

Build as follows:

# Flat kernel and modules
make -j2 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sun7i_defconfig
make -j2 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
make -j2 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage modules
make -j2 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/lib/modules modules_install - if you want to install
make -j2 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_HDR_PATH=/usr/src headers_install - if you want to install

# Build Deb packages
export ARCH=arm
export DEB_HOST_ARCH=armhf
export CONCURRENCY_LEVEL=`grep -m1 cpu\ cores /proc/cpuinfo | cut -d : -f 2`
#fakeroot make-kpkg --arch arm --cross-compile arm-linux-gnueabihf- --initrd kernel_image kernel_source kernel_headers
make -j2 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- KBUILD_DEBARCH=armhf KBUILD_IMAGE=uImage deb-pkg

I've added some extra patches - a builddeb script that can make debian kernel and source packages if you are using debian or ubuntu, GPIO patch driver, GMAC driver has a static MAC address set from the chipid, instead of random generated!

Hope this helps everyone - and ease frustations!
It is very detailed.

nice example

Reply 3# vk4tux

    http://multiupload.biz/smfidp2u0 ... Upload.biz.zip.html - has both patches, u-boot and sunxi-93.patch

Remember, the GMAC driver will only work correctly at 100mb at the moment until I can get more information on the 1gb issue.

Reply 2# tony_zhang

Hi Tony,

I would appreciate it if you could send me patches or pins to programme to get the full 1gb speed from the GMAC - any direction on this would be great!


Reply 6# db260179

Sorry, the GMAC could not release now. But you can use the GMAC driver from cubietruck, it works.

Can you find this file mach/barriers.h?

Wired ethernet eth0 is broken. Same thing with linux-sunxi Git version 3.4.90. Only Lubuntu kernel works but there are no sources available. Hence Banana-Pi is totally useless for me .

Reply 8# f4exb

https://github.com/LeMaker  Here is the newest source code

Good news! I'll try that.

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

Points Rules