JustKernel

Ray Of Hope

Cubieboard2 board bringup with Linux

Download Requirements:

1) Download linux kernel (local dir = linux): git clone https://github.com/talex5/linux.git
2) Download uboot (directory u-boot-sunxi) from git clone https://github.com/linux-sunxi/u-boot-sunxi.git . git checkout origin/sunxi-next. sunxi-next branch contains the code that allows the uboot to boot in hypervisor mode.
3) Download sunxi-tools (local dir = sunxi-tools) from git://github.com/linux-sunxi/sunxi-tools.git .
4) Download sunxi-boards (local dir = sunxi-boards) from git://github.com/linux-sunxi/sunxi-boards.git
5) Download linaro root fs from http://releases.linaro.org/14.05/ubuntu/trusty-images/developer/linaro-trusty-developer-20140522-661.tar.gz.
6) Download xen (local dir = xen) from git://xenbits.xen.org/xen.git.
7) script.bin : cd sunxi-tools. give command “make fex2bin”. cd sunxi-boards, give the following command : “../../../sunxi-tools/fex2bin cubieboard2.fex script.bin”

Compilation:
1) Install the cross compilation toolchain: http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/CrossCompiling : chroot environment for compiling xen.
2) XEN: Follow the xen compilation guide at : http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/CrossCompiling or http://openmirage.org/wiki/xen-on-cubieboard2.
3) uboot: cd u-boot-sunxi, make CROSS_COMPILE=arm-linux-gnueabihf- Cubieboard2_config, make CROSS_COMPILE=arm-linux-gnueabihf-
4) Linux kernel: cd linux, 1) make ARCH=arm menuconfig 2) copy https://github.com/mirage/xen-arm-builder/blob/master/config/config-cubie2 to linux/.config (config-cubie2 has all the relevant configs for arm compilation for linux kernel). 3) make ARCH=arm zImage dtbs modules -j 4

Prepare the SD Card.
I used USB card reader and MicroSD card. It was detected on linux as /dev/sdc

export card=/dev/sdb
export p=””
1) dd if=/dev/zero of=${card} bs=1M count=1
2) dd if=/dev/zero of=${card} bs=1k count=1023 seek=1
3) dd if=spl/sunxi-spl.bin of=${card} bs=1024 seek=8
4) dd if=u-boot.img of=${card} bs=1024 seek=40
5) {
echo 32,512,0x0C,*
echo 544,,,-
} | sudo sfdisk -D ${card}
6) mkfs.vfat ${card}${p}1
7) mkfs.ext4 ${card}${p}2
8) cardroot=${card}${p}2
9)mount ${card}${p}1 /mnt/
10) cp linux/arch/arm/boot/uImage /mnt/ // copy the linux image to /dev/sdc1
11) cp sunxi-boards/sys_config/a20/script.bin /mnt/ //copy script.bin to /dev/sdc1
12) umount /mnt/
13) vi /mnt/boot.cmd and paste the following content:
# SUNXI Xen Boot Script

# Addresses suitable for 1GB system, adjust as appropriate for a 2GB system.
# Top of RAM: 0x80000000
# Xen relocate addr 0x7fe00000
setenv kernel_addr_r 0x7f600000 # 8M
setenv ramdisk_addr_r 0x7ee00000 # 8M
setenv fdt_addr 0x7ec00000 # 2M
setenv xen_addr_r 0x7ea00000 # 2M

setenv fdt_high 0xffffffff # Load fdt in place instead of relocating

# Load xen/xen to ${xen_addr_r}.
fatload mmc 0 ${xen_addr_r} /xen
setenv bootargs “console=dtuart dtuart=/soc@01c00000/serial@01c28000 dom0_mem=128M”

# Load appropriate .dtb file to ${fdt_addr}
fatload mmc 0 ${fdt_addr} /sun7i-a20-cubieboard2.dtb
fdt addr ${fdt_addr} 0x40000
fdt resize
fdt chosen
fdt set /chosen \#address-cells <1>
fdt set /chosen \#size-cells <1>

# Load Linux arch/arm/boot/zImage to ${kernel_addr_r}
fatload mmc 0 ${kernel_addr_r} /vmlinuz

fdt mknod /chosen module@0
fdt set /chosen/module@0 compatible “xen,linux-zimage” “xen,multiboot-module”
fdt set /chosen/module@0 reg <${kernel_addr_r} 0x${filesize} >
fdt set /chosen/module@0 bootargs “console=hvc0 ro root=/dev/mmcblk0p2 rootwait init=/bin/bash clk_ignore_unused”

bootz ${xen_addr_r} – ${fdt_addr}

Please refer http://openmirage.org/wiki/xen-on-cubieboard2 for details.
14) cd /mnt . sudo mkimage -C none -A arm -T script -d /mnt/boot.cmd /mnt/boot.scr
15) umount /mnt
16) mount /dev/sdc2 /mnt. cd /mnt
17) sudo tar xf /your/path/to/linaro-trusty-developer-20140522-661.tar.gz
sudo mv binary/* .
sudo rmdir binary
18) Go back to the directory where you compiled your Linux kernel and do:
make ARCH=arm INSTALL_MOD_PATH=’/mnt/mmc2′ modules_install

Boot..
Your board will be able to boot linux and root prompt will come after the boot.

Resources, links:
http://linux-sunxi.org/Bootable_SD_card#Bootloader
http://linux-sunxi.org/Manual_build_howto#boot.cmd
http://openmirage.org/wiki/xen-on-cubieboard2
https://github.com/mirage/xen-arm-builder/blob/master/config/config-cubie2
https://github.com/talex5/linux
https://github.com/mirage/xen-arm-builder
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Allwinner

Thanks
Anshul Makkar

Tags:


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.