cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Keil MDK debugger. STM32F072.

Pavel A.
Evangelist III

I've reinstalled latest Keil MDK v 5.26.2 and have show-stopper issue with debugging STMF072.

When the debugger starts, it throws the following error:

Load "…………....axf"

Error while accessing a target resource.

Resource perhaps not available or a wrong access was attempted.

*** error 57: illegal address (0x08000000)

 Then it shows disassembly (correctly) but won't allow to set breakpoints in source, looks like it does not load the debug info or fails to associate it with the executable.

The flash loading itself seems to work correctly (the program runs as expected).

The address 0x08000000 is, of course, legal... and disassembly shows it correctly.

Before installing 5.26.2, I had v. 5.24 and the debugger worked great, with same ST-LINKV2 dongle.

The project is same as before, just opened and rebuilt in new MDK.

However the debugger works well with my other boards with STM32F4, with same ST-LINK and cables. ST-LINK updated to version V2J31S7.

Anyone has seen this error? Please advice.

-- pa

12 REPLIES 12
Pavel A.
Evangelist III

Well it occurs that this error is caused by use of Keil's event recorder module. I use it for debug prints on F0.

Without the event recorder, the debugger works well... except no debug prints :(

The latest MDK update 5.26 changed the debugger protocol so that using DWT Cycle Counter for timestamp source is no longer valid for Cortex M0.

The next choice - SysTick - does not work because their SysTick handler conflicts with Cube generated one (I couldn't find how to splice them yet).

Other choices require additional timers or RTOS timer, it's too much to change...

Unrolled the event recorder component from 1.6 (latest) to 1.4 - then it compiles without warnings for timestamp source  - but it did not help, the breaking change is in the debugger.

Will ask Keil support.

-- pa

Pavel A.
Evangelist III

Keil support reply is that Cortex M0 ​and M0+ do not have DWT, so using DWT clock with their EVR always was a bug, and they fixed it (added the warning) in recent versions (5.25-5.26) and library v.1.6.

Unfortunately they advise to use SysTick instead, which does not work as already explained above.

So just to close the debugging gap, I did a terrible hack.

  1. Selected CMSIS_RTOS timer for EVR timestamp source, and Time Stamp Clock Frequency= my actual SysClock frequency in EventRecorderConf.h
  2. Added file cmsis_os2.h with following content:

static inline int osKernelGetState(void)
{ return 0; }
 
#define osKernelRunning (1)
 
static inline unsigned osKernelGetSysTimerFreq(void)
{ 
	return 48000000;
}
 
static inline  unsigned osKernelGetSysTimerCount(void)
{
	return 0;
}

There's no RTOS in this project so it is 100% fake. But should work also with older freeRTOS which provides cmsis_os.h . So, cmsis_os2.h is not part of it and won't conflict.

Then it builds without warnings and the debugger seems to work, with debug prints!

-- pa

Pavel A.
Evangelist III

​Too early rejoiced. Have the same problem again, on another very simple F072 board, without any connection to Keil's EVR.

It is a brand new project just generated by Cube.

The target, I guess, is in good state because flash erase and download are ok, and the debugger shows disassembly and can single step.

What now??

-- pa

maurizio23
Associate II

I have follow the instruction on KEIL 5.25.2 how to instrument Event Record into STM32F030R8 with User Timer.

Event Recorder do not work without DWT on CortexM0, but with User Timer can be added to complet the configuration.

I have use TIM16 as counter and setup all the inizialization need by Event Records.

Program compile without any error. TIM16 run correctly, but the problems are:

  • TIM16 is only 16bit timer, while EventRecorder want 32 bit timer. To solve this I have used an incremental variable every 10ms and add to current TIM16 counter value when request by EventRecord.
  • No Event Record output is running and also statistic is without any data.

Someone has find the solution to run EventRecord on Cortex-M0 STM32F030 with User Timer ?

Maurizio

Pavel A.
Evangelist III

If you're locked out of recent Keil versions 5.27/5.28 with matching version of EVR component, and must stay at 5.25, I'm afraid you're out of luck.

Have you reserved memory area for EVR as described in their EVR app. note? Without this , EVR behaves strangely on Keil v. 5.25+

-- pa

I have update Keil 5.28a, but still not wotking .

Resume the situation. No error at compilation.

EVTrecorder set to use User Timer TIM6 at 1MHz. Set Memory IRAM2 noInit for Event Recorder.

I see Scatter File .sct is wrong if leave default target configuration. Disable default scatter is now correct, assigning EventRevorder.c filo at IRAM2 space. But no record or statistic is running.

In Debug mode is not possible assign breakpoint... why?

I would like to use Event recorder for time analisys on my project, it is useful.

I follow the manual on how to configure Event Recorder but no result.

Any other hints?

Maurizio

In this situation, I'd open a support case with Keil.

-- pa

@Bob Boys​  Did something break or change?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hello

Please see this document: www.keil.com/appnotes/docs/apnt_321.asp

DWT does not exist in Cortex-M0/M0+.

It is easy to change the timer in STM32Cube. See the appnote. Then you can use Systick.

Sometimes with printf you must use or not MicroLib and/or add some Heap memory or Hard fault.

Using non-initialied m emory is optional.

Are you creating your own scatter file ?

Bob Boys