Adafruit Feather M0 Express

The courier showed up today, with a really neat new board from Adafruit – the Feather M0 Express. It is essentially a break out board for the Microchip (formerly Atmel) ATSAMD21G18, which is the same ARM M0+ micro used in the Arduino Zero, plus a 2MB flash memory, RGB LED, and a LiPoly charger. It’s not too expensive at $20USD, nice and tiny, and I think could be a real hit.

Using the Feather M0 Express from Arduino IDE almost couldn’t be easier – just add the Adafruit Board Manager URL to your Arduino IDE settings, then install the “Adafruit SAMD Boards” – instructions at https://learn.adafruit.com/add-boards-arduino-v164 .

However, the really exciting new option available with this new board, is CircuitPython – Adafruit’s implementation of MicroPython. Continue reading “Adafruit Feather M0 Express”

Using the inductor tester

inductor tester
The inductor tester, and inductors used for examples below

A few weeks back, we had a talk on KiCad (presentation available at http://ianrrees.github.io/KiCad_talk/ ) where we ordered some PCBs to make an inductor tester (Henryometer?) from dirty PCBs. Those boards came in this week, and a few folks have already put theirs together. This post aims to be a quick guide to the usage of the tester; if you’d like to build one yourself just let Ian know, parts cost is $15. You’ll need an oscilloscope and a current-limited DC power supply to make use of it.

Continue reading “Using the inductor tester”

Debugging AVRs (without Atmel Studio)

This post is somewhere between a guide and a collection of notes, aimed at debugging programs for AVR microcontrollers (like the ones in most Arduinos) “on target”. We’ll be using an AVR Dragon connected to the target micro via the normal 6-pin programming header, with a Mac or Linux PC as the host.

Although this is a bit more advanced than most of our other projects, it’s really quite approachable and is a very powerful technique for fixing AVR software problems.

From a high level; we’ll use a debugging program on a Mac (or Linux, Windows, etc) “host” computer, which communicates with a Dragon “In Circuit Emulator” (ICE) via USB to debug a buggy program running on the “target” AVR, which is presumably running in some circuit we’re interested in. Small variations might apply for Windows hosts, using JTAG instead of DebugWIRE, other debugger tools (Atmel JTAGICE mkII for example), etc.

Continue reading “Debugging AVRs (without Atmel Studio)”

Talk: OpenWRT

OpenWRT: thats an odd name…

The story starts late 2002 when Linksys released a wireless router called the WRT54G.

Andrew Miklas noticed (from the visible names used in the internal filesystem, amongst other things) that it was using Linux, without in any way acknowledging this or making the source available. They had obvioulsy modified Linux to get it to run on their hardware. This is a violation of the Linux license, the GPL. He tried contacting Linksys who weren’t immediately co-operative, so he posted to the Linux Kernel mailing list and Linksys came under considerable pressure to release their source. Linksys then released the source, and people started rebuilding and fiddling with it. They actually had started patching the binary firmware before Linksys did this.

A number of different projects appeared, one was OpenWRT which is first named as such in Jan 2004. So its 7-8 years old.

So what is it?
In hardware terms, OpenWRT systems are designed as Internet routers. They fall into the space between something like an Arduino (8/16 bit CPUs, battery powered, no or minimal OS) and a mini-ITX PC (32-bit CPU, 100W+ power supply). Or a netbook. They run on a plugpack/wall wart, have 4-8M of flash, 8-32M of RAM, and a ~200MHz 32-bit CPU. Can run on battery, but you need a big one and it won’t last very long. Just enough hardware to do a serious Internet connection, and they always have the hardware for that.

So what is it?
In software terms, OpenWRT is a very versatile system for making embedded Linux devices that can fit in 4-8Mbytes of flash. They are not confined to Linksys routers (although a descendant of the WRT54G that will run OpenWRT, the WRT54GL is still available today in NZ for $130). OpenWRT now runs on a *lot* of wireless routers. A list can be found at http://wiki.openwrt.org/toh/start.

Embedded Linux means not using standard gcc libraries. OpenWRT uses a much smaller library called ucLibC. It also means not including anything you don’t need. So OpenWRT has a very extensive set of customisation options.  Its filesystem is somewhat eccentric (as it has to be to run out of a small amount of flash). The kernel is compressed (twice) and written to raw flash, the rest goes into a combination of squashfs (read-only) and jffs2 (read-write). The result is a system that they were able to fit into 2Mbyte of flash but now usually needs 4Mbyte.

OpenWRT has a package managment system; almost everything is an opkg. If you don’t use it, you can leave it out to save space.
None of this is terribly unusual for a embedded Linux distribution, but OpenWRT takes things a bit further in the way it does it. Instead of distributing a kernel and libraries for all the different CPUs and options that they support, they don’t distribute source at all. OpenWRT is a set of patches and scripts that build OpenWRT binaries, a system called Buildroot.

You can use OpenWRT in a number of ways; they provide prebuilt binaries, an ImageBuilder tool, and the ability to build a custom binary. I adopted the latter because I wanted to make a remote camera system that could be used by others; I was able to use OpenWRT to make a turnkey binary that could be easily installed and used by anyone with an NSLU2 and a UVC camera.
See http://wiki.openwrt.org/doc/start for an entrypoint into the OpenWRT documentation

Caveats

OpenWRT is a bleeding-edge open-source project. Documentation can be out of date or missing, things don’t always work, and you need to be prepared to use Google to search for answers. If you really can’t find answers and have a focused question there are mailing lists and forums where you should be able to get answers, but they don’t like being used as a substitute for doing your own research. OpenWRT does not run on all hardware, you need to research before buying.

Can be used as
A pretty amazing wireless router; QoS, custom hotspot, OpenVPN. Web server.
Units with USB ports open up a huge range of other possibilities: file server, music player, camera server, print server, GPS, etc.

What I did
I built OpenWRT (kamikaze) for a device called an NSLU2, which was nominally a NAS device. It wasn’t a great NAS device, but OpenWRT got ported to it and then it could do all manner of things. It has two USB ports. I bought a good quality webcam and set up OpenWRT with a package called mjpg_streamer, which takes Linux video in and feeds it out to a web page or to a file. Got it to write periodically to a file on a USB flash drive; this produced time-lapse movies. The objective was to set it up at a remote crib where we have no electricity.
The second stage was to get it to shut down to reduce power consumption; I had to patch the Linux driver for the RTC chip and do a one-wire hardware mod to get a device that could turn its own power off, and get it turned back on some time later. I submitted patches back to the Linux rtc mailing list and in due course they were blessed by Linus and went into the kernel.

See my blog posts at http://johnarthur.wordpress.com/2008/03/25/a-high-resolution-ip-webcam/ and subsequently for more details.