上篇详细的介绍了加密锁定Kinetis的一种方法,本篇再接再厉,给大家再介绍一种加密方法(哎,这点家底都晒出来了)。当然实际上原理还是不变的,即还是通过修改0x400~0x40F地址段的内容来实现加密锁定,万变不离其宗,所谓殊途同归罢了,下面好戏登台:
既然实现security最终都是改写寄存器加载段flash地址的内容,那实际上修改flash内容的方式还是灵活多变的,方案一中提到的在中断向量表的最后添加flash配置信息只是其中一种,那还有哪些呢?还是不摆谱了,小心被拍砖,哈哈。不错,那就是通过在指定地址定义常量的方法,当然定义常量大家都会用到(有些应用譬如LCD显示的字模或者一些固定的查找表为节省RAM空间我们一般会选择定义const常量的方法将它们存放到flash空间中),但是指定地址的存放方式用的会少些(一般都是让编译器自动分配的),如果我们非要指定地址呢(哎,强迫症又开始了,呵呵),即将flash配置信息作为常量强制指定存放到0x400起始的地址,那岂不是跟方案一有了异曲同工之妙了,好吧,这样的话那就该“@”这位老兄上场了(咳咳,可不是给单片机发email啊,呵呵),相信很多人到此处就都明白了。下面我仍然以IAR环境下锁定K60为例,简单介绍下方案二的使用步骤:
1. 打开待加密工程中的main.c文件,在其中的main函数之前以添加如下图所示常量定义,即将FlashConfig数据组数据存放到“.flashConfig”段中,其中FlashConfig[11]即为0x40C地址:
16257078069558.png (39.1 KB, 下载次数: 0)
下载附件
2013-10-27 15:22 上传
3. 编译通过,下载调试,程序下载之后同样会出现进入不到调试窗口的现象,这个是正常现象,因为这个时候芯片就已经被security了,这样就可以放心量产了,呵呵~
希望这两篇系列文章能对大家有所帮助,enjoy it~
谢谢楼主分享~
楼主,使用第一种方法发现我的vectors.c中没有4个CONIFG_x配置信息,于是改用你的第二种方法.
但是,在debug时后出现:
Wed Jun 25, 2014 16:35:33: Logging to file: D:projectscspycomm.log
Wed Jun 25, 2014 16:35:33: JLINK command: ProjectFile = D:projectssettings
GPIO_demo_frdm_FLASH_64KB_PFLASH.jlink, return = 0
Wed Jun 25, 2014 16:35:33: Device "MKE02Z16XXX2" selected (16 KB flash, 2 KB RAM).
Wed Jun 25, 2014 16:35:33: DLL version: V4.74a, compiled Jul 23 2013 08:47:58
Wed Jun 25, 2014 16:35:33: Firmware: J-Link ARM V8 compiled Sep 20 2013 15:09:45
Wed Jun 25, 2014 16:35:33: Selecting SWD as current target interface.
Wed Jun 25, 2014 16:35:33: JTAG speed is initially set to: 32 kHz
Wed Jun 25, 2014 16:35:33: Found SWD-DP with ID 0x0BC11477
Wed Jun 25, 2014 16:35:33: Found SWD-DP with ID 0x0BC11477
Wed Jun 25, 2014 16:35:33: FPUnit: 2 code (BP) slots and 0 literal slots
Wed Jun 25, 2014 16:35:33: Found Cortex-M0 r0p0, Little endian.
Wed Jun 25, 2014 16:35:34: Hardware reset with strategy 0 was performed
Wed Jun 25, 2014 16:35:34: Initial reset was performed
Wed Jun 25, 2014 16:35:35: J-Link: Flash download: Flash programming performed for 1 range (512 bytes)
Wed Jun 25, 2014 16:35:35: J-Link: Flash download: Total time needed: 1.418s (Prepare: 1.280s, Compare: 0.032s, Erase: 0.023s, Program: 0.031s,
Verify: 0.015s, Restore: 0.035s)
Wed Jun 25, 2014 16:35:35: 14696 bytes downloaded and verified (8.50 Kbytes/sec)
Wed Jun 25, 2014 16:35:35: Warning:
Verify error at address 0x0000040E, target byte: 0xFE, byte in file: 0xFF //这里说明我没写进去?
Wed Jun 25, 2014 16:35:37: Warning: There were warnings during download, see Log Window
Wed Jun 25, 2014 16:35:37: Loaded debugee: D:projectsGPIO_demo_frdm.out
Wed Jun 25, 2014 16:35:37: Hardware reset with strategy 0 was performed
Wed Jun 25, 2014 16:35:37: Target reset
Wed Jun 25, 2014 16:35:38: There was 1 warning during the initialization of the debugging session.
一周热门 更多>