User Guide LINUX FOR AT91CAP9-STK VERSION: 1.1 1/11
History of Changes Revision Issue Date Descripion Author Ver 1.0 2009-04-24 First version of the document Olivier Arnal Ver 1.1 2009-04-27 Minor modification (SAM-BA patch) Olivier Arnal 2/11
Table of Contents 1 Scope... 4 2 Requirements... 5 2.1 Hardware requirements... 5 2.2 Software requirements... 5 3 Linux on AT91CAP9-STK architecture... 6 3.1 Supported features... 6 3.2 Boot sequence... 7 3.3 NandFlash memory map... 7 4 Installation... 8 4.1 NandFlash installation... 8 5 Rebuild from source... 9 6 Develop a sample Linux application... 10 7 References... 11 3/11
1 Scope This document is a getting starting guide describing how to put a running embedded Linux distribution on an AT91CAP9-STK board. Chapter 2 of this document details the hardware and software requirements. Chapter 3 explains how the AT91CAP9-STK board boots and how the different binaries are installed into the flash memories. Chapter 4 details the installation instructions, letting you install the delivered binaries on the board. Chapter 5 explains how to rebuild all the binaries from source, in case you want to customize some of them. Chapter 6 shows how to develop a sample Linux application and run it on the board. The procedure is heavily based on the work done for AT91SAM systems, and the reading of the information which can be found at http://www.linux4sam.org is strongly recommended. 4/11
2 Requirements 2.1 Hardware requirements an AT91CAP9 starter kit (AT91CAP9-STK), composed of: AT91CAP9-STK board ; 5V power supply ; USB Device Cable (type A-B connector); serial Cross Cable (Female-Female) ; a serial terminal emulator (HyperTerminal, minicom, etc.) a Windows XP host (or above) to run the SAM-BA tool. a Linux host to rebuild the binaries (if wanted) 2.2 Software requirements a serial terminal emulator (HyperTerminal, minicom, etc.) the AT91CAP9-STK Linux package, containing: AT91 ISP 1.12 (or higher) ; containing the SAM-BA tool at91-isp_1.12b_patch.zip : SAM-BA patch for new Nand memory support prebuilt binaries for AT91Bootstrap, u-boot, Linux kernel, root filesystem sources and patches for AT91Bootstrap, u-boot and Linux kernel cross-compiler for rebuilding the binaries 5/11
3 Linux on AT91CAP9-STK architecture 3.1 Supported features The AT91CAP9STK supported features are listed below. U-Boot features : SDRAM Serial port DBGU Timer PIT Nand Flash with ECC soft Ethernet Linux kernel features : SDRAM Interrupt Controller AIC Timer PIT Serial port DBGU LEDs USB Host OHCI USB High Speed Device SPI TWI MCI : handles SD card Nand Flash with ECC soft LCDC Ethernet Touchscreen RTC (using RTT) 6/11
3.2 Boot sequence The AT91CAP9-STK board has only boot configuration, boot from NandFlash. BMS is always high level (BMS=1). The only one bootable memory present on the board is a NandFlash. A jumper is present on the board for the NandFlash chip select line. At power on, the ROM Code contained in the embedded ROM is executed. The ROM Code : initializes the hardware tries to locate a bootable program in a bootable memory (NandFlash, SDcard, DataFlash/SerialFlash, TWI eeprom) if the bootable program is found, it is downloaded into the SRAM and started if no bootable program is found, the SAM-BA monitor is executed. SAM-BA monitor waits for transactions on the USB device port or on the DBGU serial port. The SAM-BA application running on a PC can then be used to program flash memories. The Linux boot sequence on the AT91CAP9-STK involves several binaries: ROM Code Bootstrap: a small (need to be small enough to be downloaded into the 32 KB SRAM of the AT91CAP9) bootstrap code which does basic hardware initializations (flash and SDRAM), downloads a bigger binary from the external flash into the external SDRAM and launches it. U-Boot: this is the standard Linux boot loader, an interactive program which downloads the Linux kernel from the flash or from the network (using the TFTP protocol) into the SDRAM, pass some parameters to the kernel and launches it. Linux Kernel: the kernel does the full hardware initializations and loads the applications from a root file-system. Root file-system: this is a standard Linux file-system containing user applications. 3.3 NandFlash memory map Name Start offset Size Bootstrap 0x0000_0000 0x4000 U-Boot 0x0002_0000 0x30000 U-Boot environment 1 0x0006_0000 0x20000 U-Boot environment 2 0x0008_0000 0x20000 Linux kernel 0x000A_0000 0x200040 Linux root file-system 0x002A_0000 0x5C0000 7/11
4 Installation 4.1 NandFlash installation 1. Insert the AT91CAP9-STK Linux CD in the CDROM drive, and extract the linux-at91cap9stkbinary.zip file contents somewhere on your hard drive. 2. Install SAM-BA 1.12 (part of AT91 ISP tools) on the Windows PC. Install the SAM-BA patch (at91-isp_1.12b_patch.zip). Please refer to http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3883 for further instructions, as well as the SAM-BA User Manual. 3. Launch the serial terminal emulator, set it for handling connections at 115200 8N1 (115200 bps, 8 bits data connection, no parity, 1 stop bit) 4. Connect the AT91CAP9-STK evaluation board components: connect the 5V power supply on the AT91CAP9-STK board ; connect the serial cable between the DBGU port on the AT91CAP9-STK board and a serial port on the PC; connect the USB device cable between the HI-SPEED USB port on the AT91CAP9-STK board and a USB host port on the PC; 5. Ensure the jumper J66 (NandFlash Chip Select) is opened 6. Press the FORCE ON button (S4) 7. The USB connection between the PC and the board should establish (ATMEL AT91xxxxx Test Board does appear in taskbar notification area) ; 8. Close jumper J66. 9. Double-click on one of the scripts in the linux-at91cap9stk-binary folder (where you extracted the zip file). You can choose between: at91cap9stk-console-nd.bat : installs a text (console based) embedded Linux in the NAND flash ; at91cap9stk-x11-nd.bat : installs a graphical embedded Linux in the NAND flash ; 10. Wait a few minutes for the flash to be written ; 11. When the logfile.log appears, remove the USB cable ; 12. Power cycle the board ; 13. The Linux demo will automatically start, you can follow the progress in the serial terminal. If you have installed the graphical Linux image you can proceed with the calibration of the LCD screen (follow the on screen instructions) ; 14. You can log into the system on the serial terminal using the root account (no password) ; 15. Once logged, you can activate the network using (replace with your own MAC and IP addresses): ifconfig eth0 hw ether 00:01:02:03:04:05 192.168.1.42 8/11
5 Rebuild from source You can easily rebuild the provided binaries (Bootstrap, U-Boot, Linux kernel) on a Linux machine (the development was done on an Ubuntu 7.10 machine, but any recent Linux distribution should work, provided the development packages are installed). 1. Insert the AT91CAP9-STK Linux CD in the CDROM drive, and extract the linux-at91cap9stksource.zip file contents somewhere on your hard drive: $ mkdir ~/at91cap9 $ cd ~/at91cap9 $ unzip /media/cdrom/linux-at91cap9stk-source.zip $ cd linux-at91cap9stk-source 2. At the top of the directory where you extracted the file you'll find a Makefile file. Using a standard editor (vi, emacs) you can modify at the top of this file the location where temporary files will be placed (BUILD) and the location where the result of the compile process will be stored (CROSS): $ emacs Makefile 3. Type make and wait a few minutes for the compile to end ; $ make 4. CROSS contains a full cross-compiler installation you can use to develop Linux applications for the AT91CAP9-STK board. You can copy this cross-compiler to a system-wide location for further use: $ su - # cp -r /tmp/cross /usr/local/at91cap9stk 5. You will find the Bootstrap, U-Boot and Linux kernel binaries in the target subdirectory of CROSS: $ ls /usr/local/at91cap9stk/target/ 6. If you want to rebuild the root file-system, you need to follow the instructions at http://www.linux4sam.org. 9/11
6 Develop a sample Linux application A sample demo application is provided on the CD and can serve as a basis for developing your Linux application. 1. Install the cross-compiler as seen in Chapter 5 ; 2. Make sure the cross-compiler binaries are in your PATH, for example if your shell is bash: $ export PATH=$PATH:/usr/local/at91cap9stk/bin You will probably want to make this setting permanent by modifiying your shell's startup files (~/.bashrc). 3. Insert the AT91CAP9-STK Linux CD in the CDROM drive, and extract the linux-at91cap9stkhelloworld.zip file contents somewhere on your hard drive: $ mkdir ~/at91cap9 $ cd ~/at91cap9 $ unzip /media/cdrom/linux-at91cap9stk-helloworld.zip $ cd linux-at91cap9stk-helloworld 7. Compile the example using the Makefile file: $ make 8. Copy the binary to the AT91CAP9-STK board over the network: first, start the network on the AT91CAP9-STK board: at91cap9 $ ifconfig eth0 hw ether 00:01:02:03:04:05 192.168.1.42 then assign a password to the root user on the AT91CAP9-STK board: at91cap9 $ passwd and finally copy the binary from the PC to the AT91CAP9-STK board: $ scp helloworld root@192.168.1.42:/home/root/ 9. Alternatively, if using a NFS mounted root file system, you can simply copy the binary to the destination: $ cp helloworld /nfsroot/angstrom-x11-image-demo-glibc/home/root 10. On the AT91CAP9-STK board, execute the binary: at91cap9 $ cd /home/root at91cap9 $./helloworld 11. If you want helloworld to be run on each boot, create a sample boot script: at91cap9 $ echo #! /bin/sh > /etc/init.d/helloworld.sh at91cap9 $ echo /home/root/helloworld & >> /etc/init.d/helloworld.sh at91cap9 $ chmod +x /etc/init.d/helloworld.sh at91cap9 $ update-rc.d helloworld.sh defaults 99 10/11
7 References Linux on AT91SAM products: http://www.linux4sam.org CodeSourcery cross-compiler: http://www.codesourcery.com/gnu_toolchains/arm U-Boot manual: http://www.denx.de/wiki/dulg/manual Linux kernel distribution site: http://www.kernel.org/ Linux Angstrom distribution: http://www.angstrom-distribution.org/ 11/11