Sunday, 10 April 2016


A few weeks ago, some enforced time off gave me time to do some research into a topic that some of my colleagues have been getting quite excited about. Rust.

Rust is a new language from Mozilla. Unlike Java and C#, it compiles down to machine code. Unlike Swift and Go it doesn't require an OS - a subset of the standard library (known as core) can be used on any platform. Unlike C++, it's been designed with good ideas from the start, including strong borrow semantics and pattern matching, and unlike C it contains good ideas, period. No more writing your own linked-list implementation on every platform you develop for. It's the first language I've seen where there's no "I'll just have to do this bit in C". Pure Rust, even on a Cortex M4, is the promise. But is it the reality?

First impressions weren't good. Rust's stable/beta/nightly model means that you can experiment with new features considered unstable. Unfortunately these features can and do change, and many of them are required to do bare metal Rust. So github is littered with projects which probably used to work for some platform or another, but don't any more. is probably the biggest, but when I checked a change in compiler internals meant that their clever Rust compiler plugin for auto building platform setup code no longer compiled. It was too much to unpick, especially for a newbie. I saw some good projects for bare metal on x86, but I really wanted to use my M4F Stellaris  Launchpad.

Eventually I found which did at least compile out of the box on Rust 1.9 nightly. Some time later, I've got running on the Stellaris.

Top tip - don't leave unimplemented!() in your code as it calls panic!().

Top tip 2 - Don't forget to keep generating a bin from the ELF, otherwise you're running one version of the code while debugging the other, and that's just baffling.

Sunday, 28 February 2016


Raspberry Pi 3 Model B

So, worst kept secret ever - it appears there's a Raspberry Pi 3 coming soon. Probably tomorrow (the fourth anniversary of the original release). I wasn't told in advance, so unlike most of the internet, I'm not under NDA. Here's what we know:

  • There's an FCC submission qualifying it's Wifi and Bluetooth LE performance. From photos it looks like the same 1GiB SDRAM as the Pi 2.
  • There's a half page advert (and front page picture) of a "Raspberry Pi 3" in this month's CPC catalog. D'oh! It talks about a 64-bit 'ARM 7', but that's nonsense as a) they mean ARM v7 as the ARM 7 is ancient at this point, and b) they actually mean ARM v8-A as ARM v7 is a 32-bit only ISA. We don't which of the Cortex A-3x or A-5x series it's packing at the moment, but I'm predicting an A53. According to the advert it's clocked at 1.2GHz, so that's a good speed bump over the Pi 2. It almost certainly continues to pack a VideoCore 4, given all the good work that's gone in to the Linux/Mesa support for that GPU.

Sunday, 24 January 2016

Some progress

Well, I've missed Christmas, obviously. Maybe it'll be done for Christmas 2016...

I did manage to spend a few hours on it last night. I'd been thinking for a while about fixing the LED to small pieces of PCB, but I didn't think standard 2.54mm pitch Veroboard would fit (four holes would be ~7.6mm, and the holes are only 6mm), I considered getting some 2mm pitch board, but it's remarkably difficult to find in small quantities. I also thought about getting PCBs made, but it just seemed too expensive.

In the end, I thought I'd at least try with some scrap 2.54mm pitch board I had lying around and, well it's not to bad. The board stands a little proud of the rear of the letter, but that's OK. I little work with a file to widen the hole at the appropriate place and it should be OK. The upside is that it is so much easier to solder solid-core to Verboard that it is to try and lay-on not just one but two pieces of wire on each individual leg. Plus the legs were getting dangerously close together for something fused at about 2A.

I had one mishap with an LED that went pop (I could have sworn it was in the right way around), and another that didn't solder correctly, but I got five done in the end and I was starting to get the hang of it. And the little shards of Verboard look like Shreddies.

Only another 39 or so to go.

Tuesday, 22 December 2015


I've now got a Python webserver up an running (on my Linux server, for now), which offers a list of modes for the user to select from. When a mode is selected, it uses jQuery to push this back to the webserver, which then tells the other thread to change which animation it should play.

It's on Github, obviously -

The letters have arrived too, and I had to re-jig the LED layout a bit. It was tricky to get something that lines up in nice neat rows, but I think I got there in the end. After a few goes on the computer using LibreOffice Draw, I decided to just use chads from a hole punch to get the layout right.

Sunday, 13 December 2015

Christmas with a Pi Zero

I picked up a couple of Raspberry Pi Zeroes (plus one with the Mag Pi magazine, which I'm not going to open) when they went on sale. It's Christmas, so what better than a Christmas Pi project?

While in the local garden centre, I saw a Christmas ornament I quite liked - the word XMAS in MDF lit up with LEDs. But they were just regular LEDs, and that's dull. An idea formed.

The project is underway, but here's where we are so far:

  • Four letters (X, M, A and S) ordered in MDF from I considered making the letters myself, but I don't yet have access to the scroll-saw at work and I figured I'd just make a mess doing it by hand. I'll put up some photos when they arrive. I've gone for a flat bottomed Arial Bold, as the serif fonts are generally asymmetric and that messes with the LED layout.

  • 40 off WS2811 5mm Neo-Pixel LEDs ordered from The standard LED format will be so much cleaner when mounted in the letters than the more common surface mount versions. A dab of glue should hold them in place. I bought some rainbow ribbon to use as hook-up wire as well.

  • Some WS2811 test code at They're known to have tight timing requirements, so I looked around for someone who's already done the work on a Pi. I found an existing Pi library which used sent data to the PWM engine using DMA , but I had to patch up support for inverted outputs (I'm using an inverting hex buffer I had lying around in a scraps box to bump the 3.3V output to 5V). If you don't fix it, you'll find the green channel on the first LED stuck at 100%, which is really confusing. I used a breadboard to wire up a couple of the LEDs, and it now all seems to work OK.

  • Python test code. The Zero will run a web interface in order to select the currently running routine. To test the animations in advance of the build, I've been rendering them to animated GIF. Here are the first three routines, and although I'm not convinced about the snow effect, I quite like the other two. The LEDs won't be strictly laid out like that, but I hope to keep the same sort of grid as it makes the effects easier.

Sunday, 14 June 2015

Back to our regular programming

A recent holiday gave me time to catch up on things. One of them was the electronics to control the automatic signalling for my model railway.

I found an interesting chip from ONsemi. The NCV7608 is a 8-way FET driver with SPI interface. The particularly useful feature is that it exposes both drain and source on each of the 8 output FETs, allowing it to be used for high-side and low-side applications.

A small PCB with an NCV7608 could operate 8 colour signalling aspects, regardless of whether they were wired common-anode or common-cathode and regardless of the voltage the resistors were set for. With an RDS(on) of 1.2 ohms, the chip can source (or sink) a fair amount of current before going pop, so you could also use it as a relay driver to operate points (although perhaps driving the points directly might be a bit ambitious).

I feel some Eagling coming on.