Dear All:
尝试使用F28002X 的DCSM对程序加密,TI FAE的那个使用DCSM相关的使用也看了,F2800X的 dcsm_security_tool列程也看过了,
都没说清楚,如何在如何在28002X_FLASH_lnk.cmd 添加相关DSCM的CMD文件?
根据F2800X的 dcsm_security_tool的列程,在工程中添加了dcsm.asm程序:
;----------------------------------------------------------------------
; Zone 1
;----------------------------------------------------------------------
.sect "dcsm_otp_z1_linkpointer"
.retain
.long 0x1FFFFFFF ;Z1-LINKPOINTER1
.long 0xFFFFFFFF ;Reserved
.long 0x1FFFFFFF ;B0_Z1OTP_LINKPOINTER2
.long 0xFFFFFFFF ;Reserved
.long 0x1FFFFFFF ;B0_Z1OTP_LINKPOINTER3
.long 0xFFFFFFFF ;Reserved
.sect "dcsm_otp_z1_pswdlock"
.retain
.long 0xFB7FFFFF ;Z1-PSWDLOCK
.long 0x7FFFFFFF ;Reserved
.sect "dcsm_otp_z1_crclock"
.retain
.long 0x4BFFFFFF ;Z1-CRCLOCK
.long 0x3FFFFFFF ;Reserved
;; .sect "dcsm_otp_z1_gpreg"
;; .retain
;; .long 0x5AFF1921 ;Z1OTP_BOOTPIN_CONFIG
;; .long 0x5AFFFFff ;Z1OTP_GPREG2
;; .sect "dcsm_otp_z1_bootctrl"
;; .retain
;; .long 0x00000000 ;Z1OTP_BOOTDEF_LOW
;; .long 0xFFFFFFFF ;Z1OTP_BOOTDEF_HIGH
.sect "dcsm_zsel_z1"
.retain
.long 0x000000F0 ;Z1-EXEONLYRAM
.long 0x0000FFFF ;Z1-EXEONLYSECT
.long 0x0000AA00 ;Z1-GRABRAM
.long 0xAAAAAAAA ;Z1-GRABSECT
.long 0xFFFFFFFF ;Z1-CSMPSWD0 (LSW of 128-bit password)
.long 0x47FFFFFF ;Z1-CSMPSWD1 // this value is for ZSB0
.long 0xFFFFFFFF ;Z1-CSMPSWD2
.long 0xFFFFFFFF ;Z1-CSMPSWD3 (MSW of 128-bit password)
;----------------------------------------------------------------------
; For code security operation,after development has completed, prior to
; production, all other zone select block locations should be programmed
; to 0x0000 for maximum security.
; If the first zone select block at offset 0x10 is used, the section
; "dcsm_rsvd_z1" can be used to program these locations to 0x0000.
; This code is commented out for development.
; .sect "dcsm_rsvd_z1"
; .loop (1e0h)
; .int 0x0000
; .endloop
;----------------------------------------------------------------------
; Zone 2
;----------------------------------------------------------------------
.sect "dcsm_otp_z2_linkpointer"
.retain
.long 0x1FFFFFFF ;B0_Z2OTP_LINKPOINTER1
.long 0xFFFFFFFF ;Reserved
.long 0x1FFFFFFF ;B0_Z2OTP_LINKPOINTER2
.long 0xFFFFFFFF ;Reserved
.long 0x1FFFFFFF ;B0_Z2OTP_LINKPOINTER3
.long 0xFFFFFFFF ;Reserved
.sect "dcsm_otp_z2_pswdlock"
.retain
.long 0xBF7FFFFF ;Z2-PSWDLOCK
.long 0x77FFFFFF ;Reserved
.sect "dcsm_otp_z2_crclock"
.retain
.long 0x0FFFFFFF ;Z2-CRCLOCK
.long 0x37FFFFFF ;Reserved
;; .sect "dcsm_otp_z2_gpreg"
;; .retain
;; .long 0x5AFF1921 ;Z2OTP_BOOTPIN_CONFIG
;; .long 0x5AFFFFff ;Z2OTP_GPREG2
;; .sect "dcsm_otp_z2_bootctrl"
;; .retain
;; .long 0x00000000 ;Z2OTP_BOOTDEF_LOW
;; .long 0xFFFFFFFF ;Z2OTP_BOOTDEF_HIGH
.sect "dcsm_zsel_z2"
.retain
.long 0x000000F0 ;z2-EXEONLYRAM
.long 0x0000FFFF ;z2-EXEONLYSECT
.long 0x0000AA00 ;z2-GRABRAM
.long 0xAAAAAAAA ;z2-GRABSECT
.long 0xFFFFFFFF ;B0_Z2OTP_CSMPSWD0 (LSW of 128-bit password)
.long 0xE3FFFFFF ;B0_Z2OTP_CSMPSWD1
.long 0xFFFFFFFF ;B0_Z2OTP_CSMPSWD2
.long 0xFFFFFFFF ;B0_Z2OTP_CSMPSWD3 (MSW of 128-bit password)
;----------------------------------------------------------------------
; For code security operation,after development has completed, prior to
; production, all other zone select block locations should be programmed
; to 0x0000 for maximum security.
; If the first zone select block at offset 0x10 is used, the section
; "dcsm_rsvd_z2" can be used to program these locations to 0x0000.
; This code is commented out for development.
; .sect "dcsm_rsvd_z2"
; .loop (1e0h)
; .int 0x0000
; .endloop
;----------------------------------------------------------------------
; End of file
;----------------------------------------------------------------------
F2800X的 dcsm_security_tool的列程中有相关的dcsm.cmd文件,如下图:
但是例程的28002X_generic_flash_lnk.cmd文件中没有如何相关DCSM的内容,说明DCSM的存储应该是dcsm.cmd文件的,
现在是如何把dcsm.cmd的内容移植到我的项目工程文件中?
方式1,直接把dcsm.cmd的内容复制到28002X_FLASH_lnk.cmd文件中,程序编译不通过!
MEMORY
{
PAGE 0 : /* Program Memory */
/* Z1 OTP. LinkPointers */
DCSM_OTP_Z1_LINKPOINTER : origin = 0x78000, length = 0x00000C
/* Z1 OTP. GPREG1/GPREG2 */
DCSM_OTP_Z1_GPREG : origin = 0x7800C, length = 0x000004
/* Z1 OTP. PSWDLOCK/RESERVED */
DCSM_OTP_Z1_PSWDLOCK : origin = 0x78010, length = 0x000004
/* Z1 OTP. CRCLOCK/RESERVED */
DCSM_OTP_Z1_CRCLOCK : origin = 0x78014, length = 0x000004
/* Z1 OTP. RESERVED/BOOTCTRL */
DCSM_OTP_Z1_BOOTCTRL : origin = 0x7801C, length = 0x000004
/* DCSM Z1 Zone Select Contents (!!Movable!!) */
/* Z1 OTP. Z1 password locations / Flash and RAM partitioning */
DCSM_ZSEL_Z1_P0 : origin = 0x78020, length = 0x000010
/* Z2 OTP. LinkPointers */
DCSM_OTP_Z2_LINKPOINTER : origin = 0x78200, length = 0x00000C
/* Z2 OTP. GPREG1/GPREG2 */
DCSM_OTP_Z2_GPREG : origin = 0x7820C, length = 0x000004
/* Z2 OTP. PSWDLOCK/RESERVED */
DCSM_OTP_Z2_PSWDLOCK : origin = 0x78210, length = 0x000004
/* Z2 OTP. CRCLOCK/RESERVED */
DCSM_OTP_Z2_CRCLOCK : origin = 0x78214, length = 0x000004
/* Z2 OTP. GPREG3/BOOTCTRL */
DCSM_OTP_Z2_BOOTCTRL : origin = 0x7821C, length = 0x000004
/* DCSM Z1 Zone Select Contents (!!Movable!!) */
/* Z2 OTP. Z2 password locations / Flash and RAM partitioning */
DCSM_ZSEL_Z2_P0 : origin = 0x78220, length = 0x000010
BEGIN : origin = 0x080000, length = 0x000002
BOOT_RSVD : origin = 0x00000002, length = 0x00000126
RAMM0 : origin = 0x00000128, length = 0x000002D8
RAMM1 : origin = 0x00000400, length = 0x000003F8 /* on-chip RAM block M1 */
// RAMM1_RSVD : origin = 0x000007F8, length = 0x00000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
/* RAMLS4 : origin = 0x0000A000, length = 0x00000800
RAMLS5 : origin = 0x0000A800, length = 0x00000800
RAMLS6 : origin = 0x0000B000, length = 0x00000800
RAMLS7 : origin = 0x0000B800, length = 0x00000800 */
/* Combining all the LS RAMs */
RAMLS4567 : origin = 0x0000A000, length = 0x00002400
RAMGS0 : origin = 0x0000C400, length = 0x000003FC
// RAMGS0_RSVD : origin = 0x0000C7F8, length = 0x00000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
RESET : origin = 0x003FFFC0, length = 0x00000002
BOOTROM : origin = 0x003F0000, length = 0x00008000
BOOTROM_EXT : origin = 0x003F8000, length = 0x00007FC0
/* Flash sectors */
/* BANK 0 */
// FLASHBANK0 : origin = 0x00080000, length = 0x00007FF0
FLASH_BANK0_SEC0 : origin = 0x080002, length = 0x000FFE /* on-chip Flash */
FLASH_BANK0_SEC1 : origin = 0x081000, length = 0x001000 /* on-chip Flash */
FLASH_BANK0_SEC2 : origin = 0x082000, length = 0x001000 /* on-chip Flash */
FLASH_BANK0_SEC3 : origin = 0x083000, length = 0x001000 /* on-chip Flash */
FLASH_BANK0_SEC4 : origin = 0x084000, length = 0x001000 /* on-chip Flash */
FLASH_BANK0_SEC5 : origin = 0x085000, length = 0x001000 /* on-chip Flash */
FLASH_BANK0_SEC6 : origin = 0x086000, length = 0x001000 /* on-chip Flash */
FLASH_BANK0_SEC7 : origin = 0x087000, length = 0x000FF0 /* on-chip Flash */
// FLASH_BANK0_SEC7_RSVD : origin = 0x087FF0, length = 0x000010 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
}
SECTIONS
{
dcsm_otp_z1_linkpointer : > DCSM_OTP_Z1_LINKPOINTER PAGE = 0
dcsm_otp_z1_gpreg : > DCSM_OTP_Z1_GPREG PAGE = 0
dcsm_otp_z1_pswdlock : > DCSM_OTP_Z1_PSWDLOCK PAGE = 0
dcsm_otp_z1_crclock : > DCSM_OTP_Z1_CRCLOCK PAGE = 0
dcsm_otp_z1_bootctrl : > DCSM_OTP_Z1_BOOTCTRL PAGE = 0
dcsm_zsel_z1 : > DCSM_ZSEL_Z1_P0 PAGE = 0
dcsm_otp_z2_linkpointer : > DCSM_OTP_Z2_LINKPOINTER PAGE = 0
dcsm_otp_z2_gpreg : > DCSM_OTP_Z2_GPREG PAGE = 0
dcsm_otp_z2_pswdlock : > DCSM_OTP_Z2_PSWDLOCK PAGE = 0
dcsm_otp_z2_crclock : > DCSM_OTP_Z2_CRCLOCK PAGE = 0
dcsm_otp_z2_bootctrl : > DCSM_OTP_Z2_BOOTCTRL PAGE = 0
dcsm_zsel_z2 : > DCSM_ZSEL_Z2_P0 PAGE = 0
codestart : > BEGIN, ALIGN(8)
.text : >> FLASH_BANK0_SEC2 | FLASH_BANK0_SEC3 | FLASH_BANK0_SEC4| FLASH_BANK0_SEC5| FLASH_BANK0_SEC6| FLASH_BANK0_SEC7, ALIGN(8)
.cinit : > FLASH_BANK0_SEC1, ALIGN(8)
.switch : > FLASH_BANK0_SEC1, ALIGN(8)
.reset : > RESET, TYPE = DSECT /* not used, */
.stack : > RAMM1
.init_array : > FLASH_BANK0_SEC1, ALIGN(8)
.bss : > RAMLS4567
.bss:output : > RAMLS4567
.bss:cio : > RAMGS0
.const : > FLASH_BANK0_SEC1, ALIGN(8)
.data : > RAMLS4567
.sysmem : > RAMLS4567
ramgs0 : > RAMGS0
/* Allocate IQ math areas: */
IQmath : > RAMLS4567
IQmathTables : > RAMLS4567
.TI.ramfunc : LOAD = FLASH_BANK0_SEC1,
RUN = RAMGS0,
LOAD_START(RamfuncsLoadStart),
LOAD_SIZE(RamfuncsLoadSize),
LOAD_END(RamfuncsLoadEnd),
RUN_START(RamfuncsRunStart),
RUN_SIZE(RamfuncsRunSize),
RUN_END(RamfuncsRunEnd),
ALIGN(8)
}
/*
//===========================================================================
// End of file.
//===========================================================================
*/
方式2:直接添加dcsm.cmd文件到工程文件中,也是无法编译通过!
或者移植的dcsm.cmd的内容是否有错误?只要其中一部份?
如何具体操作?把DCSM加密功能实现?
这个问题已经困恼好几天,还是无法解决?