A Processor Expert Component to Help with Hard Faults

Ahrg! Again my ARM application crashed somewhere and I ended up in a HardFault exception :-(. In my earlier post I used a handler to get information from the processor what happened. But it is painful to add this handler again and again. So I decided to make things easier for me: with a special HardFault Processor Expert component :-).

After adding this HardFault component to my project, it automatically adds an entry to the vector table. So no manual steps are needed: having the component in the project and enabled will do the needed steps.

Continue reading

Adding Symbols to the CodeWarrior Debugger

On the TWR-LCD, I’m using a USB MSD bootloader. In Programming part of flash I showed how to download and debug the application on top of the bootloader. But how to debug both the bootloader and the application? At the same time with CodeWarrior for MCU? The magic key is tell CodeWarrior to use ‘Other Executables’.

Continue reading

KL25Z and I2C: Missing Repeated Start Condition

I really hate this kind of stuff: I know it should work, but it does not. I’m loosing a lot of time (hours, days, even weeks) to track it down to the root cause. Yes, I create my own bugs. Yes, there are bugs in tools, sources, libraries and components. But what many might not believe: there are bugs in silicon too :-(. If you do not believe, here is one: there is a hardware I2C problem on the KL25Z used on the Freedom board. It worked in one project, but not in another.

❗ The silicon bug described here is present on many Kinetis devices, not only the KL25Z!

Logic Analyzer attached to the FRDM-KL25Z board

Logic Analyzer attached to the FRDM-KL25Z board

So if you are facing a problem where you read 0xFF or wrong values from the I2C bus with the KL25Z, here is probably why (and how to workaround it). The problem showed up with a modified version of the Freedom Accelerometer tutorial….

Continue reading

Debugging Hard Faults on ARM Cortex-M

It is as bad as this: my application stopped in an unhandled interrupt service routine:

Cpu_Interrupt
Cpu_Interrupt

That does not tell much. I’m using Processor Expert generated code, and with this all my ‘unhandled’ vectors are pointing the same handler:

Continue reading

SWD Debugging with the FRDM-KL25Z Board

The OpenSDA on the FRDM-KL25Z board is a cool feature: I do not need any external debugging device to program and debug my board :-). But my KL25Z custom board will not have that OpenSDA on it: first because it would add additional costs, and I do not see a way how I could use it for my board. I better start using a SWD/JTAG debugger for my Freedom board to have everything in place.

What I need to add to the black Freedom board is the SWD header:

SWD J6 (populated) and J11 (unpopulated)

SWD J6 (populated) and J11 (unpopulated)

Continue reading

How (not) to Secure my Microcontroller

There are several reports in the Freescale forums around having ‘secured’ the Freedom board. But what does ‘securing’ a board mean? And what does it mean if I get that ‘Device is Secure’ dialog?

Device is Secure. Erase to unsecure?

Device is Secure. Erase to unsecure?

There are different levels of protection you can find in many embedded microprocessors, and the terms might vary from vendor to vendor:

  1. Protect
  2. Secure
  3. Disable Mass Erase

Continue reading

Speeding up the Debug Launch in CodeWarrior

Whenever I do a debug launch in the Eclipse based CodeWarrior, it takes some time until actually I’m ready to step through my code on the target. Yes, a good part of that is by Eclipse. But another part is that Eclipse helps me to do stupid things (which is a good thing). But say if I know what I’m doing, I could remove some of that safety belts and still doing fine. But only if I know what I’m doing.

A good indicator where Eclipse is spending time is to have a look in the Progress View:

Progress information during launch

Progress information during launch

It shows an interesting information: ‘Build before Launch’….

Continue reading

Assembly Instruction Stepping

Usually I debug and step on C and C++ level: means I step on C/C++ source lines. But sometimes a finer stepping detail is required. What I need is stepping on assembly level. For first time users of Eclipse, that might not be that obvious, so here is the hint:

In the Debug view toolbar (while debugging), there are the normal stepping commands like ‘step’, ‘step over’ or ‘step out’. All these stepping can be performed on assembly instruction level if I enable the ‘Instruction Stepping Mode’:

Instruction Stepping Mode: Assembly level stepping

Instruction Stepping Mode: Assembly level stepping

Continue reading

Unsecuring the KL25Z Freedom Board

In ‘Device is Secure‘ I had a case where this was a false alarm. But recently there has been a report in the Freescale Forum that this can be a real problem with the Freedom KL25Z board I’m using too. I was not able to reproduce this on my end, so a reader of this blog who sent me a binary file to reproduce it.

Well, I was really scared to try that ‘killer’ file on my board, but well, that board is not that expensive, and I have 5 pieces of silicon at hand from a sample order :-). So I took some risk, and programmed that binary using the simple flash programmer. And indeed, when I wanted to debug it again, I got that dialog with my black Freedom board:

Device is Secure. Erase to unsecure?

Device is Secure. Erase to unsecure?

Continue reading

Hot-Sync: Attach, Connect & Download

Usually I compile my sources, link it and pass it to the debugger for downloading it to the target. And ‘downloading’ means for me: flashing to the target (RAM debugging is something for the non-hardcore programmers ;-)). But there are more options than only downloading and flashing. There is definitely more which helps me to do post-mortem (yes, I *love* Latin :cool:) debugging.

Downloading means to me that the debugger will program my application into the device, then loads the symbolics (debug information, source file information, …) and then I debug my application. Looking at the ‘Debug As’ options, there is as well Attach and Connect:

Debug as Attach, Connect and Download

Debug as Attach, Connect and Download

Continue reading