Beruflich Dokumente
Kultur Dokumente
Raspeberry PI
Paulo Cardoso
Department of Industrial Electronics
School of Engineering,
University of Minho
Guimares, Portugal
Outline
Glossary
Before start... our board
Custom Linux systems
Buildroot
Creating an emb. system using Buildroot
Boot loader
U-Boot
Booting with device tree
Glossary
Application Binary Interface (ABI)
Defines a mapping between low-level hardware/OS
concepts and high-level languages
Includes things like:
How program startup/initialization works
How functions/system calls are called
Sizes, layout, and alignment of data types
Glossary
Board Support Package (BSP)
Software code that access hardware-specific
features
Provides a standardized interface between hardware and
the operating system
Isolating hardware-specific functionally
Cross-development
The process of developing code on one machine
(host) to run on another machine (target)
Host is a desktop/laptop machine running Windows, OS X,
Linux
Target is the embedded system, a single board computer
Glossary
In-circuit emulator (ICE)
External hardware (board) to debug software in
embedded systems
Allows change the contents of registers, memory and I/O,
breakpoint execution, ...
JTAG interface
Is an access point to processor hardware circuity
For debugging, diagnosis...
In system programming
Programming a processor positioned inside the end system
Manually
E.g. http://www.linuxfromscratch.org
Somedistributions,suchasDebian,areavailableforembe
dded architectures (ARM,MIPS,PowerPC)
Pros
Theymakeitrelativelyeasytogetaworkingsystem
Cons
Distribution choices don't necessarily match system's needs
Buildrooot
Site of the project
http://www.buildroot.net/
...
Buildroot
Best suited for small embedded systems
Buildroot
A set of Makefiles that automates the process
of building a cross-compiling toolchain and a
root filesystem for an embedded system
Has been initially developed by uClibc developers
Uses Kconfig configuration system and menuconfiglike interface
Also known by those that configure Linux kernel in desktop
systems
Download Buildroot
$ mkdir -p $HOME/buildroot
$ cd $HOME/buildroot
$ wget http://buildroot.uclibc.org/downloads/buildroot2014.05.tar.gz
$ tar xvzf buildroot-2014.05.tar.gz
Known as $TOPDIR in
$ cd buildroot-2014.05
the configuration tool
Select Exit to go
back in a sub-nebu
configuration
Use horizontal
arrows to navigate
among menu
options.
Press ENTER to
select
Use vertical
arrows to
navigate among
configuration
submenus/options.
Press ENTER to
enter a submenu.
SelectSPACE
Help to
Press
to
get information
select
an option
on the
configuration
option
highlighted
Selects the
target hardware
Selects the
compiling
toolchain and
options
Configures
compiled Linux
system
Selects kernel
source
Selects software
packages to
include in the
system
Selects
filesystem
format and
compression
methods
Aside...
Shell
The command line when you use Terminal
There are several. The most known is bash
That is the one you are using now
Some of the commands you type are builtin, not external programs
For performance reasons or because a particular built-in needs direct
access to the shell internals
E.g. cd, pwd, pushd, popd, dirs, export, echo, etc.
Sometimes there are both implementations, e.g. echo and /bin/echo
More on bash
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Aside...
Shell
Our embedded system will use Busybox
It is a kind of super shell
It is a single binary, which is a conglomerate of many
applications
We can say that it's a shell with a lot if built-in commands
Busybox implements the ash shell
Aside...
Shell
Redirecting output
A shell has always three default files open
stdin (the keyboard)
stdout (the screen)
stderr (error messages output to the screen)
This is like in a C program
Unix (from witch Linux is a flavor of) has its roots in C
Aside...
Shell
Redirecting output
Examples
ls -la > list.txt
Redirects output of command ls to file list.txt
This the most used form of redirection
Aside...
Shell
Redirecting output
Examples (cont.)
command 1> filename
Redirect stdout to file filename
Aside...
Shell
Redirecting output
Examples (cont.)
command M>N
File descriptor M (which defaults to 1) is redirect to N. If not
explicitly set, N is a filename
command M>&N
File descriptor M is redirect to file descriptor N
Redirecting input
command < filename
Accept input from a file. E.g. grep word < filename
Pipe: |
The output of a program is the input of another
EXT4 partition
Linux filesystem partition
Partitions' creation
Using fdisk utility
Unmount SD card
cmdline.txt
Contains arguments to the Linux kernel
/boot vfat
defaults
0 0
TTL-USB
Serial connection to provide boot console
It could be used also to provide power
5V on pin2; 3,3V on pin1
On next slide: red wire provides 5V. It could be connected to
pin2. In that case we SHOULDN'T use USB cable
Boot loader
A (or a set of) computer program executed after
hardware reset
Executes self-tests and timer calibration routines
Loads operating system
As the bootloader runs before any piece of software on a
device, it it is processor specific and every motherboard has
its own
bootcode.bin is loaded
Enables SDRAM
Knows about the .elf format and loads start.elf into RAM
It reads cmdline.txt
Contains parameters to be passed to the application (boot
parameters)
From 0x00008000
Used to load the appliction (Linux or whatever)
More on this:
http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html
systemd
The new generation init system for Linux
It does far more than traditional init programs: aggressive
parallelization capabilities, uses socket and D-Bus activation for
starting services, offers on-demand starting of daemons, keeps track of
processes using Linux control groups, supports snapshotting and
restoring of the system state, etc.
It will be useful on relatively complex embedded systems, for example
the ones requiring D-Bus and services communicating between each
other
Boot loader
U-Boot
A popular open source boot loader used in many
embedded devices
Executes self-tests and timer calibration routines
Loads operating system
As the bootloader runs before any piece of software on a
device, it it is processor specific and every motherboard has its
own boot loader
U-Boot
Download the sources
$
$
$
$
cd ~/buildroot
wget ftp://ftp.denx.de/pub/u-boot/u-boot-2014.07.tar.bz2
tar xvf u-boot-2014.07.tar.bz2
cd cd u-boot-2014.07/
Compile U-Boot
Since there is already a cross-compilation environ.
It will bee used instead of creating a new one
$ export CROSS_COMPILE=$HOME/buildroot/buildroot2014.05/output/host/usr/bin/arm-buildroot-linuxuclibcgnueabi$ make rpi_b_config
$ make
U-Boot
Copy boot loader to SD card
Insert the SD card on a PC
Copy boot loader to SD card
$ sudo cp ./u-boot.bin /media/pfc/boot
U-Boot
Copy boot loader to SD card
Insert the SD card on a PC (cont.)
Create uEnv.txt on SD card
$ cd /media/pfc/boot
$ sudo nano uEnv.txt
U-Boot
Boot
Unmount the card and insert it on RPi
Power the board
U-Boot
Boot
Type the commands to boot
U-boot> fatload mmc 0:1 ${kernel_addr_r} kernel.img
U-Boot> bootz ${kernel_addr_r}
To automate boot
Insert the following line in uboot.scr
bootcmd=echo starting from MMC ; mmc dev 0; fatload mmc 0:1 $
{kernel_addr_r} kernel.img; bootz ${kernel_addr_r}
Other advantages
Easier to add support for newer platforms
Reduces amount of board specific code
Faster board ports
bcm2835.dtsi
SoC level definitions
The end