资源描述
Mini2440(128M)
环境
下面的操作环境见下表:
目 录
说 明
OS
Redhat 企业版 5
交叉编译工具
arm-linux-gcc 4.3.2
Uboot
获取u-boot.tgz,将其拷贝至虚拟机的工作目录下。
编译
步骤如下:
[root@localhost jj]# tar xzvf u-boot.tgz
[root@localhost jj]# cd u-boot-2010.03/
[root@localhost u-boot-2010.03]# make distclean
[root@localhost u-boot-2010.03]# make smdk2440a_config
Configuring for smdk2440a board...
[root@localhost u-boot-2010.03]# make
烧写
首先,安装开发板的USB驱动,并将USB接口线与主机相连。同时,使用串口线连接开发板与主机。
将开发板的启动模式选择为nor,开发板上电后输出信息如下:
##### FriendlyARM BIOS 2.0 for 2440 #####
[x] format NAND FLASH for Linux
[v] Download vivi
[k] Download linux kernel
[y] Download root_yaffs image
[a] Absolute User Application
[n] Download Nboot for WinCE
[l] Download WinCE boot-logo
[w] Download WinCE NK.bin
[d] Download & Run
[z] Download zImage into RAM
[g] Boot linux from RAM
[f] Format the nand flash
[b] Boot the system
[s] Set the boot parameters
[u] Backup NAND Flash to HOST through USB(upload)
[r] Restore NAND Flash from HOST through USB
[q] Goto shell of vivi
[i] Version: 0945-2K
Enter your selection:
键入“f”,完成nand flash的格式化。随后,键入“n”:
Enter your selection: n
USB host is connected. Waiting a download.
此时,开发板完成烧写uboot-bin文件的准备工作。在主机中打开“dnw”:
顶部显示[USB:OK],即表示usb驱动正常,可以实现文件下载。
点击“USB Port”-》“Transmit/Restore”,在弹出的对话框中,选择uboot的镜像文件“u-boot.bin”,点击“打开”后完成文件的烧写。
此时,串口的输出信息如下:
Enter your selection: n
USB host is connected. Waiting a download.
Now, Downloading [ADDRESS:30000000h,TOTAL:256942]
RECEIVED FILE SIZE: 256942 (250KB/S, 1S)
Downloaded file at 0x30000000, size = 256932 bytes
Erase flash ok: start address = 0x0, size = 0x40000
Write to flash ok: start address = 0x0, size = 0x3eba4
测试
首先,将开发板的启动模式,切换为nand flash启动。
然后,开发板上电,敲回车阻止自启动,输出信息如下:
U-Boot 2010.03 (Sep 16 2010 - 19:01:40)
I2C: ready
DRAM: 64 MB
Flash: 2 MB
NAND: 128 MiB
*** Warning - bad CRC or NAND, using default environment
Video: no VESA Mode found, switching to mode 0x211 640x480x8 31kHz 59Hz
In: serial
Out: serial
Err: serial
Net: dm9000
Hit any key to stop autoboot: 0
[u-boot@SMDK2440A]#
到此,uboot成功烧写!
内核
获取linux-2.6.32.2-mini2440-20100609.tar.gz,将其拷贝至虚拟机的工作目录下。
编译
步骤如下:
[root@localhost jj]# tar xzvf linux-2.6.32.2-mini2440-20100609.tar.gz
[root@localhost jj]# cd linux-2.6.32.2
[root@localhost linux-2.6.32.2]# cp config_mini2440_n35 .config
[root@localhost linux-2.6.32.2]# make bzImage
制作uImage镜像文件:
[root@localhost linux-2.6.32.2]# cd arch/arm/boot/
[root@localhost boot]# mkimage -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -n "Linux kernel Image" -d zImage uImage
烧写
首先,在主机下开启tftp服务器,并将uImage镜像文件拷贝到tftp工作目录下。然后,用网线将开发板与主机连接起来,将连接的主机网卡,ip地址配置为:192.168.1.172
启动开发板,配置其网路环境参数如下:
[u-boot@SMDK2440A]# set serverip 192.168.1.172
[u-boot@SMDK2440A]# set ipaddr 192.168.1.226
[u-boot@SMDK2440A]# saveenv
重新复位开发板,下载uImage镜像文件至内存:
[u-boot@SMDK2440A]# tftp 0x30008000 uImage
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.172; our IP address is 192.168.1.226
Filename 'uImage'.
Load address: 0x30008000
Loading: T #################################################################
#################################################################
##########################################
done
Bytes transferred = 2517112 (266878 hex)
最终烧写到nand flash:
[u-boot@SMDK2440A]# nand erase 60000 500000
NAND erase: device 0 offset 0x60000, size 0x500000
Erasing at 0x54000002800000 -- 0% complete.
OK
[u-boot@SMDK2440A]# nand write 0x30008000 60000 500000
NAND write: device 0 offset 0x60000, size 0x500000
Writing at 0x54000000020000 -- 100% is complete. 5242880 bytes written: OK
测试
见根文件系统的测试一节。
到此,内核成功烧写!
根文件系统
制作
Busybox
准备
解压busybox。
[root@localhost busybox-1.2.0]# tar xjvf busybox-1.2.0.tar.tar
配置
[root@localhost busybox-1.2.0]# make menuconfig
(1) 编译busybox为静态链接库
Busybox Settings --->
Build Options --->
[*]Build BusyBox as a static binary (no shared fibs)
这一项将BusyBox编译为静态链接,可以减少启动时查找动态链接库的时间。
[*] Do you want fo build BusyBox with:Cross Compiler?
(arm-linux-) Cross Compiler prefix
指定交叉编译器
(2)安装
Busybox Settings --->
Installation Options --->
[*] Don't use /usr
Applets links (as soft-links) -->
(/home/alex/project/boot/mini2440/minifs)BusyBox installation prefix
指定安装路径
(3)选择 init
Init Utilities --->
[*] init
(5)选择shell
Shells --->
Choose your default shell (ash) --->
(4)添加tab
Shells --->
[*] msh
[*] Command line editing
[*] Tab completion
(5)选择tty
Coreutils --->
[*] tty
(6)
Login/Password Management Utilities --->
[*] getty
其他命令选项可选。
编译
[root@localhost busybox-1.2.0]# make
[root@localhost busybox-1.2.0]# make install
执行make install后,将编译生成安装在/home/alex/jj/minifs路径下。
系统目录
[root@localhost minifs]# mkdir dev etc home lib mnt proc sys tmp var
inittab文件
[root@localhost minifs]# mkdir etc/init.d
1)创建inittab文件
[root@localhost minifs]# touch etc/inittab
2)编辑inittab
vi etc/inittab
编辑如下:
# System initialization.
::sysinit:/etc/init.d/rcS
::sysinit:/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
3)添加执行权限
[root@localhost etc]# chmod +x inittab
rcS文件
1) 创建rcS文件
[root@localhost minifs]# touch etc/init.d/rcS
2)编辑rcS
vi etc/init.d/rcS
编辑如下:
#!/bin/sh
mount –a
3)添加执行权限
[root@localhost etc]# chmod +x rcS
fstab文件
1) 创建fstab文件
[root@localhost minifs]# touch etc/fstab
2) 编辑fstab文件
vi etc/fstab
编辑如下:
none /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
设备文件
创建设备文件节点。
[root@localhost minifs]# cd dev/
[root@localhost dev]# mknod ttySAC0 c 204 64
[root@localhost dev]# ln –s ttySAC0 console
[root@localhost dev]# mknod null c 1 3
[root@localhost dev]# mknod mtdblock0 b 31 0
[root@localhost dev]# mknod mtdblock1 b 31 1
[root@localhost dev]# mknod mtdblock2 b 31 2
库文件
拷贝库文件,包括加载器、动态库文件和静态库文件。
[root@localhost lib]# cp /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/* ./ -arp
Yaffs镜像
最终,利用mkyaffs2image-128M工具完成yaffs镜像的制作:
mkyaffs2image-128M minifs minifs.img
烧写
首先,在主机下开启tftp服务器,并将yaffs镜像文件拷贝到tftp工作目录下。然后,用网线将开发板与主机连接起来,将连接的主机网卡,ip地址配置为:192.168.1.172
启动开发板,配置其网路环境参数如下:
[u-boot@SMDK2440A]# set serverip 192.168.1.172
[u-boot@SMDK2440A]# set ipaddr 192.168.1.226
[u-boot@SMDK2440A]# saveenv
重新复位开发板,下载uImage镜像文件至内存:
[u-boot@SMDK2440A]# tftp 0x30008000 minifs.img
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.172; our IP address is 192.168.1.226
Filename 'minifs.img'.
Load address: 0x30008000
Loading: T ###############T ##################################################
#################################################################
#################################################################
#################################################################
#################################################################
#############################
done
Bytes transferred = 5187072 (4f2600 hex)
最终烧写到nand flash:
[u-boot@SMDK2440A]# nand erase 0x560000 $filesize
NAND erase: device 0 offset 0x60000, size 0x500000
Erasing at 0x54000002800000 -- 0% complete.
OK
[u-boot@SMDK2440A]# nand write.yaffs 0x30008000 0x560000 $filesize
NAND write: device 0 offset 0x560000, size 0x4f2600
Skip the first good block 56000000020000
Writing at 0xa4000000020000 -- 100% is complete. 5029888 bytes written: OK
测试
开发板复位,正常启动串口输出如下:
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing init memory: 160K
init started: BusyBox v1.2.0 (2010.09.16-15:52+0000) multi-call binary
Starting pid 671, console /dev/console: '/etc/init.d/rcS'
Starting pid 675, console /dev/console: '/bin/sh'
BusyBox v1.2.0 (2010.09.16-15:52+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
#
展开阅读全文