Embedded Linux Workshop on Blueboard-AT91
B. Vasu Dev vasu@[Link]
Enabling the Embedded Learning in INDIA
Workshop Overview
Day 1
Embedded Linux Intro Linux Basics (Lab) Toolchain (Lect) Toolchain (Lab) Bootloader (Lect) Bootloader (Lab) Running Linux on Target > Using SD Card for rootfs > Configuring NFS > Configuring TFTP
Day 2
Linux Kernel Arch. Linux Kernel Source code browsing and porting changes (Lect) Kernel Configuration & Compiling (Lab) Kernel modifications Root File System (Lect) Building Root FS (Lab) App Development & Cross Compilation ( Lab)
Enabling the Embedded Learning in INDIA
Embedded Linux
Enabling the Embedded Learning in INDIA
Embedded Linux
Customisation of Linux to fit on a Embedded Board designed for one or a few dedicted functions. All hardware sits on a single board most of the time. Computer system used in common deviced in daily use.
Enabling the Embedded Learning in INDIA
Applications
Enabling the Embedded Learning in INDIA
Hardware Requirement
A CPU supported by gcc and the Linux kernel 32 bit CPU MMU-less CPUs are also supported, through the uClinux project. A few MB of RAM, from 4 MB. 8 MB are needed to do really do something. A few MB of storage, from 2 MB. 4 MB to really do something. Linux isn't designed for small microcontrollers that just have a few tens or hundreds of KB of flash and RAM. Base metal, no OS Reduced systems, such as FreeRTOS
Enabling the ARM Learning in INDIA
Our Hardware
BlueBoard AT91
180 MHz ARM9 processor (Atmel AT91RM9200) 4MB of serial flash 32MB SDRAM 1 SD/MMC slot USB 2.0 host I2C port 1 10/100 Ethernet interface 1 high speed USB 2.0 interface GP IO lines brought out on to a header JTAG support 2 serial ports
Enabling the ARM Learning in INDIA
ARM Core Family
Application Cores
ARM720T ARM920T ARM922T ARM926EJ-S ARM1020E ARM1022 ARM1026EJ-S ARM11 MPCore ARM1136J(F)-S ARM1176JZ(F)-S ARM Cortex-A8 ARM Cortex-A9
Embedded Cores
ARM7EJ-S ARM7TDMI ARM7TDMI-S ARM946E-S ARM966E-S ARM968E-S ARM996HS ARM1026EJ-S ARM1156T2(F)-S ARM Cortex-M0 ARM Cortex-M1 ARM Cortex-M3
Secure Cores
SecureCore SC100 SecureCore SC110 SecurCore SC200 SecurCore SC210
Enabling the ARM Learning in INDIA
ARM Core Family
T: Thumb D: On-chip debug support M: Enhanced multiplier I: Embedded ICE hardware T2: Thumb-2 S: Synthesizable code E: Enhanced DSP instruction set J: JAVA support, Jazelle Z: Should be TrustZone? F: Floating point unit H: Handshake, clockless design for synchronous or asynchronous design
Enabling the ARM Learning in INDIA
Development of the ARM Architecture
1 2 3
Early ARM architectures Halfword and signed halfword / byte support System mode
4
SA-110 SA-1110
Improved ARM/Thumb Interworking CLZ
5TE
Jazelle Java bytecode execution ARM9EJ-S ARM7EJ-S
5TEJ
ARM926EJ-S ARM1026EJ-S
Saturated maths DSP multiplyaccumulate instructions ARM1020E XScale ARM9E-S ARM966E-S
Thumb instruction set ARM7TDMI ARM720T
SIMD Instructions Multi-processing V6 Memory architecture (VMSA) Unaligned data support
4T
ARM9TDMI ARM940T
ARM1136EJ-S
Enabling the ARM Learning in INDIA
ARM Cores & Arch Ver
Enabling the ARM Learning in INDIA
Software Components
Application Application
Library Tools
Library
Library
Standard C library Linux kernel Bootloader Hardware Enabling the ARM Learning in INDIA
Linux on Board
Flash contents
Bootloader Kernel
Bootloader: First program executed by hardware and is responsible for basic initilization, loading and starting kernel.
Root filesystem
Kernel: Is the main program which provides platform to the application to execute. Kernel contains the process and memory management, network stack, device drivers and provides services to userspace applications.
File System: Linux is File system based OS. It supports various tyes of file system. The first node of linux file system is root '/' and the file system mounted to '/' is called Enabling root file system. the ARM Learning in INDIA
Linux Basics
Enabling the ARM Learning in INDIA
Linux Basics
Linux Structure Basic Linux Commands Shell Scripting Basics
Enabling the ARM Learning in INDIA
Linux Directory Structure
Condition code flags N = Negative result from ALU Z = Zero result from ALU C = ALU operation Carried out V = ALU operation Overflowed Sticky Overflow flag - Q flag Architecture 5TE/J only Indicates if saturation has occurred J bit Architecture 5TEJ only J = 1: Processor in Jazelle state Interrupt Disable bits. I = 1: Disables the IRQ. F = 1: Disables the FIQ. T Bit Architecture xT only T = 0: Processor in ARM state T = 1: Processor in Thumb state Mode bits Specify the processor mode
Enabling the ARM Learning in INDIA
ls, Give a listing of the current directory. Try also ls -l cp, Copy file from sorce to destination mv, Move file from source to destination. If both are the same directory, the file is renamed vi, Edit a file. vi is one of the most powerful text editors chmod, Change file permissions mkdir, rmdir Make/Remove a directory cd, Change directory rm, Remove a file. Can also remove directory tree man ls, Get help for ls. All commands have help
Enabling the ARM Learning in INDIA
What is Shell Scripting
% cat > [Link] <<MY_PROGRAM #!/bin/sh echo Hello, world MY_PROGRAM % chmod +x [Link] % ./[Link] Hello, world
Enabling the ARM Learning in INDIA
Tool Chain
Enabling the ARM Learning in INDIA
Native Compilers Cross Compilers
Enabling the ARM Learning in INDIA
Toolchain
Source code Cross-compiling toolchain x86
Compilation machine
Native toolchain
x86 binary x86
ARM binary ARM
Execution machine
Enabling the ARM Learning in INDIA
Toolchain components
Kernel headers
C/C++ libraries
Binutils
GCC compiler
GDB debugger (optional)
Enabling the ARM Learning in INDIA
Kernel Headers
The C library and compiled programs needs to interact with the kernel Available system calls and their numbers Constant definitions Data structures, etc. Therefore, compiling the C library requires kernel headers, and many applications also require them.
Kernel Kernel headers C Library Applications
Available in <linux/...> and <asm/...> and a few other directories corresponding to the ones visible in include/ in the kernel sources
Enabling the ARM Learning in INDIA
Binutils
Binutils is a set of tools to generate and manipulate binaries for a given CPU architecture as, the assembler, that generates binary code from assembler source code ld, the linker ar,ranlib, to generate .a archives, used for libraries objdump,readelf,size,nm,strings, to inspect binaries. Very useful analysis tools ! strip, to strip useless parts of binaries in order to reduce their size [Link] GPL license
Enabling the ARM Learning in INDIA
GNU Compiler
GNU C Compiler, the famous free software compiler Can compile C, C++, Ada, Fortran, Java, Objective-C, Objective-C++, and generate code for a large number of CPU architectures, including ARM, AVR, Blackfin, CRIS, FRV, M32, MIPS, MN10300, PowerPC, SH, v850, i386, x86_64, IA64, Xtensa, etc. [Link] Available under the GPL license, libraries under the LGPL.
Enabling the ARM Learning in INDIA
C Library
The C library is an essential component of a Linux system Interface between the applications and the kernel Provides the well-known standard C API to ease application development Several C libraries are available: glibc, uClibc, eglibc, dietlibc, newlib, etc. The choice of the C library must be made at the time of the cross-compiling toolchain generation, as the GCC compiler is compiled against a specific C library.
Enabling the ARM Learning in INDIA
Toolchain Compiling
Steps to compile Toolchain Manually 1. Download and extract sources 2. Patch the sources for ARM 3. Install Kernel headers 4. Build & Install GMP 5. Build & Install MPFR 6. Build & Install binutils 7. Build & Install core GCC 8. Build & Install glibc 9. Build & Install full GCC
Enabling the ARM Learning in INDIA
Crosstool GCC-3.4
Directory structure used:
/home/ubuntu/bb_at91/tools => top_dir /home/ubuntu/bb_at91/tools/crosstool-0.42 => source /home/ubuntu/bb_at91/tools/crosstool => output /home/ubuntu/bb_at91/tools/downloads => download dir Copy all the tars in downloads directory
Step1: Download the source in bb_at91/tools ubuntu$ wget [Link] Step 2: Download the [Link] or create it ubuntu$ wget [Link]
Enabling the ARM Learning in INDIA
Crosstool GCC-3.4
[Link]
#!/bin/sh set -ex TOP_DIR=/home/ubuntu/tools TARBALLS_DIR=$TOP_DIR/downloads RESULT_TOP=$TOP_DIR/crosstool GCC_LANGUAGES="c,c++" PARALLELMFLAGS="-j2" GDB_DIR=gdb-6.5 export GCC_LANGUAGES PARALLELMFLAGS TARBALLS_DIR RESULT_TOP GDB_DIR mkdir -p $RESULT_TOP # Create the toolchain. This will take a lot of time. # Add --gdb to the next line if you are going to use GDB! eval `cat [Link] [Link]` sh [Link] --notest echo Done.
Enabling the ARM Learning in INDIA
Crosstool GCC-3.4
Step 3: sudo apt-get install patch bison flex gcc-3.4 Step 4: Change the gcc link to gcc-3.4 ubuntu$ sudo rm /usr/bin/gcc ubuntu$ sudo ln -s /usr/bin/gcc-3.4 /usr/bin/gcc Step 5: Change the default shell to bash from dash ubuntu$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2009-10-23 22:13 /bin/sh -> dash
ubuntu$ sudo rm /bin/sh ubuntu$ sudo ln -s /bin/bash /bin/sh ubuntu$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2009-10-23 22:13 /bin/sh -> bash Enabling the ARM Learning in INDIA
Crosstool GCC-3.4
Step 6: Add execute permission to [Link] ubuntu$ chmod +x [Link] Step 7: Execute the [Link] to start compiling ubuntu$ ./[Link] If all things goes fine U will get print Done on console.
Enabling the ARM Learning in INDIA
Credits
Most of the data for this presentation is taken from 1. [Link] 2. [Link]
Enabling the ARM Learning in INDIA
Enabling the ARM Learning in INDIA
?
Enabling the ARM Learning in INDIA