I have built a code for AT91R4008 in keil and now I want to debug it by J-Link 14 pin on pcb. But when I connect the J-Link to the USB port of my pc and the 14 pin Jtag IDE connector on pcb, keil does not recognize anything. Even windows find j-link and install the driver, but there is no change in keil and when I click on start debug session an error comes saying:
Target DLL has been cancelled. Debugger aborted!
Without connecting the j-link to the pc, if you click on start debug session, this error will be announced too.
I have searched a lot about debugging with j-link but I couldn't find any solution.
AT91R40008 is correct, not AT91R4008. I made a mistake. sorry.
Can the JLink Commander application see the chip?
If not review the 14 pin header format/connectivity.
I retried with J-Link commander, it finds the chip but when I use <unlock kinetis> command, the below error messages appear: could not reset error in ctrl/statc register. unblocking device... error: read from dp/ap register failed!
And when I use <erase> command, the below error message appears: ERROR: erase returned with error code -1
In brief, the j-link connected successfully to the pcb but I couldn't program arm7.
<unlock kinetis>? It's an ATMEL part, not a KINETIS/FREESCALE part.
It's a very antiquated part, are you sure you can flash it via JTAG? Probably need an applet to support whatever external flash you have on the device. Looked at J-Flash?
In Keil, you'd probably want to target the internal SRAM (Target RAM + SAM-ICE), and create a debugger script (.ini) to download the code into RAM and execute it from there.
C:\Keil421\ARM\Boards\Atmel\EB40A\Hello\Hello.c
In the J-Link 'Cortex-M Target Driver Setup' dialog:
http://www.keil.com/support/man/docs/jlink/jLink_cortexDebug.htm
The following steps are based off of www.keil.com/.../ulink2_trblshooting.htm
*On the top left of the dialog, can you see the J-Link serial number?
*On the top right of the dialog, next to SWD, can you see the ARM CoreSight device ID? - If not, the device may be locked up.
If the device is locked up, -in the middle of the dialog, in the 'Debug' box, for 'Connect:' change the drop down from 'Normal' to 'Under Reset'
http://www.keil.com/support/man/docs/jlink/jlink_conf_debug.htm
Now, regardless of what is running on the device, the J-Link will try to connect. Press the OK buttons to close the dialogs.
Try Flash->erase and see if it works.
This is similar to the procedure in
http://www.keil.com/support/docs/3566.htm
Then, Instead of running your code, try running a known working exmaple