Code Warrior, Eclipse, and Freedom boards

As you may recall, I have plans to use a Freescale ARM development board (such as a KL25Z, or a K20D50M) as an I/O interface for at least one Raspberry Pi project. These boards are a bit like a super-Arduino: small enough to fit in the archetypal mint ton, bristling with pins for digital, analog, PWM and the like, but packing a 32-bit ARM Core running several times faster than any of the regular Arduinos. However, it’s not all roses. One of the best things about Arduino is the software environment. Writing a program (known as a “sketch”) for an Arduino is surprisingly simple. The combination of a standard architecture, built-in bootloader and a freely available IDE means that getting software onto the device is as easy as pasting some text into a box and clicking a button.

Unfortunately, getting software onto a Freescale board is not quite so straight-forward. One way to make things more like Arduino is to use mbed. Mbed is very nice in use, has a good development community and requires no software installation. But it has its problems. The biggest issue is that it is an on-line service. To work with mbed software you need a good internet connection and a reasonably fast browser. I cam’t help thinking that I would prefer a locally-installed solution.

I have spent a lot of time recently digging through the huge amount of useful stuff at Erich Styger’s blog “MCU on Eclipse“. As a bit of background, Eclipse is an open software development environment (IDE) platform which can easily be customised for all sorts of purposes. Freescale provide a customised version of Eclipse called “Code Warrior“. The full version costs quite a lot of money, but there is a free “special” version which has all the features but is limited in the size of the code it can generate. For the kind of projects I’m thinking of, the limits in the free version seem quite generous, so that’s the one I went for.

This is where Erich Styger’s blog comes in. I use Eclipse a lot in my “day job” to write Java, C and even Ruby code for enterprise customers, so I thought it would be easy to pick up and use for writing embedded software too. However, the customisations for use with a wide range of embedded systems give it quite a different feel. Erich has a ton of useful tutorials and examples on just this topic, and best of all he was willing to help when I asked newbie questions. If you are at all interested in this kind of thing, his blog is well worth a read.

To cut a long story short, the steps I needed to do to get things working were as follows:

Prepare the development board (in this case the KL25Z)

  1. Download the latest OpenSDA firmware (you may need to register for this)
  2. Unzip the file, and then unzip the enclosed bootloader update app zip file
  3. Follow the instructions in BOOTUPDATEAPP_release_notes.txt to install the latest bootloader
  4. Copy the Debug SDA application (named something like DEBUG-APP_Pemicro_v106.SDA) to the BOOTLOADER mass-storage device. Be careful not to load any of the mass-storage applications as I did at first.
  5. When the installation has completed, power-cycle the board. It should now be running the OpenSDA debug application, so it will no longer appear as a mass-storage device. My Windows box took a while to install the appropriate drivers, and popped up a few dialog boxes, but it got there in the end.

Prepare Code Warrior

  1. Download the “Special Edition: CodeWarrior for Microcontrollers 10.3 (Eclipse, Online)“.
  2. Run the downloaded executable to install the software
  3. When the IDE starts, select a workspace. If you have not used Eclipse before, it’s fine to accept the default suggestion.

Create and run an example project

At this point, I recommend following along with Erich’s Processor Expert Quick Start. Just make sure you choose the appropriate processor type. If you are using a K20D50M board, there is also some useful information here.

Once I had got over my bootloader problems, building and debugging simple Code Warrior / Processor Expert applications became relatively simple. There is still quite a lot of “boiler plate” code which the system generates (and warns you to stay clear of), but if you avoid that, then it’s just a case of writing some C.

Of course, as with any bare-metal code, you haven’t got an operating system to fall back on, so not much is immediately available. I wanted to start with flashing an LED (the “hello world” of embedded programming) I found that the “Processor Expert” wizard had tools to set and invert an output pin, but did not have anything to wait between doing so. Once again Erich had provided an answer.

After installing the “wait” plugin, I was able to get my LED flashing on and off for half a second each.

All in all that took quite a lot of time, but I am now confident that I can at least build and run code on a Freedom board using a local Code Warrior setup. And that’s a big step.

Leave a Reply

Your email address will not be published. Required fields are marked *