Click here to learn
about this Sponsor:
Home  |  News  |  Articles  |  Forum

  Home arrow Linux For Devices Articles arrow An introduction to the Scratchbox cross-development tool

An introduction to the Scratchbox cross-development tool
By Linux Devices

Rate This Article: Add This Article To:

Foreword: This article by Movial Technical Manager Veli Mankinen introduces a GPL-licensed environment that provides a set of tools to integrate, cross-compile, and test Linux software. Scratchbox provides a sandbox build environment that assures that the intended versions of libraries, headers, and other such files are used during the build.



Mankinen asserts that most of the higher-level software built using GNU Autotools does not cross-compile nicely in their as-is form. Scratchbox solves this problem by allowing the small test programs (used by the configure script to test for availability of features in the environment) to run transparently either using an emulator or through "CPU-Transparency" on an actual target device.

In practice, software configuration and building using Scratchbox is quite identical to how it's done for the desktop, Mankinen says, making it possible to bring regular developers to the embedded project.



Scratchbox - Making Cross-Compilation Faster and Easier

In early years of computing there was no such thing as cross-compiling software. As technology and needs advanced, many different processors and applications were brought to the market. Embedded processors are in many cases powerful enough to run the software. However, development, compiling, and testing of embedded software still requires a lot of effort and time.

As a result, more software has to be run on a variety of hardware platforms and at the same time device manufacturers want to make more use of existing software across platforms to speed up their development. As device manufacturers have identified Linux and Open Source Software as a strategic operating system for embedded devices, there is a need to use the same software across devices. However, when making use of existing software originally developed for desktop or server environments, this becomes very challenging.

One of the reasons for these challenges is because most application development is done on and for desktops and servers. The software compilation takes place natively on those machines. Developers have therefore taken various tools into use that help them compile their software. Unfortunately these tools rarely fully support cross-compiling or have accurate documentation about the scripts and macros used in compiling. Hence, device manufacturers have a need to facilitate and speed up cross-compilation of software for embedded devices.

Device manufacturers' software development and cross-compilation problems

Linux device manufacturers face a number of critical problems when developing and cross-compiling software for devices. The first problem relates to the fact that most Open Source software projects use a 'configure' script to configure their software for compilation. This script is produced by tools called 'autoconf' and 'automake', which processes 'm4' macros written by the application developer. The script will generate the Makefiles that are used for building the software and a 'config.h' header file containing defines for features found on the build system. Configure is meant to ease configuring the software for compilation and its default assumption is that the software will be run in the same environment and processor in which it was compiled in and run from the place where it was installed to.

Autoconf provides application developers certain macros to check out features in the system. The problematic macros for cross-compilation are:
  • AC_TRY_RUN -- Tries to compile, link and run given test code for some feature. Test programs return zero for success.

  • AC_TRY_LINK -- Tries to compile and link test code for library function existence.

  • AC_CHECK_LIB -- Tries to compile and link test code using certain library.

  • AC_SEARCH_LIBS -- This does the same as AC_TRY_LINK, but 'configure' tries to do linking from all of the system library paths, not just from ones given in CPPFLAGS, CFLAGS and CXXFLAGS environment variables.
The second problem device manufacturers face is that most application developers don't take cross-compilation into account when using these macros, so 'configure' ends up cross-compiling test code and trying to run it on the build host, which breaks the configuration. Configure can also find libraries, headers and versions of those that are only present on the build host, not on the target, which will fail either compilation of the program or running it on the target.

A third problem is when the developer does not know whether 'configure' found the correct values or not, unless he manually goes through tens of thousands lines of output it produces (or the binary fails when it's run). This results in a lot of manual work.

For more about the problems of cross-compiling open source programs, see this paper (PDF download) from Movial.

It is of course possible to just take the easy road and use native compiling. However, this is rarely an option as the embedded processors lack the computing power that the desktop computers have, and therefore it takes a lot of time to compile a necessary set of software.

Software development and cross-compilation for Linux device manufacturers can therefore result in a number of problems that slow down the development process significantly, as well as making development and cross-compiling more difficult. This requires more manual work from the development team.

Current cross-compile solutions and limitations

There are commercial embedded solutions available for device manufacturers for solving some of these problems. However, it seems most of those solutions only offer a limited set of programs and libraries that have been made cross-compile aware. This limits the selection of other programs and libraries that the device manufacturer can use in its products. In many cases the libraries and tools offered by the commercial embedded solutions are also quite out-dated.

Device manufacturers therefore face problems when they want to use or experiment with new software libraries and programs that are not supported by any commercial embedded solutions. In this case a device manufacturer then has three options:
  1. Decide what software to use and then manually get these to cross-compile, which is often very time consuming and difficult, or . . .

  2. Use native compiling which drastically slows down the development process, or . . .

  3. Find a whole cross-compile environment with which most of the software and libraries cross-compile straight out of the box.
Scratchbox - speed up development, testing, and time to market

Scratchbox was developed to facilitate making use of any existing open source software in embedded devices. Scratchbox is a configuration and compilation environment for building Linux software and entire Linux distributions. The basic idea in Scratchbox is to offer developers an environment that works and looks like the target environment before the target environment is available. This drastically speeds up development and facilitates cross-compilation, enabling device manufacturers to bring their products to the market faster.

With Scratchbox all the work that needs computing power, like compiling, is done on a desktop machine instead of on the target device. This makes the compilation process much faster, and making small changes and testing cycles a lot shorter. Scratchbox can be run on an x86 machine and supports compiling for x86 and ARM architectures. Adding additional architectures and integration into IDE's can be done rapidly. It is also possible to use other than glibc C-library within Scratchbox.

Scratchbox makes it possible to configure and compile software for other architectures than where Scratchbox itself is running. It is also possible to run the software compiled for other architectures inside Scratchbox using the target device transparently. This means it makes it easier to bring non-embedded developers to the development team since most of the development is similar as development for desktop or servers. Scratchbox makes it possible to share the target device with the entire development team, regardless of their physical location.

When logging into Scratchbox for the first time in ARM-mode it looks like you are logging into a Linux distribution installed on for example an ARM device. However, this distribution seems to be empty (/bin, /usr, /var do not contain anything). This makes it possible to compile and install software so that everything can be installed on the default locations but nothing from the environment will be overwritten. Although the environment looks empty it contains most of the tools needed for normal configuration and compilation process. As it is also possible to run compiled ARM programs in Scratchbox the illusion of being on a real ARM device is almost perfect.

To summarise, Scratchbox offers device manufacturers the following benefits:
  • Easy cross-compiling
  • Shorter compilation times (Compared to native building)
  • Shorter development and test cycles
  • Automates and facilitates cross-compilation and development
  • Makes it easier to develop your own cross-compiled embedded Linux distribution
  • Share target device with the entire development team
  • Development does not differ a lot from normal desktop software development
  • Bring regular Linux developers to the embedded development team
Conclusion

Embedded software development can result in a number of problems for device manufacturers such as long compile times or many configuration problems when cross-compiling software. Scratchbox is a solution that speeds up and facilitates the development, cross-compile, and test times.

Scratchbox solves most of the traditional problems in cross-configuring and cross-compiling by emulating the target environment. Although you would be using some existing Linux distribution it is in many cases required to be able to compile the whole system for assuring decent testing and quality. In these cases native compiling is rarely an option and Scratchbox can be used to speed up the development.



About the author: Veli Mankinen has been a technical project manager in Movial for over two years, and has been involved in many of Movial's embedded Linux projects. Veli is one of the lead architects and developers behind Scratchbox. The Scratchbox project originated at and is maintained by Movial, a Finnish software design, integration, and development firm specializing embedded Linux and Symbian devices.



Related Stories:


Discuss An introduction to the Scratchbox cross-development tool
 
>>> Be the FIRST to comment on this article!
 
 
 
>>> More Linux For Devices Articles Articles          >>> More By Linux Devices
 



FUEL Database on MontaVista Linux
Whether building a mobile handset, a car navigation system, a package tracking device, or a home entertainment console, developers need capable software systems, including an operating system, development tools, and supporting libraries, to gain maximum benefit from their hardware platform and to meet aggressive time-to-market goals.

Breaking New Ground: The Evolution of Linux Clustering
With a platform comprising a complete Linux distribution, enhanced for clustering, and tailored for HPC, Penguin Computing¿s Scyld Software provides the building blocks for organizations from enterprises to workgroups to deploy, manage, and maintain Linux clusters, regardless of their size.

Data Monitoring with NightStar LX
Unlike ordinary debuggers, NightStar LX doesn¿t leave you stranded in the dark. It¿s more than just a debugger, it¿s a whole suite of integrated diagnostic tools designed for time-critical Linux applications to reduce test time, increase productivity and lower costs. You can debug, monitor, analyze and tune with minimal intrusion, so you see real execution behavior. And that¿s positively illuminating.

Virtualizing Service Provider Networks with Vyatta
This paper highlights Vyatta's unique ability to virtualize networking functions using Vyatta's secure routing software in service provider environments.

High Availability Messaging Solution Using AXIGEN, Heartbeat and DRBD
This white paper discusses a high-availability messaging solution relying on the AXIGEN Mail Server, Heartbeat and DRBD. Solution architecture and implementation, as well as benefits of using AXIGEN for this setup are all presented in detail.

Understanding the Financial Benefits of Open Source
Will open source pay off? Open source is becoming standard within enterprises, often because of cost savings. Find out how much of a financial impact it can have on your organization. Get this methodology and calculator now, compliments of JBoss.

Embedded Hardware and OS Technology Empower PC-Based Platforms
The modern embedded computer is the jack of all trades appearing in many forms.

Data Management for Real-Time Distributed Systems
This paper provides an overview of the network-centric computing model, data distribution services, and distributed data management. It then describes how the SkyBoard integration and synchronization service, coupled with an implementation of the OMG¿s Data Distribution Service (DDS) standard, can be used to create an efficient data distribution, storage, and retrieval system.

7 Advantages of D2D Backup
For decades, tape has been the backup medium of choice. But, now, disk-to-disk (D2D) backup is gaining in favor. Learn why you should make the move in this whitepaper.

Got a HOT tip?   please tell us!
Free weekly newsletter
Enter your email...
PLATINUM SPONSORS

 


ADVERTISEMENT


Check out the latest Linux powered...

Mobile phones!

MIDs, UMPCs
& tablets

Mobile devices

Other cool
gadgets

Resource Library

• Unix, Linux Uptime and Reliability Increase: Patch Management Woes Plague Windows Yankee Group survey finds IBM AIX Unix is highest in ...
• Scalable, Fault-Tolerant NAS for Oracle - The Next Generation For several years NAS has been evolving as a storage ...
• Managing Software Intellectual Property in an Open Source World This whitepaper draws on the experiences of the Black Duck ...
• Open Source Security Myths Dispelled Is it risky to trust mission-critical infrastructure to open source ...
• Bringing IT Operations Management to Open Source & Beyond Download this IDC analyst report to learn how open source ...




Most popular stories -- past 90 days:
· Linux boots in 2.97 seconds
· Tiniest Linux system, yet?
· Linux powers "cloud" gaming console
· Report: T-Mobile sells out first 1.5 million G1s
· Open set-top box ships
· E17 adapted to Linux devices, demo'd on Treo650
· Android debuts
· First ALP Linux smartphone?
· Cortex-A8 gaming handheld runs Linux
· Ubuntu announces ARM port


DesktopLinux headlines:
· Simulator runs Android apps on Ubuntu
· Hypervisor rev'd for higher reliability
· Pluggable NAS now supports Linux desktops
· Moblin v2 beta targets netbooks
· Linux-ready netbook touted as "Student rugged"
· USB display technology heading for Linux
· Ubuntu One takes baby step to the cloud
· Game over for Linux netbooks?
· Linux Foundation relaunches Linux web site
· Dell spins lower-cost netbook


Also visit our sister site:


Sign up for LinuxForDevices.com's...

news feed


Or, follow us on Twitter...