В статье описана проблема запуска отладки в IAR Embedded Workbench for ARM из-за неправильно сконфигурированного загрузчика кода.
[Симптомы]
Проект настроен для запуска и работы из flash (в настройках линкера выбран файл конфигурации $PROJ_DIR$\..\at91lib\board\at91sam7x256\flash.icf). После успешной компиляции маленькое окошко "Progress... Programming flash" некоторое время висит, а потом вываливается ошибка J-Link (ошибки могут быть разные, но чаще всего это что-то типа "Read memory error @ address 0xFFFFFF68, word access: Core error.", "Read memory error @ address 0xFFFFFF68, word access: Core error. Bad JTAG communication: Write to IR: Expected 0x1, got 0xf (TAP Command : 15) @ Off 0x5.").
В логе отладки (Debug log) выводится следующее:
Wed Jul 14 11:46:50 2010: Loaded macro file: C:\Program Files\IAR Systems\Embedded Workbench 5.0 Evaluation\ARM\config\flashloader\Atmel\FlashAT91SAM7X.mac Wed Jul 14 11:46:50 2010: Logging to file: C:\asm\FreeRTOS\Demo\uIP_Demo_IAR_ARM7\ewp\cspycomm.log Wed Jul 14 11:46:50 2010: DLL version: V3.96, compiled Oct 31 2008 19:06:25 Wed Jul 14 11:46:50 2010: Firmware: J-Link compiled Jul 30 2008 11:24:37 ARM Rev.5 Wed Jul 14 11:46:50 2010: JTAG speed is using adaptive clocking (RTCK signal) Wed Jul 14 11:46:50 2010: Initial reset was performed Wed Jul 14 11:46:50 2010: TotalIRLen = 4, IRPrint = 0x01 Wed Jul 14 11:46:50 2010: J-Link found 1 JTAG device(s). ARM core Id: 3F0F0F0F ARM7 Wed Jul 14 11:46:50 2010: Device at TAP0 selected Wed Jul 14 11:46:50 2010: JLINK command: ProjectFile = C:\asm\FreeRTOS\Demo\uIP_Demo_IAR_ARM7\ewp\settings\rtosdemo_Debug.jlink, return = 0 Wed Jul 14 11:46:50 2010: JLINK command: device = AT91SAM7X256, return = 0 Wed Jul 14 11:46:50 2010: ---------------------------------------- FLASH Download V1.3 Wed Jul 14 11:46:50 2010: ---------------------------------------- 14/November/2005 Wed Jul 14 11:46:50 2010: TotalIRLen = 4, IRPrint = 0x01 Wed Jul 14 11:46:50 2010: Hardware reset with strategy 0 was performed Wed Jul 14 11:46:50 2010: Set Main Oscillator Wed Jul 14 11:46:50 2010: Set PLL to 96MHz Wed Jul 14 11:46:50 2010: Set Master Clock to 48MHz Wed Jul 14 11:46:50 2010: ---------------------------------------- GPNVM 2 is already Set Wed Jul 14 11:46:50 2010: ------------------------------- The Remap is done ---------------------------------------- Wed Jul 14 11:46:50 2010: ---------------------------------------- Chip ID 0x275B0940 Wed Jul 14 11:46:50 2010: ---------------------------------------- Extention 0x00000000 Wed Jul 14 11:46:50 2010: ---------------------------------------- Flash Version 0x00000112 Wed Jul 14 11:46:50 2010: 7952 bytes downloaded (16.04 Kbytes/sec) Wed Jul 14 11:46:50 2010: Loaded debugee: C:\Program Files\IAR Systems\Embedded Workbench 5.0 Evaluation\ARM\config\flashloader\Atmel\FlashAT91SAM7X.out Wed Jul 14 11:46:50 2010: Target reset Wed Jul 14 11:46:51 2010: Downloader Version 1.6 (22-Apr-2008) Wed Jul 14 11:46:51 2010: Download1: AT91SAM7X At: 0x100000 Wed Jul 14 11:46:51 2010: -- AT91SAM7X256 Wed Jul 14 11:46:51 2010: Download: AT91SAM7X Version: 0x112 Wed Jul 14 11:46:51 2010: End Init Wed Jul 14 11:48:57 2010: Fatal error: Read memory error @ address 0xFFFFFF68, word access: Core error. Session aborted! Wed Jul 14 11:49:02 2010: Non-zero or missing exit code. Wed Jul 14 11:49:03 2010: Warning: Code still contains old breakpoints Wed Jul 14 11:49:34 2010: Fatal error: Read memory error @ address 0xFFFFFF68, word access: Core error. Bad JTAG communication: Write to IR: Expected 0x1, got 0xf (TAP Command : 15) @ Off 0x5. Session aborted!
В логе cspycomm.log выводится примерно следующее (повторяющиеся строки опущены): ... T0AC0 000:130 JLINKARM_ReadReg(CPSR) returns 0x000000D3 (0000ms, 0094ms total) T0AC0 000:130 JLINKARM_BeginDownload(Flags = 0x01) (0000ms, 0094ms total) T0AC0 000:130 JLINKARM_IsHalted() >0x48 JTAG> returns TRUE (0002ms, 0094ms total) T0AC0 000:132 JLINKARM_WriteMem(0xFFFFFC20, 0x0004 Bytes, ...) -- Data: 01 40 00 00 - Writing 0x04 bytes @ 0xFFFFFC20 - Reading all registers >0x8C8 JTAG> -- WriteRemote(4 bytes @ 0xFFFFFC20) returns 0x04 (0006ms, 0100ms total) T0AC0 000:138 JLINKARM_EndDownload() (0000ms, 0100ms total) T0AC0 000:138 JLINKARM_ReadMemU32(0xFFFFFC68, 0x0001 Items, ...) -- ReadRemote(4 bytes @ 0xFFFFFC68) -- Data: 08 00 00 00 returns 0x01 (0003ms, 0103ms total) ... T0D08 041:150 JLINKARM_ReadMemU32(0x0000030C, 0x0001 Items, ...) JLINKARM_GetDeviceFamily() returns 7 (0000ms, 0000ms total) JLINKARM_ReadMemHW(0xFFFFF240, 0x0004 Bytes, ...) -- ReadRemote(4 bytes @ 0xFFFFF240) -- Data: 40 09 5B 27 returns 0x00 (0003ms, 0003ms total) JLINKARM_ReadMemHW(0xFFFFFF68, 0x0004 Bytes, ...) -- ReadRemote(4 bytes @ 0xFFFFFF68) -- Data: 01 04 00 00 returns 0x00 (0003ms, 0006ms total) -- ReadRemote(4 bytes @ 0x00000000) - Writing 0x04 bytes @ 0x00000000 -- WriteRemote(4 bytes @ 0x00000000) -- ReadRemote(4 bytes @ 0x00000000) -- ReadRemote(4 bytes @ 0x00100000) -- MA0 is in flash -- Unmirror addr 0x0000030C -- Read from flash cache (4 bytes @ 0x0010030C) -- Data: 21 54 6D 1C returns 0x01 (0017ms, 19747ms total) T0D08 041:167 JLINKARM_Step() -- Unmirror addr 0x00000008 -- Read from flash cache (4 bytes @ 0x00100008) -- Not simulated -- Not emulated -- Unmirror addr 0x00000008 -- Unmirror addr 0x00000008 -- Unmirror addr 0x00000008 -- Invalidate MA0 status >0x9E8 JTAG> >0x48 JTAG> >0x738 JTAG> JLINKARM_GetDeviceFamily() returns 7 (0000ms, 0000ms total) JLINKARM_ReadMemHW(0xFFFFF240, 0x0004 Bytes, ...) - Reading all registers >0x8C8 JTAG> -- ReadRemote(4 bytes @ 0xFFFFF240) -- Data: 40 09 5B 27 returns 0x00 (0007ms, 0007ms total) JLINKARM_ReadMemHW(0xFFFFFF68, 0x0004 Bytes, ...) -- ReadRemote(4 bytes @ 0xFFFFFF68) ***** Error: Read memory error @ address 0xFFFFFF68, word access: Core error. -- Abort occured -- Data: 40 09 5B 27 returns 0x01 (0004ms, 0011ms total) ********* J-Link owning thread terminated ******** ********* J-Link owning thread terminated ******** Closed
[Причина]
Неправильно сконфигурирован загрузчик (flash loader).
[Как устранить]
Выберите в меню Project -> Options... -> Debugger -> закладка Download -> поставить галочку Use flash loader(s), и проверить, что у Вас в окошке слева от кнопки Edit... стоит ",,,0x100000,(default),". Если это не так (например, у Вас скорее всего стоит ,,,,(default),), то нажмите кнопку Edit..., щелкните на строку с конфигурацией, нажмите на другую кнопку Edit..., поставьте галочку Relocate, задайте Offset: равным 0x100000.
|