NXP

质疑:“中断向量表中所有数据32位累加和为0”,lpc芯片真的做校验了吗?

2019-07-12 12:00发布

我在使用LPC2294时的新发现: 在NXP的LPC21XX、LPC22XX中,规定“中断向量表中所有数据32位累加和为0,否则程序不能脱机运行。”我发现这个规则完全是没有用的。 中文规则是周立功公司翻译过来的,我不大相信,所以找到了英文的描述。 原文的在NXP的LPC英文用户手册(LPC2119/2129/2194/2292/2294 USER MANUAL  2004 May 03) 第263页这样写道: Criterion for valid user code: The reserved ARM interrupt vector location (0x0000 0014) should contain the 2’s complement of  the check-sum of the remaining interrupt vectors. This causes the checksum of all of the vectors together to be 0. The boot loader code disables the overlaying of the interrupt vectors from the boot block, then calculates the checksum of the interrupt vectors in sector 0 of the flash. If the signatures match then the execution control is transferred to the user code by loading the program counter with 0x 0000 0000. Hence the user flash reset vector should contain a jump instruction to the entry point of the user application code. 这个描述的意思是在中断向量表的0x00000014这个地方,要放入检查字,让编译后向量表中所有数据32位累加和为0,否则会影响程序的脱机运行,通常的情况是JTAG调试正常,但程序无法脱机运行! 然而,经过我的实验,将启动代码中的第0x00000014的数随便改变,让中断向量表中所有数据32位累加和不为0,将程序脱机运行,结果一样,根本不影响LPC2294的启动,一点问题也没有! 下面是我的lpc2294的启动代码: ;中断向量表
Reset
        LDR     PC, ResetAddr
        LDR     PC, UndefinedAddr
        LDR     PC, SWI_Addr
        LDR     PC, PrefetchAddr
        LDR     PC, DataAbortAddr
        DCD     0xaaaaaaaa
;       0xb9205f80                            原来是这个,将它注释掉改为0xaaaaaaaa
;       NOP                                      或者改为nop指令,根本不影响脱机运行!
        LDR     PC, [PC, #-0xff0]
        LDR     PC, FIQ_Addr
ResetAddr           DCD     ResetInit
UndefinedAddr       DCD     Undefined
SWI_Addr            DCD     SoftwareInterrupt
PrefetchAddr        DCD     PrefetchAbort
DataAbortAddr       DCD     DataAbort
Nouse               DCD     0
IRQ_Addr            DCD     0
FIQ_Addr            DCD     FIQ_Handler
贴出来,不知道其他人的是什么情况,大家实验一下。 应该是NXP弄错了吧,启动时根本没检查用户代码的有效性哦!         找到问题了,是用H-JTAG软件下载时,在H-Flasher中有选项 是否检查LPC2000的校验值。应该是我在ADS中改完之后,在下载是H-Flasher自己把这个值做了校验,改为正确的值了。 现在没时间,等等我在用ISP下载试试看