Getting Started with ARM and Embedded Linux

You may have noticed that among those working in embedded systems, there are far more people researching Linux than those working with WinCE. Many manufacturers also provide documentation primarily focused on Linux. I have always found it hard to understand; in fact, the interface of WinCE is much more visually appealing than that of Linux, and it is also much more user-friendly. More importantly, development for WinCE is quite similar to development under Windows, making it much simpler to learn. However, there are many more people learning Linux or using Linux for embedded systems compared to WinCE. In conversations with many professionals, I learned that their companies never considered using WinCE due to its high costs, opting instead for Linux for development. In my graduate laboratory, we did not use WinCE; most research focused on Linux, with a few projects using VxWorks, but I have never heard of anyone using WinCE, primarily because of its open-source nature! Of course, I have heard that WinCE 6.0 is now open-source as well, but in terms of cost and resources, Linux has an unbeatable advantage. Correspondingly, more and more electronics manufacturers have begun developing products using Linux. For example, the Android operating system developed by Google is actually based on an improved version of the Linux 2.6.23 kernel.First, Learn the Basics of Bare-Metal ProgrammingFor those studying hardware, it is essential to have an intuitive understanding of the basic usage of hardware and to deeply understand the control methods of that hardware. If you start by learning the Linux system or porting it, you will quickly find yourself in a deep vortex. When I first started learning ARM, I chose ARM7 (mainly because ARM9 was still quite expensive at that time). While learning ARM7, I maintained the mindset of learning the 51 microcontroller, using ADS for programming. My first experiment was to control an LED. Those who have learned ARM for a while will laugh at how silly this is, but I actually think this process is quite beneficial. Regardless of how complex the system may be, it ultimately boils down to the control of the underlying hardware. Therefore, having an intuitive understanding of this hardware control makes it much easier. While learning bare-metal programming, it is essential to thoroughly understand the architecture and control principles of the hardware, which I refer to as understanding the hardware.Understanding hardware means comprehending how this hardware organizes so many resources and how these resources are controlled by the CPU and programming. For instance, in the S3C2410, there are ADC converters, GPIO (General Purpose I/O), and NAND flash controllers. Each of these components has certain registers for control, and each register has an address. What do these addresses mean? How do we control these peripheral devices through registers? Moreover, each unit inside the NOR flash has a corresponding address unit in the chip’s memory. What is the relationship between these addresses and the previously mentioned register addresses? Are they the same? In contrast, the storage units inside NAND flash are not linearly arranged. How does the S3C2410 map the NAND flash addresses into memory space for use? Or simply put, how should one use NAND flash? Furthermore, when programming ARM9 with ADS, an initialization assembly file is required. What is the purpose of this file? What do the codes inside it mean? Can we do without it?Such inquiries represent an understanding of hardware. Once you grasp these concepts, you will have a much deeper understanding of the hardware, which will greatly assist you in further studies. If you skip this step, I believe you will feel increasingly confused as you progress, finding these topics incomprehensible, because your foundation is not solid.However, I must clarify that I have not used ADS for programming ARM9; after completing ARM7, I directly used ARM9 to learn the Linux system. Therefore, I find it challenging to answer questions related to programming ARM9 with ADS^_^. You will have to research this on your own.For this part, I will soon provide a tutorial. The examples in this tutorial are not written for the boards we represent; they are from the laboratory of our college, written by Yingpeite for their own experimental box, but they are quite valuable as a reference.Second, Conduct Basic Experiments Using the Linux SystemWhen purchasing a board, it usually comes with some Linux experiment examples. Spend some time working on these; this process is also significant and helps accumulate intuitive knowledge for further learning. Can you imagine someone who has never used a Linux system being able to learn Linux programming well? Follow the manual’s examples and conduct the experiments therein. Although it may feel a bit like a toddler learning to walk, I believe many experts have gone through this process.Currently, we at Deep Blue Technology do not plan to provide corresponding examples, as the development board providers will offer a wealth of examples. We do not want to duplicate efforts; instead, we focus on providing the most valuable content that they do not offer.Third, Study the Complete Operation Process of the Linux SystemWhat does a complete Linux system consist of? It consists of three parts: Bootloader, Linux Kernel, and Root File System. How do these three parts collaborate to form the system? What is the function of each? What are their connections? What is the execution flow of the system? Clarifying these questions will give you a clear understanding of the entire system’s operation and lay another important foundation for the next step of creating this Linux system. You can find tons of resources online regarding this topic; be sure to research thoroughly.Fourth, Start System PortingHaving discussed that a complete Linux system has three parts and knowing their relationships and functions, your next task is to learn how to create these components yourself. Of course, I cannot ask you to write this code; that is impractical. In fact, you can download the corresponding source code for all three parts online, but this source code cannot simply be downloaded and compiled to run on your system without many modifications. This modification process is called porting. During the porting process, you will need to learn a lot and understand many related concepts. Once you complete this process, you will find that you have become a novice expert. If you have a strong research spirit during this process, you will definitely want to look at the source code. Many books will guide you on how to read Linux source code, but I do not advocate aimlessly looking at the Linux source code, as it is meaningless. When you feel the need to look at the source code during the porting process, you should refer to good books. I recommend a good book by Ni Jili titled “Analysis and Programming of the Linux Kernel,” which focuses on the Linux 2.6.11 kernel and is quite in-depth. I suggest improving your C programming skills before reading it. As for the porting of each part, you can find a lot of information online; be sure to study it. However, I must remind you that many pieces of advice shared from personal experiences often have some omissions. If you follow their instructions, you may encounter issues that they do not explain how to resolve. At that point, you will need to rely on yourself. If you cannot depend on yourself, feel free to reach out to me for joint research. I cannot guarantee I can solve your problem, as I may not have encountered it before, but I believe I can offer some suggestions that may help you find a solution. The ultimate goal of this step is to download the standard source code package from the official homepage (which is always foreign, unfortunately), modify it, and ultimately run it on your board. To quote Archimedes: “Give me a network cable, and I can get Linux running.”Fifth, Study the Development of Linux Device DriversPorting the system is not the final goal; the ultimate aim is to develop products and projects, all of which require driver development. Linux drivers can be quite diverse; there are significant differences between Linux 2.4 and Linux 2.6, and even between different versions of Linux 2.6, writing Linux drivers is not an easy task. There is often insufficient reference material for developing drivers for the latest versions. Therefore, my suggestion is to use and port a not-so-recent version of the kernel, which will provide enough resources for learning driver programming.Sixth, Study the Development of Application ProgramsIn addition to writing drivers for projects, you will also need to develop application programs. The current trend is the development of graphical applications, and the most commonly used library for graphical applications is the Qt/E function library. I have consistently used this library to develop my applications, but I hope you can use the domestic MiniGUI function library. To borrow a phrase from Jay Chou’s advertisement: “Support domestic products, support MiniGUI.” MiniGUI programming is quite similar to VC programming under Windows, making it relatively easy to get started, and the results are quite good. I have used it to develop programs for ARM7. However, the biggest drawback of MiniGUI is that it does not have a graphical operating platform like Qtopia, which greatly limits its promotion. I once fantasized about collaborating with Beijing Feiman Company (the copyright owner of MiniGUI) to develop a graphical operating platform like Qtopia using the MiniGUI function library, but due to my limited skills, that remains a fantasy, haha. Once you complete this step, you will have essentially learned all about embedded Linux. Lastly, I would like to share a small piece of advice. During my study of embedded Linux, I rarely asked others for help. The objective reason was that there were no experts around me among my teachers, classmates, or seniors. The subjective reason was that I do not like asking others; I prefer to research and solve problems myself. This approach has the benefit of enhancing my problem-solving abilities because there are always many issues that are difficult to understand, and not everyone has experience with them. Not all problems will have someone to provide answers, so you must solve them yourself. Thus, my advice is to search online for general questions; if you genuinely cannot find an answer, then ask an expert. If that fails, continue your research; do not wait passively for others to help you solve your problems. Remember, problems are the best opportunities for learning.

Leave a Comment