DM36x的UBL分析以及串口启动

      UBL是RBL引导启动的一段小程序,主要负责初始化时钟,串口,NAND,DDR2等,然后把uboot, kernel, rootfs复制到DDR2上并引导uboot。为什么UBL跟串口启动一起讲,那是因为这两个关系很密切,很多代码是共用的,而且代码都放在同一个目录下,所以就合起来一起讲了。

 

一。UBL

        ubl的代码放在dvsdk目录下的/psp/flash-utils文件夹。flash-utils目录里有很多基于不同平台的文件夹,但对我DM36x来说,只需要Common和DM36x两个文件夹就可以了,其他的都可以删掉,而且删掉后清爽多了,呵呵。UBL的源码分析网上已经很多人介绍了,我移植的时候参考了一篇很好的文章:http://zjbintsystem.blog.51cto.com/964211/392000

1. 各个makefile的修改

    修改各个目录下的makefile,主要是屏蔽掉不编译的选项。

 

2. /psp/flash-utils/DM36x/Common/src/devices.c

     这个文件很重要,里面包括了所有的CPU内部接口的初始化,包括时钟,DDR2,串口......。要是换了DDR2那就得在这修改DDR的配置。因为这个文件没有定义CPU的主频和DDR2频率的配置,使用了默认的//Arm 297 DDR 243 MHZ,所以我再这个文件的头部定义了一个宏

    #define ARM432_DDR340_OSC24     

 

3. /psp/flash-utils/DM36x/Common/src/devices.c

   由于DEVICE_DDR2Init()函数调用的DDR_Get_Val()编译时报错,这个是因为DDR_Get_Val()函数里面的除法和求余函数跟编译器不匹配造成的。改发就是把算好的值代替掉DDR_Get_Val()。

 

4./psp/flash-utils/DM36x/GNU/ubl/ubl.lds

   这个链接文件里面有内存的起始地址和大小,NAND的起始地址和大小的配置,这个根据板子的实际情况修改好。

 

完成上面的修改后就可以make了,生成的ubl_DM36x_nand.bin就是我们所要的NAND启动的UBL了。

 

 

二。串口启动

串口启动相关的代码在/psp/flash-utils/DM36x/GNU下面的sfh,sft,slh,slt。

其中sfh,sft,是一对,sfh(Serial Flasher host)是PC端的下载工具,sft(Serial Flasher target)是运行在ARM上的程序。编译sfh需要sfl文件,从UART启动时,RBL先跟sfh通讯把sft下载到IRAM中运行,然后sft通过跟sfh通讯,在PC端用命令行的方式把要下载的代码烧写到NAND上去。下面是使用的介绍:

Serial Flasher Usage

====================

More info can be found by running the utility with the '-h' option.

               sfh_DM36x.exe  -h

 

1) Erase the NAND flash

                sfh_DM36x.exe -nanderase

 

2) Flash the NAND with a UBL and u-boot image

               sfh_DM36x.exe -nandflash  <UBL binary file> <binary application file>

 

The entry point of the UBL is assumed to be 0x0100, but this can be changed by using the -UBLStartAddr option.  The entry point and load address of the application default to 0x81080000 (u-boot defaults).  To change these values, use the -APPStartAddr and  -APPLoadAddr option.

 

NOTE: Currently, YOU MUST USE THE UBL BINARY CREATED BY THE UBL PROJECT IN THIS PACKAGE.  If you use any other UBL binary, the boot procedure will most likely fail.

 

 

同样,slh和slt也是一样的道理,只是他们是把代码下载到内部RAM或者DDR2上面去。下面是使用介绍:

 

Serial Loader Usage

===================

More info can be found by running the utility with the '-h' option.

          slh_DM36x.exe   -h

 

1) Load a UBL or small UBL-like application to the DM36x IRAM

           slh_DM36x.exe  -load2IRAM   <UBL binary file>

 

2) Load a larger image compiled to run at start of DDR space

           slh_DM36x.exe  -load2DDR  <binary application file>

 

For the load to IRAM option, the file size is limited to 14KB, and the application assumes an entry point address of 0x0100 (the smallest allowed).  The entry point address canbe modified by using the -startAddr command line option, with the address specified in hex.

 

For the load to DDR option, the file size is limited to 32MB, and the application assumes a load address and entry point address of 0x80000000.

The entry point address can be altered by using the -startAddr command line option, as with the -load2IRAM case.  The load address can be altered from the default by using the -loadAddr command line option

 

 

 

由于使用sfh_DM36x.exe需要安装.Net Framework 2.0或更高的版本,所以先安装.net固件。

烧写UBL和UBOOT

1.PC端打开命令行工具,把sfh_DM36x.exe和要烧写的UBL,uboot文件放在同一个目录下,然后使用命令

        sfh_DM36x -nandflash ubl_DM36x_nand.bin u-boot.bin -p "COM1"

       如果需要指定UBOOT的装在地址或入口地址的话需要加上-APPStartAddr 和-APPLoadAddr 指定。

 

2.把板子设为串口启动,BTSET[2:0]=011. 接上串口0,然后上电,成功的话会出现如下图所示:

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值