Module 4
Module 4
It is up to the system designer who can decide which hardware peripheral can produce
which interrupt request. By using an interrupt controller we can connect multiple
external interrupts to one of the ARM interrupt requests and distinguish between
them.
There is a standard design for assigning interrupts adopted by system designers:
• SWIs are normally used to call privileged operating system routines.
• IRQs are normally assigned to general purpose interrupts like periodic timers.
• FIQ is reserved for one single interrupt source that requires fast response time, like
DMA or any time critical task that requires fast response.
What is interrupt latency? Explain briefly.
Interrupt latency is the interval of time between from an external interrupt signal being
raised to the first fetch of an instruction of the ISR of the raised interrupt signal.
System architects must balance between two things, first is to handle multiple interrupts
simultaneously, second is to minimize the interrupt latency.
In the following figure we have two memory layouts which show how the stack is
placed in memory:
The first is the traditional stack layout. The second layout has the advantage that when
overflow occurs, the vector table remains untouched so the system has the chance to
correct itself.
Firmware
What is firmware?
The firmware is a low-level software that provides an interface between the
hardware and the application/operating system level software. It resides in the
ROM and executes when power is applied to the embedded hardware system.
Firmware can remain active after system initialization and supports basic system
operations.
What is bootloader?
The bootloader is a small application that installs the operating system or
application onto a hardware target. The bootloader only exists up to the point that
the operating system or application is executing, and it is commonly incorporated
into the firmware.
Explain different stages involved in Firmware execution .
1. Set up the target platform: Prepare the environment to boot an operating system since an
operating system expects a particular type of environment before it can operate.
This step involves making sure that the platform is correctly initialized (for example, making
sure that the control registers of a particular microcontroller are placed at a known address or
changing the memory map to an expected layout).
Platform identification: The firmware has to identify and discover the exact core and
platform it is operating on. The core is normally recognized by reading register 0 in coprocessor
15, which holds both the processor type and the manufacturer name.
Diagnostics: Diagnostics software provides a useful way for quickly identifying basic
hardware malfunctions. Because of the nature of this type of software, it tends to be specific to
a particular piece of hardware.
Debug Interface: Debug capability is provided in the form of a module or monitor that
provides software assistance for debugging code running on a hardware target. This
assistance includes the following:
■ Setting up breakpoints in RAM. A breakpoint allows a program to be interrupted and
the state of the processor core to be examined.
■ Listing and modifying memory (using peek and poke operations).
■ Showing current processor register contents.
■ Disassembling memory into ARM and Thumb instruction mnemonics.
Command line interpreter(CLI):
It allows you to change the operating system to be booted by altering the default
configurations through typing commands at a command prompt. For embedded systems,
the CLI is commonly controlled through a host terminal application. Communication
between the host and the target is normally over a serial or network connection.
2. Abstract the hardware: The Hardware Abstraction Layer (HAL) is a software layer that
hides the underlying hardware by providing a set of defined programming interfaces.
The HAL software that communicates with specific hardware peripherals is called a
device driver. A device driver provides a standard application programming interface (API)
to read and write to a specific peripheral.
3. Load a bootable image: The ability of firmware to carry out this activity depends upon the
type of media used to store the image. Note that not all operating system images or
application images need to be copied into RAM. The operating system image or application
image can simply execute directly from ROM.
ARM processors are normally found in small devices that include flash ROM. A common
feature is a simple flash ROM filing system (FFS), which allows multiple executable images
to be stored.
4. Relinquish control: This is where the firmware hands over control of the
platform to an operating system or application. Note that not all firmware
hands over control; instead the firmware can remain the controlling software
on the platform. Firmware designed to pass control to an operating system
may become inactive once the operating system has control. Alternatively, the
Machine Independent Layer (MIL) or Hardware Abstraction Layer (HAL) part
of the firmware can remain active. This layer exposes, through the SWI
mechanism, a standard application interface for specific hardware devices.
Write short note on ARM Firmware Suite (AFS).
ARM has developed a firmware package called the ARM Firmware Suite (AFS). AFS is
designed purely for ARM-based embedded systems. It provides support for a number of
boards and processors including the Intel XScale and StrongARM processors. The package
includes two major pieces of technology, a Hardware Abstraction Layer called μHAL
(pronounced micro-HAL) and a debug monitor called Angel.
μHAL provides a low-level device driver framework that allows it to operate over dif-
ferent communication devices (for example, USB, Ethernet, or serial). It also provides a
standard API.
μHAL supports these main features:
■ System initialization—setting up the target platform and processor core. Depending
upon the complexity of the target platform, this can either be a simple or complicated
task.
■ Polled serial driver—used to provide a basic method of communication with a host.
■ LED support—allows control over the LEDs for simple user feedback. This provides an
application the ability to display operational status.
■ Timer support—allows a periodic interrupt to be set up. This is essential for preemptive
context switching operating systems that require this mechanism.
■ Interrupt controllers—support for different interrupt controllers.
The boot monitor in μHAL contains a CLI.
The second technology, Angel, allows communication between a host debugger and a
target platform. It allows you to inspect and modify memory, download and execute
images, set breakpoints, and display processor register contents. All this control is through
the host debugger. The Angel debug monitor must have access to the SWI and IRQ or FIQ
vectors. Angel uses SWI instructions to provides a set of APIs that allow a program to
open, read, and write to a host filing system. IRQ/FIQ interrupts are used for
communication purposes with the host debugger.
Write short note on RedBoot firmware .
RedBoot is a firmware tool developed by Red Hat. It is provided under an open source
license with no royalties or up front fees. RedBoot is designed to execute on different CPUs
(for instance, ARM, MIPS, SH, and so on). It provides both debug capability through GNU
Debugger (GDB), as well as a bootloader. The RedBoot software core is based on a HAL.
RedBoot supports these main features:
Communication—configuration is over serial or Ethernet. For serial, X-Modem protocol
is used to communicate with the GNU Debugger (GDB). For Ethernet, TCP is used to
communicate with GDB. RedBoot supports a range of network standards, such as bootp,
telnet, and tftp.
Flash ROM memory management—provides a set of filing system routines that can
download, update, and erase images in flash ROM. In addition, the images can either
be compressed or uncompressed.
Full operating system support—supports the loading and booting of Embedded Linux,
Red Hat eCos, and many other popular operating systems. For Embedded Linux,
RedBoot supports the ability to define parameters that are passed directly to the kernel
upon booting.
Explain Sandstone firmware package.
Sandstone firmware package carries out only the following tasks:
set up target platform environment
load a bootable image into memory and
relinquish control to an operating system.
It is, however, still a real working example.
The implementation is specific to the ARM Evaluator-7T platform, which includes an
ARM7TDMI processor.
Table 10.2 lists the basic characteristics of Sandstone.
Sandstone Directory Layout
The sandstone source file sand.s is located under the sand/build/src directory.
The object file produced by the assembler is placed under the build/obj
directory.
The object file is then linked, and the final Sandstone image is placed under the
sand/build/image directory.
This image includes both the Sandstone code and the pay-load.
The payload image, the image that is loaded and booted by Sandstone, is found
under the sand/payload directory.
For information about the Sandstone build procedure, take a look at the
readme.txt file under the sand directory.
This file contains a description of how to build the example binary image for the
ARM Evaluator-7T.
Sandstone Code Structure
Sandstone consists of a single assembly file. The file structure is broken down into a
number of steps, where each step corresponds to a stage in the execution flow of Sandstone.
Step 1: Take the Reset Exception
Execution begins with a Reset exception. Only the reset vector entry is required in the
default vector table. It is the very first instruction executed.
Step 2: Start Initializing the Hardware
The primary phase in initializing hardware is setting up system registers. These registers
have to be set up before accessing the hardware.
Step 3: Remap Memory
One of the major activities of hardware initialization is to set up the memory environment.
Sandstone is designed to initialize SRAM and remap memory. This process occurs fairly
early on in the initialization of the system.
Step 4: Initialize Communication Hardware
Communication initialization involves configuring a serial port and outputting a standard
banner. The banner is used to show that the firmware is fully functional and memory has
been successfully remapped. The serial port is set to 9600 baud, no parity, one stop bit, and no
flow control host terminal has to be configured with these
settings.
Step 5: Bootloader—Copy Payload and Relinquish Control
The final stage involves copying a payload and relinquishing control of the pc
over to the copied payload.