Timesys Getting Started Guide for Atmel AT91SAM9G15-EK


Contents

Introduction

This document will describe in detail the procedures for booting a Linux kernel image and mounting a root file system over NFS on the Atmel AT91SAM9G15-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.39-ts-armv5l) and Root File System (rootfs.ubi) 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 AT91SAM9G15-EK, you will need the following items:

  • Atmel AT91SAM9G15-EK Board
  • Serial NULL Modem Cable
  • USB A to Micro-B Cable

Once you have all of the necessary components, you should perform the following steps:

  1. Connect the debug port of the board to the serial port of your workstation using the null modem cable.
  2. Connect the USB Gadget port of the board to the USB cable. Connect the other end to your workstation.
  3. Connect the power supply to your board.

Preparing the Target

Configuring Serial Communication

The AT91SAM9G15-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

  1. Start minicom on your host machine in configuration mode. As root:

    # minicom -o -s -w

  2. A menu of configuration should appear. Use the Down-arrow key to scroll down and select the Serial port setup option, and press Enter.
  3. 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.
  4. 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.
  5. Set Hardware flow control to No using the F key.
  6. Set Software flow control to No using the G key.
  7. Press Enter to return to the main configuration menu, and then press Esc to exit this menu.
  8. 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:

# fuser /dev/ttyS0
/dev/ttyS0:         28358

# ps 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:

# fuser -k /dev/ttyS0

Using GNU Screen

To quickly connect to a board using Gnu Screen, execute the following:

# screen /dev/ttyS0 115200

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 AT91SAM9G15-EK boards do not come with a bootloader preloaded. You must burn the bootloaders to flash using the Atmel SAM-BA tool.

The AT91SAM9G15-EK uses a three stage boot process:

  1. The BootROM finds a valid bootstrap image and loads it into SRAM
  2. The Bootstrap loader initilizes hardware and loads the image into SDRAM
  3. U-Boot boots the Linux kernel

This document assumes that you are booting from nandflash. 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
  • at91sam9x5ek-nandflashboot-3.2.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 Nandflash

  1. Start up SAM-BA.
  2. Enable the Nandflash chip.
    1. Click the Nandflash tab.
    2. Select Enable Nandflash under the Scripts dropdown and click Execute.
  3. Burn the AT91 Bootstrap Loader file to Nandflash:
    1. Select Send Boot File under the Scripts dropdown and click Execute
    2. Navigate to the .bin file and click Open.
  4. You may leave SAM-BA open until you write U-Boot to the board.

Burning U-Boot to Nandflash

  1. Start up SAM-BA, if it is not already open.
  2. Burn U-Boot to Nandflash.
    1. Click the Nandflash tab.
    2. Select Enable Nandflash under the Scripts dropdown and click Execute.
    3. Select Enable OS PMECC under the Scripts dropdown and click Execute.
    4. Click OK to accept the defaults.
    5. 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.
    6. Set the Address box to 0x40000.
    7. Click Send File.
  3. Unless you wish to write the kernel and RFS to NAND, you may close SAM-BA and reset the board.

Burning Kernel to Nandflash

  1. Start up SAM-BA, if it is not already open.
  2. Burn kernel to NandFlash.
    1. Click the Nandflash tab.
    2. Select Enable Nandflash under the Scripts dropdown and click Execute.
    3. Select Enable OS PMECC under the Scripts dropdown and click Execute.
    4. Click OK to accept the defaults.
    5. Erase the NAND flash section used to store the kernel. Type the following into the console at the bottom of SAM-BA and press Enter:

      NANDFLASH::EraseBlocks 0x200000 0x7FFFFF
    6. Click the Browse button next to Send File Name under the Download/Upload File section. Navigate to the uImage-2.6.39-ts-armv5l file and click Open.
    7. Set the Address box to 0x200000.
    8. Click Send File.
  3. You may leave SAM-BA open until you write the RFS to the board.

Burning RFS to Nandflash

  1. Start up SAM-BA, if it is not already open.
  2. Burn kernel to NandFlash.
    1. Click the Nandflash tab.
    2. Select Enable Nandflash under the Scripts dropdown and click Execute.
    3. Select Enable OS PMECC under the Scripts dropdown and click Execute.
    4. In the dialog box, select the Trimffs option.
    5. Click OK.
    6. Erase the NAND flash section used to store the kernel. Type the following into the console at the bottom of SAM-BA and press Enter:

      NANDFLASH::EraseBlocks 0x800000 0xFFFFFFF
    7. Click the Browse button next to Send File Name under the Download/Upload File section. Navigate to the rootfs.ubi file and click Open.
    8. Set the Address box to 0x800000.
    9. Click Send File.
  3. You may leave SAM-BA open until you write the RFS to 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 nandflash. 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=ubi0_0 rw ubi.mtd=1 mtdparts=atmel_nand:8M(bootstrap/uboot/kernel)ro,-(rootfs)
bootcmd nand read.jffs2 22000000 200000 250000\; bootm

Example

> setenv bootargs console=ttyS0,115200 root=ubi0_0 rw ubi.mtd=1 mtdparts=atmel_nand:8M(bootstrap/uboot/kernel)ro,-(rootfs)
> setenv bootcmd nand read.jffs2 22000000 200000 250000\; bootm
> saveenv

Load The Kernel

You can use the cp command to load the kernel from Dataflash.

Example

> cp.b 22000000 200000 250000

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

> bootm
## Booting kernel from Legacy Image at 22000000 ..
   Image Name:   Linux-2.6.39
   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

Creating SD Card Bootloaders

In order to boot from an SD card, you must use the SD card configurations for at91bootstrap and u-boot. NOTE: You need a Desktop Factory build system to perform these steps

  1. Run make menuconfig to modify your Desktop factory configuration.
  2. Navigate to Target Software->Bootloaders->at91bootstrap-3
  3. Change at91bootstrap-3 Configuration Target to at91sam9x5sduboot
  4. Navigate to Target-Software->Bootloaders->u-boot
  5. Change u-boot Configuration Target to at91sam9x5ek_nandflash
  6. Remove your existing at91bootstrap-3 and u-boot builds:

    make at91bootstrap-3-clean u-boot-clean
  7. Rebuild Factory:

    make

Preparing the Secure Digital Card

The AT91SAM9G15-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:

  1. 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.
  2. 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 sfdisk tool to create a Linux partition on your SD card. Please note that all data on the card will be lost upon completion of these steps.
  1. Unmount the partition if it was automounted by using the umount command.
    $ umount /dev/sdX1
  2. As root, run the following sfdisk command on the drive. This creates a 64 MB (131072 512-bye sectors) boot partition, with the remaining space as a second partition.
    $ sudo sfdisk /dev/sdX « EOF
    ,131072,6
    ;
    EOF
  3. Format the first partition of the SD card with a FAT16 filesystem using the mkfs.msdos tool.
    $ sudo /sbin/mkfs.msdos -n boot /dev/sdX1

  4. Format the second partition of the SD card with an ext4 filesystem using the mkfs.ext4 tool.

    $ sudo /sbin/mkfs.ext4 -L rfs /dev/sdX2

Writing the Files to the Card

We will write the bootloader, kernel, and rfs files to the SD card.

  1. Mount the SD card partitions. 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/boot
    $ sudo mount /dev/sdX2 /media/rfs

    NOTE: The following path strings are broken with a backslash for formatting purposes. When typing them on your host system, they should be a single spaceless string without a backslash representing the full path to your files. Substitute /path/to/factory/ with the path to your factory and /media/boot and /media/rfs with the paths to your mounted SD Card devices.

  2. Write the bootstrap loader, at91sam9x5ek-sdcardboot-3.2.bin, to the boot partition of the SD Card device.

    cp /path/to/factory/build_armv5l-timesys-linux-<libc>/images/\
            bootloader/at91sam9x5ek-sdcardboot-3.2.bin /media/boot/boot.bin
  3. Write the u-boot binary, u-boot.bin, to the boot partition of the SD Card device.

    cp /path/to/factory/build_armv5l-timesys-linux-<libc>/images/\
            bootloader/u-boot.bin /media/boot/u-boot.bin
  4. Write the kernel binary, uImage-2.6.39-ts-armv5l, to the boot partition of the SD Card device.

    cp /path/to/factory/build_armv5l-timesys-linux-<libc>/images/\
            images/uImage-2.6.39-ts-armv5l /media/boot/uImage

  5. Copy the root files system rootfs.tar.gz to the RFS partition on the SD card.

    $ sudo tar xf rootfs.tar.gz -C /media/rfs

  6. Flush the SD card I/O buffer with a sync call.

    sync
  7. Unmount the microSD card, remove the card from your host, and slide it into the slot of your AT91SAM9G15-EK. You should hear the card 'click' into place.

Factory Documentation