The knowledge needed for embedded Linux development is also the technology needed to deal with data flow. The development of embedded Linux project mainly includes the following knowledge points:
1. Data input / output interface — embedded Linux driver development
2. Data running platform and supporting environment — uboot development, Linux kernel tailoring, file system transplantation
3. Data processing and conversion — development of embedded application layer
If we continue to subdivide, we should include the following work:
Embedded Linux driver development is divided into two parts
1. For the hardware operation and debugging of external devices (this part is connected with MCU), including SPI, I2C, ETH, HDMI, CMOS, etc
2. Linux implements API interface of driver module (including basic module)_ XXX functions, as well as add class, device interface function and extended virtual bus interface)
3. To solve the redundancy of driver code, the knowledge of device tree and the code implementation of device tree are analyzed
Uboot development, Linux kernel tailoring, file system porting
1. Uboot is mainly involved in the application development of embedded bare metal. Non original personnel will not modify it. At most, they can modify the logo or add some simple control, so they will not implement complex applications in uboot.
2. For Linux kernel tailoring, what I have been exposed to is the configuration deletion function in menuconfig and the implementation of adding driver modules to the kernel. I have not touched on more complicated issues, and I will not express my views
3. File system transplantation, the mainstream is to transplant QT or Android environment to the platform, of course, the application without interface can meet the needs with the smallest system. On this basis, the basic lib, startup file, instruction file and directory have been transplanted and supported, and I have not involved in more complex issues
Development of embedded application layer
The application layer of embedded system is the part to realize the function, mainly including
1. Use open, write, read, IOCTL to operate the underlying hardware information (including receiving and sending)
2. Basic Linux API processing based on system interface, such as command line information, process and thread, socket communication interface (TCP / UDP), synchronization mechanism (mutex, spin lock, pipeline, message queue, etc.), file I / O, etc
3. The upper application implementation based on the above interface implementation, such as TCP based network application HTTP or mqtt, video application RTMP, and the thread or process mechanism introduced for functional requirements. In order to meet the needs of complex applications, the thread or process synchronization mechanism is also used. In addition, SQLite may be introduced for data management, and OpenSSL for data encryption All of them are the common technical means of application layer development. The biggest advantage of embedded Linux is that it has many ready to use schemes, which is very convenient for the function development of application layer.
4. In order to meet the needs of industrial interface, the current mainstream of embedded system is QT / C + + and Android / Java
With this understanding, you may have a general understanding of the embedded Linux project. Here are some key points:
one Embedded Linux driver driver layer related API interface, DTS syntax these are practitioners must master the technology, if you want to engage in the development of driver layer, this part must be understood and mastered, then what is the biggest difference between ordinary people and senior practitioners, for hardware debugging experience, how I2C or SPI data is not available, how to quickly distinguish between software or hardware The most important skill is to solve problems (device problems or circuit problems) and have feasible methods to solve them. Hardware debugging experience is the most difficult thing for you to learn from a development board. This is pure project experience.
two Uboot development, Linux kernel tailoring, file system transplantation, this part is difficult for me to give experience. On the one hand, this part does not occupy a high proportion in the work (from my development experience), on the other hand, this part is actually in accordance with the tutorial process (including the actual development, a lot of it is also in accordance with the official program process). Non original manufacturers rarely understand the internal implementation of this part But I think this is reasonable. These three pieces are all the best engineers in the world over the years. If the average person can quickly get through it, that person must be a genius. I can’t do it. This part of the source code is a lot of essence, but I do not recommend beginners to chew this part, it is enough to compile and meet a demand environment, if you really want to learn. It’s faster and more useful to take time to improve.
3. For the development of embedded application layer, the main focus of the project is actually the driver and application, in which the application is the specific implementation part, which is often the core to master (in fact, the test scheme boards purchased by many companies basically contain all the required peripheral drivers and implementations, At most, the pin pin should be changed, or the interface should be replaced, or the external devices should be replaced, or the configuration of some registers should be modified. The original manufacturer and solution provider are not involved, and the driver development accounts for a small proportion in the work, As I mentioned above, applications are basically used in real products, and the application layer has started to move closer to desktop or mobile applications. In addition to the direct operation of the underlying hardware, the languages used include C (Linux API), C + +, python, nodejs, Java to deal with the graphical interface, network, web, algorithm and other needs, in fact, many of the implementation here is really implemented in the desktop Linux, there is no problem, and run faster, debugging is more convenient, many of my own code, are running in the WSL or virtual machine, involving hardware, then packaged as a data package test, are verified after the function When cross compiling to embedded platform testing, the effect is basically the same.
After that, I should have a basic understanding of what embedded Linux does and what the key points are. Now I really start to share my learning methods.
1. Familiar with the common instructions of Linux platform and the usage of vim-
I list some commonly used sudo, LS, VIM / VI, ifconfig, clear, Chmod, MKDIR, CP, tar, cat, etc
2. Be familiar with the knowledge of cross compiling, including the understanding of basic makefile. Don’t spend a lot of time to master the grammar of makefile. Here is the recommended document “write with me” Makefile.pdf 》At the beginning, I understand the first three chapters, and then I master them in desynchronization according to the experience.
We must master these two parts, or at least be familiar with them. Only in this way can we not make progress later
Now I start to choose the main direction of study, driver layer or application layer. With most training institutions or development board manufacturers, I prefer the development of application layer according to dozens of chapters of driver. At the same time, I also pay attention to the development and debugging of the underlying driver. Of course, it has something to do with my own working experience. I prefer the technology used in my work. Of course, this is not the underlying driver It doesn’t matter. When you are given a fully tested development board, a lot of debugging experience of the underlying hardware will be left to the development of the driver software (it’s very likely that you won’t implement it all by yourself, but the same set of code is compiled and run again). Many of the design ideas can’t be understood. In this case, it’s unwise to spend a lot of time repeatedly Finally, choose the driver layer or application layer. It’s not recommended to spend a lot of time in uboot, kernel or file system to build a stable platform to meet the needs. Don’t go deep into it at the initial stage, not because it’s not important, but because when you know little about embedded Linux, you can learn the most complex part with half the effort If you are rich, you will naturally summarize similar design ideas. When you go back to study, you can also have your own learning methods and get twice the result with half the effort.
3. For the application layer, how to learn is something. There are not only the transplanting of Python and node, but also the transplanting of SQLite database, OpenSSL encryption algorithm, opencv image processing library, mqtt communication application, as well as the functional application requirements and interface development based on these transplanting libraries and applications. Because of the different industries involved, the required technology is often different The same, but what we need is basically the knowledge mentioned above, which is not very different from desktop development (in fact, many codes can be directly executed after recompiling with desktop compiler tools, so we can learn without development board). Here’s the main point. Linux API is one of the things that we need to learn from the system.
But a year ago, I was concerned that learning embedded with requirements can make the following smoother. Now I am more concerned that through the implementation of the whole application, I can master the implementation of embedded driver, custom protocol, multithreading and thread synchronization. If we transplant RTMP extension to this application, we can achieve image acquisition and network forwarding function, a real webcam with control Case application has been implemented. Many times, embedded products are not so complicated. Learning embedded Linux is also the essence of embedded Linux system and uboot for people coming to the world. In fact, I am going to further study that part of code, but for beginners, this part is actually a natural cut. If the initial entry is in the vast Linux code, In one driving application after another, the experience is very poor. I meet many people who improve very fast in their work. They study and improve in order to solve practical problems. The same is true of the learning method I said. They treat learning as the purpose of their work. When you change your mind, you will naturally think about how to do it, search materials and design ideas, It’s natural to think about how to learn. This is also the learning method I share. In addition, if you only want to engage in the development of embedded Linux, single-chip microcomputer does not have a big impact, and they have only the same thing in common with the actual operation of the underlying hardware, but it doesn’t make much difference in my opinion whether you choose to study Linux or single-chip microcomputer for this part of technology. However, if you are not familiar with the joint debugging of software and hardware, you can also use single-chip microcomputer for transition. Finally, I share an example You can consider implementing part of the embedded scheme you are implementing, and naturally you will know the meaning of the method I mentioned.