Build and Install Linux for ARM Cortex-A5 based embedded board

For this present article, we use SAMA5d3_Xplained board based on ATSAMA5D36 (ARM based MPU). But, the same step follows for any other hardware.

This article aims to introduce on bringing up SAMA5D3_Xplained board as a Linux System.

Before we start, we need to understand the boot sequence to know what should be done (Ref. Getting Started - at91.com)

Boot Sequence - at91.com
Boot Sequence (Source: at91.com)
The above image will show you three levels of bootloaders which are optional based on whether we implement simple firmware or OS.

Step:1 Prepare the necessary objects
  1. Bootstrap image
  2. Kernel Image
  3. Kernel modules
  4. Device tree file
  5. Rootfs Image 

Note:
arm-linux-gnueabi- toolchain required to build the image, can be downloaded form release.linaro.org and add path to gcc-linaro_<version>_arm-linux-gnueabi/bin directory.

$ export PATH=~/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabi/bin/:$PATH

To permanently add the path to the environment, add the above command to .bashrc file.

Building Bootstrap Image

  1. Clone/Download at91bootstrap source from linux4sam/at91bootstrap git repository.
  2. Configure the source with the default configuration for SD Card boot. You can find a number of default configurations for different boot media at ./board/sama5d3xek/ directory.
    $ cd at91bootstrap/
    $ make mrproper
    $ make sama5d3_xplainedsd_linux_image_dt_defconfig 
    Note:
    nf- NandFlash, sd - MMC Card, df - SerialFlash, linux - linux kernel, android - android kernel, uboot - u-boot, dt - device tree binary (dtb). (Ref. AT91Bootstrap - at91.com)

  3. Compile the at91bootstrap
    $ make CROSS_COMPILE=arm-linux-gnueabi-
    The resulting binary will be created at ./binaries/ with the name sama5d3_xplained……bin .

Building Kernel Image, Device Tree (.dtb) and Kernel Modules

The Kernel Image, Device Tree Binary and Kernel Modules are all built form Kernel Source with different options.
  1. Get Kernel Source either from kernel.org or linux4sam/linux-ar91 git repository.
  2. Configure the build with default configuration.
    $ cd linux-at91
    $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- sama5_defconfig
    Note: More default configurations for various standard boards can be found at arch/arm/configs/. Equivalently, you can also copy the desired configuration file from this directory to root directory with file name '.config' and run make defconfig.
  3. For any changes needed in the configuration, configure using menuconfig
    $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
  4. Compile for Kernel Image
    $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- zImage
  5. Compile for Device Tree Binary(.dtb)
    $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- dtbs
  6. Compile for Kernel Modules
    $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules
    The images will be created at arch/arm/boot/.

Building Rootfs

There are several Roofs build systems available such as Yocto, Buildroot, Busybox, Multistrap, etc.,
For our convenience, we can get the archived pre-built custom Rootfs from shark/zdrive. Other sources can also be found online(sborut.wordpress.com, Dropbox). But, for ARM architecture.

Preparing SD/MMC Card

In SD Card, two partitions are to be created.
  • First partition (FAT32)boot/ ⇒ required to move the boot images(bootstrap, kernel image and device tree binary).
  • Second partition (EXT4)rootfs/ ⇒ for the root file system requied by the kernel to run.
Note:
fdisks is a command-line tool for creating and managing partitions. mkfs is another command-line tool to format paritions to required file system. Need to be super user to use this tool.
  1. After the SD Card is ready with the required partitions say by name, boot and rootfs, copy the bootstrap image, kernel image, dtb to boot/ as follows.
    $ at91bootstrap/binaries/sama5d3_xplained-sdcardboot-linux-image-dt-3.8.bin  /media/user/boot/boot.bin
    $ cp linux-at91/arch/arm/boot/zImage /media/user/boot/image
    $ cp linux-at91/arch/arm/boot/dts/at91-sama5d3_xplained.dtb /media/user/boot/
  2. Untar the downloaded rootfs archive to the second partition rootfs
    $ tar -xvf  rootfs-armel-wheezy.tar.xz -c /media/user/rootfs
  3. Install the Kernel Modules into rootfs
    ~/linux-at91 $ make modules_install ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=/media/user/rootfs
    Now, your SD Card is ready with the necessary components to run Linux on SAMA5D3 Xplained board.

Bringing Wi-Fi Client Feature

To bring Wi-Fi client feature with the given NIC, we may need
  1. Device driver for the given NIC enabled in the Kernel.
  2. Some HAL layer firmware, if required by the device driver. (Ref. ath9k_htc firmware - github.com)
  3. Certain utilities to configure and manage Wi-Fi.
    (iw, ip, iwconfig, wpa_passphrase, wpa_supplicant, firmware-atheros)
  4. Read on through this link to bring WiFi Client feature.

Disclaimer:
The above article doesn't give you any guarantee and the sole purpose of this article is to share my learning in the way I understood. Any comments to refine this article are welcome with great pleasure. Please report any breaking link by commenting below.

Receive all updates via Facebook. Just Click the Like Button Below

You can also receive Free Email Updates:

dgpride - Study Zone - Free Books - Tamil Lyrics

Copyright © 2008 -2012 dgpride. All rights reserved.

Subject/Topics

2 Marks (26) 8051 (1) AC Machines (7) Animations (1) Anna University Chennai (31) Arduino (4) ARM (3) Audio (1) Basic C Concepts (8) Basic Electronics (13) Basic principles (9) Book list (1) CAD (1) Chemical (2) Circuit theory (6) Civil (2) Cloud Computing (1) Communication (4) Competitive exams (2) Computer Architecture (4) Control system and components (9) CSE (40) Curriculum (4) DC Machines (9) Did you know (14) Digital (13) DLC (4) Documentation (1) DSP (1) EC 2201 (3) ECE (45) EDC (1) EEE (34) EIE (63) Electrical (35) Electronics (43) Electroplating (2) Emacs (1) Embedded basics (19) Embedded C Programming (19) Embedded Linux (5) Embedded System (22) Engineering basics (15) Environmental Science (1) Fibre Optics (1) Filters (2) FPGA (1) GATE (3) General (7) GNU (4) Handwritten (1) Hobbyist (15) How to (8) HTML (3) Humanities (2) IC Engines (7) ICE (5) Industrial Electronics (10) Industrial Instrumentatin (2) industrial process (2) Instrumentation (21) IoT (2) IT (2) Laboratory Manuals (17) LabVIEW (2) Lesson notes (2) LIC (2) Links (9) Linux (8) Magnetics (1) Management (1) Mechanical (5) Mechatronics (9) Microcontrollers (14) Microprocessors (9) Microsoft (1) Motivation (1) Must Know (11) Networks (1) NuttX (1) Objective type (1) Open Source (1) Opportunities (7) Oscillators (2) Part Time (1) Physics (1) Post Graduation (1) Power Electronics (12) Power Plant Engineering (2) Power Supplies (2) Previous GATE Papers (1) Process Control (2) Project (4) Protocol (1) R2008 (11) R2009 (1) R2013 (1) Recruitment (2) Research (2) Robotics (9) RTOS (3) Signal Processing (8) Signals and Systems (4) SMPS (1) Software tutorial (4) Stepper Motor (2) Syllabus (5) Texas Instruments (2) Thermodynamics (2) Training and Placement (6) Transducer Engineering (2) Transformer (2) Transmission (1) Tutorials (48) Two Marks (26) U-Boot (1) University Question Papers (16) Verilog (1) Video (4) Virtual Instrumentation (3) Visual Basic (21) VLSI (11) Web designing (4) Wi-Fi (3) Wireless (6)