Timesys Getting Started Guide for Atmel SAMA5D3 Xplained
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 over NFS on the Atmel SAMA5D3 Xplained.
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 (zImage-4.1-ts-armv7l) 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_armv7l-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 SAMA5D3 Xplained, you will need the following items:
- Atmel SAMA5D3 Xplained Board
- Micro USB Cable
- MicroSD Card
- Ethernet Crossover Cable or Ethernet hub/switch and Ethernet Patch Cables
Once you have all of the necessary components, you should perform the following steps:
- Connect the micro USB port labeled J14 to a USB port of your workstation using the micro USB cable.
- If you are using a cross-over cable, connect the Ethernet port of the board to the second Ethernet port of your workstation.
- If you are using an Ethernet hub or switch, connect the board to the hub with a straight-through Ethernet cable, then connect the hub to the second Ethernet port of your workstation.
- Connect the power supply to your board.
Preparing the Target
Preparing the Secure Digital Card
The SAMA5D3 Xplained 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 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.- Unmount the partition if it was automounted by using the umount command.
$ umount /dev/sdX1
- 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
- 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
- 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.
- 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.
- Write the bootstrap loader, sama5d3_xplained-sdcardboot-uboot-3.8-beta1.bin, to the boot partition of the SD Card device.
cp /path/to/factory/build_armv7l-timesys-linux-<libc>/images/\
bootloader/sama5d3_xplained-sdcardboot-uboot-3.8-beta1.bin /media/boot/boot.bin
- Write the u-boot binary, u-boot.bin, to the boot partition of the SD Card device.
cp /path/to/factory/build_armv7l-timesys-linux-<libc>/images/\
bootloader/u-boot.bin /media/boot/u-boot.bin
- Write the kernel binary, zImage-4.1-ts-armv7l, to the boot partition of the SD Card device.
cp /path/to/factory/build_armv7l-timesys-linux-<libc>/images/\
images/zImage-4.1-ts-armv7l /media/boot/zImage
- Write the device tree blob, sama5d3_xplained.dtb, to the boot partition of the SD Card device.
cp /path/to/factory/build_armv7l-timesys-linux-<libc>/images/\
images/sama5d3_xplained.dtb /media/boot/at91-sama5d3_xplained.dtb
- 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
- Flush the SD card I/O buffer with a sync call.
sync
- Unmount the microSD card, remove the card from your host, and slide it into the slot of your SAMA5D3 Xplained. You should hear the card 'click' into place.
Preparing the Host
No additional host setup is required to boot from SD.
Booting the Board
Set Environment Variables
You must set a few environment variables in order to boot the board from the SD card. 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 earlyprintk root=/dev/mmcblk0p2 rw rootwait |
load_kernel | fatload mmc :1 22000000 zImage |
load_dtb | fatload mmc :1 21000000 at91-sama5d3_xplained.dtb |
bootcmd | mmc rescan\; run load_kernel load_dtb\; bootz 22000000 - 21000000 |
Example
> setenv load_kernel fatload mmc :1 22000000 zImage
> setenv load_dtb fatload mmc :1 21000000 at91-sama5d3_xplained.dtb
> setenv bootcmd mmc rescan\; run load_kernel load_dtb\; bootz 22000000 - 21000000
> saveenv
Load The Kernel
You can use the mmc subsystem to load the kernel from the SD card.Example
> fatload mmc :1 22000000 zImage
reading zImage
3008612 bytes read
Load The Device Tree
You can use the mmc subsystem to load the device tree file (dtb) from the SD card.Example
> fatload mmc :1 21000000 at91-sama5d3_xplained.dtb
reading at91-sama5d3_xplained.dtb
24612 bytes read
Boot the Kernel
The bootz command is used to boot the kernel. It loads the file that was previously loaded using the fatload command.Example
## Booting kernel from Legacy Image at 22000000 ..
Image Name: Linux-4.1
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
## Flattened Device Tree blob at 21000000
Booting using the fdt blob at 21000000
Loading Kernel Image ... OK
OK
Additional Information
Factory Documentation