Tutorial: Getting ETM Instruction Trace with NXP Kinetis ARM Cortex-M4F

It seems to me that not many developers use hardware trace? ARM indicates that maybe only <5% of developers are using trace. Too bad! Why are all the ARM Cortex microcontroller vendors putting a powerful hardware (and complicated!) trace engine into their devices, if only few developers are using it? Seems like a waste of silicon and an unnecessary price adder? Well, hardware trace can be a life saver: Because only with hardware trace the most complicated bugs and problems can be solved. And maybe because only the best are using it ;-).

In this article I proudly present my research how to get instruction trace out of the ARM Cortex-M4 microcontroller on a NXP TWR-K64F120M board with a Segger J-Trace for ARM:

J-TRACE tracing NXP TWR-K64F Board

J-TRACE tracing NXP TWR-K64F Board

Continue reading

Advertisements

First Steps with Ozone and the Segger J-Link Trace Pro

From time to time I face some problems which are really hard to find. Mostly these kind of bugs are very timing sensitive and depend on interrupt execution order. Maybe a dangling pointer is overwriting memory, code is running wild, or some functions are not reentrant as they should be. For these kind of bugs, good tools are worth their weight in gold. The Percepio FreeRTOS+Trace and the Segger SystemView have helped me many times to narrow down such kind problems in my applications. Another ultimate tools is hardware trace: Now I have a Segger J-Trace Pro for ARM Cortex-M in my arsenal of bug extinguishing weapons on my desk:
Dear bugs, look what I have on my desk. Your hiding time is over! 🙂

tracing-cortex-m4-with-j-trace

tracing-cortex-m4-with-j-trace

Continue reading

Bricking and Recovering OpenSDA Boards in Windows 8 and 10

Getting a board from a distributor like Farnell/Element14/Mouser (add your own distributor) means that chances are high that the default firmware on it is written years from now because the inventory has not been updated, or because boards are still produced with that original firmware (because of testing?). So what happens if I use board with a firmware developed pre-Windows 8/10 area?

Freshly Unboxed NXP FRDM-KL25Z Board

Freshly Unboxed NXP FRDM-KL25Z Board

It might work, but chances are high that the bootloader and firmware is not ready for the ‘modern age’, and as a result the board might be bricked. If you still have a Windows 7 machine around (I do!), you are lucky. If not, then you need to read this article….

Continue reading

Swiss Army Knife of Terminal Program for Serial Bootloaders

A bootloader shall be small and concise. I very much like bootloaders which do not need a ‘special’ program on the host, so I prefer a simple terminal for this. While porting my serial bootloader to the NXP FRDM-K64F board, I have found RealTerm which offers a lot of cool features:

RealTerm

RealTerm

Continue reading

First NXP Kinetis SDK Release: SDK V2.0 with Online On-Demand Package Builder

There are plenty of different software packages available for microcontroller these days from all the silicon vendors. Finding a good software package is one challenge, getting what I really need is another one. Freescale is now part of NXP since December 2015, so this is probably the first release of the former Freescale part now as NXP: The NXP Kinetis SDK Version 2.0.

It comes with an interesting distribution way: instead of downloading huge packages with all-and-everything in it, I can build it ‘on demand’ online and get what I need, on demand from a web-based front end:

NXP Kinetis Expert with Kinetis SDK

NXP Kinetis Expert with Kinetis SDK

Continue reading

Aligning S19 Records to 64-bit Boundaries

Many tool chains and linker are able to produce S19 files, such as with the GNU tools it is the ‘objcopy‘ which does this job (see “Binary (and S19) Files for the mbed Bootloader with Eclipse and GNU ARM Eclipse Plugins“). But these tools usually cannot handle the special cases. For example on the Freescale Kinetis K64F my serial bootloader (see “Serial Bootloader for the Freedom Board with Processor Expert“) had a problem with these lines in the S19 file:

Not aligned S19 file entries

Not aligned S19 file entries

Continue reading

Debugging the FRDM-K64F with P&E Multilink

The FRDM-K64F board as other Freescale Freedom board have an onboard debugging device. For everyone who wants to debug the FRDM-K64F board with say a P&E Universal Multilink, here is my setup in case you do not get it working out of the box:

FRDM-K64F with P&E Multilink

FRDM-K64F with P&E Multilink (click to enlarge)

Continue reading

UART printf() for the FRDM-K64F Board and Kinetis Design Studio

I had great plans for this Saturday: to work on really cool project. But as so many times, things turned out to be different. Maybe you have read my recent posts about printf()? A colleague wanted to use that article to the same thing with the Kinetis Design Studio on the FRDM-K64F board. I used the FRDM-KL25Z board, so I expected this to work out of the box for him too. Well, turned out that I was wrong about this, and my Saturday was used for debugging and googling about a printf() problem 😦

While things work as expected for the FRDM-KL25Z (ARM Cortex-M0+) and using the standard GNU GCC ARM Embedded from the launchpad, the application traps on the K64F (ARM Cortex-M4F) in initialise_monitor_handles() with KDS:

Trap in initialize_monitor_handles()

Trap in initialize_monitor_handles()

Continue reading

Tutorial: DIY Kinetis SDK Project with Eclipse – Startup

This is the start of a multi-post tutorial about the Freescale Kinetis SDK, released back in April as beta version. The SDK a set of peripheral drivers, and will become the standard software foundation and drivers provided by Freescale for their ARM Cortex based devices. Similar what other vendors already do. While this is a good step, it is the same time very disruptive for my university projects with new Freescale Cortex-M devices. And with everything new (and beta), it needs time to learn. So this post is about creating a Do-It-Yourself Kinetis SDK project from scratch for Eclipse. This part is about the startup code: about everything to get the application started.

FRDM-K64F with SD, nRF24L01+ and HC-06 Bluetooth

FRDM-K64F with SD, nRF24L01+ and HC-06 Bluetooth

Continue reading

Recovering FRDM-K64F mbed Board

The mbed for FRDM-K64F firmware (http://mbed.org/handbook/Firmware-FRDM-K64F) has great potential. Unfortunately it seems that edges are still very rough: It happens very  often that my FRDM-K64F board gets locked up :-(. I can see that the target CPU is constantly resetting: the red reset LED is always on:

FRDM-K64F Red Reset LED always on

FRDM-K64F Red Reset LED always on

Continue reading

First Steps with the Freescale TWR-K64F120M

Naturally, I have several project ideas lingering around. No time to make them all (for now). One of it is interfacing the Raspberry Pi camera with a microcontroller. To store the images, I need plenty of RAM on the device, and so far the Kinetis microcontroller did not have that. Finally, Freescale announced the K64F120 a few months back, and my ordered TWR-K64F120M board arrived on my desk, waiting to be used: Finally I get an ARM Cortex-M4F with 1 MByte of FLASH and 256 KByte of RAM :-).

TWR-K64F120M Box

TWR-K64F120M Box

Continue reading