Embedded Linux From a Microcontroller Engineer’s Perspective

Embedded Linux From a Microcontroller Engineer's Perspective

01
【Introduction】

This article will briefly organize some knowledge about Embedded Linux, providing reference for those who, like me, want to progress from microcontrollers to Embedded Linux.

With the increasing number of Embedded Linux tutorials, I believe many friends studying microcontrollers have started experimenting with it~

02
What to Learn About Embedded Linux

1. Understanding Linux

Embedded Linux From a Microcontroller Engineer's Perspective

Some friends studying microcontrollers may already have some basic knowledge of Linux, but there are also friends who have never used Linux, and some beginners may not have heard of Linux. To accommodate these friends, let’s briefly understand Linux:

Embedded Linux From a Microcontroller Engineer's Perspective

2. Understanding Embedded Linux

When learning Embedded Linux, we need to focus on the following major areas:

Embedded Linux From a Microcontroller Engineer's Perspective

The three most important parts of Embedded Linux software are the Bootloader, Linux kernel, and root filesystem. With these three parts, we have the minimum, complete, and runnable embedded system.

(1) BootLoader

The BootLoader is a piece of code that runs before the operating system to boot the OS. There are many open-source BootLoaders, such as RedBoot and U-Boot, among which U-Boot is the most commonly used. The source code for U-Boot is quite large:

Embedded Linux From a Microcontroller Engineer's Perspective

Our focus is to learn how to modify the U-Boot provided by the chip manufacturer and adapt it to our board:

Embedded Linux From a Microcontroller Engineer's Perspective

When we talk about U-Boot porting, we usually refer to the process of modifying the U-Boot provided by the chip manufacturer to adapt it to our board.

(2) Linux Kernel

The Linux kernel is an open-source monolithic Unix-like operating system kernel. The Linux kernel we need to learn to port is also the one provided by the chip manufacturer. The kernel source directory is as follows:

Embedded Linux From a Microcontroller Engineer's Perspective

(3) Root Filesystem

The root filesystem (rootfs) is the first filesystem mounted when the kernel starts, where the kernel code image file is stored.

The system boot program will load some basic initialization scripts and services into memory to run after mounting the root filesystem.

The importance of the root filesystem is similar to that of the system disk on our computer; without this system disk, we cannot install our system. The root filesystem has a root directory /, which contains many subdirectories:

Embedded Linux From a Microcontroller Engineer's Perspective

The root filesystem requires a special framework to create, such as BusyBox, Yocto, Buildroot, etc.

(4) Linux Drivers

Linux drivers should be the starting point and focus of our learning Embedded Linux. The above three parts have already created a complete Embedded Linux environment for us.

With such an environment, our Linux drivers can be installed on top of it. Linux drivers:

Embedded Linux From a Microcontroller Engineer's Perspective

There are three major types of drivers in Linux: character device drivers, block device drivers, and network device drivers.

Device Tree: A file that describes the device tree. This DTS file uses a tree structure to describe the board-level devices, such as the number of CPUs, memory base address, devices connected to the IIC interface, devices connected to the SPI interface, etc.

(5) Linux Applications

In Linux: everything is a file. In C programming, we know that file operations involve opening files, reading and writing files, and closing files.

In embedded Linux application programming, our focus is also on how to operate (open, close, read, write, etc.) these files (device files, etc.).
03
【Some Experience】

Learning Embedded Linux is much more difficult than learning microcontrollers; not only has the content increased, but just getting familiar with the development environment (Linux environment, cross-compiler, Makefile, etc.) involves quite a bit of content.

In terms of depth, it is significantly deeper than microcontrollers. For example, learning STM32 used IDE compilation, while Embedded Linux involves compiling directly with a compiler or using compilation scripts.

From my experience of starting and giving up, starting with Linux drivers and applications is a good approach. Don’t jump straight into the three giants mentioned above, or you might easily go from beginner to giving up…

Be prepared for hardship; many issues can drive you crazy. For example, when you follow a tutorial, the final result may differ, and many problems may arise. This is very normal.

Sometimes, a problem may seem isolated, but it can lead to other issues that need to be resolved patiently.

For instance, when I compiled the Linux kernel previously, I encountered the following issue:

Embedded Linux From a Microcontroller Engineer's Perspective

According to the problem description, I was missing something called lzop, so I installed it as instructed, only to encounter another issue:

Embedded Linux From a Microcontroller Engineer's Perspective

Then I had to look online for solutions, trying them one by one until I finally resolved it:

Embedded Linux From a Microcontroller Engineer's Perspective

Embedded Linux From a Microcontroller Engineer's Perspective

My experimental method was exactly the same as the tutorial, including the development environment provided by the tutorial. Even with identical operations, issues can still arise, so if you have to set up your environment, the chances of errors increase.

Regardless, don’t give up so easily.

04
【Conclusion】

The knowledge of Embedded Linux is not limited to what has been mentioned above, but it basically includes our main learning content. The above only covers some superficial conceptual knowledge; later we will learn and share more in-depth and detailed knowledge together.

To help upstream and downstream enterprises in the industry better grasp the business opportunities in the AIoT market, AspenCore, a global leading professional electronic media organization, will collaborate with the Shenzhen New Generation Information and Communication Industry Cluster to jointly host the 【2023 International AIoT Ecological Development Conference】, which will be grandly held on June 8 at the Nanshan Kexing Science Park International Conference Center in Shenzhen!
Embedded Linux From a Microcontroller Engineer's Perspective
Scan ↑↑ to register for the conference!
Author: ZhengN, Source: Embedded Miscellaneous

This article is reprinted with permission from the “Embedded Miscellaneous” WeChat public account. Reprinting is for learning reference only and does not represent our endorsement of its views. We also do not bear any copyright responsibility for its content, text, or images.

END
Previous Recommendations
1. Three reasons why CAN is better than RS-485?
2. A foreign review of a Chinese LED flashlight, measuring found to be falsely labeled six times!

3. Summary of a recently designed PCB, where a two-layer board turned out to be more difficult to design than a multi-layer board.

Leave a Comment