西游记86版潮汕话:在ARMulator中移植uClinux(1)

来源:百度文库 编辑:九乡新闻网 时间:2024/05/04 19:48:09

Getting Familiar with uClinux/ARM 2.6
by Hyok S. Choi
the author and maintainer of uClinux/ARM2.6
 
Why uClinux/ARM 2.6?
Whywould you want to use uClinux? There could be many reasons to considerthe uClinux for your embedded OS. Some of them could be as following:

Lightweight
You can make a complete linux 2.6 preemptible kernelimage including console and some basic device drivers and ROMFS under300KB! (zImage) and the applications in flat-binary format areapproximately 30~50% lighter than typical conventional linux ELFbinaries, thanks to lighter standard C and C++ libraries.

XIP
With much smaller RAM, you can execute your kernel and eventhe applications by XIP(eXecution In Place). It could help you to bootup faster, although the access time for the flash or rom for boot imageshould be fast enough and/or enough cache size. (There could be atrade-off between those values if we want to find the optimal balance.)

Cheaper
It is known that the MMU core size in typical ARM SoCwafer is about 30%. In typical network or embedded systems more than ahalf of applications do not need the MMU. Many of RTOS do not use MMU indefault, even if target CPU has one.

Full Linux API
You can use the full Linux APIs on your uClinuxplatform with few exceptions. You can use the pThread in uClibc and thestandard system calls. There are plenty of applications which are portedto uClinux in the userland in uClinux distribution package.

Easier to adapt
One of the interesting natures of uClinux is thepossibility of user application accessing the whole system, includingregisters in devices. With a bit of wrapper, we can make the firmwarecode run on uClinux as a plain application! Of course, you can add somedevice driver and call the linux system calls and use many open Ips inmixed with the old firmware code. If you're planning to migrate yourfirmware codes to Linux, but you're not familiar with Linux systemprogramming, uClinux could be a good starting point. ;-)

Full Linux 2.6 kernel features
Although, it is lighter, itsupports almost full features of conventional linux 2.6 kernel,including preemptible kernel feature and so many file-systems, devicedrivers. Porting of device drivers for conventional Linux is handy.Almost all codes should be compiled without change, except memorymapping from virtual address to physical.

The First Compile Guide
If you decided to set up an uClinux development environment, this is the list that you have to grab on your linux host:

uClinux distribution
The easiest way to get started with uClinux is to play with a copy of uClinux-dist from the uClinux.org site at:
http://www.uclinux.org/pub/uClinux/dist/
Notethat the kernel version in the distribution may not be the latest.You'll be able to gather the latest patch set and the vanilla Linuxkernel from the kernel.org to make a latest copy of uClinux kernel.
Atthis time (20040427), the latest distribution is“http://www.uclinux.org/pub/uClinux/dist/uClinux-dist-20040408.tar.gz”.If you have some strange trouble with compilation, even after followingthis guide, simply use this distribution for your testing, and updatelater. :-)

the Kernel and patch
You could find the latest uClinux/ARM kernel patch at:
http://opensrc.sec.samsung.com/
At the download section, you'll find the link of latest “linux-2.6.x-hscx.patch.gz” and the original kernel package like:
http://opensrc.sec.samsung.com/download/linux-2.6.5-hsc2.patch.gz
and
http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.5.tar.bz2

ARM-ELF toolchain
Since the Linux 2.6 kernel code uses some of thenew features from newer binutils, you need a newer ARM-ELF toolchainfor kernel compilation than the one of uclinux.org. You could find thelatest toolchain at the same place with the kernel and patch downloadsection above, and the direct url at current time is :
http://opensrc.sec.samsung.com/download/arm-elf-tools-20040427.sh

Hardware Platform or an ARMulator
Of course, you need a platformto run the kernel on. Please refer the notice section which platform issupported. Even if you can not find the one that you have, or if youdon't have any hardware platform, you can run a complete kernel on yourLinux PC! : the ARMulator.
The ARMulator is a GDB based emulator which emulates full Atmel AT91x, arm7tdmi EB01. The url of ARMulator home is :
http://www.uclinux.org/pub/uClinux/utilities/armulator/
You can download directly at this urls:
http://www.uclinux.org/pub/uClinux/utilities/armulator/gdb-5.0.tar.bz2 (the original gdb-5.0 archive)
http://www.uclinux.org/pub/uClinux/utilities/armulator/gdb-5.0-uclinux-armulator-20021127.patch.gz (Patches against gdb-5.0)

And another patch if you want to run the kernel with ramdisk on the ARMulator :
http://opensrc.sec.samsung.com/download/gdb-5.0-uclinux-armulator-ramdisk-20040412.patch.gz

That's all for your first compilation.

Okay, here we go step by step.
(This guide is assuming that the downloaded files are located at ~/incoming and the ARMulator is used for platform to run on.)