建立一个可以启动linux的SD卡

1 创建工具连 toolchain

# apt-get install gcc-arm-linux-gnueabihf ncurses-dev uboot-mkimage build-essential git

# Older (prior to 2013): apt-get install gcc-4.6-arm-linux-gnueabi ncurses-dev uboot-mkimage build-essential git

building bootable sd card with debian linux image for a13 olinuxino

Building Uboot# mkdir olinuxino # cd olinuxino

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

# cd uboot-allwinner/

# make CROSS_COMPILE=arm-linux-gnueabihf- A13-OLinuXino_config# make CROSS_COMPILE=arm-linux-gnueabihf-

# (Older (prior 2013): make a13_olinuxino CROSS_COMPILE=arm-linux-gnueabi

# ls u-boot.bin spl/sunxi-spl.bin

Building the Kernal

# cd ..

下载内核 这个大概700M左右 时间会有点长的

# git clone https://github.com/linux-sunxi/linux-sunxi.git

下载之后进入内核的目录

# cd linux-sunxi/

之后进行相关的配置

# make ARCH=arm a13_defconfig

# make ARCH=arm menuconfig

if you want to use GPIOs for instance they are not enabled by default and you can do this by adding:

SUN4I_GPIO_UGLY = y inside .config

then you can contiue with:

# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage 在这里需要注意的是标记的地方不能少 否则编译错误

when this finish’s you will have uImage ready and you can build the kernel modules:

# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=out modules

# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=out modules_install

Format and setup the SD-card(格式化和设置 SD-card)

首先,我们必须做出正确的卡片分区,这是用fdisk来完成。

把SD卡插入读卡器,并且进入终端,然后根据

命令:ls /dev/sd

按匹配按键,你将会看到sd设备的列表,比如:sda sdb sdc 你首先要确定哪个设备是你的sd设备,可以拔下再插上去来进行区分。一旦你知道了哪个设备是你的sdCard 假如是sdX

命令: fdisk -u=sectors /dev/sdX

然后做以下几个步骤

1 p

列出分区表 如果在你的SD卡中已经存在分区表partitions 你就继续第二步骤

2 d 1

去删除它们

3 n p 1

创建第一个分区表,开始2048 结束34815

4创建第二个分区表

n p 2 enter enter

5 然后列出创建的分区表

p

如果你正确的做了每一件事情,那么你应该看到下面的信息:

Disk /dev/sdX: 2001 MB, 2001731584 bytes 42 heads, 41 sectors/track, 2270 cylinders, total 3909632 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: 0×00000000

Device Boot Start End Blocks Id System /dev/sdX1 2048 34815 16384 83 Linux /dev/sdX2 34816 3909631 1937408 83 Linux

6 把建立的分区表写入SD卡中

w

第一个分区应该是vfat 这是被全志的bootloader所能理解的

命令: mkfs .ext3 /dev/sdX1

第二个分区应该是正常的linux EXT3 FS

命令: mkfs .ext3 /dev/sdX2

根文件系统 Debian rootfs

linux内核和Uboot已经准备好,,现在我们有linux根文件系统,如何构造一个是一个很长的话题,最好的就是我们有已经预建的我们可以下载的并且可以使用的。

首先退出kernel目录

命令: cd ..

接着下载debian rootfs

命令:wget ~lkcl/mele_debian_armhf_minimal.cpio.gz

挂载你的sd卡分区表

# mount /dev/sdX2 /mnt

# cd /mnt/

并解压rootfs(根据具体的目录而定)

# gunzip -c /home/user/olinuxino/mele_debian_armhf_minimal.cpio.gz | cpio -i where "user" is the user name of your root user

# cd ..

# sync

# umount /mnt

此时 在你sd卡的第二分区上已经有Debian了

Write Uboot and Kernel you build # mount /dev/sdX1 /mnt/

copy the Kernel uImage to root directory in partition 1

# cp linux-allwinner/arch/arm/boot/uImage /mnt/.

download the script.bin from: https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/A13/script.bin

and copy it to the same directory as uImage

script.bin是一个很重要的文本文件,可以配置一些参数,比如GPIO引脚的分配,内存参数,视频分辨率等。通过改变该文件中的一些参数你可以配置你的linux,并不需要一遍又一遍的重新编译。

write the Uboot

# cd uboot-allwinner/

# dd if=spl/sunxi-spl.bin of=/dev/sdX bs=1024 seek=8

# dd if=u-boot.bin of=/dev/sdX bs=1024 seek=32

# sync

# umount /mnt

and copy the Kernel modules for partition 2 # mount /dev/sdX2 /mnt

# cd ..

# cp -a linux-allwinner/out/lib/modules/3.0.42+/ /mnt/lib/modules/.

# umount /mnt

那么现在你有一个已经准备引导debian的sd卡了

(Now you have an SD card ready to boot debian on A13-OLinuXino.)

连接USB转串口或者VGA屏幕,将SD卡插入A13-OLinuXino(-WIFI),并且上电,

你应该在终端看到Uboot和之后的内核信息。

默认的用户名字/密码是: root/password

Software Links

Linux Sunxito build latest Kernel yourself

U-bootto build community U-boot

Building bootable Debian SD card for A13-OLinuXinoOriginal step by step instructions how to make SD card image with above Kernel and U-boot

Forum postwith yet another more up to date explanation how to build SD card

会得到最大的满足,因为它填补了你的空虚。

建立一个可以启动linux的SD卡

相关文章:

你感兴趣的文章:

标签云: