Posts

I decided to make an 1980's Home Computer in Rust - Part 1

Image
I've had a few projects over the past few years using the TI Stellaris Launchpad. It's nothing particularly special - just a Cortex-M4 based LM4F120 MCU at up to 80 MHz with 256 KiB of Flash and 32 KiB of SRAM, an RGB LED and an on-board USB programmer - but it's pretty cheap and I've gotten to know it quite well.

The provided StellarisWare software was a 300 MiB installer, so I threw that out and wrote all of the drivers from scratch. I started out in C, and managed to get a simple car dashboard module working, using an LCD TFT with on-board framebuffer and 8-bit 6800/8080 bus interface (despite the chip not having such a bus - I cheated and used GPIO pins instead). My first attempt at Rust programming was the stellaris-launchpad crate. This has a few demos that either blink the LED or roll it through an RGB rainbow using the PWM timers. From this, I then decided to move the chip support package into a separate crate, in case anyone wanted to use the chip on a differe…

Supporting the new Embedded HAL

Recently, @japaric posted a about a new approach to an Embedded HAL in Rust. This is something that's been kicked around on #rust-embedded for a while, but it was great to see it get to a point it could be pushed out to the wider world.

I run the Cambridge Rust Meetup and the post coincided with our next Hack-n-Learn evening. The purpose of these evenings is to work through problems together and I decided it would be fun to try and implement the Embedded HAL on my LM4F120 chip crate, and then fix the Stellaris Launchpad examples to use the new HAL. To engage some of the attendees new to Rust, I thought it would help if I did it live on the big projector and talked through the changes as I made them.

Well, despite a quick 10 minute break for pizza (thanks Cambridge Consultants) I managed to get the changes completed to the UART driver in under two hours. Here's what I had to do.

The old UART driver in the LM4F120 crate used my earlier Embedded Serial HAL. That looked like this:

Embedded Rust in 2018

I recently picked up an embedded project that I hadn't touched for a few months, so I could add some new features. I was disappointed to note that it no longer compiled - nothing in the code had changed, but it only compiles with Nightly Rust and that had recently had a bunch of changes that completely broke my build. This is then a tale about what I'd like to see from Rust in 2018.

I know there's been a lot of interest in WASM and other 'high level' applications, but Rust also lends itself very well to embedded development. I have a demonstration project for the Texas Instruments Stellaris Launchpad (now rebadged the Tiva-C Launchpad). This project comprises approximately three Assembler instructions (to bounce into the hardfault handler), and the rest is Rust - no C required! Exception handlers, setting the stack pointer and initialising the .data and .bss segments can all be done in pure Rust. Thanks to brilliant work by the likes of @japaric, with the Xargo cro…

Advent of Code

Over the past weeks, I've been working through Advent of Code. If you haven't seen it, it's basically a daily programming challenge - one a day for the 25 days running up to Christmas. Each challenge has two parts, and you get points for being in the first 100 people to submit a correct answer (usually a number, or a short string). There's nothing for coming 101st! The challenges open at 00:00 EST (so, 05:00 GMT) so if you want to have a crack at the leaderboard, it's a very early start. The best I've managed so far is about 162nd, but there's a few days left.

Most people tackle the problems in Python, and arguably that's a very good choice. It's a very expressive language, and as the winners produce short, dense code - it needs to be fast to type after all - the lack of static type checking isn't as much of a problem as it might be in a larger application.

I'm doing it in Rust, and it's been very educational.

I thought my Rust was OK go…

Results Analysis

Curious as to how each category did in PiWars (Professional, Intermediate and Beginner), I've annotated the official results with the category of the team and their overall leaderboard position in that category. For example, "2 wheels or not 2 wheels" is "Pro 1", as the winning Professional. You'll note that "Beginners" top four out of the seven categories!

Obstacle Course
1 2 wheels or not 2 wheels (Brian Corteil)Pro 12 Maxeos (Alex Daily)Inter 43 PiSquared (Leo White)Pro 64 Team Steve (Jonathan Pallant)Inter 15 Team 3.14 Musketeers / Robot B√Ętagnan (Mark Edwards)Beginner 46 Hitchin Hackspace (David Booth)Pro 57 Slice of Pi Club (Martin Eyre)Inter 68 SmartPi (David Plaquin)Beginner 119 CNM Hackerspace / Not Today Skynet (Kerry Bruce)Beginner 210 Little TREV (Matt Teague)Pro 711 Metabot3 (John Palombo / Lance Robson)Pro 312 Ipswich Makerspace / Robot Tractorbot (Keith Ellis)Pro 213 PiTastrophy (James Cohen)Pro 914 KEITH 3 – “Mostly Harmless” (Harry …

It's a win for Steve!

Image
What a weekend. I'm exhausted! At this time we're still waiting on the full results breakdown, but in the Intermediate category, Team Steve managed a 3rd place, a 2nd place and a 1st place (for the Slightly Deranged Golf)! The three placings (plus, I guess, points elsewhere - I don't know yet) were enough to put Steve, the dog/robot at the top of the rankings for the Intermediate category. I wouldn't have believed it was possible looking at the pile of scrap parts I had on my desk at the middle of last week, so the moral is - never give up!

Here are some photos from the day:


And a couple of videos, starting with Steve playing golf:







The prize bundle I received was pretty epic. Thank you so much to all the sponsors - it really is incredible how generous they've all been. I found (in not particular order):

A Pi-DAC+. This is going to sound awesome in the Jag...An Astro Designs PiZ-Moto L293 motor driver for the Raspberry Pi  A Pi Zero kit with cables and case, from Eve…