Build an embedded Linux software and hardware development environment by yourself

Source: Internet
Author: User
Tags gz file gdb debugger

Build an embedded Linux software and hardware development environment by yourself

--------------------------------------------------------------------------------
 
10:55:22 from: Mr. Linux
 
 

Linux and uClinux
In August 1991, a student from Finland posted the following in the comp. OS. minix news group:

Hello everyone who uses minix-I am working on a free operating system for 386 (486) at (just for hobbies, not as professional as GNU.

This student is Linus Torvalds, and what he calls "hobbies" is what we know today in Linux.

Since the source code of Linux is published on the Internet and can be obtained free of charge, it has attracted UNIX experts from around the world from the very beginning.
A large number of drivers and applications have been compiled. In just a few years
It has developed into a quite complete operating system, and Linux supports the most hardware platforms among all operating systems. Currently, Linux supports hardware platforms: Intel IA64,
Compaq Alpha, sun's iSCSI/sparc64, SGI's MIPS, IBM's s396, arm, PowerPC, etc. The biggest impact of Linux is that it is gradually
For embedded devices, uClinux is created in this atmosphere. UClinux is micro-control-Linux, which is also an open source project, the source code of uClinux
And development tools can be downloaded from the http://www.uclinux.org for free. UClinux is designed for embedded processors without MMU (Memory Management Unit) and mainstream Li
Compared with nux, uClinux has the following features:
1. simplified the kernel loading method, uClinux
The kernel can be run directly on FLASH: It is to burn the executable image of uClinux kernel to flash, and execute it one by one from an address of flash when the system starts; it can also be loaded to the memory for running.
: Stores the compressed file of the kernel in flash. When the system starts, it reads the compressed file and decompress it in the memory. Then it starts execution.
2. The romfs file system is used as the root file system: this file system requires less space than the general ext2 file system. First, the kernel supports the romfs file system.
The ext2 file system requires less code. Secondly, the romfs file system is relatively simple. Creating a file system superblock requires less storage space. The romfs file system does not support dynamic erasure.
The data to be dynamically stored is processed using the ramdisk method, and the ramdisk uses the ext2 file system.
3. The flat executable file format is used: the ELF format has a large file header, and the flat file simplifies the file header and some segment information.
4. The application library is rewritten:
Uclibc simplifies libc and uClinux uses static connections for user programs. Development Environment of uClinux
Www.uclinux.org provides GNU cross compiler for uClinux, including the following components: GCC cross compiler, which is the binary file that can be run on the development and compilation targets of the host machine; binut
Ils auxiliary tools, including objdump, As, LD, etc.; gdb debugger. Taking the development of uClinux ON ARM7 as an example:
1. Obtain the source code package of uClinux-Dist. On www.uclinux.org, the source code package for the new Linux kernel is released on a regular basis. The latest version is kernel-2.4.21,
From http: // www.uclinux.org/pub/uclinux/dist/
You can download it for free. This source package contains uCLinux-2.4.21, uclibc and user applications that have been ported to uClinux. After the download is complete,
UClinux-dist-20030522.tar.gz file, save it to the/home directory, and then execute: Tar zxvf
UClinux-dist-20030522.tar.gz, when tar is running, there will be a/home/uClinux-Dist under the/Home Directory
The new directory. This directory is the source code root directory of uClinux, which contains all the source code for uClinux development.
2. Get the ARM development tool. www.uclinux.org provides the uClinux source code and the corresponding cross-compilation tool. To compile uClinux for the ARM7 target system on the development host,
You also need to go from http: // www.uclinux.org/pub/.../arm-elf-tools/
The arm cross compiler: arm-elf-tools-20030314.sh. After obtaining this file, run the following command: Sh
Arm-elf-tools-20030314.sh, which automatically creates a uClinux-arm cross-compilation environment on the Development host. Type Arm-elf-GCC,
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 patchesfrom)
Http://www.snapgear.com/) indicates that the cross-compiling environment of uClinux-arm has been established.
Now the development host has the source code of uClinux and the tool for compiling the source code. You can also use make menuconfig,
Make and other commands are used to compile uClinux and user programs, and a kernel image file is compiled for the arm target board. The next step is to run the image file using a development board named ARM7 (about how to compile UCL ).
For inux and user programs, please refer to the relevant documentation on www.uclinux.org ). Build ARM7-uClinux Development Board
UClinux can run with only a small amount of hardware resources. Taking ARM7TDMI as an example, you only need the following hardware: 1.cpu? Samsung s34510b
2. 8 MB or above. 3. A simple serial port 4.2 M Flash 5. An Ethernet interface (optional)
At present, various embedded microprocessor manufacturers provide a demo board for users to test the performance of each processor while launching each processor. Samsung provides an snds
100 demo board. The schematic diagram of the demo board can be downloaded free of charge from the website of Samsung. Make some modifications to this schematic, only keep the five parts listed above, and remove other unnecessary parts. Modified
The schematic diagram is a schematic diagram of the ARM7 target board that can run uClinux. Then, several PCB boards can be processed based on the principle diagram, and corresponding components can be welded. A piece of the ARM7 development board that can run uClinux will be made.
(This Development Board corresponding schematic, PCB diagram can be downloaded from the http://www.dailzh.net for free ).
Slow down. Although this development board has been welded, it is only a simple combination of a bunch of electronic parts. To run uClinux on it, you also need corresponding software to manage the hardware.
As mentioned above, uClinux can run directly from flash, that is, the uClinux image file can be directly written to flash, and then powered on, uClinux will
Start in flash? Yes, indeed. Now we need to write the kernel image of uClinux to flash. Write the uClinux kernel image
Flash, and then solder the flash to the PCB or plug into the flash outlet of the Development Board? Of course. If you have a writer. However, few people have such writers. What we need
Is a cheap flash writing solution. With JTAG, a JTAG is set on the s4510b. Through JTAG, we can control all the pins on the s4510b so that we can use the JTAG interface
Enter the relevant commands and data, use the software method to generate the read/write operation sequence of the flash device on the data, address, and control bus of, and burn the kernel image file of uClinux to flash.
(For the compilation and downloading of the JTAG interface cable of the initi4510b, please refer to the http://www.dailzh.net
).
Finally, the image file of uClinux is burned to flash, and a serial port cable is used to connect the ARM7 development board with the COM1 port of the Development host. Download a tip program from the Internet and run the following command: tip
? L/dev/ttys0? S 19200 and other screens
Connected. Later, connect the power supply of the ARM7 development board. If you are lucky enough, you should see the following information:> Linux version 2.4.20-uc0
(Root @ dailzh) (GCC 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/) May 19 23:44:11 CST 2003> processor: Samsung
Initi4510b Revision 6> architecture: snds100> on node 0 totalpages: 4096> zone (0 ):
0 pages.> zone (1): 4096 pages.> zone (2): 0 pages.> kernel command line:
Root =/dev/rom0> calibrating delay loop... 49.76 bogomips…> Command: Cat
/Etc/motd> welcome to uclinux.org> for further information check:
Http://www.uclinux.org/> uClinux has run on the ARM7 target board, type familiar LS command, see what output.
Writing a uClinux image file to flash through the JTAG interface is too slow and debugging the uClinux kernel is very inconvenient. Is there any other method? Yes. In addition to flash, uClinux can
In addition to running, it can also be loaded into the memory for running. We will write a bootloader for the ARM7 development board. The function of bootloader is to initialize the ARM7 development board, and then use the Ethernet interface
The inux image is downloaded to the memory and then runs uClinux from the memory. This method only takes 10 seconds to download the uClinux kernel image. It is suitable for use when the uClinux kernel is frequently modified in the development stage (Bo
Otloader for ARM7 source code can be from the http://www.dailzh.net
). After debugging the uClinux kernel, you can use the JTAG interface to burn the uClinux image file to flash, so that you can run the debugged uclin directly from flash.
UX. Development and debugging of user programs in uClinux
Now the ARM7 development board can run uClinux. How can I develop applications in uClinux? Like developing a Linux program on a common computer, you must first compile the source code of the application, but compile
It cannot be compiled using gcc, but it must be compiled using ARM-elf-GCC. After compilation, the executable files must be downloaded to the ARM7 development board to run. To download the program to the target board, you can enable it in uClinux.
Tftpd program, using tftpcmd on the development host
Program to download, and then in the uClinux Console window type executable file name method to run. You can modify
The/etc/rc file in the system. If you want to use GDB to debug your program, you can refer to the relevant documentation on www.uclinux.org. About the author Dai lizhou,
Love embedded systems and Linux development, if you are interested in Embedded Linux development, please visit our website http://www.dailzh.net, invites you to join.

 
 

Related Article

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.