问题一:
.sect "b0_dcsm_otp_z1_pswdlock"
; .long 0xFFFFFFFF ;Z1OTP_PSWDLOCK
;;.long 0xFFFFFFFF ;Reserved
在使用280049C芯片的DCSM模块进行芯片加密时,将上面代码取消注释,加入代码后会导致在烧录过程中突然中断,并报出一下故障(使用的是CCSV8.3.1版本以及18.1.4编译器和32位电脑),cmd文件就是用的例程中的。
C28xx_CPU1: GEL Output:Memory Map Initialization Complete
C28xx_CPU1: GEL Output: … DCSM Initialization Start …C28xx_CPU1: GEL Output: … DCSM Initialization Done …
C28xx_CPU1: GEL Output: … DCSM Initialization Start …C28xx_CPU1: GEL Output: … DCSM Initialization Done …
C28xx_CPU1: GEL Output: … DCSM Initialization Start …C28xx_CPU1: GEL Output: … DCSM Initialization Done …
C28xx_CPU1: Error during Flash programming (Flash algorithm returned error code). Operation cancelled.
C28xx_CPU1: File Loader: Memory write failed: Unknown error
C28xx_CPU1: GEL: File: E:\DVR-CODE\DVRSlaverLock\Debug\DVRSlaverLock.out: Load failed.
将以上代码注释后可以将代码(这里说的代码指加密单独的代码)烧录到芯片中,会导致正常代码不会运行(之前已经烧录,且烧录加密代码时没有进行擦除),只有带仿真器才可以正常运行,但之前没烧录加密代码时是可以正常运行的(重新上电后也可以正常运行),以下是我在f28004x_dcsm_z1otp.asm文件中的配置情况(可以正常烧录的代码配置),f28004x_dcsm_z2otp.asm文件没有配置:
.sect "b0_dcsm_otp_z1_linkpointer"
.long 0x1FFFFFFF ;B0_Z1OTP_LINKPOINTER1
.long 0xFFFFFFFF ;Reserved
.long 0x1FFFFFFF ;B0_Z1OTP_LINKPOINTER2
.long 0xFFFFFFFF ;Reserved
.long 0x1FFFFFFF ;B0_Z1OTP_LINKPOINTER3
.long 0xFFFFFFFF ;Reserved
.sect "b0_dcsm_otp_z1_gpreg"
; .long 0xFFFFFFFF ;Z1OTP_BOOTPIN_CONFIG
; .long 0xFFFFFFFF ;Z1OTP_GPREG2
.sect "b0_dcsm_otp_z1_pswdlock"
; .long 0xFFFFFFFF ;Z1OTP_PSWDLOCK
; .long 0xFFFFFFFF ;Reserved
.sect "b0_dcsm_otp_z1_crclock"
; .long 0xFFFFFFFF ;Z1OTP_CRCLOCK
; .long 0xFFFFFFFF ;Reserved
.sect "b0_dcsm_otp_z1_bootctrl"
; .long 0xFFFFFFFF ;Z1OTP_BOOTDEF_LOW
; .long 0xFFFFFFFF ;Z1OTP_BOOTDEF_HIGH
.sect "b0_dcsm_zsel_z1"
.long 0xFFFFFFFF ;B0_Z1OTP_EXEONLYRAM
.long 0xFFFFFFFF ;B0_Z1OTP_EXEONLYSECT
.long 0xFFFFF666 ;B0_Z1OTP_GRABRAM 0xFFFFF666
.long 0xFFFFFE66 ;B0_Z1OTP_GRABSECT 0xFFFFFE66
.long 0x58534C4C ;B0_Z1OTP_CSMPSWD0 (LSW of 128-bit password)
.long 0x47556953 ;B0_Z1OTP_CSMPSWD1
.long 0x16071217 ;B0_Z1OTP_CSMPSWD2
.long 0x091543F1 ;B0_Z1OTP_CSMPSWD3 (MSW of 128-bit password)
.sect "b1_dcsm_otp_z1_linkpointer"
.long 0x1FFFFFFF ;B1_Z1OTP_LINKPOINTER1
.long 0xFFFFFFFF ;Reserved
.long 0x1FFFFFFF ;B1_Z1OTP_LINKPOINTER2
.long 0xFFFFFFFF ;Reserved
.long 0x1FFFFFFF ;B1_Z1OTP_LINKPOINTER3
.long 0xFFFFFFFF ;Reserved
.sect "b1_dcsm_zsel_z1"
.long 0xFFFFFFFF ;Reserved
.long 0xFFFFFFFF ;B1_Z1OTP_EXEONLYSECT
.long 0xFFFFFFFF ;Reserved
.long 0xFFFFFE66 ;B1_Z1OTP_GRABSECT
.long 0x58534C4C ;Reserved
.long 0x47556953 ;Reserved
.long 0x16071217 ;Reserved
.long 0x091543F1 ;Reserved
问题二:
在遇到问题一后,经过查阅TI论坛,我得出结论就是CCS或者编译器版本过低,但是对于32位系统的电脑CCSV8.3.1和18.1.4编译器已经为顶配。于是我换了一个64位电脑使用CCSV10版本以及20.2.0的最新编译器并在f28004x_dcsm_z1otp.asm文件中的代码如下:
.sect "b0_dcsm_otp_z1_linkpointer"
.long 0x1FFFFFFF ;B0_Z1OTP_LINKPOINTER1
.long 0xFFFFFFFF ;Reserved
.long 0x1FFFFFFF ;B0_Z1OTP_LINKPOINTER2
.long 0xFFFFFFFF ;Reserved
.long 0x1FFFFFFF ;B0_Z1OTP_LINKPOINTER3
.long 0xFFFFFFFF ;Reserved
.sect "b0_dcsm_otp_z1_gpreg"
.long 0xFFFFFFFF ;Z1OTP_BOOTPIN_CONFIG
.long 0xFFFFFFFF ;Z1OTP_GPREG2
.sect "b0_dcsm_otp_z1_pswdlock"
.long 0xFFFFFFFF ;Z1OTP_PSWDLOCK
.long 0xFFFFFFFF ;Reserved
.sect "b0_dcsm_otp_z1_crclock"
.long 0xFFFFFFFF ;Z1OTP_CRCLOCK
.long 0xFFFFFFFF ;Reserved
.sect "b0_dcsm_otp_z1_bootctrl"
.long 0xFFFFFFFF ;Z1OTP_BOOTDEF_LOW
.long 0xFFFFFFFF ;Z1OTP_BOOTDEF_HIGH
.sect "b0_dcsm_zsel_z1"
.long 0xFFFFFFFF ;B0_Z1OTP_EXEONLYRAM
.long 0xFFFFFFFF ;B0_Z1OTP_EXEONLYSECT
.long 0xFFFF6666 ;B0_Z1OTP_GRABRAM
.long 0x66666666 ;B0_Z1OTP_GRABSECT
.long 0x58534C4C ;B0_Z1OTP_CSMPSWD0 (LSW of 128-bit password)
.long 0x47556953 ;B0_Z1OTP_CSMPSWD1
.long 0x16071217 ;B0_Z1OTP_CSMPSWD2
.long 0x091543F1 ;B0_Z1OTP_CSMPSWD3 (MSW of 128-bit password)
.sect "b1_dcsm_otp_z1_linkpointer"
.long 0x1FFFFFFF ;B1_Z1OTP_LINKPOINTER1
.long 0xFFFFFFFF ;Reserved
.long 0x1FFFFFFF ;B1_Z1OTP_LINKPOINTER2
.long 0xFFFFFFFF ;Reserved
.long 0x1FFFFFFF ;B1_Z1OTP_LINKPOINTER3
.long 0xFFFFFFFF ;Reserved
.sect "b1_dcsm_zsel_z1"
.long 0xFFFFFFFF ;Reserved
.long 0xFFFFFFFF ;B1_Z1OTP_EXEONLYSECT
.long 0xFFFFFFFF ;Reserved
.long 0x66666666 ;B1_Z1OTP_GRABSECT
.long 0x58534C4C ;Reserved
.long 0x47556953 ;Reserved
.long 0x16071217 ;Reserved
.long 0x091543F1 ;Reserved
在烧录加密软件过程中会报出以下故障:
C28xx_CPU1: GEL Output:Memory Map Initialization Complete
C28xx_CPU1: GEL Output: … DCSM Initialization Start …C28xx_CPU1: GEL Output: … DCSM Initialization Done …
C28xx_CPU1: GEL Output: … DCSM Initialization Start …C28xx_CPU1: GEL Output: … DCSM Initialization Done …
C28xx_CPU1: GEL Output: … DCSM Initialization Start …C28xx_CPU1: GEL Output: … DCSM Initialization Done …
C28xx_CPU1: Error during Flash Programming. Address 0x00078010, Data 0x0000E000, FMSTAT 0x00000030
C28xx_CPU1: File Loader: Memory write failed: Unknown error
C28xx_CPU1: GEL: File: E:\My Project\DVR\DVRSlaverLock\Debug\DVRSlaverLock.out: Load failed.
求大神给个解决方案
Green Deng:
其实DCSM模块的使用说明之前FAE有分享过,建议你可以参考一下:e2echina.ti.com/…/dcsm
user6341694:
回复 Green Deng:
这个我看过,但是感觉代码写的没什么问题,就是按照这个上面做的,但是依然会报出错误,现在我这边在查找到底是哪里出现问题,现在一直报一个错,我想知道这个错代表什么,可以帮忙看下吗?也许这个错误就是个线索:
C28xx_CPU1: Error during Flash Programming. Address 0x00078010, Data 0x0000E010, FMSTAT 0x00000030
C28xx_CPU1: File Loader: Memory write failed: Unknown error
C28xx_CPU1: GEL: File: E:\My Project\DVR\DVRSlaverLock\Debug\DVRSlaverLock.out: Load failed.
user6341694:
回复 user6341694:
而且您给我发的这个链接我是没有权限看图片的。我的这个芯片比较新,是280049C的,好像和其他的不太一样,因为我们原来有做过28377D芯片的加密,我也进行了对比,也按照更改了寄存器,但是依然还是报错,目前无法解决,不知道是哪里出现了问题。
Green Deng:
回复 user6341694:
尝试一下更改参数默认值:
.long 0xFFFFFFFF ;Z1OTP_PSWDLOCK .long 0xFFFFFFFF ;Reserved .sect "b0_dcsm_otp_z1_crclock" .long 0xFFFFFFFF ;Z1OTP_CRCLOCK .long 0xFFFFFFFF ;Reserved改成:
.long 0xfb7fffff ;Z1-PSWDLOCK .long 0x7fffffff ;Reserved
.sect "b0_dcsm_otp_z1_crclock" .long 0x4bffffff ;Z1-CRCLOCK .long 0x3fffffff ;Reserved
user6341694:
回复 Green Deng:
您好,感谢您提供方案。按照您的提示,我也做了尝试,但是在烧录结束后还是会导致我烧录到芯片内部的代码停止运行(使用32位电脑以及CCSV8.3.1和编译器18.1.4),但是我又用64位电脑以及CCSV10和编译器20.2.0进行测试,烧录过程中会报出如下错误:
C28xx_CPU1: GEL Output:
Memory Map Initialization Complete
C28xx_CPU1: GEL Output: … DCSM Initialization Start …
C28xx_CPU1: GEL Output: … DCSM Initialization Done …
C28xx_CPU1: GEL Output: … DCSM Initialization Start …
C28xx_CPU1: GEL Output: … DCSM Initialization Done …
C28xx_CPU1: GEL Output: … DCSM Initialization Start …
C28xx_CPU1: GEL Output: … DCSM Initialization Done …
C28xx_CPU1: Error during Flash Verification. Address 0x00078019, Expected 0x00009FFF, Read 0x0000FFFF
C28xx_CPU1: File Loader: Memory write failed: Unknown error
C28xx_CPU1: GEL: File: E:\workspace_v10\DVRSlaverLock\Debug\DVRSlaverLock.out: Load failed.
于是我将报错的对应位置按照以上期望值改过来,如下:
.sect "b0_dcsm_otp_z1_P0"
.long 0x1FFFFFFF ;B0_Z1OTP_LINKPOINTER1 .long 0xFFFFFFFF ;Reserved .long 0x1FFFFFFF ;B0_Z1OTP_LINKPOINTER2 .long 0xFFFFFFFF ;Reserved .long 0x1FFFFFFF ;B0_Z1OTP_LINKPOINTER3 .long 0xFFFFFFFF ;Reserved .long 0xFFFFFFFF ;Z1OTP_BOOTPIN_CONFIG .long 0xFFFFFFFF ;Z1OTP_GPREG2 .long 0xfb7fffff ;Z1OTP_PSWDLOCK .long 0x7fffffff ;Reserved .long 0x4bffffff ;Z1OTP_CRCLOCK .long 0x3fffffff ;Reserved .long 0xFFFFFFFF ;Reserved .long 0xFFFF9FFF ;Reserved .long 0xFFFFFFFF ;Z1OTP_GPREG3 .long 0xFFFFFFFF ;Z1OTP_BOOTCTRL
其中,上面标红位置原来的例程中没有,是我后加的(我认为这个是寻址的,需要都进行配置,于是将所有地址位置补全了),也对应改了cmd文件如下:
MEMORY{
PAGE 0 :
/* BANK0 */ B0_DCSM_OTP_Z1_P0 : origin = 0x78000, length = 0x000020 B0_DCSM_OTP_Z2_P0 : origin = 0x78200, length = 0x000020
B0_DCSM_ZSEL_Z1_P0 : origin = 0x78020, length = 0x000010 B0_DCSM_ZSEL_Z2_P0 : origin = 0x78220, length = 0x000010
/* BANK1 */ B1_DCSM_OTP_Z1_P0 : origin = 0x78400, length = 0x000020 B1_DCSM_OTP_Z2_P0 : origin = 0x78600, length = 0x000020
B1_DCSM_ZSEL_Z1_P0 : origin = 0x78420, length = 0x000010 B1_DCSM_ZSEL_Z2_P0 : origin = 0x78620, length = 0x000010
}
SECTIONS{
/* BANK0 */ b0_dcsm_otp_z1_P0 : > B0_DCSM_OTP_Z1_P0 PAGE = 0 b0_dcsm_otp_z2_P0 : > B0_DCSM_OTP_Z2_P0 PAGE = 0
b0_dcsm_zsel_z1 : > B0_DCSM_ZSEL_Z1_P0 PAGE = 0 b0_dcsm_zsel_z2 : > B0_DCSM_ZSEL_Z2_P0 PAGE = 0
/* BANK1 */ b1_dcsm_otp_z1_P0 : > B1_DCSM_OTP_Z1_P0 PAGE = 0 b1_dcsm_otp_z2_P0 : > B1_DCSM_OTP_Z2_P0 PAGE = 0
b1_dcsm_zsel_z1 : > B1_DCSM_ZSEL_Z1_P0 PAGE = 0 b1_dcsm_zsel_z2 : > B1_DCSM_ZSEL_Z2_P0 PAGE = 0
}
但是报出来的故障还是没变,如下:
C28xx_CPU1: Error during Flash Verification. Address 0x00078019, Expected 0x00009FFF, Read 0x0000FFFF
C28xx_CPU1: File Loader: Memory write failed: Unknown error
C28xx_CPU1: GEL: File: E:\workspace_v10\DVRSlaverLock\Debug\DVRSlaverLock.out: Load failed.
于是我将以下部分注释掉
; .long 0xFFFFFFFF ;Reserved; .long 0xFFFF9FFF ;Reserved; .long 0xFFFFFFFF ;Z1OTP_GPREG3; .long 0xFFFFFFFF ;Z1OTP_BOOTCTRL
但是又报出不同的故障,如下:
C28xx_CPU1: GEL Output:
Memory Map Initialization Complete
C28xx_CPU1: GEL Output: … DCSM Initialization Start …
C28xx_CPU1: GEL Output: … DCSM Initialization Done …
C28xx_CPU1: GEL Output: … DCSM Initialization Start …
C28xx_CPU1: GEL Output: … DCSM Initialization Done …
C28xx_CPU1: GEL Output: … DCSM Initialization Start …
C28xx_CPU1: GEL Output: … DCSM Initialization Done …
C28xx_CPU1: Error during Flash Programming. Address 0x00078210, Data 0x0000E010, FMSTAT 0x00000030
C28xx_CPU1: File Loader: Memory write failed: Unknown error
C28xx_CPU1: GEL: File: E:\workspace_v10\DVRSlaverLock\Debug\DVRSlaverLock.out: Load failed.
是不是我之前调试的时候最开始烧录了一个值,就固定了,需要换一块板子?
user6341694:
回复 user6341694:
请问,您那边有280049C的特定的DCSM加密的例程吗?我这边看了C2000里面的例程没有多大帮助,而且我是按照里面配置的,然后取消注释,自己配置的寄存器,但是感觉还是找不准方向,不知道是哪里出现的问题。
Green Deng:
回复 user6341694:
这边没有F280049C特定的DCSM例程,只有F2837xD的,不知道你这边是否有参考过?两者应该区别不大,位置在:
C:\ti\c2000\C2000Ware_3_01_00_00\device_support\f2837xd\examples\cpu1\blinky_with_DCSM\cpu01
Green Deng:
回复 user6341694:
user6341694之前调试的时候最开始烧录了一个值
是指在芯片的哪个内存部位烧录了一个值?一般不是烧写在OTP部分的话都不会固定。
user6341694:
回复 Green Deng:
这个有参考的,因为我们公司之前用过2837xD的,也做过相应的加密,可以正常使用的。我刚开始就是按照我们公司之前做的2837xD的加密代码做的,然后按照280049C的寄存器和2837xD不一样的地方相应更改,但是就是有问题,烧录不进去,一直报以下故障:
C28xx_CPU1: GEL Output:Memory Map Initialization CompleteC28xx_CPU1: GEL Output: … DCSM Initialization Start …C28xx_CPU1: GEL Output: … DCSM Initialization Done …C28xx_CPU1: GEL Output: … DCSM Initialization Start …C28xx_CPU1: GEL Output: … DCSM Initialization Done …C28xx_CPU1: GEL Output: … DCSM Initialization Start …C28xx_CPU1: GEL Output: … DCSM Initialization Done …C28xx_CPU1: Error during Flash programming (Flash algorithm returned error code). Operation cancelled.C28xx_CPU1: File Loader: Memory write failed: Unknown errorC28xx_CPU1: GEL: File: E:\DVR-CODE\DVRSlaverLock\Debug\DVRSlaverLock.out: Load failed.
后来我继续调试,并查找资料,看这个问题怎么解决,于是在一个连接里面找到了一种方式,链接为https://e2echina.ti.com/question_answer/microcontrollers/c2000/f/56/p/176131/576686#pi58711=2
但按照他的方式,我也遇到了相同的问题,可以烧录进去了,但是会使原来在板子里面的正式代码无法运行,用仿真器烧录(填写正确密码后)是可以正常烧录的(烧录成功后,代码正常运行),但是重新上电后就不会代码不会正常运行(通过板子上的一个灯判断的),而且看门狗似乎也没有复位,导致代码停止运行。我又换了最高版本的CCSV10以及64位电脑和编译器20.2.0,于是就出现了上面我提出的问题,而且还报出了具体位置的问题:
C28xx_CPU1: Error during Flash Programming. Address 0x00078010, Data 0x0000E000, FMSTAT 0x00000030C28xx_CPU1: File Loader: Memory write failed: Unknown errorC28xx_CPU1: GEL: File: E:\My Project\DVR\DVRSlaverLock\Debug\DVRSlaverLock.out: Load failed.
后来我有查找C2000里面是否有有关280049C的DCSM模块相关例程,于是看到TI员工说在C:\ti\c2000\C2000Ware_3_01_00_00\driverlib\f28004x\examples\led里面有例程,我又在这个例程的基础上更改了相关寄存器的配置,用64位电脑(最高版本的CCS和编译器)进行烧录,可以烧录进去,但是还是会导致正式代码不运行(换了块新板,之前没有烧过加密代码的)。
user6341694:
回复 Green Deng:
因为之前一直在调试,但是就是烧录不进去代码,于是我就会更改那些寄存器的配置,就是OTP部分的,有可能从0改到了1,但是后来我又换了一个新板子进行烧录(之前没有烧录过加密代码的),还是不行,会导致正式代码不会正常工作。