Timesys Getting Started Guide for Atmel AT91SAM9RL-EK
Contents
- Introduction
- Prerequisites
- Preparing the Target
- Preparing the Host
- Booting the Board
- Additional Information
Introduction
This document will describe in detail the procedures for booting a Linux kernel image and mounting a root file system from an SD Card on the Atmel AT91SAM9RL-EK.
Prerequisites
Host Requirements
To properly boot a board using software from Timesys, your host machine must meet the following requirements:
- Modern GNU/Linux Distribution. While you can use nearly any modern Linux distribution released in the last 24 months, Timesys recommends one of the following:
- Ubuntu (Most recent release or LTS)
- Fedora (Most recent release)
- An internet connection on the Development Host.
- Root or sudo permission on the Development Host.
- A copy of the Linux Kernel (uImage-2.6.36-ts-armv5l) and Root File System (rootfs.tar.gz) for the Target Board downloaded from Factory. These are found in the output directory of your online build, or in the directory build_armv5l-timesys-linux-<libc>/images/ on the command line.
- If you are booting your root file system over the network, you will need two network cards installed and configured in the Development Host. One to communicate normally with your LAN/WAN while installing host packages, the other to communicate solely with the target board.
- An available serial port on your Development Host.
Target Requirements
To boot the Atmel AT91SAM9RL-EK, you will need the following items:
- Atmel AT91SAM9RL-EK Board
- Serial NULL Modem Cable
- Secure Digital (SD) Card
Once you have all of the necessary components, you should perform the following steps:
- Connect the debug port of the board to the serial port of your workstation using the null modem cable.
- Connect the power supply to your board.
Preparing the Target
Preparing the Secure Digital Card
The AT91SAM9RL-EK boots from an SD card. Some kits may be shipped with one that contains a sample kernel and RFS preloaded. We will be replacing these with the kernel and RFS from Factory. If you are using a blank SD card or have trouble replacing the software on the preloaded one, see Partitioning the SD Card. Otherwise, skip directly to Writing Boot Files to the SD Card.Before you begin, you should determine the name of your SD card on your host system. To do so:
- Connect the SD card to your host system. Many modern systems have SD card slots on the case, or you can purchase a USB SD Card Reader for around $15 US.
- Determine the device name of the SD Card. This can be done using dmesg. In the following example, the device is /dev/sdX, which contains one partition sdX1.
$ dmesg | tail
[88050.184080] sd 4:0:0:0: [sdX] 1990656 512-byte hardware sectors: (1.01 GB/972 MiB)
[88050.184821] sd 4:0:0:0: [sdX] Write Protect is off
[88050.184824] sd 4:0:0:0: [sdX] Mode Sense: 03 00 00 00
[88050.184827] sd 4:0:0:0: [sdX] Assuming drive cache: write through
[88050.185575] sd 4:0:0:0: [sdX] 1990656 512-byte hardware sectors: (1.01 GB/972 MiB)
[88050.186323] sd 4:0:0:0: [sdX] Write Protect is off
[88050.186325] sd 4:0:0:0: [sdX] Mode Sense: 03 00 00 00
[88050.186327] sd 4:0:0:0: [sdX] Assuming drive cache: write through
[88050.186330] sdX: sdX1
Partitioning the SD card
If you want to use a different SD card or its contents become corrupted, you can use the fdisk tool to create a single Linux partition on your SD card. Please note that all data on the card will be lost upon completion of these steps.- Unmount the partition if it was automounted by using the umount command.
$ umount /dev/sdX1
- As root, run the fdisk utility on the drive.
$ sudo fdisk /dev/sdX
- In fdisk, Delete the existing partition table and create a new one using the o command.
Command (m for help): o
Building a new DOS disklabel with disk identifier 0x8b025602.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
- Create a new primary partition using the n command.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-30679039, default 2048):
Using default value 2048
Last sector, +sectors or +sizeK,M,G (2048-30679039, default 30679039):
Using default value 30679039
- Verify that the partition table is correct by using the p command. It should look similar to the following:
Command (m for help): p
Disk /dev/sdX: 15.7 GB, 15707668480 bytes
64 heads, 32 sectors/track, 14980 cylinders, total 30679040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6eaae8f8
Device Boot Start End Blocks Id System
/dev/sdX1 2048 30679039 14773960 83 Linux
- This step will destroy all data on the SD Card - Write the partition table to the card using the w command.
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
- Format the first partition of the SD card with the ext2 filesystem using the mkfs.ext2 tool.
$ sudo /sbin/mkfs.ext2 -L rfs /dev/sdX1
Writing Boot Files to the SD Card
- Mount the partition. You can remove and reinsert the card to trigger the automount, or you can use the mount command to mount the partition to an arbitrary location.
$ sudo mount /dev/sdX1 /media/rfs
- As root, extract the rootfs.tar.gz archive to the mounted directory. This file is located at build_armv5l-timesys-linux-<libc>/images/rfs/ on Desktop Factory builds.
$ sudo tar xzf rootfs.tar.gz -C /media/rfs
- If you have included the kernel image in your rootfs, this next step is not necessary
As root, create the boot directory on the RFS partition of the card.
$ sudo mkdir /media/rfs/boot
- As root, copy the uImage file, uImage-2.6.36-ts-armv5l, to the boot directory on the RFS partition of the card.
$ sudo cp uImage-2.6.36-ts-armv5l /media/rfs/boot/
- As root, umount the SD Card.
$ sync
$ sudo umount /media/rfs
- Remove the SD Card from the host machine, and insert it into the SD Card slot on the target board J15. You should hear the card 'click' into place.
Configuring Serial Communication
The AT91SAM9RL-EK uses a serial debug port to communicate with the host machine. The commands discussed in this section are meant to be performed by a privileged user account. This requires the root login or prepending each command with sudo.Using Minicom
- Start minicom on your host machine in configuration mode. As root:
# minicom -o -s -w
- A menu of configuration should appear. Use the Down-arrow key to scroll down and select the Serial port setup option, and press Enter.
- Verify that the listed serial port is the same one that is connected to the target board. If it is not, press A, and enter the correct device. This is /dev/ttyS0 on most Linux distributions.
- Set the Bps/Par/Bits option by pressing the letter E and using the next menu to set the appropriate values. You press the key that corresponds to the value 115200, then press Enter.
- Set Hardware flow control to No using the F key.
- Set Software flow control to No using the G key.
- Press Enter to return to the main configuration menu, and then press Esc to exit this menu.
- Reset the board, and wait for a moment. If you do not see output from the board, press Enter several times until you see the prompt. If you do not see any output from the board, and have verified that the serial terminal connection is setup correctly, contact your board vendor.
TIP: If you experience an error similar to Device /dev/ttyS0 is locked when starting minicom, it usually means that another process is using the serial port (which is usually another instance of minicom). You can find the process that is currently using the serial port by executing the following:
/dev/ttyS0: 28358
PID TTY STAT TIME COMMAND
28923 pts/0 S+ 0:00 minicom
This process can also be killed directly with fuser as root. Please use this command with caution:
Using GNU Screen
To quickly connect to a board using Gnu Screen, execute the following:
For more information about using screen, please consult the man page, or view the manual online at http://www.gnu.org/software/screen/manual/screen.html
Installing Bootloaders
Most AT91SAM9RL-EK boards do not come with a bootloader preloaded. You must burn the bootloaders to flash using the Atmel SAM-BA tool.
The AT91SAM9RL-EK uses a three stage boot process:
- The BootROM finds a valid bootstrap image and loads it into SRAM
- The Bootstrap loader initilizes hardware and loads the image into SDRAM
- U-Boot boots the Linux kernel
This document assumes that you are booting from dataflash. For other configurations, please see the document /docs/wiki/engineering/HOWTO_Write_Bootloaders_to_Flash_on_Atmel_SAM9_Boards
NOTE: The following procedures will not work if a bootloader is already present on the board. To remove a bootloader, please see /docs/wiki/engineering/HOWTO_Reset_Atmel_SAM9_Boards_to_Factory_Defaults
Prerequisites
- SAM-BA Tool - Available from the Atmel website: http://www.atmel.com/tools/ATMELSAM-BAIN-SYSTEMPROGRAMMER.aspx
- Root privileges on your workstation
- dataflash_AT91SAM9RL-EK.bin file. This can be found in the bootloaders directory of the web output, or in build_armv5l-timesys-linux-<glibc>/images/bootloader directory of your Desktop build.
- u-boot.bin file. This can be found in the bootloaders directory of the web output, or in build_armv5l-timesys-linux-<glibc>/images/bootloader directory of your Desktop build.
- USB cable, type A to micro B.
Burning AT91Bootstrap to Dataflash
- Start up SAM-BA.
- Enable the DataFlash chip.
- Click the Dataflash AT45 tab.
- Select Enable Dataflash on CS0 under the Scripts dropdown and click Execute.
- Burn the AT91 Bootstrap Loader file to DataFlash:
- Select Send Boot File under the Scripts dropdown and click Execute
- Navigate to the .bin file and click Open.
- You may leave SAM-BA open until you write U-Boot to the board.
Burning U-Boot to Dataflash
- Start up SAM-BA, if it is not already open.
- Burn U-Boot to DataFlash.
- Click the Dataflash AT45 tab.
- Select Enable Dataflash on CS0 under the Scripts dropdown and click Execute.
- Click the Browse button next to Send File Name under the Download/Upload File section. Navigate to the u-boot.bin file and click Open.
- Set the Address box to 0x8400 for U-Boot 2008.10 or newer. If you are using an older version of U-Boot, use the address 0x8000.
- Click Send File.
- Close SAM-BA and reset the board.
Burning Kernel to Dataflash
- Start up SAM-BA, if it is not already open.
- Burn kernel to DataFlash.
- Click the DataFlash AT45 tab.
- Select Enable Dataflash on CS0 under the Scripts dropdown and click Execute.
- Click the Browse button next to Send File Name under the Download/Upload File section. Navigate to the uImage-2.6.36-ts-armv5l file and click Open.
- Set the Address box to 0x42000 for U-Boot 2008.10 or newer. If you are using an older version of U-Boot, use the address 0x40000.
- Click Send File.
- Close SAM-BA and reset the board.
Preparing the Host
Since this board does not contain a network interface, there is no additional host configuration necessary.
Booting the Board
Set Environment Variables
You must set a few environment variables in order to boot the board from dataflash. This is done with the setenv and saveenv commands in U-Boot. On the target, set the following environment variables:
Variable | Value |
bootargs | console=ttyS0,115200 root=/dev/mmcblk0p1 rw |
bootcmd | cp.b 22000000 c0042000 21000\; bootm |
Example
> setenv bootcmd cp.b 22000000 c0042000 21000\; bootm
> saveenv
Load The Kernel
You can use the cp command to load the kernel from Dataflash.
Example
Boot the Kernel
The bootm command is used to boot the kernel. It loads the file that was previously loaded using the cp command.
Example
## Booting kernel from Legacy Image at 22000000 ..
Image Name: Linux-2.6.36
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3008548 Bytes = 2.9 MB
Load Address: 80008000
Entry Point: 80008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
Additional Information
Factory Documentation