The general process of Linux porting

Source: Internet
Author: User

A while ago in the company transplant Linux2.6 to a piece of ARM11 Development Board, the following roughly talk about the general process of porting Linux.

At the beginning of the uboot transplant did not say much. Uboot finally has two ways to enter Linux, one is to use uimage, you can attach command line parameters at boot, but the operation is more troublesome. Another simple way is to use TFTP to load the Linux kernel into the 0x80008000 (default start Address), and then use the GO command to jump directly. I'm using the second approach, with the disadvantage that you need to modify the. config file when adjusting the command line arguments, and then force recompilation of the SETUP.C (can be forced to recompile by removing SETUP.O). In addition, the value of the R0 and R1 registers must be set when you boot Linux under Arm, respectively, for your CPU (as if, not remembering) and board type, otherwise it will go wrong in the first assembly of Linux, this should be noted. http://hovertree.com/menu/linux/

In addition, Linux also has two ways of booting, one is Zimage, the other is image. Personal opinion, it is easier to use image at the beginning of a transplant, although TFTP is a little more time-consuming to download, but reducing the intermediate decompression steps can reduce the chance of error and speed up development progress.

After jumping to Linux, it is necessary to debug with JTAG, such as setting a hardware breakpoint at 0x80008000, because it is a compilation code at the beginning. The main task of the assembly code is to add the mapping of the serial IO address in the memory map table, so that the serial output debugging information can be manipulated. Then use the C language in the Start_kernel file to write a printk function, called Temp_print, the specific code can refer to the implementation of PRINTK. This phase is more painful because it is cumbersome to use the JTAG debug assembly. Once the Temp_print is successfully exported and Linux enters the C code in the Start_kernel start, it can discard Jtag and use the serial output to debug.

Next is the output of the system's own PRINTK, because the Linux kernel itself debug information is output through PRINTK. Here the main is to set the command line startup parameters of Linux, including console and Earlyconsole two, set them to the serial number you need to output, and check the serial port driver code, such as 8250.C and 8250_early.c two files.

After the PRINTK is successfully output, the next system clock is interrupted. This requires familiarity with the processing code for clock interrupts in Linux, and the information on the web needs to be looked at. It should not be difficult to read.

You can then debug the Flash drivers and network cards, both of which run the root file system as long as they support one. It is simpler and more flexible to use a network card in general. After the network card is started, set the NFS root file system in the command line parameters, and put the file system on a Linux server through NFS export. In this way, basically the transplant succeeds in one of the simplest Linux systems.

After the Linux run, and then add Flash, LCD and other drivers as needed, a complete system can be set up step-by-step.

Here are some of the problems I encountered when debugging:

When debugging Onenand drivers, it is important to note that the connection between Onenand and Linux is via a 16-bit data cable or 32-bit data cable. In the case of a 16-bit data cable connection, the memcpy function in the driver code will be faulted because memcpy replicates the data by default in 32 ways. You can rewrite a memory copy function, which uses unsigned short method to copy data.

When debugging network card drivers, pay attention to the actual use of the network card interrupt polarity. Although Linux comes with the driver of most network cards, the interrupt polarity may be reversed and needs attention. In addition, the network card is usually connected to the CPU of the gpio above (such as I use the smc91c111), here need to adjust the code in accordance with the actual wiring of the interrupt line Gpio occupancy number. and take care to prevent the use of gpio lines from conflict.

linux2.6 is more than a eabi compiled, such as Android on top of the regular use. If the kernel compiles using Eabi, then you must ensure that your root filesystem is compiled by Eabi, otherwise the kernel will go wrong when entering/bin/sh, and there will be no hint.

Push: http://www.cnblogs.com/roucheng/p/3470287.html

The general process of Linux porting

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.