[Go to-Recommended] Application of coLinux in building an embedded development environment.

Source: Internet
Author: User
Tags ping and traceroute
[Go to-Recommended] Application of coLinux in building an embedded development environment. -- Linux general technology-Linux programming and kernel information. The following is a detailed description. Abstract: There is an excellent free cross-development tool chain in Linux, and an excellent code editor and other excellent tool software in Windows. This article uses coLinux to create an efficient and simple Linux embedded development environment in Windows, this not only avoids the inconvenience of frequently restarting the computer to switch the operating system after developers install the Windows + Linux dual system, in addition, Linux virtual machines running in Windows systems have higher operating efficiency and fewer host resource requirements. The most important thing is that developers can take advantage of the advantages of Linux and Windows at the same time, this has good practical value in practice.
1 Introduction
The GNU project provides excellent cross-development tool chains for embedded development. Although these tool chains are also transplanted to Windows systems, another simulated Linux environment, Cygwin, is usually required. Efficiency is a new problem. In addition, the Cygwin environment is not a real Linux environment. Compared with the real Linux environment, Cygwin is still insufficient. Basically, the GNU tool chain is developed based on the Linux operating system environment.
Among many open-source projects, most embedded-related development projects still need to be compiled and linked based on the Linux system. Although complex settings in Cygwin may also meet the development needs, for developers, the preferred choice is to use Linux. Programmers who are familiar with Windows usually install a large Linux virtual machine in the system, or directly install two operating systems. Programmers must endure the major disadvantages of Low Running Efficiency of virtual machines, or repeatedly restart computers with dual operating systems to switch their operating systems. If you need to transfer files between Linux and Windows, you also need to do some additional work.
However, the emergence of coLinux has changed all this.
2. Introduction to coLinux
CoLinux is also an open-source software. Its full name is Cooperative Linux (Collaborative Linux ). CoLinux is the first software that can efficiently run Linux in native mode on the Win32 platform, it far exceeds the running efficiency of the Virtual Machine (to simulate an assembly command, the virtual machine usually uses a piece of C language code ). CoLinux has now evolved to version 0.73, providing the latest source code and binary code on its official website http://www.colinux.net.
CoLinux is highly efficient and requires only a small amount of system resources. Linux in coLinux runs directly in PC hardware, rather than on virtual machines. Unlike a virtual machine, coLinux removes a large block of memory from the system at a time, but allows the host system to dynamically allocate memory for it based on actual needs.
CoLinux creates a "real" Linux operating system. In contrast, CygWin provides a simulated Linux environment. If a Linux program is not re-built, it cannot be directly run in Cygwin.
In coLinux, you can use the cofs driver to share folders between the host machine (Windows XP) and Linux. After simple settings, you can share a folder in Windows with the Linux System in coLinux. Linux can also operate files in this folder in Windows.
CoLinux features high portability. Create a coLinux release on a Windows host and install a set of customized applications in the root file system. You can then transfer the root file system to another host and restart it. In this way, a mobile development platform is available, and the compressed root file system can be placed in a standard USB disk.
3. How coLinux works
CoLinux runs as a process in Windows. CoLinux is an interface between Linux and Windows. The two operating systems achieve Cooperative by transferring control of the processor (CPU) to each other. They use kernel drivers to share physical resources such as network interfaces and serial ports.

CoLinux is a modified Linux kernel that can run in collaboration with another operating system. The host operating system controls the hardware resources of the local machine, while the guest operating system only obtains the virtual abstraction of the local hardware. The host operating system provides a way to execute the driver at the privileged level (ring 0) and a way to allocate memory.

Other features required by the Linux kernel (such as network connection, serial port, or video access) are implemented through external proxies,
For example, coLinux can access the external network through the TUNTAP driver and access the display (X Window System) through a proxy.
CoLinux installation and configuration
CoLinux installation is very easy, including several simple steps. During the installation process, coLinux prompts you to download the compressed packages of Several Linux File System images, such as ArchLinux, Debian 4.0, Fedora 7, Gentoo Deluxe, and Ubuntu 7.1, from the Internet. Click the corresponding "* Notes" to open the corresponding instructions and download pages. The following uses the Fedora9 file system image compressed package as an example to introduce the installation and configuration of Linux in coLinux.
The Fedora9 file system image compression package downloaded from the Internet contains five files, which are common files for the host operating system (Windows, but for coLinux, some of these files (Fedora-9.img, swap. img) is a readable ext3/swap Linux File System.
The Fedora-9.img is a 4G Fedora9 file system image that contains all the necessary files in the Fedora9 system and pre-configures the slirp network, the Xvnc that is logged on to the machine by running the machine running on the machine running the sound. When using Fedora9, you can control the current network adapter (NIC) through the host machine API to send and receive TCP/UDP packets without configuring the network functions of the host machine. Because Slirp cannot send and receive ICMP messages, commands such as ping and traceroute cannot work, but other network functions will not be affected. To access Linux from outside, port redirection is required. In the coLinux configuration file, you can perform simple settings. In addition, coLinux provides the tuntap and pcap-bridge communication modes between Linux. For more information, see the help documentation provided by colinux.
Swap. img: this is an image of a 512M swap partition.
Start-Fedora-9.bat: Start the Fedora9 + coLinux batch file (need to modify according to the situation), which is a command to start coLinux, the command is followed by the relevant configuration parameters.
Start-Fedora-9.sh: Start the script file of Fedora9 + coLinux (which needs to be modified as needed and run in Bash of Cygwin environment ).
README-Fedora-9.txt: A description of the current image.
Decompress the downloaded file and release it, edit the file start-Fedora-9.bat, according to The Fedora-9.img and swap. img in the real location of the host machine (Windows System), make appropriate changes to cobd0, cobd1 (Note: Use "/" to separate Directories. After the modification, save it to the coLinux installation location, for example, "C: Program FilescoLinux". Double-click it to start coLinux. After Fedora9 Linux starts running, the Linux Startup information is sent to a newly opened FLTK console. If the configuration information of cobd0 and cobd1 is correct, it can be started smoothly.
5. Construct an embedded development environment with both Windows and Linux advantages
Similar to Cygwin, coLinux allows the development and execution of Linux applications on Windows operating systems. However, for coLinux-based Linux systems, you can use apt-get/yum and other application management software to install, update, or delete applications to maintain the Linux operating system. 2/3 | maximum latency 1 2 3 › |
Unlike Cygwin, Linux applications executed on coLinux do not need to be rebuilt. From this perspective, coLinux is not a simulated environment, but a real Linux operating system.
After Fedora9 is started, a FLTK console is displayed, where you can perform basic operations on Fedora9. To build an embedded development environment, you also need to install some software, such as the gcc tool chain. Because sliora9 has configured the slirp network function, these software can be installed directly through the network. Enter a simple "yum install gcc" and follow the prompts to install the gcc tool chain. Other missing software can be installed in the same way. If something you need cannot be found on the network, you can use source code reconstruction.
Fedora 9 shares files with the host machine (Windows XP) through the cofs driver. Cofs is similar to a UML host
File System, used to bind the host machine VFS (Virtual File System) to the Linux VFS. In this way, you can mount the folder on the host machine to the Linux File System, so that the host machine and Linux can read and write the content in the folder at the same time, this facilitates file exchange between Windows and Linux.
File Sharing configuration: Add the following content to the configuration parameters for coLinux startup:
Cofs0 = "D:/test /"
After coLinux is restarted, run the following command on the console to mount the "D: test" folder in Windows to the/mnt folder in the Fedora system.
Mount-t cofs cofs0-o uid = dax, gid = dax/mnt
In this way, Windows XP and Fedora have full access to the content in this folder. For detailed parameters, see the Help File cofs.txt provided by coLinux. The software used in Linux can be downloaded from Windows, saved to the "D: test" folder, and installed directly in Linux. You can also put the code that needs to be compiled using the Linux environment in the "D: test" folder. You can use a familiar editing tool in Windows to edit the source code and compile it in Linux, you can use a tool in Windows to download and debug the compilation results.
6. Conclusion
This article introduces a kind of software, coLinux, that can run Linux in a native way in Windows. By analyzing the operating mechanism of coLinux, this paper expounds the advantages of coLinux-based Linux systems, and introduces the basic configuration methods of coLinux-based Fedora 9, it provides users who are familiar with Windows platform development with a better way to use Linux, which has certain guiding significance in practice.
Innovation point: Use coLinux to create a Linux embedded development environment that is efficient, easy to configure, and truly runs in Windows, this not only avoids the inconvenience of frequently restarting the computer to switch the operating system after developers install the Windows + Linux dual system, in addition, Linux virtual machines running in Windows systems have higher operating efficiency and fewer host resource requirements. The most important thing is that developers can take advantage of the advantages of Linux and Windows at the same time, it simplifies the development environment and increases the development efficiency, which has good practical value in practice.





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.