The FRDM-KL25Z – Freescale’s first “Freedom” board – is one of a new batch of very cheap ARM Cortex-M development boards now available. It costs about USD15.00 and sports the following features:

Freescale FRDM-KL25Z “Freedom” board

Why I think this board is great

Bang for buck Cheaper and faster than an Arduino. Plus, it’s an ARM, not an AVR. (I’m not a fan of the AVR.)

128 KiB of Flash memory While not megabytes, this is a lot of code space for a small microcontroller. And because it’s not an 8-bitter, there is no need to play funny games with paging to use the memory

I like Freescale’s hardware I’ve been playing around with their 8-bit parts – the S08 series – and I really like them. They are solid, well-engineered, and pretty bug-free. (Freescale’s firmware is another matter though...)

Cortex-M0+ This series of MCUs from Freescale – the Kinetis L – is apparently the first in the industry to sport a Cortex-M0+, which has a few nifty features:

Hmm. Firmware.

... but Freescale really screwed up the firmware!

I’m not sure why they thought it would be a good idea, but they put a “mass storage bootloader” onto the debug chip. (There is a second part on the board – a Kinetis K20 USB MCU – that acts as a debug “host” so it’s possible to program and test the KL25.)

I think there is this idea that “drag-and-drop” is easy, but in practice it’s a bad choice. It requires a lot of code on the target (USM mass storage layer, code to “parse” the file being copied and turn that into blocks of code to write to Flash). The feedback is poor – difficult to know if it “took” or not. It doesn’t work on OSX – which insists on scribbling random files and directories onto newly-inserted USB media. And, because of the complexity, it’s hard to get right.

Which, needless to say, Freescale didn’t do. But they didn’t just get it wrong – they embarrassed themselves. (They aren’t alone, among semiconductor folks, in this kind of thing. ST did something very similar with their initial version of ST-LINK.)

The bootloader enumerates but doesn’t attach as a storage device under Linux. It seems that the metadata for the “volume” that it emulates is all wrong. Even on OSX (and Windows!) where it at least can be mounted as a filesystem, it advertises a capacity of 136MB or so.

It’s sensitive to Windows versions too. I tried it on Windows 2000 and on Windows 7. It failed on 2000 but worked on 7. My guess is it should work on anything XP or later.

Had they made a simpler choice – a trivial bootloader for instance, with a simple, published interface (like on Freescale’s S08JS16) – it could easily be cross-platform. Instead, the board at first appeared to be a very light paperweight.

Until I discovered the CMSIS-DAP firmware, that is...

How to rescue your Freedom board from the (idiotic) clutches of Freescale (and P & E)

I haven’t mentioned P & E yet.

They were clearly a partner in developing the (idiotic) firmware on the board. They call it “OpenSDA” – which I think means “open simple debug architecture” – but it’s not open, and it’s not simple. There is supposed to be a developer’s guide, but it’s nowhere to be found. Supposedly one can develop firmware to this “open” spec, that you program onto the board using their broken mass-storage bootloader. But since there is no spec...

Well, there is a “quick start package” that includes an s19 (Motorola S-record) file and a couple of .sda files. The .sda files – for OpenSDA – are encrypted. WTF?! So much for open!! They are also tied to P & E’s debugging tools – which, I forgot to mention, are advertised via .htm (not html!) files in the mass-storage bootloader’s home directory! Tacky! Anyway. I started to disassemble the s19 file (slow going because I was using my muforth disassembler, and had to add ARM v7-M opcodes to it as I went!) but coincidentally, before I had got very far, I stumbled over a mention of something called CMSIS-DAP – the very file I was disassembling.

This turns out to be the firmware that Freescale should have put onto the board in the first place. It turns the board into something that can be interacted with in real-time. Unfortunately, support (on the host side) is (at the time of writing) spotty. But it’s how muforth connects to the board. ;-)

Here’s what you have to do to rescue your board:

In the Keil zip the file you want is at the root: ./CMSIS-DAP.S19. In the Freescale zip the file is "./FRDM-KL25Z Quick Start Package/OpenSDA Applications/CMSIS-DAP_OpenSDA.S19”.