安装所需要的包
sudo apt-get install qemu-user-static binfmt-support
生成镜像文件
dd if=/dev/zero of=rock_rootfs.img bs=1M count=1024
mkfs.ext4 -F -L linuxroot rock_rootfs.img #kernel use the label linuxroot to mount the rootfs as /
sudo mount -o loop rock_rootfs.img /mnt
当然你也可以从linaro下载已经编译好的ubuntu根文件系统:
wget https://releases.linaro.org/13.08/ubuntu/raring-images/alip/linaro-raring-alip-20130826-474.tar.gz
sudo tar zxvf linaro-raring-alip-20130826-474.tar.gz -C /mnt
cd /mnt
sudo mv binary/* .
sudo rmdir binary
拷贝你之前 编译内核的内核模块
sudo mkdir -p /mnt/lib/modules
sudo cp -r /path/to/rockchip-3.0/modules/lib/modules/3.0.36+ /mnt/lib/modules
准备 chroot
sudo cp /usr/bin/qemu-arm-static /mnt/usr/bin
sudo modprobe binfmt_misc
sudo mount -t devpts devpts /mnt/dev/pts
sudo mount -t proc proc /mnt/proc
Chroot 并 更新配置
sudo chroot /mnt
现在我们已经在目标系统的rootfs中了,下面继续配置这个系统。
修改默认shell bash
root@target:# rm /bin/sh && ln -s /bin/bash /bin/sh
安装需要预安装到系统的软件包
root@target:# apt-get update
root@target:# apt-get install ssh vim usbutils wpasupplicant wireless-tools
增加一个链接到mtd块名称的脚本(Add a script to link the mtd blocks to names)
root@target:# vim /usr/local/bin/mtd-by-name.sh
增加如下字段:
#!/bin/sh -e
# mtd-by-name link the mtdblock to name
# radxa.com, thanks to naobsd
rm -rf /dev/block/mtd/by-name/
mkdir -p /dev/block/mtd/by-name
for i in `ls -d /sys/class/mtd/mtd*[0-9]`; do
name=`cat $i/name`
tmp="`echo $i | sed -e 's/mtd/mtdblock/g'`"
dev="`echo $tmp |sed -e 's/\/sys\/class\/mtdblock/\/dev/g'`"
ln -s $dev /dev/block/mtd/by-name/$name
done
增加mtd-by-name脚本到rc.local,使得上段代码可以随开机启动:
root@target:# vim /etc/rc.local
在 “exit 0”前增加一行
/usr/local/bin/mtd-by-name.sh
完成! 😄
root@target:# exit
sync
sudo umount /mnt
现在你已经有了RR的根文件系统 rock_rootfs.img 了。
故障排除
bluez的包配置错误
Setting up bluez (4.101-0ubuntu8b1) ...
reload: Unknown instance:
invoke-rc.d: initscript dbus, action "force-reload" failed.
start: Job failed to start
invoke-rc.d: initscript bluetooth, action "start" failed.
dpkg: error processing bluez (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of blueman:
blueman depends on bluez (>= 4.25); however:
Package bluez is not configured yet.
...
这是因为bluez包如果要正确配置,必须要dbus服务运行才行。参照下面的:
service dbus start
dbus start/running, process 24551
dpkg --configure bluez
非root用户不能使用网络
编辑/etc/group,并添加以下代码:
inet:x:3003:root
net_raw:x:3004:root
然后运行
gpasswd -a username inet