Rookie's Cubieboard Tour (ii)-SD card image production

Source: Internet
Author: User
Tags bz2 mkdir spl hex code git clone

Referring to the Http://mer.jolladev.net/wiki.php?id=%E5%90%AF%E5%8A%A8cubieboard2%E5%88%B0linux_kernel and tll, the great God. Cubieboard System Documentation

First step: Download the kernel code and compile it

git clone Git://github.com/linux-sunxi/linux-sunxi

Configure and compile:

Gerneral setup->cross compilter too prefix here to fill arm-linux-gnueabihf-

Make Arch=arm Cross_compile=arm-linux-gnueabihf-cubieboard2_defconfig

Make Arch=arm cross_compile=arm-linux-gnueabihf--j4 uimage Modules

Make Arch=arm cross_compile=arm-linux-gnueabihf--j4 install_mod_path=output Modules_install

If successful, there will be uimage in the/arch/arm/boot/directory, and there will be a Lib directory under output

Step two: Download the uboot code and compile it

git clone git://github.com/linux-sunxi/u-boot-sunxi.git

Make Distclean cross_compile=arm-linux-gnueabihf-

Make Cubieboard2 cross_compile=arm-linux-gnueabihf-

If successful, there will be a u-boot.bin in the home directory, u-boot-spl.bin in the SPL directory

Step three: Generate BOOT.SCR

what is BOOT.SCR.

According to the data description (Https://github.com/linux-sunxi/u-boot-sunxi/wiki#bootscr-support), U-boot will be found in the first partition (FAT/EXTX format) when it is started/ BOOT.SCR or/BOOT/BOOT.SCR files, BOOT.SCR can contain uboot commands for loading script.bin,kernel,initrd (optional) and setting kernel boot parameters.

How the Boot.cmd is generated.

Create a new Boot.cmd file in the $work_dir directory and add the following:

setenv Bootargs console=ttys0,115200 noinitrd disp.screen0_output_mode=edid:1280x1024p60 init=/init root=/dev/ MMCBLK0P2 rootfstype=ext4 rootwait panic=10 ${extra}

Fatload MMC 0 0x43000000 boot/script.bin

Fatload MMC 0 0x48000000 boot/uimage

Bootm 0x48000000

Generate BOOT.SCR:

Kimage-c none-a arm-t script-d boot.cmd BOOT.SCR

Fourth step: Generate Script.bin

git clone git://github.com/linux-sunxi/sunxi-tools.git, this download is the tool needed to generate the last script

git clone git://github.com/linux-sunxi/sunxi-boards.git This is the list of resources for the Board

Compile tool:

CD $WORK _dir/sunxi-toolsmake

Produce Script.bin

CD $WORK _DIR/SUNXI-BOARDS/SYS_CONFIG/A20

$WORK _dir/sunxi-tools/fex2bin Cubieboard2.fex Script.bin

So that the production of the necessary things are ready, the next is to put these copies to the TF card

When the A20 chip is on, it will read the 1M content in front of the SD card to get bootloader, so we need to write u-boot to the first 1M interval of the SD card.

The details of the SD card layout are as follows:

starting size Use
0 8KB Storing content such as partition tables
8 24KB SPL Loader
32 512KB U-boot
544 128KB Environment
672 352KB Keep
1024 - For remaining partitions

As you can see, you should copy the Uboot compiled u-boot-spl.bin this file to the 8k location, put U-boot.bin to 32k this position

First, we need to partition the TF card.

The specific partitioning steps are as follows:

Create the first partition

root@kubuntu:~/src/u-boot-sunxi# fdisk ${card}
Device contains neither a valid DOS partition table, nor Sun, SGI or OS F Disklabel
Building A new DOS disklabel with disk identifier 0x911332e8.
Changes'll remain in memory only, until the decide to write them.
After that, of course, the previous content won ' t is recoverable.

Warning:invalid flag 0x0000 of partition Table 4 would be a corrected by W (rite)

Command (M-help): N                                   #键入n然后回车 
  partition type:
   P   Primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):                                       #直接回车
Using Default response P
Partition number (1-4, default 1):                        #直接回车
Using default value 1
First sector (2048-15278079, default 2048):               #直接回车
Using default value 2048 last
sector, +sectors or +size{ K,m,g} (2048-15278079, default 15278079): +64m         #键入 +64m After Enter, that is, the partition size is 64M

Create a second partition

Command (M for help): N                                   #键入n然后回车
Partition type:
   P   Primary (1 primary, 0 extended, 3 free)
   e   exte nded
Select (default p):                                       #直接回车
Using Default Response P
Partition number (1-4, default 2):                        #直接回车 C11/>using Default value 2 first
sector (133120-15278079, default 133120):           #直接回车
Using Default value 133120 last
sector, +sectors or +size{k,m,g} (133120-15278079, default 15278079):      #直接回车, that is, the second partition uses all of the remaining space
Using Default Value 15278079

next Specify the partition type:

Command (M for help): T                                   #键入t然后回车
Partition Number (1-4): 1                                 #键入1然后回车, which specifies the first partition
Hex code (type L to list code s): C                        #键入c然后回车, which specifies that the first partition is VFAT
Changed system type of partition 1 to C (W95 FAT32 (LBA))

Command (M-help): W                                   #键入w然后回车, save partition Table
The partition table has been altered!

Calling IOCTL () to re-read partition table.
Syncing disks.

To format a partition:

Mkfs.vfat ${card}1
MKFS.EXT4 ${card}2                

then write bootloader:

CD $WORK _dir/u-boot-sunxi
dd if=u-boot-sunxi-with-spl.bin of= $card bs=1024 seek=8

finally install the kernel uimage, set the startup parameters:

Mount ${card}1/mnt
mkdir/mnt/boot
CP $WORK _dir/linux-sunxi/arch/arm/boot/uimage/mnt/boot
CP $WORK _dir /sunxi-boards/sys_config/a20/script.bin/mnt/boot
cp $WORK _dir/boot.scr/mnt/
sync && umount/mnt

Making a file system

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

Here set: BusyBox settings->build option->cross Compiler prefix arm-linux-gnueabihf-

Make

Make install

Copy the file system to the second TF partition

Mount/dev/sdb2/mnt

Cp-r _instll/*/mnt

Cp-r examples/bootfloppy/etc/mnt

Cd/mnt

mkdir Dev proc sys var home tmp mnt run boot Boot2 dev/pts

Delete Fstab and re-edit

RM Etc/fstab;

Nano Etc/fstab;

chmod 777 Etc/fstab;

Edit

PROC/PROC proc Nosuid,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,notime 0 2 

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.