0% found this document useful (0 votes)
74 views10 pages

You Have To Know: Release 2

The document provides step-by-step instructions for building a custom Linux system for the Cubieboard from source, including compiling the kernel, U-boot bootloader, and choosing between building a root filesystem using Busybox, Debian, or other options. Key steps include partitioning an SD card, cloning source code from GitHub, cross-compiling components, and copying files to the SD card to create a bootable system.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views10 pages

You Have To Know: Release 2

The document provides step-by-step instructions for building a custom Linux system for the Cubieboard from source, including compiling the kernel, U-boot bootloader, and choosing between building a root filesystem using Busybox, Debian, or other options. Key steps include partitioning an SD card, cloning source code from GitHub, cross-compiling components, and copying files to the SD card to create a bootable system.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

How to make a cubieboard system release 2

Author TLL Mail:[email protected]


In cubieboard forum,many people want to make their self system because they want
to know why and how.Now,let me tell you how to make a linux system for Cubieboard,like
busyOS,Debian.

Color:
You have to know
You may want to know
Code
Tips
That's the common text

First,That's the menu:


One:First step you need to do
Two:build Kernel
Three:build U-boot
Four:build script.bin
Five:build rootfs
Six:burn and run

What you need:


A cubieboard
This document
A SD card(the size of that card have to bigger than 1Gb)
Some fingers who can type the commands(one is OK too)
One or two eye(s) to read this document

First step you need to do


You may want to know,to boot a system,it will runs:

Power on → U-boot → Linux kernel → init → shell

So you know,”Power on” isn't a software,so we don't need to build it.


You can take a look at your SD card if there is a Cubieboard system (Not android!!).
It will show you 2 partitions(maybe one partition if that system is strange).
The first partition is a vFAT partition,it saves uImage,boot.scr or uEnv.txt,script.bin,etc.
Then the second partition is a ext partition,it's linux's rootfs,maybe ext2,maybe 3,maybe
4,etc.
OK,don't say that,let's start.
Oh,you should install a Ubuntu or Debian system because we have to use “apt-get”
command.
[Make sure you just have 1 disk on your computer,if you have 2,please change “sdb” to
“sdc”,etc,you can also remove a disk,that's OKay]
Run these(please do not copy because sdb may be your hard disk):
fdisk /dev/sdb #WARNING
p
d
#ENTER
d
#ENTER (try d+ENTER until it says “No partition is defined yet!”)
n
p
1
2048
+100M
n
p
2
#ENTER
#ENTER
w

Tips:You have to replace “#ENTER” to real enter.


If it says “Calling ioctl() to re-read partition table.
Syncing disks.”,then try to eject your card and insert your card or you can try “partprobe”
command
Then:
fdisk /dev/sdb -l
If you see:
Disk /dev/sdb: xxxx MB, xxxx bytes
xx heads, xx sectors/track, xx cylinders, total xx sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x xxx
Device Boot Start End Blocks Id System
/dev/sdb1 2048 206847 xx 83 Linux
/dev/sdb2 206848 xxx xx 83 Linux
That means OK.
Then build filesystem:
mkfs.ext4 /dev/sdb2
Build Kernel
Linux kernel is very important because you will need it on booting and it will runs init then
init runs shell,etc.Let's build linux 3.4 kernel for CB,CT
First,use your browser to visit “https://github.com/cubieboard2/linux-sunxi”.Then,select
branch “sunxi-3.4-ct-v101” if you have a Cubietruck(Like picture 1),then you can see kernel
files you need.
Picture 1

Do NOT click “Download Zip” because there are some links.


Open your “Terminal”,type “sudo su” and type password to use the super user – root.
Tips:When you are typing password,it will not show you that,that's good.

If you are using Cubieboard2,please type:


git clone https://github.com/cubieboard2/linux-sunxi
If you are using CubieTruck,type:
git clone https://github.com/cubieboard2/linux-sunxi -b sunxi-3.4-ct-v101

Wait,wait and wait,Chinese network has a big problem – too slow.


And Chinese people have a big wall – Great Fire Wall(That's GFW),it's too bad.
I can't understand why Chinese government build this!
OK,just wait,no talking,like picture 2.

Picture 2
Github on ubuntu in Chinese is not very good,you can take a look “Picture 2”.There are 50%
Chinese and 50% English(Maybe 60%?).
You can use this command to install something you need:
apt-get install build-essential u-boot-tools uboot-mkimage gcc-arm-linux-gnueabihf
ncurses-dev -y
Then “cd” to linux-sunxi directory:
cd linux-sunxi
Use sun7i(A20) config:
make sun7i_defconfig ARCH=arm
Then select something you want:
make menuconfig ARCH=arm
If all OK,it will show you something like picture 3.

Picture 3

Select “General setup” → “Cross-compliter tool prefix” and write “arm-linux-gnueabihf-”


Tips,there is a “-” after “gnueabihf”!
Use these command to build kernel:
make uImage CROSS_COMPILE=arm-linux-gnueabihf- -j2 ARCH=arm

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j2 INSTALL_MOD_PATH=output


modules

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j2 INSTALL_MOD_PATH=output


modules_install

mv arch/arm/boot/uImage output

Then,cd to output:
cd output

OK,that's your kernel


A very very important tips:If you enabled the pwm-sunxi,you need to edit
“./drivers/misc/pwm-sunxi.c” and change “#include <pwm-sunxi.h>” to '#include
"pwm-sunxi.h"' because pwm-sunxi.h is a local file,not in “include” file.

You have to remove links of source code in output files or you want to copy them to your
board:
rm lib/modules/*/build lib/modules/*/source

Build U-boot
U-boot is a kernel-booter like grub,if you are using windows,it likes bootmgr or ntldr.
Let's build it now.
Download files from github:
git clone https://github.com/linux-sunxi/u-boot-sunxi -b wip/a20
Aha,it's faster because it's smaller than linux kernel.
Then.cd to u-boot-sunxi directory
cd u-boot-sunxi
You can edit include/config_cmd_default.h to add something,it's useful

For cubieboard1:
make cubieboard ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
For cubieboard2/cubieboard3(cubietruck):
make cubieboard2 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
Write it:
dd if=spl/sunxi-spl.bin of=/dev/sdb bs=1024 seek=8
dd if=u-boot.bin of=/dev/sdb bs=1024 seek=32
mkfs.vfat /dev/sdb1

WARNING TOO,PLEASE REPLACE SDB TO SDC IF YOU HAVE 2 HARD DISKS ON YOUR
COMPUTER
Build script.bin
script.bin is a config file.
You can use these command to build it:
apt-get install libusb-1.0-0-dev libusb-dev -y
git clone https://github.com/linux-sunxi/sunxi-boards
git clone https://github.com/linux-sunxi/sunxi-tools
cd sunxi-tools
make
mount /dev/sdb1 /opt
./fex2bin ../sunxi-boards/sys_config/a20/cubieboard2.fex /opt/script.bin
cd ..
Build rootfs [Choose one from three systems]
BusyOS
Do you know busybox?May not,ok,that's a light linux program,all of the commands
but busybox make a link to busybox program.It means you type cd,then it run busybox's
cd.Run init is run busybox too.You will say,what a stupid guy,why he makes this.And I will
tell you,because many program use some same codes.But many program means many
same codes,so he decides to make this program,it's more light than common linux like
debian,but it supports dpkg(not apt-get)!Openwrt,dd-wrt and TP-Link wirless router are using
it too[TP-Link's router's busybox dosen't have ls!you can visit
http://see.sl088.com/wiki/WR703_%E5%AE%98%E6%96%B9%E5%9B%BA%E4%BB
%B6/TTL%E7%99%BB%E9%99%86 to take a look].
OKOK,let's start.
First,download busybox:
wget http://busybox.net/downloads/busybox-1.21.1.tar.bz2
tar jxvf busybox-1.21.1.tar.bz2
cd busybox-1.21.1
make menuconfig ARCH=arm
Then,set busybox settings → build option → Cross Compiler prefix to
“arm-linux-gnueabihf”
And:
make
make install
If success:
mount /dev/sdb2 /mnt
cp -Rv _install/* /mnt
cp -Rv examples/bootfloppy/etc /mnt
cd /mnt
mkdir dev proc sys var home tmp mnt run boot boot2 dev/pts
Then,remove and edit fstab
rm etc/fstab;nano etc/fstab;chmod 777 etc/fstab
Enter:
proc /proc proc nosuid,noexec,nodev 0 0
sysfs /sys sysfs nosuid,noexec,nodev 0 0
devpts /dev/pts devpts gid=4,mode=620 0 0
tmpfs /tmp tmpfs defaults 0 0
devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
/dev/mmcblk0p1 /boot2 vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1

Debian

You can get a copy of Debian via debootstrap command,let's do that.

First,install debootstrap:

apt-get install debootstrap -y


And mount,download,install some system packages:

mount /dev/sdb2 /mnt

cd /mnt

debootstrap --verbose --arch armhf --variant=minbase --foreign testing mnt


http://ftp.debian.org/debian wheezy .

Burn and run


Mount files:
nano /opt/boot.cmd
And type:
setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 init=/sbin/init rootwait
panic=10 ${extra}

fatload mmc 0 0x43000000 script.bin

fatload mmc 0 0x48000000 uImage

bootm 0x48000000

And cd,build:

cd /opt

mkimage -C none -A arm -T script -d boot.cmd boot.scr

And copy files:

cp {where kernel is}/output/uImage /opt

cp -Rv {where kernel is}/output/lib /mnt

cp -Rv /usr/arm-linux-gnueabihf/lib /mnt

Then umount:

umount /mnt /opt

Try to boot it!

TTL listener install:

apt-get install cu -y

chmod 777 /dev/ttyUSB0

cu -s 115200 -l /dev/ttyUSB0

OR use minicom:

apt-get install minicom -y


minicom -s

#Serial port setup

#Serial device → /dev/ttyUSB0

#Bps 115200 8N1

#Exit

OR use screen:

apt-get install screen -y

screen /dev/ttyUSB0 115200

Then power on,linux kernel start.

Aha~ash~

Enjoy using it.

You might also like