Return to Linux-embedded customization [entry level]
Source: Internet
Author: User
Return to Linux-then perform embedded customization [entry level]-general Linux technology-Linux programming and kernel information. The following is a detailed description. He helped ma brother compile the Linux kernel three or four years ago and expected to help Dr. xu ran an x86 architecture SBC (Single Board Comptuer) -- however, it was very busy at the time and the activity was not conducted without being instructed by the management, remember that the kernel is ready to run, that is, rootfs has not been customized yet.
Today, linux has evolved from 2.4 to 2.6. This evolution is said to have strong support for Embedded customization, especially for real-time performance. Recently, due to the project relationship, we also obtain a PowerPC-based COM (Computer On Module). More intuitively, the vendor provides a complete manual and a working kernel image, and it has been loaded into flash. Although the project won't use linux, it still aroused my interest-after so many years, there is no practical opportunity to indulge myself in Linux embedded, which is truly the Firmware Design Engineer.
The prelude is too long. In fact, the process is very simple.
First, the COM provides a key thing, NetBootloader, which saves you a lot of tedious preliminary work. Everyone knows that calling bootloader is equivalent to handling half of the embedded system, let alone this bootloader is already mature. In short, it supports load linux image from tftp. However, I have not implemented this step yet-because the kernel image has not been compiled-Haha, that's all. By the way, bootloader on PowerPC is equivalent to x86 bios + grub or lilo boot program.
However, an image has been written into the existing hardware, and the image can be started after it is started-it is slow, and rootfs is not there! Apparently, the supplier published a tar.bz2 file, which contains the rootfs (including etc configuration, lib library, and bin application) of the customized ppc architecture. When their engineers were there a few days ago, we have a nfs rootfs configuration together and can work it up (rootfs = nfs root = nfsserverip:/nfs/export/path)-strong, linux can solve diskless workstations in such a simple way, but it is still embedded.
Obviously, the first thing I want to do is to add rootfs to the CF card, which is quite simple.
Step 1. Mount the CF card with a card reader to a linux workstation, use fdisk-l to find the hard disk partition (such as/dev/sda) mounted to the USB, and then use fdisk/dev/sda to partition, then use mkfs. format ext2/dev/sda1 and the file system is ready.
Step 2: Mount/dev/sda1 to the ghost file system, and decompress the original rootfstar.bz2 package to/dev/sda1.
Next, set netbootloader and let it regard the CF card as root. In my system, the CF card is/dev/hda1. Therefore, you only need to set root =/dev/hda1 (same as lilo or grub) in the startup line ~)
So linux started running.
Next, we need to compile the kernel on our own. If everything is ready, the operation is poor. The steps are as follows:
0. set the development environment. Of course, you need to have the cross-compilation tool gcc/g ++ (The Development workstation is an x86 machine, and the goal is PowerPC ), you also need to set some environment variables-so that you do not need to manually modify the Makefile and input a bunch of parameters during compilation, such as ARCH = ppc;
1. find a default Kernel configuration for the target system (that is, my PowerPC COM). In the arch/ppc/configs directory, copy it to the root directory and rename it. config;
2. make menuconfig to add or delete features that you are interested in or not interested in;
3. make..., ha. I'll talk about it later.
4. Of course, it is to load the compiled image to the target machine.
Next, we plan to compile some applications and libraries. This seems simple.
Finally, I want to find a way to build a bootloader myself.
It's easy and difficult. I 've done this recently.
Ps. after counting a linux 2.6.21 source code scale, we found that the number of linux kerne files supporting 25 architectures and many hardware peripherals has reached 22000, the number of lines in the c/h source file code exceeds 7 million (70% NBNC, with only about 20% comments ). It's really scary.
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