共2条
1/1 1 跳转至页
lpc2114 lpc2114加密问题
问
手册上说,往flash的0x1fc处写入0x87654321,下次系统复位后,读保护有效:jtag口失效,isp功能被限制为只能读ID和整块擦除。
但我加密后的现象并不是这样。而是:
jtag仍有效,可进行仿真,观察memory的0x1fc数据确实为0x87654321.isp功能被限制为只能读ID和整块擦除。这与手册描述的不一致,大家碰到过这种现象吗?
我的加密程序加在VECTORS.S中,如下:
;********************************************************************************************************/
InitStack
MOV R0, LR
;设置管理模式堆栈
MSR CPSR_c, #0xd3
LDR SP, StackSvc
;设置中断模式堆栈
MSR CPSR_c, #0xd2
LDR SP, StackIrq
;设置快速中断模式堆栈
MSR CPSR_c, #0xd1
LDR SP, StackFiq
;设置中止模式堆栈
MSR CPSR_c, #0xd7
LDR SP, StackAbt
;设置未定义模式堆栈
MSR CPSR_c, #0xdb
LDR SP, StackUnd
;设置系统模式堆栈
MSR CPSR_c,#0xdf
LDR SP, StackUsr
MOV PC, R0
StackUsr DCD UsrStackSpace + (USR_STACK_LEGTH - 1) * 4
StackSvc DCD SvcStackSpace + (SVC_STACK_LEGTH - 1)* 4
StackIrq DCD IrqStackSpace + (IRQ_STACK_LEGTH - 1)* 4
StackFiq DCD FiqStackSpace + (FIQ_STACK_LEGTH - 1)* 4
StackAbt DCD AbtStackSpace + (ABT_STACK_LEGTH - 1)* 4
StackUnd DCD UndtStackSpace + (UND_STACK_LEGTH - 1)* 4
;/********************************************************************************************************/
;/*********************************************************************************************************
;** unction name 函数名称: CrpData
;** Descriptions 功能描述: encrypt the chip
;** input parameters 输 入: None 无
;** Returned value 输 出 : None 无
;** Used global variables 全局变量: None 无
;** Calling modules 调用模块: None 无
;**
;** Created by 作 者: Chenmingji 陈明计
;** Created Date 日 期: 2004/03/27 2004年3月27日
;**-------------------------------------------------------------------------------------------------------
;** Modified by 修 改:
;** Modified date 日 期:
;**-------------------------------------------------------------------------------------------------------
;*********************************************************************************************************/
;IF :DEF: EN_CRP
IF . >= 0x1fc
INFO 1,"\nThe data at 0x000001fc must be 0x87654321.\nPlease delete some source before this line."
ENDIF
CrpData
WHILE . < 0x1fc
NOP
WEND
CrpData1
DCD 0x87654321 ;/*When the Data is 为0x87654321,user code be protected. 当此数为0x87654321时,用户程序被保护 */
;ENDIF
;/* 分配堆栈空间 */
AREA MyStacks, DATA, NOINIT, ALIGN=2
UsrStackSpace SPACE USR_STACK_LEGTH * 4 ;用户(系统)模式堆栈空间
SvcStackSpace SPACE SVC_STACK_LEGTH * 4 ;管理模式堆栈空间
IrqStackSpace SPACE IRQ_STACK_LEGTH * 4 ;中断模式堆栈空间
FiqStackSpace SPACE FIQ_STACK_LEGTH * 4 ;快速中断模式堆栈空间
AbtStackSpace SPACE ABT_STACK_LEGTH * 4 ;中止义模式堆栈空间
UndtStackSpace SPACE UND_STACK_LEGTH * 4 ;未定义模式堆栈
END
答 1: 您使用的是我们的工程模板吗?目标选择RelInFlash即可加密。 答 2: 没有使用模版.没有使用模版.通过程序修改效果应该一样的吧
答 3: 在环境中定义一下这个变量EN_CRP即可,没看是条件编译吗 答 4: 再补一点,查看你的代码,看看,如果如下,肯定行 StackIrq
0x000000c0: 40001e0c ...@ DCD 1073749516
StackFiq
0x000000c4: 40001e4c L..@ DCD 1073749580
StackAbt
0x000000c8: 40001e4c L..@ DCD 1073749580
StackUnd
0x000000cc: 40001e4c L..@ DCD 1073749580
CrpData
$a
0x000000d0: e1a00000 .... NOP
0x000000d4: e1a00000 .... NOP
0x000000d8: e1a00000 .... NOP
0x000000dc: e1a00000 .... NOP
0x000000e0: e1a00000 .... NOP
0x000000e4: e1a00000 .... NOP
0x000000e8: e1a00000 .... NOP
0x000000ec: e1a00000 .... NOP
0x000000f0: e1a00000 .... NOP
0x000000f4: e1a00000 .... NOP
0x000000f8: e1a00000 .... NOP
0x000000fc: e1a00000 .... NOP
0x00000100: e1a00000 .... NOP
0x00000104: e1a00000 .... NOP
0x00000108: e1a00000 .... NOP
0x0000010c: e1a00000 .... NOP
0x00000110: e1a00000 .... NOP
0x00000114: e1a00000 .... NOP
0x00000118: e1a00000 .... NOP
0x0000011c: e1a00000 .... NOP
0x00000120: e1a00000 .... NOP
0x00000124: e1a00000 .... NOP
0x00000128: e1a00000 .... NOP
0x0000012c: e1a00000 .... NOP
0x00000130: e1a00000 .... NOP
0x00000134: e1a00000 .... NOP
0x00000138: e1a00000 .... NOP
0x0000013c: e1a00000 .... NOP
0x00000140: e1a00000 .... NOP
0x00000144: e1a00000 .... NOP
0x00000148: e1a00000 .... NOP
0x0000014c: e1a00000 .... NOP
0x00000150: e1a00000 .... NOP
0x00000154: e1a00000 .... NOP
0x00000158: e1a00000 .... NOP
0x0000015c: e1a00000 .... NOP
0x00000160: e1a00000 .... NOP
0x00000164: e1a00000 .... NOP
0x00000168: e1a00000 .... NOP
0x0000016c: e1a00000 .... NOP
0x00000170: e1a00000 .... NOP
0x00000174: e1a00000 .... NOP
0x00000178: e1a00000 .... NOP
0x0000017c: e1a00000 .... NOP
0x00000180: e1a00000 .... NOP
0x00000184: e1a00000 .... NOP
0x00000188: e1a00000 .... NOP
0x0000018c: e1a00000 .... NOP
0x00000190: e1a00000 .... NOP
0x00000194: e1a00000 .... NOP
0x00000198: e1a00000 .... NOP
0x0000019c: e1a00000 .... NOP
0x000001a0: e1a00000 .... NOP
0x000001a4: e1a00000 .... NOP
0x000001a8: e1a00000 .... NOP
0x000001ac: e1a00000 .... NOP
0x000001b0: e1a00000 .... NOP
0x000001b4: e1a00000 .... NOP
0x000001b8: e1a00000 .... NOP
0x000001bc: e1a00000 .... NOP
0x000001c0: e1a00000 .... NOP
0x000001c4: e1a00000 .... NOP
0x000001c8: e1a00000 .... NOP
0x000001cc: e1a00000 .... NOP
0x000001d0: e1a00000 .... NOP
0x000001d4: e1a00000 .... NOP
0x000001d8: e1a00000 .... NOP
0x000001dc: e1a00000 .... NOP
0x000001e0: e1a00000 .... NOP
0x000001e4: e1a00000 .... NOP
0x000001e8: e1a00000 .... NOP
0x000001ec: e1a00000 .... NOP
0x000001f0: e1a00000 .... NOP
0x000001f4: e1a00000 .... NOP
0x000001f8: e1a00000 .... NOP
CrpData1
$d
0x000001fc: 87654321 !Ce. DCD 2271560481
$f
0x00000200: 00000000 .... DCD 0
0x00000204: e01fc040 @... DCD 3760177216
__main
但我加密后的现象并不是这样。而是:
jtag仍有效,可进行仿真,观察memory的0x1fc数据确实为0x87654321.isp功能被限制为只能读ID和整块擦除。这与手册描述的不一致,大家碰到过这种现象吗?
我的加密程序加在VECTORS.S中,如下:
;********************************************************************************************************/
InitStack
MOV R0, LR
;设置管理模式堆栈
MSR CPSR_c, #0xd3
LDR SP, StackSvc
;设置中断模式堆栈
MSR CPSR_c, #0xd2
LDR SP, StackIrq
;设置快速中断模式堆栈
MSR CPSR_c, #0xd1
LDR SP, StackFiq
;设置中止模式堆栈
MSR CPSR_c, #0xd7
LDR SP, StackAbt
;设置未定义模式堆栈
MSR CPSR_c, #0xdb
LDR SP, StackUnd
;设置系统模式堆栈
MSR CPSR_c,#0xdf
LDR SP, StackUsr
MOV PC, R0
StackUsr DCD UsrStackSpace + (USR_STACK_LEGTH - 1) * 4
StackSvc DCD SvcStackSpace + (SVC_STACK_LEGTH - 1)* 4
StackIrq DCD IrqStackSpace + (IRQ_STACK_LEGTH - 1)* 4
StackFiq DCD FiqStackSpace + (FIQ_STACK_LEGTH - 1)* 4
StackAbt DCD AbtStackSpace + (ABT_STACK_LEGTH - 1)* 4
StackUnd DCD UndtStackSpace + (UND_STACK_LEGTH - 1)* 4
;/********************************************************************************************************/
;/*********************************************************************************************************
;** unction name 函数名称: CrpData
;** Descriptions 功能描述: encrypt the chip
;** input parameters 输 入: None 无
;** Returned value 输 出 : None 无
;** Used global variables 全局变量: None 无
;** Calling modules 调用模块: None 无
;**
;** Created by 作 者: Chenmingji 陈明计
;** Created Date 日 期: 2004/03/27 2004年3月27日
;**-------------------------------------------------------------------------------------------------------
;** Modified by 修 改:
;** Modified date 日 期:
;**-------------------------------------------------------------------------------------------------------
;*********************************************************************************************************/
;IF :DEF: EN_CRP
IF . >= 0x1fc
INFO 1,"\nThe data at 0x000001fc must be 0x87654321.\nPlease delete some source before this line."
ENDIF
CrpData
WHILE . < 0x1fc
NOP
WEND
CrpData1
DCD 0x87654321 ;/*When the Data is 为0x87654321,user code be protected. 当此数为0x87654321时,用户程序被保护 */
;ENDIF
;/* 分配堆栈空间 */
AREA MyStacks, DATA, NOINIT, ALIGN=2
UsrStackSpace SPACE USR_STACK_LEGTH * 4 ;用户(系统)模式堆栈空间
SvcStackSpace SPACE SVC_STACK_LEGTH * 4 ;管理模式堆栈空间
IrqStackSpace SPACE IRQ_STACK_LEGTH * 4 ;中断模式堆栈空间
FiqStackSpace SPACE FIQ_STACK_LEGTH * 4 ;快速中断模式堆栈空间
AbtStackSpace SPACE ABT_STACK_LEGTH * 4 ;中止义模式堆栈空间
UndtStackSpace SPACE UND_STACK_LEGTH * 4 ;未定义模式堆栈
END
答 1: 您使用的是我们的工程模板吗?目标选择RelInFlash即可加密。 答 2: 没有使用模版.没有使用模版.通过程序修改效果应该一样的吧
答 3: 在环境中定义一下这个变量EN_CRP即可,没看是条件编译吗 答 4: 再补一点,查看你的代码,看看,如果如下,肯定行 StackIrq
0x000000c0: 40001e0c ...@ DCD 1073749516
StackFiq
0x000000c4: 40001e4c L..@ DCD 1073749580
StackAbt
0x000000c8: 40001e4c L..@ DCD 1073749580
StackUnd
0x000000cc: 40001e4c L..@ DCD 1073749580
CrpData
$a
0x000000d0: e1a00000 .... NOP
0x000000d4: e1a00000 .... NOP
0x000000d8: e1a00000 .... NOP
0x000000dc: e1a00000 .... NOP
0x000000e0: e1a00000 .... NOP
0x000000e4: e1a00000 .... NOP
0x000000e8: e1a00000 .... NOP
0x000000ec: e1a00000 .... NOP
0x000000f0: e1a00000 .... NOP
0x000000f4: e1a00000 .... NOP
0x000000f8: e1a00000 .... NOP
0x000000fc: e1a00000 .... NOP
0x00000100: e1a00000 .... NOP
0x00000104: e1a00000 .... NOP
0x00000108: e1a00000 .... NOP
0x0000010c: e1a00000 .... NOP
0x00000110: e1a00000 .... NOP
0x00000114: e1a00000 .... NOP
0x00000118: e1a00000 .... NOP
0x0000011c: e1a00000 .... NOP
0x00000120: e1a00000 .... NOP
0x00000124: e1a00000 .... NOP
0x00000128: e1a00000 .... NOP
0x0000012c: e1a00000 .... NOP
0x00000130: e1a00000 .... NOP
0x00000134: e1a00000 .... NOP
0x00000138: e1a00000 .... NOP
0x0000013c: e1a00000 .... NOP
0x00000140: e1a00000 .... NOP
0x00000144: e1a00000 .... NOP
0x00000148: e1a00000 .... NOP
0x0000014c: e1a00000 .... NOP
0x00000150: e1a00000 .... NOP
0x00000154: e1a00000 .... NOP
0x00000158: e1a00000 .... NOP
0x0000015c: e1a00000 .... NOP
0x00000160: e1a00000 .... NOP
0x00000164: e1a00000 .... NOP
0x00000168: e1a00000 .... NOP
0x0000016c: e1a00000 .... NOP
0x00000170: e1a00000 .... NOP
0x00000174: e1a00000 .... NOP
0x00000178: e1a00000 .... NOP
0x0000017c: e1a00000 .... NOP
0x00000180: e1a00000 .... NOP
0x00000184: e1a00000 .... NOP
0x00000188: e1a00000 .... NOP
0x0000018c: e1a00000 .... NOP
0x00000190: e1a00000 .... NOP
0x00000194: e1a00000 .... NOP
0x00000198: e1a00000 .... NOP
0x0000019c: e1a00000 .... NOP
0x000001a0: e1a00000 .... NOP
0x000001a4: e1a00000 .... NOP
0x000001a8: e1a00000 .... NOP
0x000001ac: e1a00000 .... NOP
0x000001b0: e1a00000 .... NOP
0x000001b4: e1a00000 .... NOP
0x000001b8: e1a00000 .... NOP
0x000001bc: e1a00000 .... NOP
0x000001c0: e1a00000 .... NOP
0x000001c4: e1a00000 .... NOP
0x000001c8: e1a00000 .... NOP
0x000001cc: e1a00000 .... NOP
0x000001d0: e1a00000 .... NOP
0x000001d4: e1a00000 .... NOP
0x000001d8: e1a00000 .... NOP
0x000001dc: e1a00000 .... NOP
0x000001e0: e1a00000 .... NOP
0x000001e4: e1a00000 .... NOP
0x000001e8: e1a00000 .... NOP
0x000001ec: e1a00000 .... NOP
0x000001f0: e1a00000 .... NOP
0x000001f4: e1a00000 .... NOP
0x000001f8: e1a00000 .... NOP
CrpData1
$d
0x000001fc: 87654321 !Ce. DCD 2271560481
$f
0x00000200: 00000000 .... DCD 0
0x00000204: e01fc040 @... DCD 3760177216
__main
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
与电子爱好者谈读图二被打赏50分 | |
【FRDM-MCXN947评测】Core1适配运行FreeRtos被打赏50分 | |
【FRDM-MCXN947评测】双核调试被打赏50分 | |
【CPKCORRA8D1B评测】---移植CoreMark被打赏50分 | |
【CPKCORRA8D1B评测】---打开硬件定时器被打赏50分 | |
【FRDM-MCXA156评测】4、CAN loopback模式测试被打赏50分 | |
【CPKcorRA8D1评测】--搭建初始环境被打赏50分 | |
【FRDM-MCXA156评测】3、使用FlexIO模拟UART被打赏50分 | |
【FRDM-MCXA156评测】2、rt-thread MCXA156 BSP制作被打赏50分 | |
【FRDM-MCXN947评测】核间通信MUTEX被打赏50分 |