Build an embedded Linux software and hardware development environment by yourself

Source: Internet
Author: User
Article title: Build an embedded Linux software and hardware development environment by yourself. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   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 to write a large number of drivers and applications for Linux from the very beginning, in just a few years, Linux has developed into a very complete operating system, and Linux supports the most hardware platforms among all operating systems. Currently, Linux supports the hardware platform: intel IA64, Compaq Alpha, Sun's iSCSI/Sparc64, SGI Mips, IBM's S396, arm, PowerPC, etc. The biggest influence of Linux is that it is gradually applied to embedded devices. uClinux is produced in this atmosphere. UClinux is Micro-Control-Linux, it is also an open source project, uClinux source code 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). Compared with mainstream Linux systems, uClinux has the following features:
  
1. the Kernel loading method is simplified. the uClinux kernel can be directly run on Flash: the executable image of the uClinux kernel is burned to flash, when the system starts, it starts to execute one by one from an address of Flash. It can also be loaded into the memory for running: it stores the compressed kernel file on Flash, when the system starts, it reads the compressed file, decompress it in the memory, and then 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 requires less code than the ext2 file system, secondly, the romfs file system is relatively simple, and creating a file system superblock requires less storage space. The Romfs file system does not support dynamic write/erase operations. The system uses the ramdisk method to process data that needs to be dynamically stored, 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. rewrite the application library: uClibc simplifies libc and uClinux uses static connections for user programs.
  
   Development Environment of uClinux
Www.uclinux.org provides GNU... uClinux for uClinux as an example:
  
1. obtain the source code package of uClinux-dist. regularly download the new Linu... B/uClinux/dist/on www.uclinux.org for free. This source package contains uCLinux-2.4.21, uClibc and user applications that have been ported to uClinux. After the download, you will get a uclinux-dist-20030522.tar.gz file, save it to the/home directory, and then execute: tar zxvf uClinux-dist-20030522.tar.gz, when the tar program is completed, the/home directory contains a new/home/uClinux-dist directory.
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 same uClinux source code ?.. /Arm-elf-tools/download ARM cross compiler: arm-elf-tools-20030314.sh. After getting this file, execute the following command: sh arm-elf-tools-20030314.sh, which will automatically create 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 patches
From 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 to compile uClinux and user programs, compiled a kernel image file for the ARM target board, the next step is to run this image file on the arm7 Development Board (for details about how to compile uClinux and user programs, refer to relevant documents 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 SNDS100 Demo board for the processor. 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. The principle diagram after modification is a principle diagram of the ARM7 target board that can run uClinux. then, several PCB boards are processed according to the principle diagram and corresponding components are welded, A piece of can run uClinux arm7 Development Board made (the corresponding development board 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, it can directly burn the uClinux image file to Flash, and then power it on. will uClinux be started from Flash? Yes, indeed. Now we need to write the kernel image of uClinux to Flash. Can I use the writer to write the uClinux kernel image to Flash, and then weld the Flash to the PCB or plug it 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 write solution. With JTAG, a JTAG is set on the s4510b. through the JTAG, we can control all the pins on the s4510b, so that we can input the corresponding commands and data to the JTAG interface, the Flash device read/write operation time sequence is generated on the data, address, and control bus of the courseware 4510b using software methods, write the kernel image file of uClinux to Flash (for the preparation and download of the JTAG interface cable of initi4510b, burn the uClinux image file to the program executable file and source code in Flash, see relevant on the http://www.dailzh.net) content ).
  
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
After connected is displayed on the screen, connect the power of the arm7 Development Board. If you are lucky enough, you should see the following information:
< <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
< < < < < < < ...
< < < <\ <
UClinux has been running on the target board. enter the familiar ls command to check the 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 running it directly from Flash, uClinux can also be loaded to 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, then download the uClinux image to the memory through the Ethernet interface, and then run uClinux from the memory. This method to download the uClinux kernel image takes only 10 seconds, suitable for the development phase often modify the uClinux kernel used (Bootloader for arm7 source code can be downloaded 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 uClinux directly from Flash.
  
   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. However, you must use arm-elf-gcc to compile the program instead of gcc. The compiled executable file must be downloaded to the arm7 development board to run. to download the program to the target board, you can enable the tftpd program in uClinux and use the tftpcmd program on the development host, in the uClinux console window, type an executable file name. If you want the application to run automatically when uClinux is started, you can modify the content of the/etc/rc file in the uClinux system. If you want to use gdb to debug your program, you can refer to the relevant documentation on www.uclinux.org.
  
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.