As a newcomer, How do I learn embedded Linux?

Source: Internet
Author: User

As a newcomer, How do I learn embedded Linux? I have been asked too many times. I will answer this article in close-up.

Before learning embedded Linux, you must have a basic C language. It doesn't matter if there is a basis for assembly (just a few Assembly commands will be used at a Glance ). To what extent should C language be learned? The more familiar you are, the better. If you are not familiar with it, you must have basic skills. For example, you can write an array to sort and sum the input numbers. The only way to learn the C language is to write more programs and practice more. It doesn't matter if a compilation error occurs. You can solve it by yourself. It doesn't matter if an error occurs during execution. You can analyze it by yourself. I used to use VC to practice C language. I often try to write some questions about C language competitions. They are pure C, pure mathematics, and pure logic questions. They do not involve interfaces. They are suitable for refining your programming skills.

Back to the topic, first of all, we need to understand what your purpose is. The so-called embedded Linux can be divided into two parts: the underlying system and application development.
If you want to develop applications, you can learn about C, JAVA, and data structures. Embedded Application Development and PC application development do not have any special attention. Maybe you want to do some optimization on embedded systems. Yes, You need optimization, but there is no difference between unoptimized programs and program development on PC. In addition, when you have the ability to optimize, you no longer need to ask this question. Specific to an example, such as the development interface, we use VC on the PC; in Embedded Linux, we may use QT or Android. At this time, you should learn the programming of QT and Android. However, the basics are C or JAVA. On this basis, you should familiarize yourself with their interfaces. If you have learned VC, it also takes time to understand those classes and controls.
If you want to learn the underlying system, this is my specialty.
Before answering this question, I would like to answer: Many people asked me whether to learn to drive or to learn to apply?
I can only say that, based on interest, drivers and applications are not completely separated.
1. the driver we mentioned is not limited to hardware operations, but also the operating system principle and sleep and wake-up scheduling of processes. You should understand the knowledge of writing a good application and better solving problems encountered by the application.
2. Low application thresholds, especially for ANDROID and JAVA. The development path of applications is personally considered to be pure business. For example, in the communication industry, IPTV industry, and mobile phone industry, you understand the needs of the industry. Therefore, leaders are mostly engaged in application.
3. I don't want to call it "drive-by-driver", but I want to call it "build an underlying system". If I do it well, it will kill all industries. I have worked on mobile phones, IPTV, and conference TVs for a few years, but these products have no difference for me because I only work on the underlying layer. Their business has nothing to do with me. When there is a problem with the application and they cannot solve it, I will give them an idea from the kernel perspective and provide them with tools. As the underlying development direction, I personally think it is a technical expert.
4. In fact, there is no line between the underlying layer and the application. If you have the underlying experience, you will feel very steadfast. With business experience, you can learn more about the underlying layer and quickly form a team.

Back to the question of how to learn. What are the underlying systems of Embedded Linux? Don't worry. Let's give you an example.
1. Who will display the interfaces when the computer goes on? What is BIOS? Some self-check, then read windows from the hard disk, and start it. Similarly, this BIOS corresponds to the bootloader in embedded Linux. This bootloader needs to read the Linux kernel from Flash and start it.
2. What is the purpose of windows Startup? Of course it's Internet chat or something. Where are these online and chat tools? On disk C and disk D. Therefore, windows must first recognize drive C and drive D. In Linux, we call it the root file system.
3. windows can recognize drive C and drive D, so it will certainly be able to read and write the drive. This involves something called a driver. Of course, it's not just hard disks, but also NICs and USB. Embedded Linux can read and execute applications from Flash. It must also have Flash drivers, not just Flash.

Let's talk about it first. Embedded LINUX contains four major parts: bootloader, kernel, driver, and root file system.
I. bootloader:
It is a slightly complicated bare-board program. But it is not easy to understand and write this bare board program. The easy-to-use tools in Windows weaken our programming capabilities.
Many people use ADS and KEIL for embedded systems. Can you answer the following questions?
1. Where can I execute a command from the CPU when I power on the instance?
A: Generally, commands are sent from Flash.
2. However, Flash can only be read and cannot be written directly. If I use global variables, where are these global variables?
A: The global variables should be in the memory.
3. Who puts the global variables in the memory?
A: Can you answer this question if you have been using ADS and KEIL for a long time? This requires "relocation ". In ADS or KEIL, the relocated code is written by the company that makes these tools for you. Have you ever read it?
4. How do I know the address where I read the content from Flash to the memory "?
A: This address is determined by the "link script". There are scatter files in ADS and similar files in KEIL. But have you studied it?
5. You say that the relocation is to copy the program from Flash to the memory, so this program can read Flash?
A: Yes. You must be able to operate Flash. Of course, there are more than just these, as well as setting the clock to make the system run faster.

Let's answer your questions. bootloader is a bare-board program, which has three main points:
1. Hardware operations
2. Understanding of ARM system Processors
3. Basic concepts of a program: relocation, stack, and BSS segments of code segments.

For hardware operations, see the principle diagram and chip manual. This requires a certain amount of hardware knowledge, not asking you to design hardware, but at least understanding it; not understanding analog circuits, but understanding digital circuits. I learned this in school. The microcomputer principles and digital circuits are enough. But I doubt if you have the patience to read these two books. I don't know if there are any faster books. If you want to achieve this quickly, let's release it first. If you don't understand it, ask GOOGLE and post it. In addition, the chip manual must be read. If you are not looking for Chinese, you must read English. It is very painful at first, and later I will find that once I am familiar with the syntax and vocabulary, I will easily read any chip manual.
For an understanding of the ARM system processor, see du chunlei's "ARM system architecture and programming", which describes assembly instructions, exception patterns, MMU, and so on. You need to know about the three parts.
The basic concept of the program, of course, is to look at the compilation principle. Unfortunately, these types of books are definitely tianshu-level. I advise you not to go to the system unless you are a super genius. Let's take a look at the <embedded Linux application development full manual> and the 1st video I wrote. Don't worry, you don't have to spend money. The hardware-related experiments are carried out according to the video, and these concepts are clear. I have not found 2nd sets of books or videos about these concepts, allowing me to brag about them blindly.

For bootloader, I first read <ARM architecture and programming>, and then I wrote a program to repeat all the hardware experiments, for example, GPIO, clock, SDRAM, UART, and NAND. I have figured them out, and it is easy to understand u-boot when combined.
To sum up, read the hardware schematic diagram and the chip manual. You need to find the information yourself. For the rest, follow the chapter directories in the <embedded Linux application development full manual> and section 1st of the video.

Ii. kernel:
People who want to quickly learn how to write the driver should first learn from the kernel. To become a master, you must have a deep understanding of the kernel. Note: I am talking about understanding. I don't expect to write a kernel. You need to understand the scheduling mechanism, memory management mechanism, file management mechanism, and so on.
Two books are recommended:
1. Read through <Linux kernel full notes>. Please read the thin book (speed-wise in a dry Society ).
2. Select <Linux kernel scenario analysis> to learn which part to read.

Iii. DRIVER:
The driver consists of two parts: the hardware operation and the driver framework. It's hardware, or you need to understand the principle diagram, read the chip manual, and practice more.
Speaking of the driver framework, I will introduce some books. LDD3 is the <Linux Device Driver> written by foreigners. It introduces many concepts and is worth reading. However, its role is limited to introducing concepts. I used it to familiarize myself with the concept before getting started. I threw it away after getting started. A comprehensive introduction to drivers should be explained by Song Baohua's <linux device driver development details>. To be honest, I have only read the directories and many people say yes. I would like to recommend them here. To get a deeper understanding of a piece, <Linux kernel scenario analysis> is definitely a 5-star recommendation. You don't want to read it. There are more than 1800 pages and two more books. When I am confused about a piece, I will go over it. For any part, this book can cover 2 or 3 hundred pages, which is very detailed. It also takes you to analyze the kernel source code for a specific purpose. Linux 2.4 is used as an example, but the principles are the same. It is also applicable to other versions of linux.
Write a driver for all the hardware involved in your development board. If you have any questions, you should first "think bitterly". In the process of thinking, you will link up a lot of irrelevant knowledge and eventually link it through.

4. root file system:
Have you ever thought about the following two questions:
1. Some Linux products are used for monitoring, some for mobile phones, and some for tablets. Which application should be started after the kernel is started and the root file system is mounted?
A: The kernel does not know which user program should be started. It only starts the init application, which corresponds to/sbin/init. Obviously, this application needs to read the configuration file and start the user program (monitoring, manual interface, flat interface, etc.) according to the configuration file ). This problem reminds us that there are some conventions in the file system content, such as/sbin/init and configuration files.
2. You wrote hello, world! Program. have you ever wondered who implemented the printf used in it?
A: This function is not implemented by you. It is implemented by library functions. When it is running, you must find the library. This problem reminds us that the file system also has a library.

Here is a simple self-answer. If you want to learn more, you can take a look at the init. c of busybox to know what the init process is doing. Of course, you can also refer to the chapter on building the root file system in <embedded Linux application development full manual>.

Let's talk about my learning experience.
1. I studied physics and electronics at school. In fact, I didn't teach how to design circuits, But I taught some knowledge about electronic circuits. The Design of PCB is self-taught in the lab. I only designed two layers, and I forgot about it now. However, the ability to view the schematic diagram and the chip manual is retained.
2. I took a software degree and was very interested in software design, but I only learned C language and database. I have made many competitions based on my interests. Unable to participate in the competition, but the C language is very solid.
3. In the lab, there are 1st companies, that is, designing simple PCI cards and writing windows drivers.
4. In 2nd companies, 51 single-chip microcomputer was used as a car phone and began to embark on the path of pure software.
5. I started to feel that the microcontroller was insufficient. I had to resign for half a year to study Linux and how to operate red hat. The step is to first read <ARM architecture and programming>, then write the bare-board program to operate the hardware, and then analyze u-boot. At the same time, read <LINUX kernel full notes> to learn about the LINUX framework. When writing a bare board, we recommend that you enhance your understanding of the interrupt. The kernel uses the interrupt to complete various functions.
6. After u-boot is analyzed, simple driver programming is started. At this time, the capability is weak.
7. I started to work at . After two years of work, I wrote various drivers and solved various problems (driving problems and helping to locate application problems). My skills were refined.



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.