Building the Banana Pi LeMaker Kernel

I recently bought a Banana Pi because I wanted something more powerful than a Raspberry Pi (and because I had store credit to use up).

I wanted to run Debian on it, but not the Raspbian distribution provided by Lemaker because I find it’s too resource heavy for what I will be using my Banana Pi for. I followed Christian Bock’s excellent blog post on how to build a Debian rootfs for the Banana Pi.

More pre-built SD card images are coming out for the Banana Pi, but I wanted to use a spare 1GB microSD card and no one provides images that small, so I went and built my own.

As Christian noted in his blog post, the sunxi kernel sources do not work well on the Banana Pi as they contain a broken sunxi ethernet driver. The NIC is unstable when running at gigabit speeds (my testing showed approximately 60% packet loss). A definite deal-breaker if you need reliable network access. LeMaker was a bit slow in releasing their kernel source, but after users complained it was released on github.

Prerequisites for building the kernel are outlined in LeMaker’s wiki page. Basically you need the following packages:

build-essential u-boot-tools uboot-mkimage binutils-arm-linux-gnueabihf gcc-4.7-arm-linux-gnueabihf-base g++-4.7-arm-linux-gnueabihf gcc-arm-linux-gnueabihf cpp-arm-linux-gnueabihf libusb-1.0-0 libusb-1.0-0-dev git wget fakeroot kernel-package zlib1g-dev libncurses5-dev

This is the Jenkins script I use to build the LeMaker kernel for the Banana Pi:

if [ ! -d "linux-bananapi" ]; then
git clone -b bananapi-3.4 https://github.com/LeMaker/linux-bananapi.git
fi
cd linux-bananapi
git pull
wget https://watchmysys.com/blog/wp-content/uploads/2014/08/linux-bananapi.config -O .config
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- clean
make -j4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=output modules_install
mkdir -p output/boot/
cp arch/arm/boot/uImage output/boot/
tar -C output -cjvf ../linux-bananapi-3.4.90.tar.bz2 boot/ lib/

I’ve included the above commands in a script at the end of this post. I’ve added additional comments explaining the what and why for people who don’t arbitrarily trust strangers on the internet.

Installation is fairly simple, you need to mount the sdcard /boot and / partitions on your computer and then run:

tar -C /path/to/sdcard -jxvf linux-bananapi-3.4.90.tar.bz2

This will extract /boot/uImage and the kernel modules to /lib/modules/3.4.90-00261-gb3b7287

My kernel configuration includes the sunxi ethernet driver as a module (sunxi_gmac) so that you can unload/reload it if necessary. This means you need to use both the uImage and the modules provided or you will not have network connectivity.

Build script: bash/Jenkins build script
Kernel and modules: linux-bananapi-3.4.90.tar.bz2
Kernel Config: linux-bananapi-3.4.90.config

11 thoughts on “Building the Banana Pi LeMaker Kernel

  1. pete

    Hi there,

    good to see that at least somebody knows what he is doing 🙂 Always wondered why others wrote about building but did not provide anything back to the community. Did you also try building other kernel versions w/ a 100% working sunxi_gmac? Feel free to email me,

    sincerely yours && l8erz

    -pete

    Reply
  2. pete

    Okay, forget the stupid question about other kernel versions as LeMaker seems to have changed a whole lot of things even resulting in an available CONFIG_GMAC_FOR_BANANAPI=y @ their 3.4.90 kernel 🙂

    Reply
  3. Hal Martin Post author

    @pete: I have definitely considered it. I don’t think building a kernel that isn’t modified by LeMaker is an option, unless you don’t mind compromising NIC performance/reliability. The MAC address of the NIC changes if you run the sunxi kernel without the sunxi_gmac module present in the LeMaker kernel. Maybe someone with more kernel programming experience can explain why the hardware address changes.

    I’m going to try building the 3.14 kernel LeMaker have in the experimental branch to see if that has the same packet loss issue. 3.4 is quite old at this point and versions between 3.4 and 3.14 bring some nice features that would be great to have on the Banana Pi 🙂

    Reply
    1. Thierry

      Hi ,
      Great Post for newbies like me..
      So I wanted to upgrade my kernel to 3.14 but it’s not a easy handling..
      Have you succeed in building the 3.14 kernel ?
      Feel free to email me,

      sincerely yours

      Thierry

      Reply
      1. Hal Martin Post author

        Hi Thierry,

        I have experimented with building 3.14 for the Banana Pi but I can’t produce a kernel that will boot on the board. I think LeMaker still has some work to do before it can be considered functional. I’ll let you know if I succeed in building it in the future.

        Reply
        1. Thierry

          Yes, it seems not yet to be faisable

          I can’t waiiit to use the bananapi with its full of potential

          Thanks for your sharing

          Thierry

          Reply
    2. bxabi

      Hi. Did you succed with that? I would liek to have a newer kernel, because I have a wlan card which is not supported by the 3.4.90.

      Reply
      1. Hal Martin Post author

        No, sorry. The LeMaker guys do not really seem to be updating their kernel sources anymore and right now I do not have the time to try and apply their patches to a newer kernel source.

        The latest version available from LeMaker sources is 3.4.103. It is disappointing to see the BananaPi kernel languish so much when other boards (RPi) see much more frequent updates.

        OpenWRT has trunk images for the board, but their wiki page states:

        GMAC is not working due to some subtle PHY differences

        So you could use the OpenWRT imagebuilder to compile 3.14 as long as you don’t need Ethernet (e.g. wifi only)

        If there’s enough interest I can compile the 3.14 sunxi kernel OpenWRT is using and upload it. Ethernet will be unreliable or non-functional in kernels newer than 3.4.X. LeMaker has some additional patches for the GMAC that need to be applied to the vanilla sunxi sources before Ethernet is really usable.

        Reply
  4. Mayk

    So the newest kernel running stable is 3.4? I read you can build an unstable build of 3.14-3.17(rc) with quite a lot of code patching in both kernel & bootloader, and (in the end) no eth0 support for those kernels. It will still allow you to test things using a ttl/uart cable or with an usb network dongle.

    Reply
    1. Hal Martin Post author

      @Mayk: Right now it looks like the only fully-functional kernel for the Banana Pi is 3.4.90 published by LeMaker. I tried to build the 3.14 experimental kernel from their github branch but it wouldn’t boot. Hopefully they will continue to work on getting newer kernels to work on the Banana Pi and not abandon it at 3.4.90!

      Reply
  5. Pingback: Building Linux 4.1 for the Banana Pi | «WatchMySys» Blog

Leave a Reply

Your email address will not be published.