Migration of KVM on Embedded Linux

Source: Internet
Author: User
I used to want to do this game, but I didn't find it difficult to do anything ready-made. But I still don't know the specific problem.
I found this article yesterday and noted it down. It may be used in the future ..

Migration of KVM on Embedded Linux

[Reprinted please indicate the source, Author: Zhang Hongyi, patrick_zhg@hotmail.com]

Currently, embedded Linux is widely used in embedded devices. Java is based on its "write once, run anywher
E is applied to embedded systems such as handheld computers and smart phones. This document uses uCLinux embedded operations
The system is used as an example to describe how to port KVM. It is introduced in the following parts:
1. Introduction to uClinux and KVM
2. obtain and install the cross-Development Tool
3. Obtain KVM source code
4. Modify the KVM makefile.
5. Compile KVM for uClinux
6. Test KVM
7. Summary

1. Introduction to uClinux and KVM
UClinux is an excellent embedded Linux operating system, short for micro-conrol-Linux.
Embedded Linux example of source code. UClinux does not have a storage management unit MMU (
Memory Management Unit) is designed for embedded systems. It has been successfully transplanted to many platforms.
. Adhering to the excellent features of standard Linux, it has been transformed to a highly optimized
Compact embedded Linux. Although it is small, it retains most of the advantages of Linux: stability, good
Good portability, excellent network functions, complete support for various file systems, and a wide range of standard APIs. It is designed for embedded
The system has done a lot of small work, and now supports multiple CPUs. The compiled target file can be controlled at several hundred kb.
It is an order of magnitude B and has been successfully transplanted to many platforms.
KVM is a Java Virtual Machine dedicated to embedded devices. It is mainly used for j2-cldc. KVM can be understood
K virtual machine or kjava virtual machine. Is a streamlined, portable, dedicated for small
A java virtual device with memory, CPU, and other resource restrictions (such as mobile phones, PDAs, POS machines, and other embedded devices)
Machine.
KVM aims to create a Java Virtual Machine as small as possible and as complete as possible, so that developers do not need to develop C
I am equally concerned about hardware, but I am developing it in Java to achieve one compilation and use of various platforms.

2. obtain and install the cross-Development Tool
From http://sourceforge.net/project/showfiles.php? Group_id = 58162 & package_id = 54041
Obtain the cross-compiled installation package of arm-elf-tools. Here I used to compile the arm-elf-tools-20030314.sh
KVM, but encountered a compilation error. So it is recommended that readers download the arm-elf-gcc3.0 version or above for compilation.

3. Obtain KVM source code
Obtained from http://www.sun.com/software/communitysource/j2me/cldc/download.xml
Obtain the KVM source code file.

4. Modify the KVM makefile.
After downloading and unzipping the cldc, the specific KVM porting process is described below:
Modify the j2me_cldc/KVM/vmunix/build/MAKEFILE file File
This makefile is used to compile KVM. Because KVM is implemented in C language, theoretically
Use the compiler for CPU of different architectures to compile KVM. This is how to implement cross-Compiling of KVM.
.
To modify the MAKEFILE file, you must be familiar with the syntax rules of makefile. Here we will not detail the rules of this language.
For more information about makefile syntax rules, see
. The makefile modification section is as follows:

Ifeq ($ (Platform), Linux)
# Comment out the original libs =-lm-lnsl
# Libs =-lm-lnsl
# Add the following line
Libs =
# Comment out the original cppflags =-dunix-dlinux-d $ (ARCH)
# Cppflags =-dunix-dlinux-d $ (ARCH)
# Modify the cppflags definition as follows:
Cppflags =-d $ (ARCH )/
-I $ (top)/KVM/vmcommon/h-I $ (top)/KVM/vmunix/h/
-I $ (top)/KVM/vmextra/h-I $ (top)/JAM/h-I $ (top)/KVM/vmcommon/src
Endif

Build_root =/usr/local
Lib1 =$ {build_root}/lib/GCC-lib/ARM-elf/3.0
Lib =$ {build_root}/ARM-elf/lib
Include =$ {build_root}/ARM-elf/include/

# Define CC with arm-elf-GCC and specify the included header file path and compilation options
Cc = arm-elf-gcc-I $ (include)-D _ uClinux _-d1_use_bsd = 1
# Use arm-elf-LD to define the LD, which is used to connect to the target file
LD = arm-elf-LD

Wec_ldflags =-L. /-L $ {lib}/lib-L $ {lib}/libc-L $ {lib1}-T $ {lib}/elf2fl
T. LD
Extlibs =-LC-lgcc-lC
Ldflags =

Ifeq ($ (GCC), true)
# Comment out cc = GCC. In fact, ifeq ($ (GCC), true) is not true and will not be executed here.
# Cc = gcc
Cflags =-wall $ (cppflags) $ (romflags) $ (other_flags)
Debug_flag =-G
Optimize_flag =-O2
Else
# Comment out the CC = Cc line. In this way, the system uses cc = arm-elf-GCC to compile KVM.
# Cc = cc
Cflags =-Xa $ (cppflags) $ (romflags) $ (other_flags)
Debug_flag =-g-xsb
Optimize_flag =-xO2
Endif

Debug_flag + =-dincludedebugcode = 1
$ (Top)/tools/JCC/romjavaunix. C $ (top)/tools/JCC/nativefunctiontableunix. C: JCC
UNIX
. Phony: jccunix
Jccunix:
@ (CD $ (top)/tools/JCC; $ (make) UNIX)
KVM $ (j) $ (G): OBJ $ J $ g/$ (cleanupxpm) $ (objfiles)
@ Echo "linking... $ @"
# Comment out @ $ (CC) $ (objfiles)-o $ @ $ (libs) $ (extlibs) a row
# @ $ (CC) $ (objfiles)-o $ @ $ (libs) $ (extlibs)
# Use arm-elf-LD to connect to the target file
$ (LD)-o kvm. x $ (wec_ldflags)-R-d $ (objfiles) $ (libs) $ (extlibs)-map KVM. Ma
P

5. Compile KVM for uClinux
After modifying makefile, switch to the j2me_cldc/build/Linux directory and run the make command to compile KVM. If not
Through compilation, it is recommended to use the cross-compilation tool of arm-elf-gcc3.0 and later versions for compilation. After compilation
The KVM. X file is generated in the j2me_cldc/KVM/vmunix/build directory, because the files can be executed on the uCLinux operating system.
All must be in flat format. elf2flt is required to convert KVM. X. Run the following command at a terminal prompt:

Elf2lft-o kvm. x
The KVM executable file is generated. At this point, the entire KVM compilation process is completed.

6. Test KVM
In this way, the compiled KVM is based on the ARM architecture, so it cannot be run on the Red Hat Linux 7.3 system.
You can edit the "Hello World" program. Then perform the following test at the terminal prompt:
./KVM-classpath j2me_cldc/samples/classes helloworld
Program error. This indicates that the compiled KVM is not for the X86 architecture. Next, download KVM to run uclin.
Test KVM on the embedded device of the UX operating system.
Copy KVM and helloworld. class to the uClinux-Dist/romfs/bin directory.
Run make image to generate romfs. IMG that contains KVM and helloworld. Class.
Download image. Ram and romfs. IMG to the board
After the uClinux system is started, enter the following command to test
./KVM-classpath/bin helloworld

7. Summary
This article takes the uCLinux embedded operating system as an example to discuss the KVM porting process.
For Embedded Linux systems (such as PPC Linux and MIPS Linux), you can modify K
Compile VM makefile. If you want the system to support more functions, such as MIDP, further research is required.
Research and exploration.

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.