Hi, I have an AT91SAM9260 and use a segger J-Link for HW-debugging. The problem is, that debugging does only work on every second time. That means, if I want to debug, I click onto start/stop debugging, wait for the debugger to load the code into external RAM and then the program counter is somewhere in the program but the main or I get an error "cannot stop arm device". On the second try (after I switch off and on power of the device) debugging works fine.
Stefan,
I have had this occur too. The solution always seems to be associated with something I have done in code or in a configuration.
Aside from the obvious problems with hardware and external bus timing setup issues, you may want to look at some things which can cause the processor to utilize 100% of its execution time. It also seems that when you do a 'power cycle' the state(s) that caused this issue to occur are removed. That is a hint to follow.
I recall reading somewhere that when you download your code it begins running on the processor prior to the debugger gaining control of the processor and stopping it. You have also seen that once you release the debugger the code you loaded continues to execute.
Your code may contain a few while(1){} loops which can be, at times, hard to overcome in gaining processor control. An interrupt could be firing prior to actually having an ISR to vector to (all obvious but tedious to solve).
You may also want to try and verify the syatem and peripheral device settings on a load and a power cycle compared to a failed load when 'the program counter is somewhere in the program'.
Also try to do a flash Erase command prior to executing a Start/Debug and see if that makes a difference.
I hate being vague with the "I recall reading somewhere" statement so here is a link to that statement for an explanation:
www.keil.com/.../ulink_hw_reset_sequence.htm
Thanks for the information.
I will check if it is solved, when the bootloader is disabled by erasing the first page of the DataFlash.
It isn't a solution I might use. When my bootloader is disabled, SAMBA is getting started and I have other problems. My app cannot configure the watchdog register, which seems to be configured by SAMBA which starts in the "background", and throws tons of errors...
But debugging starts fine ;-)
Why don't you used ULINK?
Because the J-Link is much faster when downloading code or debugging.
Then why don't you use ULINK Pro?
Because I don't have one and it's very expensive...
Hi,
did you also try Adaptive Clocking? Just tested and works fine...
BR, /th.
Hi, yes, we work with adaptive clocking. Otherwise we would have to use a very slow frequency for JTAG, because the device starts with some 100kHz and speeds up JTAG frequency afterwards.
We had a device (same µC but different design), where the "adaptive clocking pin" was not connected to the JTAG-port... it took some minutes to load the firmware to SD-Ram and debugging was slow as a snail
We found the problem! After startup, the user reset is disabled in revision B of the AT91SAM9260. After enabling the user reset, the debugger works fine...