环境准备

本文在一台运行着ubuntu 12.04 32位系统主机上开始构建目标系统:

# uname -a
Linux ubuntu 3.8.0-29-generic #42~precise1-Ubuntu SMP Wed Aug 14 15:31:16 UTC 2013 i686 i686 i386 GNU/Linux


安装必要的软件包

# apt-get install build-essential libncurses5-dev u-boot-tools qemu-user-static debootstrap git binfmt-support libusb-1.0-0-dev pkg-config
# apt-get install gcc-arm-linux-gnueabihf

创建工作目录

# su - root
# mkdir ~/debian-rootfs-armhf
# cd ~/debian-rootfs-armhf

下载基础系统

# debootstrap --foreign --no-check-gpg --arch=armhf wheezy .
# cp /usr/bin/qemu-arm-static usr/bin/
# LC_ALL=C LANGUAGE=C LANG=C chroot . /debootstrap/debootstrap --second-stage
# LC_ALL=C LANGUAGE=C LANG=C chroot . dpkg --configure -a

到此为止,Debian基础系统已经制作好了;现在可以把 ~/debian-rootfs-armhf保存为一个压缩包,以备日后之用。

# tar jcpvf ../debian-rootfs-armhf-clean.tar.bz2 *

配置rootfs
设置管理员(root)密码

# cd ~/debian-rootfs-armhf
# chroot . passwd

配置host

# echo "cubieboard" > ~/debian-rootfs-armhf/etc/hostname
# echo "127.0.0.1" "cubieboard" >> ~/debian-rootfs-armhf/etc/hosts

内核模块安装

# cp ~/cubieboard/linux-sunxi/arch/arm/boot/uImage ~/debian-rootfs-armhf/boot/
# make -C ~/cubieboard/linux-sunxi/ INSTALL_MOD_PATH ~/debian-rootfs-armhf/ ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install

设置串口调试终端参数

# echo T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100 >> /etc/inittab

设置fstab

# echo tmpfs /tmp tmpfs defaults  0 0 >> /etc/fstab

配置并更新软件源

# echo deb http://http.debian.net/debian/ wheezy main contrib non-free > etc/apt/sources.list
# echo deb http://security.debian.org/ wheezy/updates main contrib non-free >> etc/apt/sources.list 
# chroot . apt-get update
# chroot . apt-get upgrade
# exit

安装 Open SSH Server

# chroot . apt-get install openssh-server

安装 locales

# chroot . apt-get install locales
# echo "en_US.UTF-8 UTF-8" > etc/locale.gen
# echo "zh_CN.UTF-8 UTF-8" >> etc/locale.gen
# chroot . locale-gen

您还可以依样安装其他软件,比如 wifi tools、wpasupplicant、USB 无线网卡的固件(本人用的是巴法络 (BUFFALO)WLI-UC-GNM NANO 迷你无线网卡,一款 mini 型支持软 AP 的 USB 无线网卡)

# chroot . apt-get install wireless-tools wpasupplicant firmware-ralink

打包

# tar jcpvf ../debian-rootfs-armhf-ready.tar.bz2 *