Banana Pi the Gentoo Way

This guide is going to provide details on how to install Gentoo with a user compiled kernel and Gentoo Stage 3. I have been using Banana Pi's in a clustered distcc cross compiling environment for nearly a year.There has been a lot of controversy about the Banana Pi and it developers. The hardware is a nice board, but some of the practices concerning the methods undertook by the developers concerning business practices and the software side is certainly controversial. Best summed up on the Linux-Sunxi.org/Banana_Pi page.

To provide some clarification on documentation from different sources. Nearly everything provided on the Lemaker websites, and other Banana Pi websites has been copied from the Linux-Sunxi.org pages. While all the direct copies of the Linux-Sunxi.org website have been taken down. I am assuming some copyright infringement issues surfaced. For some reason, Lemaker prefers to maintain their own full kernel git repositories rather than simply having a simple patch repository and providing patches to upstream Linux-Sunxi.org and U-Boot to be included in their git repositories. This practice also makes is more difficult for LeMaker patches to be applied to other kernel sources by the general user base. Some early patches were provided and are included in the Linux-Sunxi.org git repositories, but latter refinements have not been submitted for inclusion.

I have to provide some cautionary advice concerning some of the ready to go images for the Banana Pi, along with some of the git repositories. The LeMaker Gentoo release is not put together very well, specifically when it comes to CFLAGS. It is obvious that they are inexperienced and are not aware of the impact of having incorrect or missing CFLAGS. I have seen countless posts of people spending countless hours attempting to get hardware acceleration working, while the CFLAGS supplied with the LeMaker Gentoo release, will not allow hardware acceleration. At least it did not earlier this year 2015. Here is a post of mine concerning CFLAGS for the Banana Pi.

I have found numerous posts on a number of forums, as well as the Lemaker forums themselves, with claims of malicious content. I my self have not bothered with disseminating any of the so-called official releases, and cannot confirm any of the claims. Considering the clashes and legal disputes over trademarks and domain ownership, along with the claim of open source, when the Banan Pi is certainly not, visit the Linux-Sunxi.org website for more details on that. It may certainly be true that some parties may have injected malicious content in an attempt to harm other participating parties.

The best way to avoid any possible security risks, is to use software that has been reviewed and tested by a reputable process and group. Therefore this guide will provide details on how to compile a kernel from the soc developers git repository (Linux-Sunxi.org), as well as from the Banana Pi (Lemaker) developers git repository. While using a standard Gentoo Arm Stage 3 pulled from an approved Gentoo Mirror.

To speed up compilation, it is suggested that you set up a distcc cross compiling environment on an Amd64 or other faster architecture. Distcc and Distcc/Cross-Compiling. Not all packages will compile on other machines in the cluster, but many will. If you have a number of Banana Pi devices, use the buildpkg feature so that binary packages are built that can then be quickly installed on the other Banana Pi's or distributed to devices in other locations. An NFS mount can be used for to have the packages directory mounted on all the Banana Pi devices on your lan.

This is a work in progress, please bear with me as I review my notes and figure out the best way to present them here. For the time being, here is one of my forum posts, concerning getting the right CFLAGS for the Banana Pi.

Cross Compiling
If you do not have a running arm device/computer to build from, and are running an Amd64 or X86 Desptop/Laptop. You will need to setup a cross compiling environment. Follow the Distcc/Cross-Compiling guide. You may also want to review the Raspberry Pi Cross building. Since compiling on one Banana Pi is not all that speedy you will want to take advantage of faster computers on you network Distcc

When you install your arm crosdev it is important that you use the cflags that you will be using on the Banana Pi. If neon-vfpv4 is not use, you will be losing some performance capability. Here is a link to some detailed information Arm Cortex A Processors & GCC Commands.

You will need to run this command on every machine that is not an Arm device that will be used for distcc.

Preparing The SDCard
Insert your sdcard and run lsblk.

U-Boot
You will need to build a bootloader specific for the Banana Pi. You have a choice of using either the Linux-Sunxi git repositories or the Lemaker git repository. If you prefer to us the Linux-Sunxi repository you might want to check the boards.cfg from LeMaker to see if it has been updated and not provided to upstream Linux-Sunxi. You can simply edit the changes or copy over the LeMaker boards.cfg. You can visit the git repository to check without having to clone both repositories.

Make a build folder to work in. It can be called anything and can be located anywhere you want. Most things can be configured as a regular user, but then have to be compiled as root.

Clone the git repository.

First you need to configure for the Banana Pi.

Now you need to compile the bootloader.