- 浏览: 452681 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
zjhgx:
多谢,多谢。多谢
Ubuntu 中软件的安装、卸载以及查看的方法总结 -
37du:
受教了,对于理解运行过程有很好的效果
ActionMapper---webwork 2.1到2.2 的变化 -
chxiaowu:
非常好,谢谢!
Ubuntu 中软件的安装、卸载以及查看的方法总结 -
euii:
谢谢,这样的总结。
Ubuntu 中软件的安装、卸载以及查看的方法总结 -
xiaoyao3857:
谢谢,正需要这样的汇总型字典!
Ubuntu 中软件的安装、卸载以及查看的方法总结
Simple Embedded Linux System
by Vincent Sanders and Daniel Silverstone
Introduction
Constructing
an embedded system with Linux is often seen as a complex undertaking.
This article is the first in a series which will show the fundamental
aspects of constructing such systems and enable the reader to apply
this knowledge to their specific situation.
This first article
covers the construction of the most basic system possible, which will
provide a command shell on the console. Along with the rest of the
series, it assumes a basic understanding of a Linux-based operating
system. While discussing concepts and general approaches, these
concepts are demonstrated with extensive practical examples. All the
practical examples are based upon a Debian- or Ubuntu-based
distribution.
What is an embedded system?
The term
"Embedded System" has been applied to such a large number of systems
that its meaning has become somewhat ill-defined. The term has been
applied to everything from 4-bit microcontroller systems to huge
industrial control systems.
The context in which we are using
the term here is to refer to systems where the user is limited to a
specific range of interaction with a limited number of applications
(typically one). Thus, from the whole spectrum of applications which a
general purpose computer can run, a very narrow selection is made by
the creator of the embedded system software.
It should be
realized that the limits of interaction with a system may involve
hardware as well as software. For example, if a system is limited to a
keypad with only the digits 0 to 9, user interaction will be more
constrained than if the user had access to a full 102-key keyboard.
In
addition to the limiting of user interaction, there may also be limits
on the system resources available. Such limits are typically imposed by
a system's cost, size, or environment. However, wherever possible,
these limits should be arrived at with as much knowledge of the system
requirements as possible. Many projects fail unnecessarily because an
arbitrary limit has been set which makes a workable solution
unachievable. An example of this would be the selection of a system's
main memory size before the application's memory requirements have been
determined.
What do you want to achieve?
A project must have a clearly defined goal.
This
may be viewed as a statement of the obvious, but it bears repeating as
for some unfortunately inexplicable reason, embedded systems seem to
suffer from poorly-defined goals.
An "embedded" project, like
any other, should have a clear statement of what must be achieved to be
declared a success. The project brief must contain all the
requirements, as well as a list of "desirable properties." It is
essential that the two should not be confused; e.g., if the product
must fit inside a 100mm by 80mm enclosure, that is a requirement.
However, a statement that the lowest cost should be achieved is a
desirable item, whereas a fixed upper cost would be a requirement.
If
information necessary to formulate a requirement is not known, then it
should be kept as a "desirable item" couched in terms of that unknown
information. It may be possible that once that information is
determined, a requirement can be added.
It is, again,
self-evident that any project plan must be flexible enough to cope with
changes to requirements, but it must be appreciated that such changes
may have a huge impact on the whole project and, indeed, may invalidate
central decisions which have already been made.
General IT project management is outside the scope of this article. Fortunately there exist many good references on this topic.
Requirements which might be added to a project brief based on the assumptions of this article are:
The
implications of these statements mean the chosen hardware should have a
Linux kernel port available, and must have sufficient resources to run
the chosen programs.
Another important consideration is what
kind of OS the project warrants. For example, if you have a project
requirement of in-field updates, then you may want to use a full OS
with package management, such as Debian GNU/Linux or Fedora. Such a
requirement would, however, imply a need for a non-flash-based storage
medium such as a hard disc for storing the OS, as these kinds of
systems are typically very large (even in minimal installations), and
not designed with the constraints of flash-based storage in mind.
However, given that additional wrinkle, using an extant operating
system can reduce software development costs significantly.
Anatomy of a Linux-based system
Much
has been written on how Linux-based systems are put together; however a
brief review is in order, to ensure that basic concepts are understood.
To
be strictly correct the term "Linux" refers only to the kernel. Various
arguments have been made as to whether the kernel constitutes an
operating system (OS) in its entirety, or whether the term should refer
to the whole assemblage of software that makes up the system. We use
the latter interpretation here.
The general steps when any modern computer is turned on or reset is:
The
kernel's role in the system is to provide a generic interface to
programs, and arbitrate access to resources. Each program running on
the system is called a process. Each operates as if it were the only
process running. The kernel completely insulates a program from the
implementation details of physical memory layout, peripheral access,
networking, etc.
The first process executed is special in that
it is not expected to exit, and is expected to perform some basic
housekeeping tasks to keep a system running. Except in very specific
circumstances, this process is provided by a program named /sbin/init.
The init process typically starts a shell script at boot to execute
additional programs.
Some projects have chosen to run their
primary application as the init process. While this is possible, it is
not recommended, as such a program is exceptionally difficult to debug
and control. A programming bug in the application halts the system, and
there is no way to debug the issue.
One feature of almost all
Unix-like systems is the shell, an interactive command parser. Most
common shells have the Bourne shell syntax.
A simple beginning
We
shall now consider creating a minimal system. The approach taken here
requires no additional hardware beyond the host PC, and the absolute
minimum of additional software.
As already mentioned, these
examples assume a Debian or Ubuntu host system. To use the QEMU
emulator for testing, the host system must be supported by QEMU as a
target. An example where this might not be the case is where the target
system is x86-64, which QEMU does not support.
To ease construction of the examples, we will use the kernel's initramfs
support. An initramfs is a gzip-compressed cpio archive of a file
system. It is unpacked into a RAM disk at kernel initialization. A
slight difference to normal system start-up is that while the first
process executed must still be called init, it must be in the root of
the file system. We will use the /init script to create some symbolic
links and device nodes before executing the more-typical /sbin/init
program.
This example system will use a program called Busybox
,
which provides a large number of utilities in a single executable,
including a shell and an init process. Busybox is used extensively to
build embedded systems of many types.
The busybox-static
package is required to obtain pre-built copy of the Busybox binary and the qemu
package is required to test the constructed images. These may be obtained by executing:
$ sudo apt-get install busybox-static qemu
As
mentioned, our initramfs-based approach requires a small /init script.
This configures some basic device nodes and directories, mounts the
special /sys and /proc file systems, and starts the processing of
hotplug events using mdev.
#!/bin/sh
# Create all the busybox symbolic links
/bin/busybox --install -s
# Create base directories
[ -d /dev ] || mkdir -m 0755 /dev
[ -d /root ] || mkdir --mode=0700 /root
[ -d /sys ] || mkdir /sys
[ -d /proc ] || mkdir /proc
[ -d /tmp ] || mkdir /tmp
mkdir -p /var/lock
# Mount essential filesystems
mount -t sysfs none /sys -onodev,noexec,nosuid
mount -t proc none /proc -onodev,noexec,nosuid
# Create essential filesystem nodes
mknod /dev/zero c 1 5
mknod /dev/null c 1 3
mknod /dev/tty c 5 0
mknod /dev/console c 5 1
mknod /dev/ptmx c 5 2
mknod /dev/tty0 c 4 0
mknod /dev/tty1 c 4 1
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
echo "Creating devices"
/sbin/mdev -s
exec /sbin/init
To
construct the cpio archive, the following commands should be executed
in a shell. Note, however, that INITSCRIPT should be replaced with the
location of the above script.
$ mkdir simple
$ cd simple
$ mkdir -p bin sbin usr/bin usr/sbin
$ cp /bin/busybox bin/busybox
$ ln -s busybox bin/sh
$ cp INITSCRIPT init
$ chmod a+x init
$ find . | cpio --quiet -o -H newc | gzip >../simple.gz
$ cd ..
To test the constructed image use a command like:
$ qemu -kernel /boot/vmlinuz-2.6.26-1-686 -initrd simple.gz \
-append "root=/dev/ram" /dev/zero
This
should present a QEMU window where the OS you just constructed boots
and displays the message "Please press Enter to activate this console."
Press enter and you should be presented with an interactive shell from
which you can experiment with the commands Busybox provides. This
environment is executing entirely from a RAM disc and is completely
volatile. As such, any changes you make will not persist when the
emulator is stopped.
Booting a real system
Starting
the image under emulation proves the image ought to work on a real
system, but there is no substitute for testing on real hardware. The syslinux
package allows us to construct bootable systems for standard PCs on DOS-formatted storage.
A
suitable medium should be chosen to boot from, e.g., a DOS-formatted
floppy disk or a DOS-formatted USB stick. The DOS partition of the USB
stick must be marked bootable. Some USB sticks might need
repartitioning and reformatting with the Linux tools in order to work
correctly.
The syslinux
program should be run on the device /dev/fd0 for a floppy disk, or something similar to /dev/sdx1
for a USB stick. Care must be taken, as selecting the wrong device name might overwrite your host system's hard drive.
The target device should then be mounted and the kernel and the simple.gz
file copied on.
The syslinux loader can be configured using a file called syslinux.cfg which would look something like:
default simple
timeout 100
prompt 1
label simple
kernel vmlinuz
append initrd=simple root=/dev/ram
The complete command sequence to perform these actions, substituting file locations as appropriate, is:
$ sudo syslinux -s /dev/sdd1
$ sudo mount -t vfat -o shortname=mixed /dev/sdd1 /mnt/
$ cd /mnt
$ sudo cp /boot/vmlinuz-2.6.26-1-686 VMLINUZ
$ sudo cp simple.gz SIMPLE
$ sudo cp syslinux.cfg SYSLINUX.CFG
$ cd /mnt
$ sudo umount /mnt
The
device may now be removed and booted on an appropriate PC. The PC
should boot the image and present a prompt exactly the same way the
emulator did.
What's next?
This first step, while
simple, provides a complete OS, and demonstrates that constructing an
embedded system can be a straightforward process.
The next step is to expand this simple example to encompass a specific application, which will be covered in the next article.
This article is copyrighted 2009, Simtec Electronics
, and reproduced here with permission.
About the authors
Vincent Sanders
is the senior software engineer at Simtec Electronics
.
He has extensive experience in the computer industry, having worked on
projects from large fault-tolerant systems through accounting software
to programmable logic systems. He is an active developer for numerous
open source projects, including the Linux kernel, and is also a Debian
developer.
Daniel Silverstone
is a software engineer at Simtec Electronics
,
and has experience in architecting robust systems. He develops software
for a large number of open source projects, contributes to the Linux
kernel, and is both an Ubuntu and Debian developer.
发表评论
-
Cache 的write back和write through
2010-04-22 15:47 2579Cache 的write back和write through ... -
选择 ARM处理器,ARM7还是Cortex-M3?
2010-04-08 00:52 2627要使用低成本的 32位处理器,开发人员面临两种选择,基于Cor ... -
16道嵌入式C语言面试题
2010-03-06 17:28 5477> 预处理器(Preprocessor) 1. 用预处 ... -
elf格式学习总结
2010-03-03 15:35 2059当编译一个源文件生成目标文件时,会在目标文件中生成符号表和重定 ... -
视频播放的基本原理
2010-03-03 10:08 5329VLC是一个功能强大的玩 ... -
Data Access Arrangement
2009-12-12 09:55 1048From Wikipedia, the free encycl ... -
系统启动挂载根文件系统时Kernel panic
2009-12-07 19:53 7257这类问题很常见,先总体介绍一下解决思路。 能出现让人激动 ... -
SPI and I2C
2009-12-03 15:29 1097SPI--Serial P ... -
LTIB - Linux Target Image Builder
2009-11-27 20:12 1358LTIB - Linux Target Image Build ... -
NAND
2009-11-21 14:52 1074NAND NAND闪存是一种比硬 ... -
MMC卡和SD卡的区别
2009-11-19 20:39 3501目前诸如MMC卡 和SD卡 ... -
Building a root filesystem
2009-11-05 19:25 1082Building a root filesystem ... -
Solution to kill "version `GLIBC_2.*' not found error"
2009-10-31 14:40 11081. Make ubuntu compile using an ... -
Linux 共享库:尽量避免 LD_LIBRARY_PATH
2009-10-31 12:40 1637Linux 运行的时候,是如何管理共享库(*.so)的? ... -
nfs配置
2009-10-30 21:06 11391.安装nfs服务器端和客户端 服务器端:sudo apt- ... -
如何为嵌入式开发建立交叉编译环境
2009-10-21 20:05 1113http://www.ibm.com/developerwor ... -
Architecture and TAEGET 对照表
2009-10-21 19:38 1080也可见附件 -
Linux for PowerPC Embedded Systems HOWTO
2009-10-21 19:24 2209Table of Contents : ... -
The GNU Toolchain for ARM Target HOWTO
2009-10-21 19:22 1774Friends, After repeated attemp ...
相关推荐
Building a Simple File System Section 9.11. Chapter Summary Chapter 10. MTD Subsystem Section 10.1. Enabling MTD Services Section 10.2. MTD Basics Section 10.3. MTD Partitions Section 10.4. MTD ...
In addition, you will find simple device driver module code that connects external devices to the kernel, and network integration code that connects embedded Linux field devices to a centralized ...
This book targets Embedded System developers and GNU/Linux programmers who would like to program Embedded Systems and perform Embedded development. The book focuses on quick and efficient prototype ...
MODULE_DESCRIPTION("A simple DMA module for accessing physical memory in Linux."); ``` This example demonstrates how to create a basic kernel module that maps a specific physical memory region (`1.5 ...
What Is an Embedded System? ....................................................................... 1 Variations on the Theme .............................................................................
Device Example: System CMOS Sensing Data Availability Talking to the Parallel Port RTC Subsystem Pseudo Char Drivers Misc Drivers Character Caveats Looking at the Sources Chapter 6. Serial ...
The BeagleBone Black being an embedded Linux development board can be an excellent choice for building various measurement and control systems by developers and hobbyists. This book is thought as a ...
Getting Started with Qt/Embedded Linux Customizing Qt/Embedded Linux Integrating Qt Applications with Qtopia Using Qtopia APIs Part IV: Appendixes Appendix A. Obtaining and Installing Qt ...
Linux(2.6.18或更高版本) OSX(10.7 Lion或更高版本) Android(SDK 16或更高版本) Android Termux 的iOS 从源头建造 simple为下面的某些平台提供了自给自足的平台脚本,从而可以轻松完成工作,甚至无需付出...
4. **操作系统研究**:The Operating System是一个专注于操作系统核心研究的平台,对于深入理解嵌入式操作系统的机制非常有帮助,尤其适合从事嵌入式操作系统开发的专业人士。 5. **嵌入式Linux联盟**:嵌入式Linux...
7. Qt/Embedded是Trolltech公司开发的面向嵌入式系统的Qt版本,提供完整的图形栈,其API与Qt/X11和Qt/Windows兼容,但不依赖X11库,适用于各种硬件平台。 8. OpenGUI和PicoGUI是两个轻量级的GUI解决方案,OpenGUI...
例如**http://www.lumit.org**、**http://www.arm9e.com**、**http://ustcers.com/blogs/devzhao/articles/category/65.aspx**、**http://www.bol-system.com**、**http://www.52arm.com**、**http://www.siheng.cn*...
Installing eric5 is a simple process. Just execute the install.py script (type python install.py -h for some help). Please note that the installation has to be performed using the administrators ...
9. System Requirements 9.1. Servlet Containers 10. Installing Spring Boot 10.1. Installation Instructions for the Java Developer 10.1.1. Maven Installation 10.1.2. Gradle Installation 10.2. Installing...
- **Primary Use:** System software development, embedded systems, and performance-critical applications. - **Influences:** Influenced by earlier languages like BCPL and B, and later influenced ...
Using Python as a Simple Adding Machine Recipe 3.15. Checking a Credit Card Checksum Recipe 3.16. Watching Foreign Exchange Rates Chapter 4. Python Shortcuts Introduction Recipe 4.1. ...
PEP 519: Adding a file system path protocol PEP 495: Local Time Disambiguation PEP 529: Change Windows filesystem encoding to UTF-8 PEP 528: Change Windows console encoding to UTF-8 PEP 520: ...