Compile and port uClinux

Source: Internet
Author: User
Compile and port uClinux to-Linux general technology-Linux programming and kernel information. The following is a detailed description. 1. Download the uClinux source code package. Can be from a http://www.uclinux.org or from a license.

2, download cross compiler, also can download from the above two websites, it is recommended to use arm-elf-tools-20030314.sh
3. In addition, I also downloaded a 44B0 patch file uClinux-20040408.patch from the Forum. You can open this patch file to see where it modifies the source code. You can learn to manually modify the source code. However, it is difficult and errors often occur during compilation. Patch files are the most convenient. If you are familiar with source code modification, you can try to write a patch file by yourself. Syntax and format descriptions for patch file writing are available in http://www-128.ibm.com/developer .. cn-newsletter-linux.
4、copy uclinux-dist-20040408.tar.gz to/home/(or other directories), run the unzip command: tar xvzf uClinux-ARMSYS-20040801.tar.gz
After decompression, the uClinux-dist directory is generated under/home.
Install the patch file: copy the uClinux-20040408.patch file to the uClinux-dist directory, run the command: patch? P0 <uClinux-20040408.patch after patching will generate the Kernel configuration file kernel_44b0.cfg In the uClinux-dist/linux-2.4.x directory and generate the user configuration file user_44b0.cfg under uClinux-dist/config.
Install the cross compiler: copy the arm-elf-tools-20030314.sh to the root directory and run the installation:
Sh arm-elf-tools-20030314.sh it will automatically install under usr/local/directory. On the terminal, Type arm-elf-gcc? V if you can see the following output information: Reading specs from/usr/local/lib/gcc-lib/arm-elf/2.95.3/specsgcc version 2.95.3 20010315 (release) (ColdFire patches-20010318 from http://fiddes.net/coldfire/) (uClinux XIP and shared lib patches from http://www.snapgear.com/) indicates that the installation is successful.
5. Configure the kernel: Run cd uClinux-dist to enter the uClinux-dist directory. After running the make menuconfig command, the Kernel configuration interface is displayed. Select Samsung as the development board structure and 4510B as the chip type. (This does not matter, it already supports 44B0, just a name issue ). UCLinux version select linux-2.4.x, library file select uClib, and select Custom kernel settings and Custom User application settings options:
[*] Customize Kernel Settings
[*] Customize Vendor/User Settings
Exit and select Save.
Then, the system performs some preprocessing and may prompt you to choose whether to support the serial ports of some other types of development boards. These can be ignored. Press enter to use the default configuration. Next, you will enter the kernel customization interface. In the bottom penultimate line (as if it was), you will have an option "load the Kernel configuration file", select this option, and press enter to enter the configuration file, because our configuration file has been generated in the default directory during patching, you only need to enter the file name: kernel_44b0.cfg. In this way, the kernel automatically loads some default configurations. Of course, you can view the content under each configuration menu according to your needs after loading the configuration file, you can also add or remove some options as needed. If you have added or removed some options, you 'd better save your configuration and press enter in the last menu option "Save Configuration File, enter a custom file name. The purpose of this operation is not to affect the kernel_44b0.cfg file. Otherwise, after you modify some configurations, the system will generate a new configuration file to overwrite kernel_44b0.cfg. Exit and save the modification.
The subsequent step is the configuration interface for the user's application. Basically, the process is similar to the Kernel configuration step above. It is also the first step to load the configuration file user_44b0.cfg. On this basis, you can remove unnecessary applications, this minimizes the space occupied by the compiled kernel image and root file system image. Exit and save the configuration.
6. Compile the kernel: follow these steps to compile the kernel.
# Make dep
# Make clean (not necessary, mainly to clear the intermediate files generated during the previous compilation process)
# Make lib_only
# Make user_only
# Make romfs (generate the root file system image)
# Make image (there may be two errors at the end, so ignore them without affecting subsequent compilation)
# Make
This series of compilation operations takes about 15 minutes.
After compilation, the image will be generated under Clinux-dist/image. ram, image. rom, romfs. img files, including image. ram is a non-compressed kernel image file, image. rom is the kernel image file in the compressed format, romfs. image file of the img root file system. If you want to use Flash Programmer to burn kernel images and root file system images into Flash, you can change them to files suffixed with. bin format.
Note: Because the Flash we use is 2 MB, which is relatively small, it is best to burn the kernel image file in the compression format, which is about kb in size. The non-compressed format is about 1 MB in size. In addition, the size of the root file system image is about KB.
After Bootloader is started, the image. rom and romfs. copy the specified address from img to RAM. After the startup program gives the CPU control to the kernel, the compressed kernel will automatically decompress it to another address, which is specified in the kernel, you can modify these addresses in the source code. If they are inconsistent, the kernel cannot be started and the root file system cannot be mounted.
6. Add an application:
① Create a directory named Myapp In the uClinux-dist/user directory;
② Compile your own application. Here we take the HelloWorld application as an example to illustrate the process of adding:
Create the hello. c file in the Myapp directory. The Code is as follows:
# Include
# Include
Int main (void)
{
Printf ("Hello! My name is Sun hefei! This is my first application. \ n ");
Return 0;
}
③ Create a MakeFile file in the Myapp directory. The Code content is as follows (for details about the file content, refer to the MakeFile file in user/musicbox ):
All: hello
Hello: hello. o
$ (CC)-Wall $ (LDFLAGS)-o $ @ hello. o $ (LDLIBS)
$ (EXEC): $ (OBJS)
$ (CC) $ (LDFLAGS)-o $ @ $ (OBJS) $ (LDLIBS)
Romfs:
$ (ROMFSINST)/bin/hello
Clean:
-Rm-f hello *. elf *. gdb *. o
④ Modify user/MakeFile:
To allow the compiler to compile the content added above, add a sentence to the file (in alphabetical order ):
Dir _ $ (CONFIG_USER_MYAPP_HELLO) + = Myapp
⑤ Modify config/config. in
Add the following content at the end of the file:
######################################## ####
Mainmenu_option next_comment
Comment 'My New application'


Bool 'hello' CONFIG_USER_MYAPP_HELLO
Endmenu
######################################## ####
⑥ Configuration Compilation:
When configuring the user application, we will see an additional menu:
My New Application ???> Select "hello" and then [*] "hello". Compile the code according to the above compilation steps to generate a new romfs. imgfile and download it to the Development Board Flash.
(The application can also be compiled, copied to the file system, and then make image; make! You only need to enter the corresponding folder for running !) This method is quick <
7. Run: After uClinux is started, enter hello and press enter to run the custom application.

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.