很多年前做的针对BeagleBone Black开发板的镜像制作,因为当时涉及到非标准化的,所以把基本的kernel、uboot和跟文件系统rootfs都做了一遍,文中只做移植,不作定制化的修改。
如果觉得哪里有问题,或者操作有误,欢迎留言斧正。
码文不易,转载请申明出处和链接。
使用bbb工业版移植内核,主要做的是几个方面:
- 在linux下安装交叉编译器
- 下载并编译uboot
- 下载并编译linux
- 下载rootfs
- 制作uEnv.txt给予启动
- 制作sd卡,把相关的镜像复制卡内,即完工
以下为具体的操作步骤,本文用的linux操作系统为ubuntu16.04
1.安装交叉编译器
安装交叉编译器
sudo apt-get install gcc-arm-linux-gnueabihf
安装完后可以查看交叉编译器版本
arm-linux-gnueabihf-gcc -v
本文交叉编译器版本为gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4)
2.下载并编译uboot
以下假设所有的文件和操作路径都是在~/bb-linux下
sudo mkdir ~/bb-linux/
下载u-boot,并把文件传进ubuntu
解压
unzip -d ~/bb-linux/ u-boot-master.zip
cd ~/bb-linux/u-boot-master/
git checkout v2017.03-rc2 -b tmp
下载相应的patch
路径:~/bb-linux/u-boot-master
wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2017.03-rc2/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2017.03-rc2/0002-U-Boot-BeagleBone-Cape-Manager.patch
patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
patch -p1 < 0002-U-Boot-BeagleBone-Cape-Manager.patch
编译u-boot
路径:~/bb-linux/u-boot-master
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x_boneblack_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
编译完成后在目录下能看到MLO 和 u-boot.img这两个文件。
关于MLO、u-boot,以及am335x的启动流程,可以看BeagleBone Black 从零到一 (1 启动流程),这篇文章写得很详细。
3.linux内核下载编译
下载linux内核源码,本文的源码版本是4.4.49,并把压缩包传进~/bb-linux/下
路径:~/bb-linux/
sudo unzip linux-4.4.zip
cd linuc-4.4/
cp arch/arm/configs/bb_org.defconfig .config
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage dtbs
编译完成后在./arch/arm/boot/下有zImage文件以及dts文件夹
- 编译内核模块
因为在后续的使用过程中发现,spi1和sound card的口冲突了导致spi1不能用,所以在编译之前取消sound card模块的加载
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
选择Device Drivers ---> < M > Sound card support ---
使用空格键取消,变成< > Sound card support ---
然后保存退出,编译
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
4 文件系统rootfs下载
- Debian 8
User | Password |
---|---|
debian | temppwd |
root | root |
路径:~/bb-linux
下载debian8系统
wget -c https://rcn-ee.com/rootfs/eewiki/minfs/debian-8.7-minimal-armhf-2017-01-14.tar.xz
- 验证sha256sum
sha256sum debian-8.7-bare-armhf-2017-02-14.tar.xz
159e1a6addc35bbfff03b5eafd5cb741086a8a016d5ab9572ab122ce64d63e5e debian-8.7-bare-armhf-2017-01-14.tar.xz
- 解压
tar xf debian-8.7-bare-armhf-2017-01-14.tar.xz
5 准备烧写sd卡
假设microSD卡插进ubuntu后显示为/dev/sdb1,可以用sudo fdisk -l来查看
擦除microSD卡
sudo dd if=/dev/zero of=/dev/sdb bs=1M count=10
- 安装u-boot
sudo dd if=~/bb-linux/u-boot-master/MLO of=/dev/sdb count=1 seek=1 bs=128k
sudo dd if=~/bb-linux/u-boot-master/u-boot.img of=/dev/sdb count=2 seek=1 bs=384k
- 检查sfdisk的版本
sudo sfdisk --version
#sfdisk,来自 util-linux 2.27.1
如果sfdisk >=2.26.x
sudo sfdisk /dev/sdb <<-__EOF__
4M,,L,*
__EOF__
如果sfdisk <=2.25.x
sudo sfdisk --unit M /dev/sdb <<-__EOF__
4M,,L,*
__EOF__
如果命令过程中出现
Checking that no-one is using this disk right now ... FAILED
This disk is currently in use - repartitioning is probably a bad idea.
Umount all file systems, and swapoff all swap partitions on this disk.
Use the --no-reread flag to suppress this check.
sfdisk: Use the --force flag to overrul