Home
Prox / RFID
Verichips
Ladder Logic
Tube Joints
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
[trivia] †
Resume / Consulting
Contact Me
Bookmark and Share

Atmel AT91SAM ARM

I wrote a simple bootloader for the

  • AT91SAM7S64,
  • AT91SAM7S128,
  • AT91SAM7S256,
  • AT91SAM7X128, and
  • AT91SAM7X256

processors. This permits you to download new code to the device over USB. The bootrom is installed at address 0x00000000 in the ARM, which means that it is the first piece of code to execute after reset. At startup, it waits for a few seconds to see if the downloader is trying to connect. If not, then the bootloader gives up control and jumps to your program. If the downloader is trying to connect, then the bootloader receives the new program over USB and writes it into flash.

All of the ARM-side code is written for the GNU toolchain (arm-elf-gcc and friends). The downloader, which runs under Windows, is written for the Microsoft Visual C++ compiler, version 6.

It is necessary to use some method other than the bootloader to program the bootloader into the ARM for the first time. I have done this using JTAG. The bootrom build process creates forjtag.s19, which I download into the AT91SAM's RAM. I have used a Wiggler-compatible JTAG dongle, which works with Macraigor's OCD Commander tools. Any JTAG tools will do, though. I then run the bootrom from RAM (by starting it over JTAG), and download the bootrom into flash over USB, using the copy of the bootloader that I had downloaded into RAM.

Atmel provides a bootloader called SAM-BA, but as far as I can tell it is not what I want. SAM-BA takes full control of the processor: there is no provision for it to jump to a separate `application' after a few seconds. It would be possible to use their bootloader to download any kind of program to the device, but in doing so that program must wipe SAM-BA out (or else SAM-BA would never let it execute). This seems like it would be rather inconvenient for development; you would have to fiddle with the test pins to reload SAM-BA every time you wanted to download new code. Also, their USB driver bluescreened my computer.

I initially wrote this bootloader for my proxmarkn devices, which are based around AT91SAM7S parts. I have tested the code with an AT91SAM7S64, AT91SAM7S128, and AT91SAM7S256. It is necessary to modify the bootrom to support the xx64 vs. xx128 or xx256, because the parts do not all have the same flash page size. Note that by default, the AT91SAM7X parts boot from ROM, not flash. The bootrom must be modified to change that (flip general-purpose non-volatile memory bit 2), but if you do so then it seems to work.

Also, I recommend WinterMute's build of arm-gcc. I have not been able to get some others to work. I'm using arm-elf-gcc version 3.4.1, arm-elf-ld version 2.15.

*              *              *    

The software is available for download, including all source, tools, linker scripts, weird binutils, etc.

THIS SOFTWARE IS IN THE PUBLIC DOMAIN. It may therefore be used in any application, commercial or non-commercial, with or without attribution to the author. NO WARRANTY IS EXPRESSED OR IMPLIED.

May 2006, Cambridge