1、需求MLO、u-boot.img、uImage、Systemfile
- 获取MLO、u-boot.img下载U-boot源码,解压获得源码,进入源码目录
cd /home/zyr/Source_code/ tar zxvf u-boot-2016.03.tar.gz
cd u-boot-2016.03
make arch=arm CROSS_COMPILE=arm-linux-gnueabihf- O=am335x-boneblack am335x_evm_defconfig all获取uImage,下载kernel源码(链接: https://pan.baidu.com/s/1cqBd0q 密码: 7nzp),解压源码,进入源码目录
进入源码目录 运行脚本文件kernel.sh
#! /bin/bash
echo "Configure the kernel"
until
echo "1.make the omap2plus.defconfig"
echo "2.make the menuconfig( Boot options -> Kernel command line type (root=/dev/mmcblk0p2 rootwait console=ttyO0,115200) )"
echo "3.make the dtb"
echo "4.make the zImage"
echo "5.make the uImage"
echo "6.make the distclean"
echo "7.make the modules"
echo "8.quit"
read input
test $input = 8
do
case $input in
1)make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- omap2plus_defconfig;;
2)make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig;;
3)make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zyr-am335x-evmsk.dtb;;
4)make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage;;
5)make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x80008000 uImage;;
6)make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean;;
7)make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8 modules;;
8)echo"quit";;
esac
done第三项make dtb文件修改为am335x-boneblack.dtb
获取精简的文件系统(链接: https://pan.baidu.com/s/1o8mONgQ 密码: qq3g)
将文件系统放入指定的目录中:
例如/home/zyr/Source_code/BeagleBone/BeagleBone-crate-SDcard
2、创建制作SD启动的脚本文件(手上需要SD卡及读卡器,将SD卡与读卡器插入电脑的USB接口):
#!/bin/sh #指定SD卡的路径(lsblk查看SD卡的路径) DISK="/dev/sdb" #指定MLO(SPL)的路径 MLO="/home/zyr/Source_code/u-boot-2016.03/am335x-boneblack/MLO" #指定u-boot.img的路径 ubootimg="/home/zyr/Source_code/u-boot-2016.03/am335x-boneblack/u-boot.img" #指定uEnv.txt的路径 uEnvtxt="/home/zyr/Source_code/u-boot-2016.03/am335x-boneblack/uEnv.txt" #指定filesystem的路径 filesystem="/home/zyr/Source_code/BeagleBone/BeagleBone-crate-SDcard/Self-for-Boneblack-filesystem.tar.gz" #指定Blageboneblackdtb的路径 Beaglebonedtb="/home/zyr/Source_code/linux-3.14.65/arch/arm/boot/dts/am335x-boneblack.dtb" #指定uImage的路径 uImage="/home/zyr/Source_code/linux-3.14.65/arch/arm/boot/uImage" #擦除SD卡 dd if=/dev/zero of=${DISK} bs=1M count=10 sync #烧写MLO,U-boot dd if=${MLO} of=${DISK} count=1 seek=1 bs=128K sync dd if=${ubootimg} of=${DISK} count=3 seek=1 bs=384K sync #dd if=/home/zyr/MLO of=${DISK} count=1 seek=1 bs=128K #dd if=/home/zyr/u-boot.img of=${DISK} count=3 seek=1 bs=384K #创建分区(Linux系统) sfdisk --unit M ${DISK} <<-__EOF__ 4,,L,* __EOF__ #格式化分区(格式化为ext4) mkfs.ext4 -L rootfs ${DISK}1 ## Make sure posted writes are cleaned up sync sync echo "Formatting done." mkdir -p /media/rootfs/ mount ${DISK}1 /media/rootfs mkdir -p /media/rootfs/opt/backup/uboot/ cp -v ${MLO} /media/rootfs/opt/backup/uboot/ cp -v ${ubootimg} /media/rootfs/opt/backup/uboot/ cp -v ${uEnvtxt} /media/rootfs/ tar xfvp ${filesystem} -C /media/rootfs sync sync chown root:root /media/rootfs/ chmod 755 /media/rootfs/ cp -v ${uImage} /media/rootfs/boot/ echo "This uImage is for BeagleBoneBlack kernel. What different from Am335x_evmsk is where the filesysytem run. " echo "Am335x_evmSk's filesysytem is running in sd's part 2." echo "BeagleBoneBlack's filesystem is running in Sd's part 1." cp -v ${uEnvtxt} /media/rootfs/boot/ mkdir -p /media/rootfs/boot/dtbs/ cp -v ${Beaglebonedtb} /media/rootfs/boot/dtbs sh -c "echo '/dev/mmcblk0p1 / auto errors=remount-ro 0 1' >> /media/rootfs/etc/fstab" sync sync umount /media/rootfs
这样BelageBoneBlack(am335x)板的启动SD卡制作成功了。
说明:1、运行此脚本需要root权限:sudo sh xxxxx.sh
2、需要linux虚拟机的ubuntu知道SD卡的位置,比如lsblk,可以看出是sdb
3、若是已经分过区的SD卡,需要多次运行此脚本(至少两次,中间需要将SD卡拔下来在插入),自己经验得出,不适用所有的人。
参考网址: