SAM7_PGM - Program Atmel AT91SAM7S64

This program attempts to download firmware to an Atmel "SAM7" chip by communicating with its embedded boot agent. It's similar to Atmel's SAM-BA utility, except that this one runs on Linux and is GPL'd.

This program only communicates via a serial port to the DBGU port. You must NOT use USB. If a USB cable is attached while the boot agent is running, it will switch into USB mode. You can plug the USB cable in after your code runs, but the USB cable must be disconnected to prevent the boot agent from using USB and ignoring the DBGU port. See sam7utils for USB based flash loading in Linux.

Only the AT91SAM7S64 chip has been well tested. Some limited testing has been done with a AT91SAM7X256. Other SAM7S and SAM7X chips are likely to work. Please report success and problems. The 512K parts will not work, because they use multiple flash controllers. Maybe Atmel could sample me a eval board with a 512K chip for testing. (hint, hint)

This code is ALPHA quality. Only minimal testing has been done. Like all Free GPL software, there is absolutely no warranty!

Download

sam7_pgm_0.04.tar.gz - adds boot recovery and auto runs code after programming
sam7_pgm_0.03.tar.gz - adds support for other SAM7S and SAM7X chips
sam7_pgm_0.02.tar.gz

The serial port and baud rate are hard-coded to /dev/ttyS0 and 115200 baud. Edit settings.c if you need to change these.

Boot Agent Recovery - The Easy Way!

Every time you wish to reprogram your SAM7 chip via the boot agent, you need to follow the Boot Agent Recovery Procedure. Switching off the power, installing the jumper, cycling the power, removing the jumper, and then turning the power on again becomes tedious very quickly!

Starting with version 0.04, sam7_pgm will attempt to do this for you automatically by manipulating the DTR and RTS lines.

SignalPinStateCondition
DTR4High, +12V typPower on
DTR4Low, -12V typPower off
RTS6High, +12V typERASE or TST floating or grounded
RTS6Low, -12V typERASE or TST/PA0/PA1/PA2 pulled to Vcc

The SAM7X chips require ERASE to be pulled up to Vcc, and the SAM7S chips require TST, PA0, PA1, PA2 to be pulled up to Vcc. The PA0, PA1 and PA2 pins have pullups, so if your circuitry doesn't drive them, normally you would only need to worry about TST on your SAM7S chip.

Here is one simple example circuit, which was tested on the AT91SAM7S-EK board (trace cut between CR1 and REG1 required). This circuit is designed so the board runs normally when the serial cable is disconnected. Also sam7_pgm leaves both DTR and RTS high after it has programmed the chip, to allow your program to run.

schematic diagram

If your board uses more than 200 mA, you may need to replace the 2N3906 transistor on the far right with a PNP capable of handling your maximum current.

If your board uses very little current and has large decoupling capacitors (perhaps as a reserve for short duration bursts of power), you make need to add a resistor or special circuit to drain the capacitor when DTR goes low, or simply increase the delays in the sam7_pgm.c to allow more time for your board to discharge.

If other active (powered) signals feed into your board, please take care to make sure they won't damage anything when DTR shuts off the power. If some current "bleeds" though, you may need to add a resistor from Vcc to ground, so that the voltage seen by the SAM7 chip goes close to zero when Vcc is "off".

If you design an alternate circuit, consider that the RTS low to ERASE/TST pullup must "work" when power is off and as it is applied. The recovery procedure requires the "jumper" to be installed without power, then power is applied. If a MAX3232 or other RS-232 level translator is used, it will probably need to remain powered when the rest of the board is off.

Contact

paul@pjrc.com