为了后期使用一些开源框架(后期会有博文说明)的需求,不得不移植一套能满足需求的debian系统,下面是相应的过程(在Ubuntu14.04下进行):
1.创建bbb-debian目录并进入到该目录下:
mkdir bbb-debian
cd bbb-debian
2.准备u-boot源码
1).执行如下命令获取u-boot源码:
git clone git://git.denx.de/u-boot.git
2).进入下载的源码目录并下载补丁包及打补丁:
cd u-boot
wget -c https://raw.github.com/eewiki/u-boot-patches/master/v2013.10/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
3.下载dtc工具生成脚本
本步骤用于下载dtc工具的生成及安装脚本(后期编译脚本里会执行,但注释掉,仅执行一次即可,可不执行):
cd ..
wget -c https://raw.github.com/RobertCNelson/tools/master/pkgs/dtc.sh
chmod +x dtc.sh
4.下载kernel源码
1).下载linux stable分支源码:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
2).下载BBB的linux编译配置包并进行相应修改:
git clone git://github.com/RobertCNelson/linux-dev.git
cd linux-dev
cp system.sh.sample system.sh
修改system.sh,在适当位置添加如下语句:
CC=`pwd`/../gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-
LINUX_GIT=`pwd`/../linux-stable/
执行如下命令切换BBB的编译包分支:
git checkout am33x-v3.8
5.下载BBB的debian根文件系统
cd ..
wget -c https://rcn-ee.com/rootfs/eewiki/minfs/debian-8.0-minimal-armhf-2015-04-27.tar.xz
6.准备相关文件(均在bbb-debian目录下进行)
1).创建编译脚本build_all.sh,内容如下:
#!/bin/sh
export CC=`pwd`/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-
cd u-boot/
make ARCH=arm CROSS_COMPILE=${CC} distclean
make ARCH=arm CROSS_COMPILE=${CC} am335x_evm_config
make ARCH=arm CROSS_COMPILE=${CC}
cd ..
# just build and install device tree tools on x86/x64 based platform
#./dtc.sh
cd linux-dev/
./build_kernel.sh
cd ..
2).创建TF启动所需文件:
a.创建uEnv.txt文件,内容如下:
#u-boot eMMC specific overrides; Angstrom Distribution (BeagleBone Black) 2013-06-20
kernel_file=zImage
initrd_file=uInitrd
loadzimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${kernel_file}
loadinitrd=load mmc ${mmcdev}:${mmcpart} 0x81000000 ${initrd_file}; setenv initrd_size ${filesize}
loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdtaddr} /dtbs/${fdtfile}
console=ttyO0,115200n8
mmcroot=/dev/mmcblk0p2 ro
mmcrootfstype=ext4 rootwait fixrtc
##To disable HDMI/eMMC...
#optargs=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN,BB-BONE-EMMC-2G
##3.1MP Camera Cape
#optargs=capemgr.disable_partno=BB-BONE-EMMC-2G
mmcargs=setenv bootargs console=${console} root=${mmcroot} rootfstype=${mmcrootfstype} ${optargs}
#zImage:
uenvcmd=run loadzimage; run loadfdt; run mmcargs; bootz ${loadaddr} - ${fdtaddr}
#zImage + uInitrd: where uInitrd has to be generated on the running system.
#boot_fdt=run loadzimage; run loadinitrd; run loadfdt
#uenvcmd=run boot_fdt; run mmcargs; bootz ${loadaddr} 0x81000000:${initrd_size} ${fdtaddr}
b.创建interfaces文件,内容如下:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
allow-hotplug usb0
iface usb0 inet dhcp
c.创建fstab文件,内容如下:
/dev/mmcblk0p2 / ext4 ro,noatime 0 0
/dev/mmcblk0p1 /boot/uboot vfat ro,user,umask=000 0 0
tmpfs /tmp tmpfs nodev,nosuid,size=10m 0 0
tmpfs /var/log tmpfs nodev,nosuid,size=10m 0 0
tmpfs /var/tmp tmpfs nodev,nosuid,size=10m 0 0
d.创建serial.conf文件,内容如下:
start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]
respawn
exec /sbin/getty 115200 ttyO0
e.创建inittab文件,内容如下:
T0:23:respawn:/sbin/getty -L ttyO0 115200 vt102
3).创建TF制作脚本make_tfcard.sh,内容如下:
#!/bin/sh
DISK=/dev/sdc
dd if=/dev/zero of=${DISK} bs=1M count=16
fdisk ${DISK}<
n
p
1
+48MB
t
e
a
1
n
p
2
+1024MB
w
EOF
mkfs.vfat -F 16 ${DISK}1 -n boot
mkfs.ext4 ${DISK}2 -L rootfs -O ^has_journal
mkdir -p /tmp/boot/
mkdir -p /tmp/rootfs/
mount ${DISK}1 /tmp/boot/
mount ${DISK}2 /tmp/rootfs/
cp -v ./u-boot/MLO /tmp/boot/
cp -v ./u-boot/u-boot.img /tmp/boot/
cp uEnv.txt /tmp/boot/
tar xJvpf ./debian-8.0-minimal-armhf-2015-04-27.tar.xz
tar xpf ./debian-8.0-minimal-armhf-2015-04-27/armhf-rootfs-debian-jessie.tar -C /tmp/rootfs
cp -v ./linux-dev/deploy/*.zImage /tmp/boot/zImage
mkdir -p /tmp/boot/dtbs/
tar xfov ./linux-dev/deploy/*-dtbs.tar.gz -C /tmp/boot/dtbs/
tar xfov ./linux-dev/deploy/*-firmware.tar.gz -C /tmp/rootfs/lib/firmware/
tar xfov ./linux-dev/deploy/*-modules.tar.gz -C /tmp/rootfs/
mkdir -p /tmp/rootfs/etc
mkdir -p /tmp/rootfs/etc/network
mkdir -p /tmp/rootfs/etc/init
cp fstab /tmp/rootfs/etc/fstab
cp interfaces /tmp/rootfs/etc/network/interfaces
cp inittab /tmp/rootfs/etc/inittab
cp serial.conf /tmp/rootfs/etc/init/serial.conf
sync
umount /tmp/rootfs/
umount /tmp/boot
该脚本中的DISK=/dev/sdc一行数据请根据实际情况修改。
7.编译源码及制作启动TF卡(在bbb-debian目录下)
使用bash -e build_all.sh命令编译源码并生成所需镜像,编译完成后,将TF卡插到电脑上,再执行sudo ./make_tfcard.sh命令即可生成可启动的TF卡。
8.运行验证TF卡
将制作好的TF卡插入到BBB的TF卡槽里,然后上电启动(需要按住TF卡上面的按键后再进行该操作),在相应的调试串口可以看到最后有如下命令打印出来:
Debian GNU/Linux 8 arm ttyO0
default username:password is [debian:temppwd]
此时按上面的提示用户名和密码进行登陆即可。
9.参考网址:
http://adis.ca/article/debian-wheezy-beaglebone-black
https://www.eewiki.net/display/linuxonarm/BeagleBone+Black#BeagleBoneBlack-Debian8