原有工程是基于ADS v1.2的,使用J-Flash ARM V4.14c把编译文件写入到Flash。
尝试将工程移植到IAR 6.3上,在使用IAR的示例工程GettingStarted的Debug NOR Flash模式下载运行后,再使用J-Flash ARM V4.14c进行连接Flash时出现下面的错误信息:
Connecting ...
- Connecting via USB to J-Link device 0
- J-Link firmware: V1.20 (J-Link ARM V8 compiled Sep 22 2011 16:23:23)
- JTAG speed: 8000 kHz (Auto)
- Initializing CPU core (Init sequence) ...
- Executing Reset (0, 200 ms)
- Initialized successfully
- JTAG speed: 8000 kHz (Auto)
- J-Link found 1 JTAG device. Core ID: 0x07926009 (ARM9)
- ERROR: Flash Id error. Expected 0x1227E, found: 0xF018E28F
- ERROR: Failed to connect
网上搜索页看到类似的问题,不过没有明确的解决办法,今天成功该问题,大体思路是既然Flash Id被覆盖了,那么就要考虑如何恢复。
在参考芯片手册的S29GL128N Command Definitions, x16表格后,找到Device ID项。
| Addr | Data | Addr | Data | Addr | Data | Addr | Data | Addr | Data | Addr | Data |
| 555 | AA | 2AA | 55 | 555 | 90 | X01 | 227E | X0E | Note17 | X0F | Note17 |
X = Don’t care
Note17. S29GL512NH/L = 2223h/23h, 220h/01h; S29GL256NH/L = 2222h/22h, 2201h/01h; S29GL128NH/L = 2221h/21h, 2201h/01h.
还是在示例工程GettingStarted,不过选择Debug xRAM模式,让其在外部内存上运行,并在main循环前加入下面代码进行重新设置Device ID:
typedef uint16 flashunit;
const uint32 flashBase = 0x10000000;
/* Flash Reset */
*(volatile flashunit *)flashBase = (flashunit)0x00F0;
for(volatile int i = 20; i; i--);
volatile flashunit Dummy = *(flashunit *)flashBase;
/* Device ID */
*((volatile flashunit *)flashBase + 0x555) = (flashunit)0x00AA;
*((volatile flashunit *)flashBase + 0x2AA) = (flashunit)0x0055;
*((volatile flashunit *)flashBase + 0x555) = (flashunit)0x0090;
*((volatile flashunit *)flashBase + 0x001) = (flashunit)0x227E;
*((volatile flashunit *)flashBase + 0x00E) = (flashunit)0x2201;
*((volatile flashunit *)flashBase + 0x00F) = (flashunit)0x0001;
调试运行之后,再次通过J-Flash ARM V4.14c进行连接,即认证成功。
Connecting ...
- Connecting via USB to J-Link device 0
- J-Link firmware: V1.20 (J-Link ARM V8 compiled Sep 22 2011 16:23:23)
- JTAG speed: 8000 kHz (Auto)
- Initializing CPU core (Init sequence) ...
- Executing Reset (0, 200 ms)
- Initialized successfully
- JTAG speed: 8000 kHz (Auto)
- J-Link found 1 JTAG device. Core ID: 0x07926009 (ARM9)
- Flash ID (Chip 0) = 0x1227E (Verified)
- Connected successfully
对上述实验的思考:
Flash硬件通过地址总线和数据总线与CPU相连接,程序根据芯片手册提供的Addr和Data的序列发送数据,同时Flash芯片识别该序列,并执行对应操作。
以上为个人思考,如有不妥,喷喷无妨。