YOUR FEEDBACK
E-Commerce 2.0
Brian wrote: I think we're heading in the right direction, but we've still...
SOA World Conference
Virtualization Conference
$200 Savings Expire May 16, 2008... – Register Today!


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP LINKS YOU MUST CLICK ON


Experimenting with MontaVista Linux
Lessons learned by solving a problem

Digg This!

This article presents my working experience with the MontaVista Linux distribution (MontaVista Professional Edition 4.0 base on the 2.6.10 Linux kernel) running on a PowerPC processor board. It will present the physical memory mapping in Linux and its limitations using examples of a real problem and the suggested implemented solution that involved changes to kernel configuration.

Linux plays a significant role in embedded application development. It proved to be a platform of choice for soft real-time applications and with Linux distributions such as MontaVista Linux is being improved and hardened for mission-critical embedded application that require a hard real-time response.

Standard Linux (from www.kernel.org) supports two kinds of real-time schedulers (SCHED_RR, SCHED_FIFO) and the preemptive kernel. The hard real-time additions to the Linux kernel offered by MontaVista makes Linux ready to be a platform for developing hard real-time embedded applications. However, at this point, our goal is not the real-time capabilities of Linux but to address some general issues.

Our primary task was to bring up a system on a PC board in record time. However, the applications to be ported required more memory than an existing Linux platform could support. In general, the problem wasn't in the availability of the physical RAM but in the fact that the kernel could only see part of it. The board was equipped with more physical memory than the original kernel was able to access. Facing this problem, we had to modify the Linux kernel to get access to the whole available RAM.

The work started with a cross-development environment setting and some kernel modifications described below. However, before we begin, let's look at the Linux addressing.

Linux Address Space
Each process in the 32-bit address space can address 4GB of memory. This 4GB memory is divided into two parts:

  • User space      ( from 0x0      to      PAGE_OFFSET - 1 )
  • Kernel space      ( from PAGE_OFFSET      to 0xFFFFFFFF      )
Usually, the PAGE_OFFSET define is assigned the value of 0xC0000000. It means that the user address space covers 3GB of addresses starting from address 0x0 and the kernel space covers 1GB of addresses starting from address 0xC0000000 (see Figure 1).

The user can customize the value of PAGE_OFFSET at the kernel compilation time (the Base Address name is used when referring to it, as well).

It's very important to know that the physical RAM memory installed in the system is mapped to the addresses reserved to the kernel space (starting at PAGE_OFFSET). Therefore, if Linux is installed on the system with a huge amount of RAM, there may not be enough addressing space to do the mapping. So, some other mechanisms may be required to make the whole RAM visible.

Problem Description
Following the model described above, theoretically in the 32-bit addressing, the system can access a maximum 1GB of physical memory, assuming that the base address is set to 0xC0000000. So there's the question of what to do when there's more than 1GB of memory available, or some kernel areas are already used (leaving less that 1GB of address space for mapping).

To address this issue, recent Intel x86 microprocessors include a feature called "Physical Address Extension" or PAE that adds an extra four bits to the standard 32-bit physical address. Linux kernel version 2.4 took advantage of PAE to support up to 64GB of RAM. However, the linear address is still composed of 32 bits, so there's no permanent mapping of the whole amount of RAM.

Our board was equipped with the PowerPC processor and there was no need for a huge extension of RAM. In our case, only an extra 256MB of RAM visible to the system was sufficient.

In the next paragraphs, I will describe our solution to get the extra 256MB accessible to the system.

The step-by-step process of kernel configuration will be presented in detail as well.

Solution
When looking at the picture presented in Figure 1, there's one obvious solution. What will happen when the base address is changed from 0xC000000 to 0xA0000000? By moving the base address down by 0x20000000, there will be more address space mapped to the kernel and less to the user space. In this case we'll gain 256MB of memory access. This is exactly what we wanted (having more address space in the kernel to cover the extra RAM).

Figure 2 illustrates the address partition after the base address change. The modifications to the kernel were straightforward and done in no time as you'll see below.

Kernel Configuration
Before making the kernel modifications, the environment has to be set up for access to the proper cross-compilers and linkers. Remember that the embedded kernel will be built, not on the native environment. In our case the embedded platform was a board, running PowerPC processor and the development platform was based on Solaris (a desktop Linux could be used as well).

Figure 3 illustrates the development environment, which consists of:
a)  A Power PC board, where the Linux kernel produced will be executed
b)  A development system where the Linux kernel will be configured and built using MontaVista tools like cross-compilers, linkers, debuggers
c)  A serial connection between the target board (PowerPC) and the development platform (Solaris, Linux) The process of building the new kernel consisted of the following steps:

  • Set up the environment
    All the tools and the kernel source code have to be collected from the MontaVista distribution. The right paths also have to be set up to point to the right directories, etc.
  • Configure the kernel by executing (from the Linux base directory) % make menuconfig. Executing this command brings the menu seen in Figure 4.

    Next, the "Advance setup" option was chosen to change the default values to the customized values. Figure 5 illustrates the menu of the parameters to be changed.

    The following changes were made to this menu:

  • "Set low memory size" to be modified to 0x40000000 (represents 1GB of RAM memory)

    This parameter specifies the size of the memory the system can see. In our case, the original value wasn't set to cover the whole range of 1GB addresses because there was already some address space taken for some other purposes.

  • "Set custom kernel base address" to be modified to 0xA0000000

    The default base address is set to 0xC0000000.

The last change left to do was to modify the Makefile. Because the base address has been change, we have to adjust the "srec" generation accordingly. In this case, modify the address from 0x40500000 to 0x60500000. (See Figure 6.)

And that's all. What's left is to build the kernel and srec file by running the "make" command from the Linux base directory.

After the new kernel is built and burnt (over the serial connection) into the board, resetting the board will conclude the development process. Now, comes verifying if the kernel can see the whole memory. Before executing any more sophisticated tests the first way to verify the system is to run the "top" command. And in fact, the top display shows that the kernel can see all of the available RAM.

Conclusion
I'm sure that there are many different ways of solving the problem described here. The purpose of this article was to document one possible solution. Usually when a project requires fast results (as in our case) the most efficient way is best. Our example shows how easy the changes were to make following the clear theory behind it. And it shows how powerful open source can be when delivering a solution that requires some platform adjustments.

References
• Daniel P.Bovet and Marco Cesati.
Understanding the Linux Kernel.
www.mvista.com/
www.linuxjournal.com/

About Miroslaw Zakrzewski
Miroslaw Zakrzewski works for Ericsson Canada in Montreal and is currently on assignment in Sweden. He focuses on developing server platforms for the next generation IP networks.

ENTERPRISE OPEN SOURCE MAGAZINE LATEST STORIES . . .
Open Source Penetration and Use in SOA Deployments
Open source has made significant inroads into middleware deployments in the enterprise. More and more, open source is being used to deliver the benefits of SOA and open source to the enterprise. There are many custom Enterprise Service Bus deployments waiting to be upgraded to a simple
JavaOne 2008: Uncommon Java Bugs
Any large Java source base can have insidious and subtle bugs. Every experienced Java programmer knows that finding and fixing these bugs can be difficult and costly. Fortunately, there are a large number of free open source Java tools available that can be used to find and fix defects
OpenOffice 3.0 Goes to Public Beta
OpenOffice.org is publicly beta testing OpenOffice 3.0, which is not recommended for production use. General release is expected in September. Aside from cosmetics, it will support the upcoming OpenDocument Format 1.2 and is capable of opening Office 2007 and 2008 for Mac OS X files.
JavaOne 2008: Sun Challenges Linux
Sun's mule train has finally pulled into Indiana after three years on the road. Indiana is the Linux-friendly Fedora-like OpenSolaris project meant to move the Solaris-shy Linux community off Linux and on to Solaris tempted by Solaris widgetry like the highly scalable, rollback-easy, 1
MySQL Backs Off Closed Source Plan
MySQL has backed off a plan to charge for some encryption and compression backup widgetry in the next version of the database - and, heavens, NOT OPEN SOURCE THE STUFF, an idea it trotted a few weeks ago and predictably caught hell for. Sun, which bought MySQL for a billion dollars, a
Application Security for Open Source - The New Frontier
Hybrid applications made up of proprietary, open source and third-party components are the result of today's fast-paced and complex software development landscape. Applications developed within the last five years - whether internal or external - are at least 50% open source software (
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE