Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1869012
  • 博文数量: 473
  • 博客积分: 13997
  • 博客等级: 上将
  • 技术积分: 5953
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-22 11:52
文章分类

全部博文(473)

文章存档

2014年(8)

2013年(38)

2012年(95)

2011年(181)

2010年(151)

分类: LINUX

2010-12-05 03:14:15

Emdebian  
Bootstrap Lenny for your ARM board.

This document explaind how to bootstrap yourself a nice armel emdebian "grip" install for your ARM board.

Create a debootstrap with emdebian base minimum system

 /opt/debian-armel% sudo debootstrap --arch armel --foreign lenny grip/   

The resulting directory contains just whats needed to boot and populate a snall debian.

 /opt/debian-armel% ll grip 

total 64
drwxr-xr-x 2 root root 4096 Apr 29 2008 bin
drwxr-xr-x 2 root root 4096 Dec 4 09:23 boot
drwxr-xr-x 2 root root 4096 Mar 6 13:12 debootstrap
drwxr-xr-x 2 root root 4096 Nov 8 07:43 dev
drwxr-xr-x 30 root root 4096 Mar 6 13:12 etc
drwxr-xr-x 2 root root 4096 Dec 4 09:23 home
drwxr-xr-x 10 root root 4096 Apr 29 2008 lib
drwxr-xr-x 2 root root 4096 Dec 4 09:23 mnt
drwxr-xr-x 2 root root 4096 Dec 4 09:23 proc
drwxr-xr-x 2 root root 4096 Dec 4 09:23 root
drwxr-xr-x 2 root root 4096 Apr 29 2008 sbin
drwxr-xr-x 2 root root 4096 Sep 16 08:48 selinux
drwxr-xr-x 2 root root 4096 Aug 12 2008 sys
drwxrwxrwt 2 root root 4096 Dec 4 09:23 tmp
drwxr-xr-x 9 root root 4096 Apr 6 2008 usr
drwxr-xr-x 11 root root 4096 Aug 12 2008 var

Create a compressed file with the content of this directory, so you can use it again.

 /opt/debian-armel% (cd grip ;  tar jcf ../emdebian-grip-090306-armel-debootstrap-lenny.tar.bz2 .) 

/opt/debian-armel% ll -h

total 35M
drwxr-xr-x 18 root root 4.0K Apr 6 2008 grip
-rw-r--r-- 1 michel michel 34M Mar 6 13:13 emdebian-grip-090306-armel-debootstrap-lenny.tar.bz2

Insert your SD card in the host. You can detect what device name it is mapped on by doing :

 /opt/debian-armel% dmesg|tail -20 

...
sd 6:0:0:0: sdd 1939456 512-byte hardware sectors: (993 MB/947 MiB)
sd 6:0:0:0: sdd Write Protect is off
sd 6:0:0:0: sdd Mode Sense: 03 00 00 00
sd 6:0:0:0: sdd Assuming drive cache: write through
sdd: sdd1 sdd2 sdd3

So we know it's sdd here, so lets partition the card again the way we want it.

First partition of 50MB will be /boot, vfat, and the rest is /, ext3. Here is the complete session in fdisk:

 /opt/debian-armel% sudo fdisk /dev/sdd 

Command (m for help): o

Building a new DOS disklabel with disk identifier 0x3e53813f.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sdd: 993 MB, 993001472 bytes
31 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 1922 512 = 984064 bytes
Disk identifier: 0x3e53813f

Device Boot Start End Blocks Id System

Command (m for help): n

Command action
e extended
p primary partition (1-4)
p

Partition number (1-4): 1

First cylinder (1-1009, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1009, default 1009): +50MB

Command (m for help): n

Command action
e extended
p primary partition (1-4)
p

Partition number (1-4): 2

First cylinder (53-1009, default 53):
Using default value 53
Last cylinder, +cylinders or +size{K,M,G} (53-1009, default 1009):
Using default value 1009

Command (m for help): p

Disk /dev/sdd: 993 MB, 993001472 bytes
31 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 1922 512 = 984064 bytes
Disk identifier: 0x3e53813f

Device Boot Start End Blocks Id System
/dev/sdd1 1 52 49941 83 Linux
/dev/sdd2 53 1009 919677 83 Linux

Command (m for help): t

Partition number (1-4): 1

Hex code (type L to list codes): L

0 Empty 1e Hidden W95 FAT1 80 Old Minix bf Solaris
1 FAT12 24 NEC DOS 81 Minix / old Lin c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 82 Linux swap / So c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 83 Linux c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 84 OS/2 hidden C: c7 Syrinx
5 Extended 41 PPC PReP Boot 85 Linux extended da Non-FS data
6 FAT16 42 SFS 86 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set de Dell Utility
8 AIX 4e QNX4.x 2nd part 88 Linux plaintext df 'BootIt'
9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e4 'SpeedStor'
c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f1 'SpeedStor'
12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f4 'SpeedStor'
14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
Hex code (type L to list codes): b

Changed system type of partition 1 to b (W95 FAT32)

Command (m for help): p

Disk /dev/sdd: 993 MB, 993001472 bytes
31 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 1922 512 = 984064 bytes
Disk identifier: 0x3e53813f

Device Boot Start End Blocks Id System
/dev/sdd1 1 52 49941 b W95 FAT32
/dev/sdd2 53 1009 919677 83 Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

Now, lets create file systems on these 2 new partitions, one vfat, one ext3

 /opt/debian-armel% sudo mkfs.vfat /dev/sdd1 

mkfs.vfat 2.11 (12 Mar 2005)
/opt/debian-armel% sudo mkfs.ext3 /dev/sdd2

mke2fs 1.41.3 (12-Oct-2008)
warning: 543 blocks unused.

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
57568 inodes, 229376 blocks
11495 blocks (5.01%) reserved for the super user
First data block=0
Maximum filesystem blocks=234881024
7 block groups
32768 blocks per group, 32768 fragments per group
8224 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

 /opt/debian-armel% sudo mount /dev/sdd2 /mnt/arm
/opt/debian-armel% sudo mkdir -p /mnt/arm/boot
/opt/debian-armel% sudo mount /dev/sdd1 /mnt/arm/boot

This will uncompress the archive into the new ext3 partition on the SD card

 /opt/debian-armel% (cd /mnt/arm;sudo tar jxf /opt/debian-armel/emdebian-grip-090306-armel-debootstrap-lenny.tar.bz2 ; sync )
Some space has been taken by the bootstrap. The real amount is irrelevan, as most of it is unninstalled package files.
 /opt/debian-armel% df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sdd2 882M 98M 724M 18% /mnt/arm
/dev/sdd1 49M 0 49M 0% /mnt/arm/boot

If you have a source directory with your compiled kernel, you can already install your modules in their proper space with :

 /usr/src/linus-2.6% sudo make INSTALL_MOD_PATH=/mnt/arm modules_install 

...
INSTALL sound/usb/caiaq/snd-usb-caiaq.ko
INSTALL sound/usb/snd-usb-audio.ko
INSTALL sound/usb/snd-usb-lib.ko
DEPMOD 2.6.29-rc7
/usr/src/linus-2.6% ll /mnt/arm/lib/modules

total 4
drwxr-xr-x 3 root root 4096 Mar 6 12:20 2.6.29-rc7
2.6.29-rc7

The file system needs to be tweaked a bit to boot properly, so we do that with a root shell into the target directory. Be VERY careful not to use any leafing / in your paths!!

 /usr/src/linus-2.6% su - 

root@yap:~# cd /mnt/arm

root@yap:/mnt/arm# cp /tftpboot/uImage boot/

root@yap:/mnt/arm# echo "proc /proc proc none 0 0" >>etc/fstab

root@yap:/mnt/arm# echo "mini2440" >etc/hostname

root@yap:/mnt/arm# mknod dev/console c 5 1

root@yap:/mnt/arm# mknod dev/ttySAC0 c 204 64

root@yap:/mnt/arm# echo 'deb lenny main' >>etc/apt/sources.list

 root@yap:/mnt/arm# cd ..
root@yap:/mnt/arm# umount arm/boot arm

You can either do these steps in qemu, or using your own board. The process is the same, you need to configure the system to boot from your SD card: Set environment variables properly for booting on the memory card:

 MINI2440 # setenv bootargs console=ttySAC0,115200 noinitrd root=/dev/mtcblk0p2 rootwait=4 rw ip=dhcp init=/bin/sh 

MINI2440 # tftp;bootm

Eventualy, you should arrive at a naked shell prompt.

Do this to finish the debian install. It will take a rather long time, so be patient !

 sh-3.2# mount /proc /proc -t proc 

sh-3.2# export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

sh-3.2# /debootstrap/debootstrap --second-stage

...

Wait (a long time) -- udev might give you some warnings due to bad blocks on the NAND, in which case you might have to force-reinstall it when it's done :

 dpkg -i /var/cache/apt/archives/udev_0.125-7em1_armel.deb

Once that is done, add a bit of niceties to the install:

 root@yap:/mnt/arm# echo ttySAC0 >>etc/securetty 

root@yap:/mnt/arm# printf "T0:123:respawn:/sbin/getty 115200 ttySAC0\n" >>etc/inittab

root@yap:/mnt/arm# printf "auto eth0\niface eth0 inet dhcp\n" >>etc/network/interfaces

Reboot, you're done !

阅读(950) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~