Cross Compile High detail guide - Raspberry Pi Forums


hello, have struggled lot recompile kernel raspberry pi, changing boot logo icon , have decided share experience , things have done step step fixing every encountered error in order save lot of headaches other people

guide explains how cross compile linux raspberry pi 2/3

first must have linux installed on virtual machine, guide used virtualbox
possible use vmware workstation or similar software

1.setting environment
1.1.download , install virtualbox windows hosts official website
- https://www.virtualbox.org/wiki/downloads
1.2.download , install virtualbox extension pack (it required mount sdcard raspberry os on it)
- http://www.downloadcrew.com/article/202 ... nsion_pack
note: if extension pack cannot installed double click on icon open virtualbox , install manually
file -> preferences -> extensions -> add new package
1.3.download latest version of ubuntu mate (or ubuntu depends on user choice)
1.4.creating new virtual machine
1.4.1.from virtualbox main menu select new
1.4.2.enter name , operating system. in case we're going linux , ubuntu (64 bit)
1.4.3.memory size next.too much/too little can problematic. guide have used 2048 mb ram
feel free change value if want
1.4.4.hard drive - create virtual hard drive
1.4.5.hard drive file type - choose vdi unless have other vms
1.4.6.choose amount of storage space. - 8gb fine users. fixed size recommended if user has free space
dynamically allocated hard drive use physical hard drive fills (up maximum fixed size),
although not shrink again automatically when space free
fixed hard drive file may take longer create on systems faster use
1.4.7.press start, ask select virtual optical disk file.select downloaded ubuntu.iso file
1.4.8.select install ubuntu. no need select update if have downloaded newest version
1.4.9.after installation complete , ubuntu has started select
devices -> insert guest additions cd image , install it
------------- optional ------------
if user wants shared folder/folders
1.4.10.start terminal , run command "sudo adduser username vboxsf"
example : "sudo adduser spstrademark vboxsf"
1.4.11.shutdown ubuntu, virtualbox menu settins -> shared folder,
select folder want shared , select active on auto-mount , make permanent
------------- optional ------------
1.4.12.from settings ->usb select enable usb controller make active usb 2.0
add new usb filder , select desired usb wit sdcard wish mounted
note: if usb 1.0 selected , extension pack not installed
possible of usb drive on pc freeze (from personal experience)
2.making preparations cross compile avoid errors later on
2.1.sudo apt-get install git - installing git if not installed (needed git tools)
2.2.sudo apt-get install -y netpbm - installing netpbm if not installed (needed edit logo)
2.3.sudo apt-get install gedit - installing gedit if not installed
2.4.sudo gedit /etc/apt/sources.list - edit install package
if universe not included modify file does.
deb http://us.archive.ubuntu.com/ubuntu precise main universe click save
sudo apt-get update
sudo apt-get install gcc-4.6-arm-linux-gnueabi
2.5.sudo apt-get install libncurses5-dev libncursesw5-dev - in case of error no curses.h
2.6.sudo apt-get install libssl-dev - in case of openssl error
2.7.sudo apt-get install build-essential - in case of /bin/sh 1 gcc not found
2.8.sudo apt-get install gcc-arm* - in case of /bin/sh:1: arm-linux-gnueabihf-gcc: not found
3.cross compile
3.1.git clone https://github.com/raspberrypi/tools.git
3.2.note:since linux.git takes lot of time there alternative fast method available
3.2.1. slow method : git clone https://github.com/raspberrypi/linux.git
3.2.2. fast method : git clone --depth=1 https://github.com/raspberrypi/linux
it downloaded read try use
chown $user -r ~/.linux
note: if command not work try different 1 or delete folder , use method 1
3.3.changing boot logo (optional)
3.3.1.cd ~ / linux / drivers / video / logo
place desired logo in directory, name logo.jpg
3.3.2.jpegtopnm logo.jpg> logo.ppm
3.3.3.ppmquant 224 logo.ppm> logo_224.tmp
3.3.4.pnmnoraw logo_224.tmp> logo_linux_clut224.ppm
3.3.5.cd ~ /
3.4.build sources
3.4.1.cd linux
3.4.2.kernel=kernel7
3.4.3.make arch=arm cross_compile=arm-linux-gnueabihf- bcm2709_defconfig
3.5.open menu config (optional)
3.5.1.make arch=arm cross_compile=/usr/bin/arm-linux-gnueabihf- menuconfig
boot logo : device drivers -> graphics options -> boot logo
make sure 16-color , 224-color selected
feel free experiment in menu config suit final results personal needs :)
3.6.compile!
3.6.1.make arch=arm cross_compile=arm-linux-gnueabihf- zimage modules dtbs
note: speed compilation on multiprocessor systems, , improvement
on single processor ones, use -j n n number of processors * 1.5.
alternatively, feel free experiment , see works!
3.7.directly install on sd card
3.7.1.sudo fdisk -l
sdcard should visible sdb1 sdb2
3.7.2.mkdir mnt
3.7.2.mkdir mnt/fat32
3.7.3.mkdir mnt/ext4
3.7.4.sudo mount /dev/sdb1 mnt/fat32
3.7.5.sudo mount /dev/sdb2 mnt/ext4
4.install modules
4.1.sudo make arch=arm cross_compile=arm-linux-gnueabihf- install_mod_path=mnt/ext4 modules_install
5.copy kernel , making back-up
5.1. sudo cp mnt/fat32/$kernel.img mnt/fat32/$kernel-backup.img
5.2. sudo scripts/mkknlimg arch/arm/boot/zimage mnt/fat32/$kernel.img
5.3. sudo cp arch/arm/boot/dts/*.dtb mnt/fat32/
5.4. sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/
5.5. sudo cp arch/arm/boot/dts/overlays/readme mnt/fat32/overlays/
5.6. sudo umount mnt/fat32
5.7. sudo umount mnt/ext4
5.8. sync
done :) eject sdcard , plug in raspberry pi

note : in case when start raspberry pi there emergency message @ start following :
mount sdcard in virtual machine
run terminal
if rpi sdcard /dev/sdb :
sudo umount /dev/sdb1
sudo umount /dev/sdb2
sudo fsck /dev/sdb1
sudo fsck /dev/sdb2

if following message :
"fs not unmounted , data may corrupt" , options select from:
1) remove dirty bit
2) no active
select 1, proceed , agree on fixed data
after process complete remove sdcard , relaunch raspberry pi

feel free comment experience , think improved :)

seems maybe useful windows users switching on rpi?

though why not compile under raspbian?


raspberrypi



Comments