2013年9月7日 星期六

Mini2440我命令你復活吧!

mini2440官方網站:http://www.friendlyarm.net

底下所有步驟完成後,目錄結構如下:
|---home---renee
             |
             |----mini2440------u-boot------(source code)
             |              |           |
             |              |           ----u-boot.bin
             |              |
             |              ----kernel------(source code)
             |                          |
             |                          ----arch----arm----boot----zImage
             |
             |----myfs------rootfs------lib----modules
             |                      |
             |                      ----bin----(busybox tools)
             |                      |
             |                      ----sbin----(busybox tools)
             |                      |
             |                      ----usr------bin----(busybox tools)
             |                               |
             |                               ----sbin----(busybox tools)
             |
             |----tftpboot----uImage
下載與解壓縮toolschain:
http://www.friendlyarm.net/dl.php?file=arm-linux-gcc-4.4.3.tgz
$ sudo tar xvf ~/arm-linux-gcc-4.4.3.tgz -C /
下載u-boot:
$ mkdir mini2440
$ cd mini2440/
$ git clone git://repo.or.cz/u-boot-openmoko/mini2440.git
$ mv mini2440/ u-boot/
$ cd u-boot/
編譯u-boot:
$ export PATH=/opt/FriendlyARM/toolschain/4.4.3/bin:$PATH
$ export CROSS_COMPILE=arm-none-linux-gnueabi-
$ export ARCH=arm
$ make mini2440_config
$ make all
將NOR開關扳到on,再將開發版電源打開,準備燒入u-boot:
##### 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: 1138-2K                                                         
Enter your selection: q                                                         
Supervivi> load flash 0 243360 u                                                
USB host is connected. Waiting a download. 
關掉開發版電源,將NOR開關扳到off,再將開發版電源打開,然後在console輸入下面指令:
MINI2440 # nand scrub
MINI2440 # nand createbbt
MINI2440 # dynenv set 40000
MINI2440 # saveenv
MINI2440 # reset
下載與解壓縮kernel:
http://www.friendlyarm.net/dl.php?file=linux-2.6.32.2-mini2440_20110413.tgz
$ cd ../
$ mkdir kernel
$ cd kernel/
$ tar xvf ~/linux-2.6.32.2-mini2440_20110413.tgz -C ~/mini2440/kernel/
$ cd linux-2.6.32.2/
編譯kernel:
$ cp config_mini2440_vga1024x768 .config
$ make menuconfig
$ make
產生uImage:
$ cd ../../
$ ./u-boot/tools/mkimage -A arm -O linux -T kernel -C none -a 0x30008000 -e \
0x30008000 -d ./kernel/linux-2.6.32.2/arch/arm/boot/zImage ~/tftpboot/uImage
燒入kernel:
MINI2440 # mtdparts
MINI2440 # nand erase 0x60000 0x300000
MINI2440 # tftp 0x32000000 uImage
MINI2440 # nand write 0x32000000 0x60000 0x300000
建立rootfs:
$ cd ../myfs/
$ mkdir rootfs
$ cd rootfs
$ mkdir bin dev etc lib proc sbin sys usr mnt tmp var
$ mkdir usr/bin usr/lib usr/sbin lib/modules
$ cd dev
$ sudo mknod -m 666 console c 5 1
$ sudo mknod -m 666 null c 1 3
$ cd ../etc
$ vim fstab
proc            /proc   proc    defaults    0   0
sysfs           /sys    sysfs   defaults    0   0

$ chmod 755 fstab
$ mkdir init.d
$ vim init.d/rcS
#! /bin/sh

/bin/mount -a
/bin/mount -t tmpfs mdev /dev
/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

$ chmod 755 init.d/rcS
$ vim inittab
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
::ctrlaltdel:/bin/umount -a -r

$ chmod 755 inittab
$ vim profile
# /etc/profile: system-wide .profile file for the Bourne shells

echo
echo -n "Processing /etc/profile... "
# no-op
echo "Done"
echo

$ chmod 755 profile
編譯與安裝busybox:
$ cd ~/
$ wget http://busybox.net/downloads/busybox-1.21.1.tar.bz2
$ tar -xvjpf ~/busybox-1.21.1.tar.bz2
$ cd busybox-1.21.1
$ make menuconfig
$ make
$ make install CONFIG_PREFIX=/home/renee/myfs/rootfs
編譯與安裝kernel模組:
$ cd ../mini2440/kernel/linux-2.6.32.2/
$ make modules
$ make modules_install INSTALL_MOD_PATH=/home/renee/myfs/rootfs
下載yaffs2生成工具與製作:
http://www.friendlyarm.net/dl.php?file=linux_mktools.zip
$ sudo apt-get install zip
$ unzip linux_mktools.zip
$ mkyaffs2image /home/renee/myfs/rootfs rootfs.yaffs2
燒入rootfs.yaffs2:
MINI2440 # tftp 0x30008000 rootfs.yaffs2
MINI2440 # nand erase 0x560000 0x265b900
MINI2440 # nand write.yaffs 0x30008000 0x560000 0x265b900
設定u-boot開機參數,如果你要使用nfs開機,設定如下:
MINI2440 # setenv bootargs console=ttySAC0,115200 noinitrd init=/sbin/init mini2440=1tb 
ip=192.168.200.150:192.168.200.22:192.168.200.1:255.255.255.0 root=/dev/nfs rw 
nfsroot=192.168.200.22:/home/renee/myfs/rootfs
MINI2440 # setenv bootcmd 'nboot.e kernel; bootm'
MINI2440 # saveenv
MINI2440 # boot
如果你要使用yaffs2開機,設定如下:
MINI2440 # setenv bootargs console=ttySAC0,115200 noinitrd root=/dev/mtdblock3 rootfstyle=yaffs2 
init=/sbin/init mini2440=1tb
MINI2440 # setenv bootcmd 'nboot.e kernel; bootm'
MINI2440 # saveenv
MINI2440 # boot

1 則留言:

  1. mini2440 u-boot 及 kernel 系統移植
    https://chenlinslim.wordpress.com/

    回覆刪除