Linux uClinux is a commonly used software for computer players. Then I will study and study Linux uClinux in depth. Here I will discuss with you how to use Linux uClinux. I hope it will be useful to you. Linux OS is recommended for porting and Developing Linux uClinux hosts. If you select Windows as the development platform, Cygwin software package is required. The development platform we selected here is Fedora Core 2 and the kernel version is 2.4.x.
1. Establish a Development Environment
Before porting and Developing Linux uClinux, we need to establish a cross-compiling environment for the system, because as a host, we use the IA32 architecture processor, we only use the ARM architecture processor for the Development Board. The cross-compilation tool on the ARM platform can be obtained from the official website of Linux uClinux (www. Linux uClinux.org ).
Here we use a arm-elf-tools-20030314.sh, which is a self-extracting file that can be directly executed for installation. #./If the arm-elf-tools-20030314.sh cannot execute this file, you need to modify the executable properties of the file # chmod 755 arm-elf-tools-20030314.sh and then execute the installation of the program. The executable files are installed in the/usr/local/bin directory by default.
2. Compile the Linux uClinux kernel
Linux uClinux is an embedded operating system that supports no MMU units. We can obtain the latest Kernel File (www. Linux uClinux.org) from its official website ). We put the downloaded Linux uClinux kernel file into our working directory (/home/jelly/kernel/), and then decompress the kernel File Using the tar tool.
$ Cd/home/jelly/kernel/$ tar xvzf Linux uClinux-dist-200xxxxx.tar.gz after a period of decompression, the Linux uClinux-dist folder will be generated under the working directory. Before compiling the kernel, We need to configure the kernel. The common configuration methods are as follows:
Make xconfig-X configuration options for the Windows GUI
Make menuconfig-configuration options of the Console Gui
Make config-command interface configuration options
Note that Linux uClinux does not support loadable modules. Therefore, you should cancel the support for this module.
$ Cd Linux uClinux-dist/
$ Make menuconfig
Configure the required options, such as the processor type, development board type, and kernel version. After configuration, select Saving and Exiting to save and exit.
Common options for compiling Linux uClinux kernel are: make distclean. This command clears the files generated during previous compilation, including the. config file, all target files, and kernel image files. Make clean: this command is similar to make distclean. It also clears the make dep file generated during the previous compilation. This command only needs to be executed during the first compilation to establish dependency between files, the make command determines which files need to be re-compiled based on the dependency and which files can be skipped.
Make lib_only compiles the uClibcx library, make user_only compiles user-defined applications, such as the initialization process init and bash, and the embedded software package busybox that integrates many common tools. Make romfsLinux uClinux often uses romfs (read-only file system) as the root file system of the system. Therefore, you must first store many compiled applications in the directory format required by Linux uClinux.
For example, you can put the executable file in the bin directory and the configuration file in the etc directory. After the command is executed, a romfs directory is generated under the Linux uClinux-dist directory, and the files required by the file system are organized to generate a fomfs image file.
Make image generates image files of the romfs file system and linux image files. The Linux image file is in the elf format and cannot be directly downloaded to the Development Board for execution (it contains a large amount of debugging information, and environment Creation information before the execution of the elf File. You can use the arm-elf-objcopy tool to generate binary files that can be executed directly in RAM ).
Make linux will generate a linux Kernel File after executing this command. Make zImage creates a kernel image file compressed by the gzip algorithm. Generally, the size of the kernel image file generated by zImage cannot exceed kb. Make modules build kernel module Note: Some Linux uClinux versions provide more compilation methods, such as make linux. bin. For other compilation methods, see Makefile in the kernel source code directory.
After introducing several common kernel compilation commands, we can use the following commands to build the required kernel and file system:
Make dep
Make clean
Make all
In this way, the Linux, System. map: The image is generated in the Linux uClinux-dist/images/directory. bin, linux. bin, image. ram, image. rom, romfs. img, linux. text, linux. data files.
If you haven't encountered any errors during the compilation process but haven't mentioned these files, you can refer to the Makefile file to learn more. Image. ram is a file that can be directly downloaded to ram for execution. This file can be used in the debugging phase. Image. rom is a zImage file that can be decompressed by itself. This file needs to be written less to FLASH and cannot be directly put into RAM for execution.
3. Linux uClinux kernel creation process
To establish a kernel, you first need to establish a separate kernel module and kernel subsystem. Once these modules are established, multiple files will be connected together through the connection file. The connection file is usually in arch/$ (ARCH)/$ (PLATFORM)/$ (BOARD)/$ (MODEL). ld. The connector uses this connection file to generate the linux File: LD-T (MODUEL ). ld crt0 _ $ (MODUEL ). o [objs]-o linux connection file defines how the kernel organizes memory segments.
The System. map File is generated by a linux File for debugging. This file allows you to conveniently determine the function location. This file is generated as follows:
NM $ (LINUX) | grep-v '\ (compiled \) \ | \ (\. o $ \) \ | \ (a \)' | sort> System. map
Linux. the data file is the code that contains all data segments of the kernel. It is obtained by removing all read-only segments and other unnecessary segments from the linux file. This file can be generated through arm-elf-objcopy, for example:
OBJCOPY-O binary -- remove-section =. romvec -- remove-section =. text \
-- Remove-section =. ramvec -- remove-section =. bss \
-- Remove-section.eram linux. data
The linux. text file contains all text code segments. It is the code after the data segment is removed. OBJCOPY-O binary -- remove-section =. ramvec -- remove-section =. bss \
-- Remove-section-. data -- remove-section =. eram \
-- Set-section-flags =. romvec = CONTENTS, ALLOC, LOAD, READONLY, CODE linux. text
Linux. binfile is a file that can be actually loaded into the memory for execution. It is created through linux. text and linux. data files are connected, such as cat linux. text linux. data> linux. bin
This file is only a kernel and does not contain a file system. We can use the following method to connect the file system with the Kernel File to generate the image. bin image file: cat linux. bin romfs. img> image. bin
4. manually generate the ROMFS File System
You should create a file system tree manually before creating a ROMFS file system. For example, ROMFS usually contains the following directories: /bin/dev/etc/lib/proc/sbin/tmp/usr/var then we can put the cross-compiled application into the/bin directory, then, the genromfs tool is used to create the image of the file system, such as genromfs-v-V "ROM Disk"-f romfs. img-d romfs> romfs. map
Finally, it can be connected to the kernel file and then burned into Flash. Cat linux. bin romfs. img> image. bin
5. References
Building an embedded LINUX system O 'Reilly
Linux How To
Linux Documentation
- It's a bit strange that the Linux disk is stopped. Try other Fedora core 6
- Brief Introduction to Linux System Software
- The Linux operating system is directly built on the kernel.
- How to install Linux into a Linux USB device
- The truth about the Linux Makefile system is in line with free software practices.