You are on page 1of 3

Supporting Linux Without an domain is for a device such as simple

operations/control or data acquisition


MMU system, or a MP3 player or small VPN
Class #407 router.

D. Jeff Dionne One of the common misconceptions


about the uClinux open source project
With the advent of energy conscious, and MMUless development in general,
inexpensive and full-featured micro is that the only difference between
processors, embedded system uClinux and Linux proper (or MMUless
developers now have the opportunity to and MMUfull development) is that the
capitalize on larger and more user memory management unit has been
friendly embedded operating systems simply switched off. Those embedded
capable of hosting various applications developers who have worked in the
and protocols. This progress has acted MMUless space understand that while
as a catalyst to direct embedded system this is literally true, working in a flat
development down two paths; full- unprotected code space has its
featured X86-like systems and simple challenges. Let’s take a moment to
systems. The latter, simple embedded examine the differences and motivations
systems have design requirements behind working in an embedded MMU-
typically focused on two essential less environment.
needs, minimized cost and optimized
performance. It is in this realm that the Virtual Memory
decision to work with or without a Because the basic function of a MMU is
Memory Management Unit (MMU) to map the logical addresses of memory
becomes a serious consideration. For to the physical address, virtual memory
those embedded developers in the initial is not possible in a MMUless
design phase who have not yet selected environment. This alone creates a
a processor, or had one thrust upon number of obstacles for embedded
them, the attraction to MMUless developers and is enough to scare away
technology means also selecting a the faint of heart. Using Linux as an
careful and realistic balance between example, there are three primary
economics and feature set marketing. consequences and solutions to
operating without virtual memory.
After working almost exclusively in the
MMUless space for nearly three years, I First, processes loaded by the kernel
can empathize with those developers must be able to run independently of
who become tempted by the “forbidden their position in memory. This can be
fruit”, wanting sophisticated applications, achieved by "fixing up" address
interfaces and protocol stacks all heavily references in a program once it is
dependent on memory optimization, loaded into RAM or by generating code
Java, C++, graphic web servers and that uses only relative addressing
sophisticated GUIs. Eventually, the (referred to as PIC, or Position
point must be made that these Independent Code).
objectives really demand an MMU. This
is by no means intended to minimize the Another consequence occurs due to
functionality of an MMUless system, in memory allocation and deallocation
fact, quite the opposite. MMUless being within a flat memory model. Very
technology is ideal for what is somewhat dynamic memory allocation can result in
coyly referred to as a “traditional” or fragmentation that may starve a system.
“simple” embedded system. Ideally this One way to improve the robustness of
applications performing dynamic and COFF, require modifications. New
memory allocation is to replace loaders are required for these formats
malloc() calls with requests from a (i.e.: binfmt_flat). Futhermore,
preallocated buffer pool. since child processes run in the same
address space as their parents, the
Finally, since virtual memory is not used behaviour of both may require
in uClinux, swapping pages in and out of modification.
memory is not implemented, as no
guarantee can be given that the pages Forking
would be loaded to the same location in Within uClinux, the lack of memory
RAM. In embedded systems it is, in any management hardware on a target
case, most likely unacceptable to processor has meant that some
suspend an application in order to use changes needed to be made to the
more RAM than is physically available. system interface. Perhaps the greatest
difference is the absence of the fork()
The role of the MMU to act as a level of and brk() system calls.
protection for software should never be A call to fork() clones a process to
minimized. One of the largest difficulties create a child. Under Linux, fork() is
faced by the developer of an MMU-less implemented using copy_on_write
system is the result of invalid program pages. Without an MMU, uClinux cannot
pointers triggering an address error and completely and reliably clone a process,
potentially corrupting or downing a nor does it have access to copy-on-
system. Obviously, this is undesirable write.
and as such requires code to be In the case of uClinux, it implements a
programmed and diligently tested to version of BSD’s vfork() in order to
ensure robustness. compensate for the lack of fork().
Each step of development must be
When a parent process calls vfork()
carefully mapped out, an overview of
to create a child, both processes share
this cycle provides insight.
all their memory space including the
stack. vfork() then suspends the
First, as one might guess, support within
the code for an MMU needs to be turned parent's execution until the child process
off. To account for this change uClinux either calls exit() or execve(). Note
provides new code for the memory that multitasking is not otherwise
management subsystem of the kernel. affected. It does, however, mean that
Essentially, uClinux provides basic older-style network daemons that make
memory management functions within extensive use of fork() must be
the kernel software itself. For those modified. Since child processes run in
familiar with uClinux or a Unix like the same address space as their
system, this is the role of the directory parents, the behavior of both processes
/mmnommu derived from and replacing may require modification in particular
/mm. situations.
New strategies also must be developed
for operations like releasing memory Many modern programs rely on child
after a process ends or allocating processes to perform basic tasks,
memory to a new process. allowing the system to maintain an
interactive "feel" even if the processing
Changes to the kernel are necessary to load is quite heavy. Such programs may
run userspace programs. Some require substantial reworking to perform
program loaders, such as those for ELF the same task under uClinux. If a key
application depends heavily on such
structuring, then it may be necessary to Background Debug Module (BDM) or
either re-create the application, or an others like, JTAG. These protocols give
MMU-enabled processor may also be developers access to the internal status
needed. of the processor and allow for base level
A hypothetical, simple network daemon, debugging.
hyped, will illustrate the use of fork().
hyped always listens on a well-known uClinux, the open source project has
network port (or socket) for connections focused exclusively on the MMUless
from a network client. When the client space being able to provide the
connects, hyped gives it new functionality of a Linux operating system
connection information (a new socket into a tiny embedded environment. The
number) and calls fork(). The child valuable experience gained by the core
process then accepts the client's team and the open source community
reconnection to the new socket, freeing has proven that although MMUless
the parent to listen for new connections. embedded design is more challenging,
uClinux has neither an autogrow stack there is immense value in an robust,
nor brk() and so user space programs compatible MMUless operating system.
must use the mmap() command to Furthermore, with newer and more
allocate memory. For convenience, our powerful MMUless processors arriving
on the market, the hardware industry
C library implements malloc() as a
seems to agree that there is a definite
wrapper to mmap(). There is a compile-
need for simple, traditional embedded
time option to set the stack size of a systems.
program.

Debugging
Debugging an application in an
MMUless environment can also be more
time consuming. Typically, debugging
has to be done at arms length from the
hardware and frequently without a
console, over something simple such as
a serial port. Recently, some silicon
vendors have compounded the
obstacles in debugging. For example, a
lack of memory access alignment error
trapping creates additional debug work.
Without this error trapping built into
hardware, unaligned memory access
errors may pass through the system
without the system reporting it. The
system may still function indefinitely
though usually unreliably. Without this
trapping, developers need to forensically
examine all the code that could have
potentially run on the system to
determine the origin of the alignment
error prior to debugging the underlying
problem. On the other hand, silicon
manufacturers such as Motorola have
offered hardware debug options such as

You might also like