Configure a cross-compilation development environment for the SharpZaurus device

Source: Internet
Author: User
Article title: configure a cross-compilation development environment for the SharpZaurus device. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
When the compiler runs on a system that generates executable programs for another system, cross-compilation occurs-when the target system does not have local settings for the compilation tool, or when the host system is faster or has more resources, this is an important concept. In this how-to article, Peter Seebach discusses the initial settings of the cross-compilation environment (using the Sharp Zaurus handheld computer as the focus ), it also introduces the tool installation, basic compilation, installation programs on the Sharp Zaurus handheld computer, and advanced problems such as creating programs using configure scripts.
Generally, programs are compiled on one computer and distributed to other computers to be used. This process is called cross-compilation when the host system (the system that runs the compiler) is incompatible with the target system (the system on which the generated program runs.
  
In addition to the obvious benefits of compatibility, cross-compilation is also important for the following two reasons:
  
When the target system has no local settings for its available compilation tools.
When the host system is much faster than the target system, or has more available resources.
In this article, I will use the Sharp Zaurus series of handheld computers as the focus to discuss the initial settings of the cross-compilation environment. I will introduce the installation of tools, basic compilation problems, how to install programs on a handheld computer, and advanced problems such as creating programs using configure scripts. If you read the document in an organizational order, you will benefit the most from this article, because this article is similar to a tutorial, and each step is logically connected.
  
First, I will give a brief overview of cross-compilation.
  
   Understand cross-compilation
Skip this section if you are familiar with the cross-compilation environment. However, if you do not understand cross-compilation, continue to read it.
  
The development system I use is a Linux system with x86 architecture. I tested these commands on SuSE Linux 8.2. The target system to be tested is the Sharp Zaurus SL-5600 and C700. This document assumes that you have a background in Unix development practices and have used command lines.
  
As I mentioned earlier, cross-compilation occurs when the compiler runs on a system that generates executable programs for another system and the two systems use different operating environments. In addition, cross-compilation is useful when the target system does not have its own compilation tools, or when developers can balance the potential performance of the host system or more resources.
  
When talking about cross-compiler, I not only refer to the software that converts code from a programming language to object code, but also to other necessary development tools:
  
A assembler is part of the back-end of the compiler tool chain.
A linker, which is another part of the back-end of the compiler toolchain.
Some basic tools used to process executable programs and libraries, such as strings.
For example, the strings utility (which outputs the text string of the object module) may be useful, but the host environment version is not very useful for the binary system of the target environment. Zaurus's cross-development tool contains strings.
  
It is possible to run the compiler locally on Zaurus, but the limitations of the system impede the effective work. this is another reason that enables cross-compilation to benefit developers. The display and keyboard of typical desktops are very helpful for editing. In addition, the memory, processor, and storage capacity of the desktop can better meet the needs of compiled resources.
  
Now, let's install the required tools.
  
   Installation tools
You must download several software packages. You can obtain these software packages from the Sharp Web site (links to the site in the references section) and download them as RPM. You need the following major software packages:
Cross-compiler (gcc ).
Library (glibc ).
Contains files (header files ).
"Other tools"-a software package that contains commonly used tools in the cross-development environment.
Next, install RPM. To do this, the root permission is required. The recommended installation method is to repeat rpm-Uvh filename. rpm for each file.
The file is installed in the/opt/Embedix directory. This directory has a slightly unusual structure-the actual binary file is installed in the/opt/Embedix/tools/bin directory, it has symbolic links to these binary files installed in the/opt/Embedix/tools/arm-linux/bin directory. For example,/opt/Embedix/tools/arm-linux/bin/gcc is a symbolic link to/opt/Embedix/tools/bin/arm-linux-gcc. Both can be used.
  
Compile a simple test program and the tool has been correctly installed in the quick test. I recommend the traditional "Hello, world! "Program, which is easy to test:
Listing 1. test the correct installation
# Include <stdio. h>
  
Int main (void ){
Printf ("Hello, world! ");
Return 0;
}
  
Save the test program in a file named hello. c and compile it. Both paths to the compiler can work-I like to use/opt/Embedix/tools/arm-linux/bin/gcc. After the program is compiled, use the file command to check the type of the output file.
Listing 2. use the file command to check the output type
$/Opt/Embedix/tools/arm-linux/bin/gcc-o hello. c
$ File hello
Hello: ELF 32-bit LSB executable, ARM, version 1 (arm ),
Dynamically linked (uses shared libs), not stripped
  
You may be interested in this brief deviation topic. Remember when I mentioned the strings program? Let's try this program.
  
First, run the local strings program on your binary system:
  
Listing 3. run the local strings program
  
$/Usr/bin/strings hello
  
Next, run the arm version on the same binary system:
  
List 4. arm version
  
$/Opt/Embedix/tools/arm-linux/bin/strings hello
  
In my testing system, these results are slightly different. The strings program specific to arm discovers a new string not found in i386.
  
Now we test the program on the target system.
  
Install the application on the target system
There are several ways to move files to the target system:
  
Transfer using standard Zaurus sync software.
Copy to media.
Move through the network.
Using a wireless card or Ethernet adapter may be the easiest way to move files. If this is not the case, it is quite convenient to copy the file to CompactFlash or SecureDigital media. Unfortunately, at the time of publishing this article, Sharp has not yet officially supported sync in Linux, but it can be copied to media everywhere.
  
Depending on the ROM version on your Zaurus, the system may not recognize or install the ext2fs card. Therefore, it may be more practical to copy a file using a card formatted with FAT16. The CF and SD cards are normally formatted before leaving the factory, so they can be used out of the box.
  
(Note: The ext2fs card is a memory card formatted for the Linux file system. The FAT16 formatted card is a memory card formatted for the older MS-DOS file system. The CF card is CompactFlash, a medium standard used by some digital cameras. Most CF devices are storage devices, but CF Ethernet, wireless, and serial adapters also exist. The SD (or Secure Digital) card is a connection between the MultiMediaCard technology and our purpose. the SD card is like an MMC card that permanently saves 10% space .)
  
Copy your executable file to an installed card. When the card is moved to Zaurus, it is automatically installed as/usr/mnt. rom/cf. Now you can run the application from the card.
  
Listing 5. run the application on the slave card
  
$/Usr/mnt. rom/cf/hello
Hello, world!
  
Now you have tried this program, but you may prefer the Zaurus ipkg binary package format. The ipkg file is only a tar file that contains three other files:
  
The first file, data.tar.gz, is a compressed tar file that contains multiple files that will be installed in the correct directory structure.
The second file, control.tar.gz, is a compressed tar file that contains the installation script and information.
The third file, debian-binary, is a plain text file that contains the string "2.0 ". This file does not really do anything at present, but some tools expect this file to be available.
Although there is a convenient script for you to do this, you can also manually create an ipkg file. In case you really want to manually create an ipkg file, I will briefly discuss the format of this software package. With the standard software installer you will use, the package will correctly install the "hello" program.
  
Create a new directory named h to save the file. The name is not necessarily h, but a short name is used because it is always typed later.
Create a subdirectory named h/opt/QtPalmtop/bin and copy your "hello" executable file to this directory. This is a good directory for displaying the installed program.
Create a directory named h/CONTROL. This directory forms the content of the control.tar.gz file. other things in h are stored in the data.tar.gz file. In this directory, you only need one file called control. Put the following data into the file:
Listing 6. information to be placed in the control file
Package: hello
Priority: optional
Section: Misc
Version: 1.0
Architecture: arm
Maintainer: Your name (your.address@example.com)
Depends: libc6
Description: Just as stores have greeters, so to do PDAs have greeters.
This is a longer description, separate from the first one, which
Can be multiple lines long, with each line indented by a single space.
  
There are other files that can be placed in the CONTROL directory, but you do not need these files. For more information about this topic, see references.
  
Run ipkg_build.sh h. If everything you have done is correct, you should get a file named hello_1.0_arm.ipk. Copy the file to your Zaurus-no matter how it is copied-and run the Add/Remove Software program on Zaurus.
Install hello, which is the version 1.0 file that you should see in the package list. Now you can run it from the command line; it has been copied to the/opt/QtPalmtop/bin directory. If you install it in a media slot instead of an internal flash memory, it will be in the QtPalmtop/bin directory on the card. For example, if SD is installed, it will be installed as/usr/mnt. rom/card/QtPa
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.