Discussion

Cross-Compile BnnPi's u-boot & kernel

11 11089
FishX  
Edited by tony_zhang at Tue Nov 25, 2014 21:55

Post Last Edited by tony_zhang at 2014-7-24 07:47

Based On the newly released BSP by Tony Zhang(BSP means “Board Support Package”)

0)Get toolchains.
The toolchain is a set of binaries, system libraries and tools which allow you to build (in our case, cross-compile) u-boot and the kernel for a target platform. This will, to some limited extent, need to match the target rootfs. If you use the Ubuntu or Debian, you can get all you need by install the tools below:
  1. sudo apt-get update
  2. sudo apt-get upgrade
  3. sudo apt-get install 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
Copy the Code
1)download BSP packages
  1. git clone https://github.com/LeMaker/lemaker-bsp.git
Copy the Code
2)Compile all including u-boot,kernel,kernel modules,firmware.
  1. cd bananapi-bsp
  2. ./configure Bananapi
  3. make
Copy the Code
(default:make -j8)
It takes me about 30minutes on I3 hanswell processor. After all have been built, you will get all you want in the build/Bananapi_hwpack directory, such as u-boot-sunxi-with-spl.bin, uImage, scritp.bin, modules. You can tweak your kernel configuration too by running:
  1. make linux-config
Copy the Code
4)prepare an sd card with Lubuntu3.0 image of bananapi
download the Lubuntu3.0 image from here(http://www.lemaker.org/index.php?m=content&;c=index&a=show&catid=9&id=38) and write to a sd card with:
sudo dd bs=4M if=[path]/[imagename] of=/dev/sdx

5)unmount all partions on sdcard,use sudo fdisk -l to confirm which partion shoud be unmount.
  1. sudo fdisk -l
  2. umount /dev/sdc1
  3. umount /dev/sdc2
  4. umount /dev/sdc5
Copy the Code
6)burn the bootloader
sudo dd if=/dev/zero of=sdc bs=1k count=1023 seek=1
sudo dd if=build/Bananapi_hwpack/bootloader/u-boot-sunxi-with-spl.bin of=sdc bs=1024 seek=8

then replug the CardReader
7)burn the kernel
  1. sudo cp build/Bananapi_hwpack/kernel/uImage /media/t/disk1(first partion(format:fat) of SDCard with image)
  2. sudo cp build/Bananapi_hwpack/kernel/script.bin /media/t/disk1
Copy the Code
8)burn the new kernel modules & firmware
  1. sudo cp -r rootfs/lib /media/t/disk2(Second partion(format:ext4) of SDCard with image)
  2. sudo cp -r rootfs/etc /media/t/disk2
Copy the Code
9)unplug the sdcard and insert to Bananapi.Enjoy the new kernel.
btw:if there's error in compile,you should put the path of mkimage to the envionment variables Like:
  1. export PATH=$PATH:/home/t/bananapi-bsp/build/Bananapi-u-boot/tools/
Copy the Code
Thanks for FishX!!!

dlanor  
This was an interesting read, and I thank you for it, but I'd also be interested in how to do the same modifications to create a new image file, rather than just burning the modifications straight to an SD card.

I understand that steps 1 through three would be identical, but after half of step 4, the downloading an existing image, I'd like to learn how to add the modifications to that image,  or how to use its content together with the newly compiled modifications to create a new image file. The resulting image can then be used by anyone with a valid tool to burn the image, even if not using Linux.

Best regards: dlanor

On a Linux PC you could mount the (LUbuntu) image using a loopback device,add/remove stuff and then unmount it.
This page details the process...
http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=28860

btw thanks to FishX for outlining the build process...

Xnyle  
Any chance, anyone is going to apply the needed bpi patches to experimental/sunxi-3.10?

I tried to but I guess I failed, not so much of a c expert

ups  
Thanks to Tony Zhang and FishX
got my self-compiled kernel working with network and touchdisplay (on raspian instead of lubuntu ;)  )

Post Last Edited by SebastianB at 2014-8-23 04:31

Hi,
I am using debian wheezy on an amd-64 platform. I try to install the cross compile toolchaing but basically apt can't find any of the required tools. This is the default sources.list which came with the install:
--
deb cdrom:[Debian GNU/Linux 7.6.0 _Wheezy_ - Official amd64 DVD Binary-1 20140712-14:11]/ wheezy contrib main

deb http://security.debian.org/ wheezy/updates main contrib
deb-src http://security.debian.org/ wheezy/updates main contrib

deb http://http.debian.net/debian wheezy main
deb-src http://http.debian.net/debian wheezy main

deb http://http.debian.net/debian wheezy-updates main
deb-src http://http.debian.net/debian wheezy-updates main


---
Here are the errors from apt-get:
root@debian64:/etc/apt# apt-get install 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
Reading package lists... Done
Building dependency tree      
Reading state information... Done
E: Unable to locate package binutils-arm-linux-gnueabihf
E: Unable to locate package gcc-4.7-arm-linux-gnueabihf-base
E: Couldn't find any package by regex 'gcc-4.7-arm-linux-gnueabihf-base'
E: Unable to locate package g++-4.7-arm-linux-gnueabihf
E: Couldn't find any package by regex 'g++-4.7-arm-linux-gnueabihf'
E: Unable to locate package gcc-arm-linux-gnueabihf
E: Unable to locate package cpp-arm-linux-gnueabihf
root@debian64:/etc/apt#
What do I need to add or configure otherwise to get the arm compiler etc?

Reply 8# SebastianB

Ok, I found the answer to my question in : http://linux-sunxi.org/Toolchain

peetr04  
Hi!

I try'd to make kernel, but i have trouble now.

I try'd to ./configure Bananapi-android

After i do make. All was ok until this:

mkdir -p /home/bubuka/Banana/bananapi-bsp/output
sunxi-tools/fex2bin sunxi-boards/sys_config/a20/Bananapi.fex > /home/bubuka/Banana/bananapi-bsp/build/Bananapi.bin
mkdir -p /home/bubuka/Banana/bananapi-bsp/build/sun7i_wing_defconfig-linux
make -C linux-bananapi O=/home/bubuka/Banana/bananapi-bsp/build/sun7i_wing_defconfig-linux ARCH=arm sun7i_wing_defconfig
make[1]: Entering directory `/home/bubuka/Banana/bananapi-bsp/linux-bananapi'
  GEN     /home/bubuka/Banana/bananapi-bsp/build/sun7i_wing_defconfig-linux/Makefile
***
*** Can't find default configuration "arch/arm/configs/sun7i_wing_defconfig"!
***
make[3]: *** [sun7i_wing_defconfig] Error 1
make[2]: *** [sun7i_wing_defconfig] Error 2
make[1]: *** [sub-make] Error 2
make[1]: Leaving directory `/home/bubuka/Banana/bananapi-bsp/linux-bananapi'
make: *** [/home/bubuka/Banana/bananapi-bsp/build/sun7i_wing_defconfig-linux/.config] Error 2

I googled a lot and find this:
11:36 <oliv3r> Can't find default configuration "arch/arm/configs/sun7i_wing_defconfig"!
11:37 <oliv3r> but we don't have sun7i android config yet
11:37 <oliv3r> it hasn't been 'made' yet
11:37 <oliv3r> so that's why it fails
11:37 <mnemoc> oliv3r: great!
11:37 <JohnDoe_71Rus> oliv3r: think you add "wing"
11:37 <oliv3r> feel free to diff sun7i_defconfig and sun4i_nuclear_defconfig and create sun7i_wing_defconfig and submit it via the ML; we do nee done
11:38 <oliv3r> JohnDoe_71Rus: yeah that's the official code name for sun7i android, but we don't have android kernel for sun7i yet, wel no defconfig
12:00 hurtigbuffer is now known as jelly-home
12:12 <hramrach> JohnDoe_71Rus: or use the config from sdk .. somebody was saying earlier that it differs from sunxi config a lot



Any ide how to solve this?

Thank you!

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

Points Rules