Chinaunix首页 | 论坛 | 博客
  • 博客访问: 103102
  • 博文数量: 51
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 12
  • 用 户 组: 普通用户
  • 注册时间: 2014-02-08 10:52
文章分类

全部博文(51)

文章存档

2016年(5)

2015年(3)

2014年(43)

我的朋友

分类: 嵌入式

2015-07-16 10:48:12

首先,感谢上大牛们的帮助! 在里面学得了很多!

前面章节运行的beaglebone black 上的linux系统是以.img映像格式烧写到emmc上而启动的。如果能够通过TF启动系统,则非常便于开发。

通过查看资料可知在TF卡上启动有两种方式:
第一种:是把.img文件烧写到TF卡的启动方式,这种方式需要制作.img文件或是官网上找到.img文件。详见:中国板Beaglebone-Black之microSD卡启动系统
第二种:是直接拷贝MLO, u-boot.img, uImage 和ext4文件系统到sd卡的方式。这种方式更有利于开发,所以下面将讲解这种启动方式:

刚开始我所使用的是在开发环境安装中使用的ti-sdk-am335x-evm-07.00.00.00/board-support/中的uboot和内核,但可能是版本缘故,按照后面的步骤进行启动,每次启动内核时就说“file not found uImage”,不能启动。让我在上面大费周折,试图改过u-boot源代码,也通过uEnv.txt改过environment,但最终没能成功(后来听说的:是要替换文件系统中/boot下的镜像,自己没试过,不知道是不是??)最终按照官方文档:Sitara Linux Software Developer’s Guide 的要求,使用的是(即卸载掉前面安装的ti-sdk-am335x-evm-07.00.00.00)。在这个sdk下最终取得了成功。

具体实现方法:
首先,怎么样让系统从EMMC启动,怎么样才能让系统从TF卡启动:(参考:
A switch is provided to allow switching between the modes.  
Holding  the boot switch  down  during  boot  without a  SD  card inserted will force the boot source to be the USB port and if nothing is detected on the USB client port, it will go to the serial port for download. 
Without  holding  the switch,  the  board  will  boot  from  eMMC.  If  it  is  empty, then it will try booting from the uSD slot, followed by the serial port, and then the USB port. 
If  you  hold  the  boot  switch  down  during  boot,  and  you  have  a  uSD  card inserted with a bootable image, the board will boot form the uSD card. 
然后,就是制作启动内核的TF卡,编译u-boot、内核了:
1.制作TF卡:(参考:就是运行/ti-sdk-am335x-evm-06.00.00.00/bin,然后按照步骤一步步进行到底,执行结果对TF卡进行了两个分区:一个是fat格式,用于存放MLO, u-boot.img和uImage;一个是ext3格式,用于存放文件系统,可以通过过Disk Utility查看如下:

2.编译内核:这里再一次声明,用最初的SDK没有成功,所以换成了ti-sdk-am335x-evm-06.00.00.00下的u-boot和内核进行编译
参考:AMSDK u-boot User's Guide(编译MLO和u-boot.img),AMSDK Linux User's Guide(编译uImage)

总结下来有如下步骤:
a.编译u-boot:
make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm distclean
rm -rf ./am335x_evm
make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm O=am335x_evm am335x_evm
b.编译内核:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- mrproper
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- am335x_evm_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules (这一步是编译模块.ko文件,备用)

3.通过以上步骤,得到了所需要的文件,接下来就是拷贝和启动工作:
a. 到uboot的am335x_evm目录下:
sudo cp MLO u-boot.img /media/boot/
b. 到内核的arch/arm/boot目录下:
sudo cp uImage /media/boot/
c. 到ti-sdk-am335x-evm-06.00.00.00/filesystem目录下:
sudo tar -xzv -C /media/rootfs/ -f tisdk-rootfs-image-am335x-evm.tar.gz
完成以上步骤后,通过:
umount /media/boot 移除boot分区
umount /media/rootfs 移除文件系统分区
以上步骤也可以这样实现:
先df -BG看到如下:

然后,
umount /dev/sdb1
umount /dev/sdb2
(特别强调:这里必须使用umount移除,而不能直接拔掉,因为显示已经拷贝完成,但是数据其实还没真正写到TF卡去,所以通过sysnc或是umount后拔掉才不会导致数据被破坏)
接下来便是启动步骤了:将TF卡插入卡槽(slot),按住S2键,上电后启动如下:

大功告成!!ok

阅读(772) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~