AT91SAM7S
The AT91SAM7S is an ARM processor manufactured by Atmel.
Programming
Here is the ARM Architecture Reference Manual (ARM document DDI 0100E) (local copy), also available as a textbook from Addison-Wesley. Note that a more recent version (DDI-0100I) is available that incorporates some errata and includes the ARMv6 architecture.
Here is the ARM7TDMI Technical Reference Manual (local copy)
Here is the Procedure Call Standard for the ARM Architecture (IHI0042B) (local copy)
Here is the ARM and Thumb-2 Instruction Set Quick Reference Card.
Here is the Thumb 16-bit Instruction Set Quick Reference Card.
Here is the Atmel ARM7TDMI datasheet (local copy)
Here is Chapter 13 of the SDT 2.50 User's Guide (DUI0040D) in which the Angel monitor is described (local copy).
- Here are some links to documentation for the GCC toolchain:
Forth
Download pfarm.hex for the AT91SAM7S256. Flash it into address 0x108000 and run it at that address too. Press ENTER once you're connected to start it.
Debugging
In-circuit debugging using the JTAG interface and the on-chip EmbeddedICE module is possible using the following tools:
Dominic Raith's OpenOCD software works on both Linux and Windows. This software acts as a server that is used by GDB to convert the user's debugging commands to JTAG commands.
- Here are some pre-built packages of OpenOCD Version 1.0 (build 754) from the SVN trunk checkout of July 6, 2008 (all built on a Slackware 12.0 system):
If you don't like packages, you can just download the Slackware package (for example, to /tmp) then install as:
sudo su # Become root cd / # Go to top-level directory tar -xzf /tmp/openocd-1.0-i386-1.tgz # Extract files
The ARM-JTAG parallel port JTAG programmer works with OpenOCD, as does the ARM-USB-JTAG USB-based model.
Here is a sample configuration file for using the parallel-port ARM-JTAG converter with OpenOCD, and a sample configuration file for using the ARM-USB-JTAG Olimex converter.
If the above binary packages don't work for you, you can compile and configure OpenOCD from source. To use the ARM-JTAG parallel port programmer, try the following (or read the official instructions:
# Download the latest OpenOCD SVN code svn checkout svn://svn.berlios.de/openocd/trunk cd trunk ./bootstrap ./configure --enable-parport --enable-parport_ppdev make su -c "make install"
If you have the Olimex ARM-USB-JTAG programmer you will need to configure OpenOCD to access the FT2232 device on the programmer. Download the FTD2XX libraries from FTDI (local copy of version 0.4.13). Extract the files and read/follow instructions in README.dat. Then, go back to the OpenOCD source directory. Replace the ./configure line above with:
./configure --enable-parport --enable-parport_ppdev --enable-ft2232_ftd2xx --with-ftd2xx=/usr/local/lib
Once you have a configuration file (see above for an ARM-JTAG configuration file) you can run the OpenOCD server as follows (either make sure you're root or set the permissions on the parallel port device properly):
openocd -f openocd_pp.cfg # For parallel port access
OR
openocd -f openocd_usb.cfg # For Olimex USB deviceYou can then use GDB to connect to this server:
(gdb) target remote localhost:3333 (gdb) monitor arm7_9 sw_bkpts enable (gdb) monitor poll
Microcontroller
Here is the datasheet for the AT91SAM7S (local copy)
Links
Here is Atmel's AT91 Resource Page with information on their evaluation kit, chips, etc.
Here is a Linux resource page for AT91SAM devices. You can find a Linux version of the SAM-BA GUI program here, and also on Atmel's site.
For Windows, the WinARM project provides a pre-built toolchain for ARM. The site has a variety of distribution versions, from the older-but-tried-and-true to latest-and-greatest. You may have to try a few to find one that works for you.
The GNUARM web site has pre-built distributions of GCC for ARM for both Windows and Linux (and MacOS too, I think).
CodeSourcery creates free pre-built toolchain distributions for ARM and other platforms.
Here is a locally-built distribution of the GNU 4.2.2 ARM tools (GCC 4.2.2, BINUTILS 2.17, NEWLIB 1.15, INSIGHT 6.6) for Slackware 12.0. To install, become root and extract the archive from the filesystem root (i.e., the '/' directory):
cd / tar -xjvf gnuarm-4.2.2.tar.bz2
- To build the GCC-for-ARM tools yourself:
Download the installation script for GCC 4.2.2 and save it as install-gnuarm.sh somewhere on disk. These scripts download the source files and compile them using very basic options and C-language support only (no C++, Java, etc.) The --disable-libssp option has to be specified otherwise the C compiler will not build (maybe someone can recommend a fix for this).
- Become root
- Edit the lines at the top of the script to set configuration options
- Type the following:
nohup bash install-gnuarm.sh > install.log 2>&1 &
You can log out now...the compilation continues in the background, or you can watch the progress with tail -f install.log
Remember to add /usr/local/gnuarm-4.2.2/bin (in general, ${DESTDIR}/bin) to your PATH environment variable
If you're feeling adventurous, here is a more recent (May 6, 2008) locally-built distribution of the GNU 4.3.0 ARM tools (GCC 4.3.0, BINUTILS 2.18, NEWLIB 1.16, INSIGHT 6.8) and the installation script used to build them. Instructions are the same as for the 4.2.2 tools described above. C++ is supported in this version of the build.
Here is an ARM Wiki
AT91SAM7S Development Kit
- Buy the AT91SAM7S-EK (get the part number right!) for $100 from:
Here is the User's Guide for the kit (local copy), which includes schematics and not much else of interest.
- The two serial ports on the kit are DTE's, meaning you will need a NULL MODEM CABLE for connection to a PC.
- Everything on this board is powered by +3.3V. Some I/O's are +5V-tolerant but you MUST BE CAREFUL and always think 3.3 instead of 5.0. This includes the analog inputs! They must be kept between 0V and 3.3V.
- Here is how to program the board to run SAM-BA after it boots:
- Remove power
- Install the TST jumper (JP5) and ensure that PA0, PA1, PA2 are high (they have internal pull-ups so they should be high all by themselves unless you've connected something else to them).
- Apply power and wait 10 seconds
- Remove power
- Remove the TST jumper (JP5). SAM-BA is now installed in FLASH and will automatically run on power-up.
NOTE: The FLASH page lock bits are only rated for 100 erase/program cycles, unlike the actual FLASH memory which is rated for 10,000 cycles. Every time you install SAM-BA into flash it unlocks then re-locks the first two FLASH pages, so keep to a minimum the number of times you re-install SAM-BA in FLASH.
AT91SAM7SE Development Kit
The Atmel AT91SAM7SE development kit costs $200 instead of the $100 kit described above, but additionaly has 32MB of external DRAM, 256MB of external FLASH, a stereo audio DAC, and a joystick.
Buy the AT91SAM7SE-EK from:
Other Evaluation Kits
Even though the Atmel kit is recommended, there are other (cheaper) development boards that should do just as well (no guarantees, unless otherwise indicated for each product):
The SAM7-256 board. This is a pretty close match to the other evaluation boards used in the course. Students have used this in the past with good results.
The Bugblat Cortino is not such a good match to the other evaluation boards (ST processor, different peripherals) but it is a very inexpensive ($39.99) way to get started with ARM development.
Linux USB Programming -- Sam_I_Am
The Sam_I_Am program can be used to communicate with AT91SAM7S devices over a USB link. Support is included for FLASH programming, RAM programming, and displaying chip information.
Linux USB Programming -- sam7_pgm
- The USB needs to be initialized so that communication can be established. To do this enter the following command as root:
modprobe usbserial vendor=0x3EB product=0x6124
To check to see if the device was initialized correctly enter the following command:ls /dev/ | grep USB
The above command should return ttyUSB#, where the # is the number of the USB to serial converter device that was set up to communicate with the AT91SAM7S-EK board.
If the command did not return anything, then something went wrong. Ensure that the device is connected to a working USB port and that the USB module is loaded (type lsmod as root). Make sure that the SAM-BA boot loader has been activated (see above section). Check the system logs (usually /var/log/messages) to determine the nature of the problem if the above suggestions do not work.
There is a program that can be modified to program the AT91SAM7S Evaluation Boards located here. The program needs to be modified to accommodate the USB rather than the Serial DEBUG port.
Step One: The port needs to be changed from /dev/ttyS0 to /dev/ttyUSB# [1,2] this can be done in the settings.c file when the program is extracted on line 31. This should read:
31 #define DEFAULT_PORT "/dev/ttyUSB0"
Where /dev/ttyUSB0 [2] is an example.
Step Two: The mclk variable in the main() function of the sam7_pgm.c file needs to be set to 48000000 on line 111, then the code on line 145 should be commented out so that it reads:
111 double mclk = 48000000; . . . 145 // mclk = 115200.0 * 16.0 * (double)baud;- Step Three: Compile the code with
make
then enter the command to run the compiled program./sam7_pgm led_blink.hex
If an error occurs saying that the device is unknown with given ID, copy that ID into the appropriate location in the table located in chip_id.c, replacing the ID for the chip that you are currently working with.
- Step Four: At this point the supplied led_blink code should have been downloaded to the evaluation board. To test this press the reset button and the four LEDs on the board should light up in the following repeating pattern [LED 1, LED 2, LED 3, LED 4, LED 4, LED 3, LED 2, LED 1]. To increase the blinking rate of the LEDs press button one (the one next to the USB connector). To slow the blinking rate down press button three.
The # that was returned from the ls command above
The ttyUSB# can and will change depending on your system setup, you may need to reissue the ls command then change the ttyUSB# and recompile
AT91SAM7S Evaluation Board Examples
There are example programs that show how to work with the evaluation boards and its peripherals located here. The example code is written for the AT91SAM7S64 chip, but there are files located at the bottom for the examples to work with the AT91SAM7S256 chips.
Here is a RAM-based AT91SAM7S256 linker script for use with the GCC-for-ARM compiler. Here is a RAM-based AT91SAM7S64 linker script.
Here is a minimal crt0.S file that you can use for RAM-based execution.
Here is a minimal syscalls.c file that you can modify to add functionality.
ARM Gotchas
- LDM instructions that load user-mode registers must be followed by a NOP if the next instruction uses a banked register. See, for example, the code in Section 9.6.5 of the ARM Architecture Reference Manual.
AT91SAM7S Gotchas
- READ THE ERRATA IN THE DATASHEET!!!
ARM-GCC Gotchas
- The compiler is not above suspicion, especially the relatively-new GCC 4.x series. Some students have found that overly-long functions cause incorrect behavior, and even adding or removing comments can change the code! Try refactoring your code (smaller functions) or using a more stable compiler such as GCC 3.4.6.
