Create a mini System Using cubieboard and busybox

Source: Internet
Author: User
Tags spl

This article builds a mini Linux system and describes common methods and processes of ARM embedded devices. It is suitable for beginners. Of course, it is best to know what cross-compilation is and how to understand basic Linux commands.

Let's talk about the general idea. To run a Linux operating system on the cubieboard, four major components are required: uboot, script-bin, Linux kernel (uimage), and rootfs (we will do this ourselves)

Many people have already written related articles in the previous three articles, and we will do it again without any worries.

The system used in this paper is the FC17-i686 system, tool fuse is 4.7.2, arm-unknown-Linux-gnueabi-, online find

Source code to be prepared:

Busybox-1.21.0

Google searches for a large number of items.

Linux 3.4.5

Git clone https://github.com/linux-sunxi/linux-sunxi/tree/sunxi-3.4

Sunxi-boards

Git clone https://github.com/linux-sunxi/sunxi-boards

Sunxi-Tools

Git clone https://github.com/linux-sunxi/sunxi-tools

U-boot-sunxi

Git clone https://github.com/linux-sunxi/u-boot-sunxi

After preparing these things, we can start working. First, we can take out the SD card to ensure that there is no important data.

I recommend that you use root users for operations. Otherwise, it is very troublesome to use sudo frequently.

1. First, partition the SD card. Assume that your card is/dev/sdx.

Fdisk/dev/sdx

My card is 8 GB, and my partition is as follows:

/Dev/sdb1 2048 34815 16384 83 Linux
/Dev/sdb2 34816 15122431 7543808 83 Linux

The partition size can be based on your preferences, but the first partition starts from 2048. What fdisk won't be used ?.... D is delete, n is create, W is save, Q is quit.

The partition is formatted.

Mkfs. vfat/dev/sdx1

Mkfs. ext4/dev/sdx2

Now mount them locally

Mount/dev/sdx1/mnt/card1

Mount/dev/sdx2/mnt/card2. If you do not have a card directory, create it by yourself.

Before starting all the compilation, we need to add the cross-compilation tool to the PATH environment variable.

For example, if my toolkit is stored in/tools and the arm-unknown-Linux-gnueabi-directory in/tools/bin

export PATH="/tools/bin:$PATH"

This is only valid for the current terminal and its sub-terminals.

2. Compile uboot,

Uboot is a bootloader. We will not introduce it much here.

Go to the uboot-sunxi directory:

make distclean CROSS_COMPILE=arm-unknown-linux-gnueabi-make cubieboard CROSS_COMPILE=arm-unknown-linux-gnueabi-

After compilation, execute the command

dd if=spl/sunxi-spl.bin of=/dev/sdb1 bs=1024 seek=8 dd if=u-boot.bin of=/dev/sdb1 bs=1024 seek=32

There is a file named mkimage under tools/, which will be used in later kernel compilation and boot. SRC. Copy it to the/usr/bin directory. If you have one, you can leave it alone.

CP tools/mkimage/usr/bin

3. Compile sunxi-Tools

Make

If no error is displayed, it indicates that the operation is successful. Go to 4. If the operation fails, continue.

If an error occurs:

Package libusb-1.0 was not found in the PKG-config search path.
Perhaps you shoshould Add the directory containing 'libusb-1.0.pc'
To the pkg_config_path environment variable
No package 'libusb-1.0 'Found
Fel. C: 21: 20: Fatal error: libusb. H: No file or directory
Compilation interrupted.
Make: *** [Fel] Error 1

For Ubuntu users, use apt-Get install libusb-Dev.

But if I use a fedora user like me, it will be a little troublesome. First go to the next called libusb-1.0.9 (version does not matter) package, extract into the Directory

./configuremake CROSS_COMPILER=arm-unknown-linux-gnueabi-make installcp libusb/libusb.h /usr/includecp libusb-1.0.pc /usr/share/pkgconfig

4. compile script-bin

This is the simplest

cd sunxi-boards/sys_config/a10/../../../sunxi-tools/fex2bin cubieboard.fex script.bin

Copy script. bin to/mnt/card1

CP script. bin/mnt/card1

5. Compile uimage

This time will take a little longer. In fact, it is also very simple. However, note that unzip files are sometimes missing in Linux. We recommend that you use 7zip

make ARCH=arm sun4i_defconfigmake ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- uImage

Similarly, copy ARCH/ARM/boot/uimage to/mnt/card1.

Cp arch/ARM/boot/uimage/mnt/card1

6. Create boot. SRC

CD/mnt/card1touch boot. cmdvi boot. CMD # input the following content by I: setenv bootargs console = ttys0, 115200 root =/dev/mmcblk0p2 init =/sbin/init rootwait panic = 10 $ {Extra} fatload MMC 0 0x43000000 script. binfatload MMC 0 0x48000000 uimagebootm 0x48000000 # Press ESC and then press: WQ to save and exit mkimage-C none-A arm-T script-D boot. CMD boot. SCR

At present, your/mnt/card1 should have four files:

Boot. scr; boot. CMD; uimage; script. Bin;

This is the end to start the partition.

7. Compile busybox

make ARCH=arm defconfigmake ARCH=arm menuconfig

Busybox settings -->

Build option -->

Build busybox as a static binary (no shared libs ).

Cross Compiler Prefix: Enter the prefix of the Cross Compiler. Here is arm-unknown-Linux-gnueabi-

Networking utilities -->

If the inetd is removed, compilation may fail.

If an error occurs:

Miscutils/nandwrite. C: 49: 26: Fatal error: MTD/mtd-user.h: no such file or directory
Compilation terminated.
Make [1]: *** [miscutils/nandwrite. O] Error 1
Make: *** [miscutils] Error

Run the command to copy the corresponding file.

CP-RV/usr/include/MTD/include/

If there is nothing else, the same principle is true.

Compiled,

Make install

It is installed under the _ Install Folder by default.

8. Create a root file system

Copy all the items under _ install to/mnt/card2.

CP-RV _ install/*/mnt/card2

CP-RV examples/bootfloppy/etc/mnt/card2

Create directories such as/dev/proc/sys/var/home/tmp/mnt/run under mkdir

Modify the fstab file under etc as follows:

proc /proc proc nosuid,noexec,nodev 0 0sysfs /sys sysfs nosuid,noexec,nodev 0 0devpts /dev/pts devpts gid=4,mode=620 0 0tmpfs /tmp tmpfs defaults 0 0devtmpfs /dev devtmpfs mode=0755,nosuid 0 0/dev/mmcblk0p1 /boot vfat defaults 0 2/dev/mmcblk0p2 / ext4 defaults,noatime 0 1

Modify the initab file as follows:

::sysinit:/etc/init.d/rcS::askfirst:-/bin/sh

Okay, umount them. Try to start the system.

When you see please press enter to activate this console, click it to enter the terminal.

The NIC device has not started. If you want to start it, you can also. But it is not described here. Haha

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.