During development there are often situations in which a device is left in an unbootable state. Its flash memory has been erased, or incorrectly written, such that the unit performs no useful operation on startup. Generally, this is also how the units will be initially after assembly. Once in this state specialised tools are required to program the units. Typically, this would be JTAG, involving some kind of external JTAG adapter. This works well, as JTAG gives full access to all elements of the CPU. However, it is not without its drawbacks.

  • As standard it requires a 20-way connector, which is quite large in board real-estate.
  • It requires dedicated CPU pins to be routed appropriately.
  • The software is often not easy to automate reliably for programming units in the factory.
  • It requires an external JTAG adapter, and associated software. These are often not easily usable by an inexperienced operator.
With Atmel's AT91SAM range of CPUs, they have included a built in Boot-Rom which runs a protocol they've called SAM-BA. This code allows CPUs to be put into a programming mode when commands can be sent either over USB or the debug UART. Using this mode, we have successfully been able to program our Snapper 9260 at rates of approximately 30kB/s. This is more than ample to allow simple and reliable reprogramming of these units, using just a standard USB cable. To automate this, we've developed a SAM-BA based scripting tool, available from https://bluewatersys.com/quickstart/9260sambootassistant.php. This tool is customised for our environment, and supports several useful features
  • NAND support, for read, write & erase of the on-module NAND devices.
  • U-Boot environment support. This allows automatic programing of U-Boot environment variables.
  • YAFFS2 image support, allowing creation & writing of a YAFFS2 filesystem directly to the NAND flash.
Using these features we can reprogram a unit, from completely erased to a standard factory level, in just a few minutes, including the boot loader, kernel and filesystem. While this is not fast enough to be suitable for factory production, it is quite suitable for the occasional situation when someone accidentally erases their system.

Previously we spoke about our efforts to optimise the boot time of our Snapper 9260 module, getting it down to ~5s. Having done a bit more work on the hardware, software, and moving to the AT91SAM9G20 module, we now have this down to ~3s from initial power applied. This is a full boot, with peripherals initialised, reading from NAND Flash for its root filesystem etc. Having used a lot of embedded systems over the years, we are very pleased with this result, as it certainly out performs all the similar devices we have seen in its class.