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!
The serial port and baud rate are hard-coded to /dev/ttyS0 and 115200 baud. Edit settings.c if you need to change these.
Starting with version 0.04, sam7_pgm will attempt to do this for you automatically by manipulating the DTR and RTS lines.
Signal | Pin | State | Condition |
---|---|---|---|
DTR | 4 | High, +12V typ | Power on |
DTR | 4 | Low, -12V typ | Power off |
RTS | 6 | High, +12V typ | ERASE or TST floating or grounded |
RTS | 6 | Low, -12V typ | ERASE 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.
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.