As a newcomer, how to learn embedded Linux?

Source: Internet
Author: User


as a newcomer, how to learn embedded Linux?
before you learn embedded Linux, you must have a C language Foundation. The basis of the Assembly is not indifferent (just a few assembly instructions, with a look will be). Try to write some questions about the C language contest. They are pure C, pure mathematics, pure logic of the topic, does not involve the interface these things, is suitable for the refining programming ability.
    
back to the topic, first of all we need to understand what your purpose is, presumably, the so-called embedded Linux can be divided into two parts: the bottom system, application development.
for application development: C language, data structure, Java and so on need to learn. There is nothing special to note about embedded application development and application development on the PC. You might say that you need to do some optimizations on the embedded, yes, to optimize, but the programs that are not optimized and developed on the PC are no different. In addition, when you have the ability to optimize, you do not have to ask this question. Specific to an example, such as development interface, we use VC on the PC, in embedded Linux maybe we use QT also use Android, this time you should learn QT, Android programming. But the basics are C or Java, and on this basis they are familiar with their interfaces. When you learn VC, you also take the time to understand the classes, controls.
If your goal is to learn the underlying system, this is my specialty, but I can say a little.
before I answer this question, I answer: Many people ask me, in the end is learning to drive or to learn the application? I can only say that interest, and the drive and application are not completely separate
1. We say that the driver, in fact, is not limited to the operation of the hardware, as well as the operating system principle, the process of sleep wake scheduling concepts. Want to write a good application, want to better solve the problems encountered by the application, this knowledge you should understand
2. Low threshold to do application, especially now Android, pure java. The development path of the application is the personal view of the business proficiency. For example, in the communications industry, IPTV industry, mobile phone industry, you understand the needs of the industry. Therefore, when the leader of the people, more is to do the application.
3. Do drive, in fact I do not want to call "do the drive", but want to call "do the bottom system", do this is to kill the various industries. I worked for a few years, I did mobile phone, IPTV, conference TV, but these products don't make any difference to me, because I only do the bottom. Their business doesn't matter to me. When the application is in trouble and they can't solve it, I give them advice from the kernel point of view and provide them with tools. To do the bottom-up development direction, personally think is technical experts.
4. In fact, do the bottom or do the application, there is no boundary between, have the bottom-level experience, and then to do the application, you will feel very practical. With your business experience, you can get to the bottom and quickly form a team.
   
back to the question of how to learn. What does the embedded Linux underlying system contain? Don't worry, just give an example and you'll know.
1. When the computer is switched on, who is the interface? is the BIOS, what does it do? Some self-test, and then read from the hard disk into Windows and start it. Similarly, this BIOS corresponds to the bootloader in embedded Linux. The bootloader is going to read the Linux kernel on flash and start it.
2. What is the purpose of starting Windows? Of course, the Internet chat or something. Where are these Internet and chat tools? On the C-drive, D-Disk. So, Windows has to recognize the C-drive, D-disk first. Under Linux we are called the root file system.
3. Windows can recognize the C-drive, D-Drive, then must be able to read and write hard disk. This involves something called a driver. Of course not only hard disk, but also network card, USB and so on. Embedded Linux can read and execute applications from flash, and it must also have flash drivers, and certainly not just flash.
      
first of all, embedded Linux contains bootloader, kernel, driver, root file system this 4 chunks.
First, bootloader:
It's a slightly more complicated bare-board program. But it's not easy to read the bare-board program well. The easy-to-use tools in Windows weaken our programming capabilities.
Many people use ads and KEIL when they play embedded. Can you answer these questions?
1. Where does the CPU take the instruction from when it is power on?
A : General instructions from Flash.
2. But Flash is generally read-only and cannot be written directly, if I use global variables, where are these global variables?
Answer: Global variables should be in memory
3. So who puts the global variables in memory?
A: Long-term use of ads, Keil friends, you can answer? This requires "relocation". In ads or Keil, the relocated code is the company that made the tools to help you write it.
have you ever read it?
4. Memory size, how do I know the "original Flash content" read to the "which address of memory"?
A : This address is determined by "link script", there are scatter files in ads, and there are similar files in Keil. But have you ever studied it?
5. You say relocation is to copy the program from Flash to memory, then this program can read Flash AH?
answer: Yes, to be able to operate flash. Of course not only these, but also set the clock to make the system run faster and so on.
   
first ask yourself to answer here, bootloader this a bare board program, in fact, there are 3 parts points:
1. Operation of the hardware
2. Understanding of ARM system processors
3. The basic concept of the program: relocation, stack, code segment Data section of the BSS section or something.
   
The operation of the hardware, need to look at the schematic, chip manual. This requires a certain amount of hardware knowledge, do not ask you to design hardware, but at least can read; Not to be able to read analog circuits,
but you have to be able to read digital circuits. This ability I learned in school, the principle of microcomputer, digital Circuit 2 books (the title forget) is enough. But I doubt if you have any resistance .
mind to read these 2 books. I don't know if there are any faster books now. If you want to crash, just let go of this piece, do not understand to ask Google, posting.
In addition, the chip manual is definitely to read, do not find Chinese, just look at English. The beginning is very painful, later will find those grammar, vocabulary once familiar,
It's easy to read any chip manuals.
understanding of ARM system processor, see Duchunlei's <arm Architecture and Programming > bar, there are assembly instructions, there are abnormal mode, MMU and so on. It's about 3 pieces of content that you need to know.
The basic concept of the program, the King of course is to see the principle of compiling. Unfortunately, this kind of books is definitely a heavenly book level. Advise you not to go to the super genius or not to see. Look, I wrote it.
< embedded Linux application development full manuals > and 1th video Bar, don't worry, don't spend money. These concepts are clear when the hardware-related experiments are done in the video. I haven't yet .
The discovery of a 2nd book or video about these concepts allowed me to boast blindly.

for bootloader, I studied the <arm architecture and programming first, and then wrote the program to do all the hardware experiments, such as GPIO, clock,
SDRAM, UART, NAND. Get them all figured out, it's easy to see the u-boot together.
To summarize, to understand the hardware schematic diagram, see the Chip manual, which requires you to find information. The rest of the chapter on the development of full manuals > and 1th videos by < embedded Linux applications
let's go to school on the show.


Second, the kernel:
want to crash the person, first cross the core of learning, directly learn how to write the driver.
to be a master, the kernel must be deeply understood. Notice, I'm talking about understanding, I don't expect to write a kernel.
to the inside of the scheduling mechanism, memory management mechanism, file management mechanism and so on have some understanding.
two books recommended:
1. Read through the <linux kernel fully annotated; Please look at the thin one (the floating society stresses speed, uh),
2. Selected <linux kernel scenario analysis; Want to know which section to attend


third, drive:
The driver consists of two parts: the operation of the hardware itself, the framework of the driver.
is the hardware, or to understand the schematic, read the chip manual, more practice it.

Speaking of the driving frame, there are some books to introduce. LDD3, that is, <linux device driver; The foreigner wrote the book, which introduced a lot of concepts, it is worth reading. However, its role
It is also limited to introducing concepts. I basically used it to familiarize myself with the concept before getting started and threw it away after getting started.
driving aspect of the overall introduction, it should be Song Baohua <linux device driver Development detailed >, frankly I only read the catalogue, there are many people said, here recommend.
to get a closer look at a piece, <linux kernel scenario analysis > is definitely Super 5 star recommended. You can't expect to finish it, more than 1800 pages, and up and down two volumes. I'm not sure of a piece .
, just go over it. In any part, the book can be 2, 300 pages, very detailed. And is a goal to take you to analyze the kernel source code. It takes Linux 2.4 as an example,
but the same principle applies to other versions of Linux.

Do you have any other introductions? Oh, of course there is, Vedon Linux video phase 2nd. < embedded Linux application development Complete manual > does not speak much about the driver, not deep enough.
so I recorded this video. Not only teaches you how to write how to change the driver, but also teaches you how to write such a change drive.
Each driver is written in the field:
1. Drawing on the graphics board-the equivalent of the school teacher on the blackboard drawing on the explanation, very intuitive
It 's definitely not a PowerPoint reading.
2. Use source insight to write the program on the spot, start writing from line 1th, and every lesson is like this. I've spoken more than 20 drivers, and I've written more than 20 programs.
3. Compile and test after writing.
4. Very comprehensive, character device driver, block equipment, network card driver 3 broad categories, hardware introduction, driving framework analysis, testing 3 categories complete.
training institutions in the content, far less than this period of video rich. I have been teaching in a number of training institutions, never see which teacher dared to explain every lesson on the spot to write code
test on the spot, except me! I don't see any training agency that finishes this--because there's not enough time, it takes at least one months to finish, but it's basically only 2 weeks of teaching time.

try writing a driver by putting the hardware involved in the Development Board on your hands. If you have a problem, think in a painful way and you will have a lot of irrelevant knowledge in the process of thinking.
connected in series, and finally through.


Four, the root file system:
have you ever thought about these 2 questions:
1. For Linux products, some used for monitoring, some do mobile phones, some do tablet. After the kernel is booted, which application should be started after mounting the root file system?
A: The kernel does not know and no matter which user program should be started. It only launches the INIT application, which corresponds to/sbin/init.
Obviously, this application will read the configuration file, according to the configuration file to start the user program (monitoring, manual interface, tablet interface, etc.)
This problem suggests that the file system content is a few conventions, such as to have/sbin/init, to have a configuration file
2. Do you write the Hello,world program, have you ever thought about the use of the printf who realized it?
A : This function is not implemented by you, but is implemented by the library function. When it runs, you have to find the library.
This question suggests that there must be a library in the file system.
       
A simple self-answer to this, in order to understand, you can look at BusyBox init.c, you can know the init process to do things.
of course, you can also look at < embedded Linux application development Complete manual > build the root file system chapter.


Let's talk about my study experience.
1. I was in the School of Physics and electronics major, in fact, the course did not teach how to design the circuit, just teach some electronic circuit knowledge. Design of PCB
self-taught in the laboratory, only designed 2 layers of board, now forget about. But it retains the ability to look at the schematics and see the chip manuals.
2. Took a software degree, interested in software design, but also only learned C language, database only. With interest to do a lot of competition problems. No ability to
take part in the competition, but the C language is very solid.
3. In the laboratory, in the 1th company, is to design some simple PCI card, write the Windows driver
4. In the 2nd company, using 51 single-chip computer to do car phone, began to embark on the road of pure software.
5. Start to feel the lack of single-chip microcomputer, resigned six months to learn Linux, from Red Hat How to operate the start. The first step is to look at <arm architecture and programming;
then write the bare board program to operate the hardware, and then to analyze the u-boot. At the same time look at the <linux kernel fully annotated, the Linux framework has some knowledge.
When writing bare boards, it is recommended that you enhance your understanding of interrupts, and that the kernel uses interrupts to perform various functions.
6. After analyzing the u-boot, we began to do simple driver programming, at this time, the ability is still very weak.
7. Started to go to to work for 2 years, write various types of drive, solve all kinds of problems (driving problems, help locate application problems), the ability to be forged.

    
To summarize:
1. Hardware book: Microcomputer principle, digital circuit, the teaching materials in the university.
2. Linux-related books:
<arm architecture and Programming >
< full manuals for embedded Linux application development >
<linux device driver; The foreigner wrote the book .
<linux device Driver Development >
<linux kernel full comment >
<linux kernel Scenario analysis >
3. Video:
Vedon Linux Video phase 1th (based on s3c2440 recording): Arm experiment, u-boot, file system, primary drive
Vedon Linux Video phase 1th (based on s3c6410 recording): Bare Board program
Vedon Linux Video Phase 2nd: Advanced Driver

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.