首先这个现象并不少见,我看了好几个这种帖子了,这里说一下我的各种情况,以及我的分析,你们看看对不对,有一些问题,还请帮忙解答一下,非常感谢!
先说明一下,我用的电路板不是官方给的EVM开发板,是我自己画的一个板子,芯片也是加密型的。
现象一:
现象一操作步骤 :先用Generic SecureUartHost.exe对加密芯片解锁。
(File IO): Read 3668 bytes from file F:\C674x_OMAPL1x_Generic_Security_Flash_Boot_Utils\OMAP-L138_Secure_FlashAndBootUtils_trunk\OMAP-L138_Secure\GNU\AISUtils\led.bin.
(Serial Port): Opening COM14 at 115200 baud…
(AIS Parse): Read magic word 0x41504954.
(AIS Parse): Waiting for BOOTME… (power on or reset target now)
(AIS Parse): BOOTME received!
(AIS Parse): Performing Start-Word Sync…
(AIS Parse): Performing Ping Opcode Sync…
(AIS Parse): Processing command 0: 0x58535920.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Secure key loading, entering secure mode.
(AIS Parse): Processing command 1: 0x58535923.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Setting boot exit mode…
(AIS Parse): Set exit mode to 0x00000000.
(AIS Parse): Processing command 2: 0x5853590D.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Executing function…
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 3: 0x5853590D.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Executing function…
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 4: 0x5853590D.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Executing function…
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 5: 0x5853590D.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Executing function…
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 6: 0x5853590D.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Executing function…
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 7: 0x5853590D.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Executing function…
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 8: 0x5853590D.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Executing function…
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 9: 0x5853590D.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Executing function…
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 10: 0x5853590D.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Executing function…
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 11: 0x58535921.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Loading encoded section…
(AIS Parse): Loaded 3008-Byte section to address 0x80000000.
(AIS Parse): Processing command 12: 0x58535921.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Loading encoded section…
(AIS Parse): Loaded 52-Byte section to address 0x800013C0.
(AIS Parse): Processing command 13: 0x58535921.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Loading encoded section…
(AIS Parse): Loaded 16-Byte section to address 0x800013F4.
(AIS Parse): Processing command 14: 0x58535906.
(AIS Parse): Performing Opcode Sync…
(AIS Parse): Performing jump and close…
(AIS Parse): Secure mode; sending signature.
(AIS Parse): AIS complete. Jump to address 0x80000A80.
(AIS Parse): Waiting for DONE…
(AIS Parse): Boot completed successfully.
(Serial Port): Closing COM14.
一切正常,led.bin烧到内部Shared RAM,led开始闪烁,说明程序运行起来了………
然后执行sfh_OMAP-L138.exe -flash_noubl -targetType C6748 -flashType NAND -p COM14 led.bin
接下来命令窗提示重新复位电路板,然后我就复位dsp,确实收到了BOOTME的信息,但是再后面,上面现象一就发生了。
现象一分析:复位后(虽然一直没有掉电),dsp重新进行从UART2的启动方式,这时因为GenericSecureUartHost.exe没有操作加载led.bin,导致只能收到BOOTME,程序却无法启动,进而导致语句 sfh_OMAP-L138.exe -flash_noubl -targetType C6748 -flashType NAND -p COM14 led.bin 读取时发生错误。
question 1.1:我的分析对现象一的解释正确吗?
question 1.2:使用sfh_OMAP-L138.exe命令时,我后面跟的led.bin,而不是led.ais,但是我看到好多地方都是用的led.ais。是不是加密的就用SecureHexAIS_OMAP-L138.exe生成的.bin,而非加密的芯片用AISgen_d800k008.exe生成的.ais?(这里先不涉及UBL二次启动的问题,只是Single boot image)
question 1.3:我感觉使用串口烧写程序到NAND FLASH的过程比较复杂,先让程序通过串口进入RAM,运行,然后各种加载什么的,期间好像有DDR的参与,能不能讲一下使用串口烧写NAND FLASH的整个过程?
现象二:
现象二操作步骤:
为了避免上次遇到的问题,这次操作时有CCS的参与
首先也是用Generic SecureUartHost.exe对加密芯片解锁,完了之后led灯是可以闪烁的,debug一下,然后发现JTAG可以成功连上了,先不点击运行按钮,
这时发现led灯其实已经不闪烁了,说明Generic SecureUartHost.exe时的下载那个程序已经完全不影响了,只是解锁了一下,现在控制权在JTAG手上。
然后执行sfh_OMAP-L138.exe -flash_noubl -targetType C6748 -flashType NAND -p COM14 led.bin
接下来命令窗提示重新复位电路板,然后我就复位dsp,竟然没有收到BOOTME,过一会儿,我点击CCS运行按钮,BOOTME收到,上面现象二发生。
现象二分析:
1: CCS的代码通过JTAG进入DSP,运行后,将串口收到的BOOTME显示出来,对sfh_OMAP-L138.exe -flash_noubl -targetType C6748 -flashType NAND -p COM14 led.bin发生作用(加载led.bin?),只是由于种种原因卡在了Waiting for SFT on the OMAP-L138。
2: 至于为何停在Waiting for SFT on the OMAP-L138,文档OMAP-L138_FlashAndBootUtils 使用及编译指导里面说:
一是由于DDR 参数配置不正确从而导致程序运行异常,不能返回正确的指令给主机;
二是硬件原因,可能是焊接,或硬件连接上的错误造成的。
可以通过仿真器连接目标板用BSL库提供的测试程序验证一下DDR,和相应的flash。如果没有仿真器,可以通过间接的方法,比如用AISgen 工具
包里提供的UART 启动工具UartHost.exe 来加载运行测试程序,检测DDR,flash 等,将测试结果通过串口回传显示,或者设置GPIO 的状态来反映。
question2.1: 上面的分析1、2对么?
question2.2: 假设上面分析2对的,这时候如果仍然想用串口去烧写程序,而且不是官方的EVM板子。就先需要:
1、 更改一些参数ddr、uart等的参数(http://processors.wiki.ti.com/index.php/Serial_Boot_and_Flash_Loading_Utility_for_OMAP-L138)
2、准备编译工具()
(1) cygwin (2) .NET framework (3) ARM Compiler tools(CodeSourcery G++ Lite) (4) C6x Compiler Tools (5) CCSV6
3 、重新rebuilding the Flash and Boot Utils (http://processors.wiki.ti.com/index.php/Rebuilding_the_Flash_and_Boot_Utils_Package)
整个过程比较复杂,如果编译不成功,一样会停在Waiting for SFT on the OMAP-L138,如果是硬件的原因,就更不好排查到底问题出在哪。
所以我现在想通过CCS加载nandwriter的方法来下载程序进nand flash,下载程序前,通过加载gel文件,通过打印的一些DDR或者其他信息,可能也可以排除一些问题。
我的想法可以不(就是改用ccs下载程序,结合gel),有何建议?
question2.3: 你们现在有没有C6748能用的NAND_FLASH_TOOL或者nandwriter的CCSV6工程(就是下载程序进NAND FLASH 的工程),我官网找的都是零散的文件,要么不能导入CCSV6要么不是针对C6748?
question2.4: 因为没有办法,我就先用零散的文件做了一个nandwriter的工程,我比对了一下官方的LCDK(LCDK应该不是EVM吧),发现我们的NAND flash完全一样,都是MT29F4G16ABADAH4(Micron 4Gbit NAND Flash x16 data width),DDR SDRAM 我的是K4T1G164QF-BCF7 ,官方K4T1G164QF-BCF8,就尾号不一样,晶振都是24M,串口我的UART2,所以感觉可以借用它的方法下载。在http://processors.wiki.ti.com/index.php/L138/C6748_Development_Kit_(LCDK)#Memory中提到:
- CCS Method
- Connect to the ARM or DSP with the GEL file loaded, which will auto-initialize the DDR
- Open (CCS3) or import (CCS4, CCS5) the NANDWriter_ARM or NANDWriter_DSP project
- Modify the #define "NANDWIDTH_8" to "#define NANDWIDTH_16" in nandwriter.c
- Rebuild and run the code
于是我就在假设我的nandwriter工程正确的前提下(编译是可以通过的),按照这里说的进行,gel文件用的也是C6748_LCDK.gel,
加载gel后运行出现如下问题
如果看红色提示,好像是0xb000000c处出现问题(红色没看懂啥意思),但实际上我观察程序,应该在pll0和pll1设置好后,进行DDR配置时出现了问题,对应程序中的函数DEVICE_DDRConfig,运行到DEVICE_DDRConfig函数里面的语句:
// SyncReset the Clock to EMIFDDR SDRAM
PSC1_LPSC_SyncReset(PD0, LPSC_DDR);
出现信息
PSC1 Sync Reset Transition Timeout on Domain 0 ,LPSC 6
PSC1 Sync Reset Verify Timeout on Domain 0 ,LPSC 6
// Enable the Clock to EMIFDDR SDRAM
PSC1_LPSC_enable(PD0, LPSC_DDR);
出现信息
PSC1 Enable Transition Timeout on Domain 0 ,LPSC 6
PSC1 Enable Verify Timeout on Domain 0 ,LPSC 6
其实在DEVICE_DDRConfig的前半部分也有PSC1_LPSC_enable(PD0, LPSC_DDR),但是正常通过,后来配置DDR后,再进行PSC1_LPSC_SyncReset、PSC1_LPSC_enable时出问题了,我的DDR是 K4T1G164QF-BCF7 ,官方K4T1G164QF-BCF8,手册里面参数确实有些不一样,那么这个问题应该是DDR参数设置的不对,还是其他什么问题?
question2.5: 如果DDR参数不对,TI有没有什么工具,可以根据DDR芯片参数来设置程序的寄存器?
question2.6: 为啥往NAND FLASH 下载程序还要DDR芯片的参与,这个过程是怎样的?
比较长,问题也多,给你们添麻烦了,还请分条对question进行解答或者评价,非常非常感激!
Tony Tang:
写的好长啊。
烧加密版的过程上面第一步是对的,用一个程序解锁JTAG。但后面不对了,芯片复位后又会进入加密模式,那前第一步就白做了。
所以第二步可以用通用的nand write CCS工程连上仿真器烧NAND.
baokun hu:
回复 Tony Tang:
问题1: 之前一直怕DDR的硬件设计有问题,今天我在OMAP-L138_generic_secure.ini文件中,根据我的SDRAM型号,改了DDR的一些寄存器参数,同时在led工程的CMD文件中,将所有的SECTIONS部分定位到DDR的SDRAM上,从UART2启动,发现程序可以在DDR SDRAM上面运行了(灯在闪烁),是不是我的DDR硬件设计已经没有问题了?
串口提示信息为:
(File IO): Read 3668 bytes from file F:\C674x_OMAPL1x_Generic_Security_Flash_Boot_Utils\OMAP-L138_Secure_FlashAndBootUtils_trunk\OMAP-L138_Secure\GNU\AISUtils\led_ddr2.bin.(Serial Port): Opening COM14 at 115200 baud…(AIS Parse): Read magic word 0x41504954.(AIS Parse): Waiting for BOOTME… (power on or reset target now)(AIS Parse): BOOTME received!(AIS Parse): Performing Start-Word Sync…(AIS Parse): Performing Ping Opcode Sync…(AIS Parse): Processing command 0: 0x58535920.(AIS Parse): Performing Opcode Sync…(AIS Parse): Secure key loading, entering secure mode.(AIS Parse): Processing command 1: 0x58535923.(AIS Parse): Performing Opcode Sync…(AIS Parse): Setting boot exit mode…(AIS Parse): Set exit mode to 0x00000000.(AIS Parse): Processing command 2: 0x5853590D.(AIS Parse): Performing Opcode Sync…(AIS Parse): Executing function…(AIS Parse): Secure mode; sending signature.(AIS Parse): Processing command 3: 0x5853590D.(AIS Parse): Performing Opcode Sync…(AIS Parse): Executing function…(AIS Parse): Secure mode; sending signature.(AIS Parse): Processing command 4: 0x5853590D.(AIS Parse): Performing Opcode Sync…(AIS Parse): Executing function…(AIS Parse): Secure mode; sending signature.(AIS Parse): Processing command 5: 0x5853590D.(AIS Parse): Performing Opcode Sync…(AIS Parse): Executing function…(AIS Parse): Secure mode; sending signature.(AIS Parse): Processing command 6: 0x5853590D.(AIS Parse): Performing Opcode Sync…(AIS Parse): Executing function…(AIS Parse): Secure mode; sending signature.(AIS Parse): Processing command 7: 0x5853590D.(AIS Parse): Performing Opcode Sync…(AIS Parse): Executing function…(AIS Parse): Secure mode; sending signature.(AIS Parse): Processing command 8: 0x5853590D.(AIS Parse): Performing Opcode Sync…(AIS Parse): Executing function…(AIS Parse): Secure mode; sending signature.(AIS Parse): Processing command 9: 0x5853590D.(AIS Parse): Performing Opcode Sync…(AIS Parse): Executing function…(AIS Parse): Secure mode; sending signature.(AIS Parse): Processing command 10: 0x5853590D.(AIS Parse): Performing Opcode Sync…(AIS Parse): Executing function…(AIS Parse): Secure mode; sending signature.(AIS Parse): Processing command 11: 0x58535921.(AIS Parse): Performing Opcode Sync…(AIS Parse): Loading encoded section…(AIS Parse): Loaded 3008-Byte section to address 0xC0000000.(AIS Parse): Processing command 12: 0x58535921.(AIS Parse): Performing Opcode Sync…(AIS Parse): Loading encoded section…(AIS Parse): Loaded 52-Byte section to address 0xC00013C0.(AIS Parse): Processing command 13: 0x58535921.(AIS Parse): Performing Opcode Sync…(AIS Parse): Loading encoded section…(AIS Parse): Loaded 16-Byte section to address 0xC00013F4.(AIS Parse): Processing command 14: 0x58535906.(AIS Parse): Performing Opcode Sync…(AIS Parse): Performing jump and close…(AIS Parse): Secure mode; sending signature.(AIS Parse): AIS complete. Jump to address 0xC0000A80.(AIS Parse): Waiting for DONE…(AIS Parse): Boot completed successfully.(Serial Port): Closing COM14.
2:你们有没有通用的通用的nand write CCSV6工程,从哪可以下到C6748的通用nand write CCSV6工程?
baokun hu:
回复 Tony Tang:
现在使用官方的NandWriter烧写程序,
发现配置完成DDR2,进行syncreset时,程序卡在device.c文件的
DEVICE_LPSCTransition(PSCNUM1, LPSC_EMIFB, PD0, PSC_SYNCRESET);这句话处,
进这个函数里面观察,发现前面虽然设置成syncreset,却根本无法切换到syncreset模式(一直在等待完成),也即只能一直停留在
// Wait for transition to complete
while ( (PSC->PTSTAT) & (0x00000001 << domain) );
请问:
1、DDR设置完成后,到底需不需要对这个DDR2模块进行syncreset?
2、如果需要syncreset,那么我这个问题可能出在什么地方?