A Practical Guide to Learning Wildfire i.MX Linux Development

The content of this blog is referenced and excerpted from the wildfire i.MX Linux development guide, praise for the wildfire open source spirit and the excellent workmanship of the development board! (For more detailed content, you can follow the "Wildfire Electronics" public account on WeChat, and get stm32, i.mxrt1052, RTOS, embedded Linux and other related materials for free (no routines))

wildfire i.mx6ullNES game island of adventure

1.Uboot

The full name of Universal boot loader is an open source project that follows the terms of GPL. Since U-BOOT has developed, it has supported many operating systems. In addition to Linux, it also supports the booting of embedded operating systems such as NetBSD, VxWorks, and Android.

As mentioned in the overview, U-Boot is mainly used to start the operating system kernel. It is divided into two stages, namely boot+loader. The following table describes the specific content of these two stages

stage Work done
boot阶段 Start the system, initialize hardware devices, establish a memory space map, and bring the system's hardware and software to a suitable state
loader阶段 Load the kernel file of the operating system into memory, and then jump to the address where the kernel is located to run

When a development board is powered on, even a very simple program needs to perform a lot of initialization operations, such as initializing the clock, initializing the memory controller, copying the code to the running memory, etc. Most processors are powered on and initialized When there is a default instruction execution location, for example, the processor of the ARM architecture will read the first instruction from the address 0x00000000.
Generally speaking, the bootloader must provide the initialization code when the system is powered on. After initializing the relevant environment when the system is powered on, the bootloader needs to guide the complete operating system. The controller is then handed over to the operating system.
When developing, we may need to use some commands to operate the bootloader and let the bootloader do some things. We can call this mode 下载模式, such as booting from the ELF image in the memory, and starting the application image from the memory. Of course, the download mode is It is meaningful for developers, but for users, these operations are not required, and the operating system can be directly started to run, and this mode of directly starting the operating system becomes the startup mode. As we said, U-BOOT is very powerful, can support download mode and boot mode at the same time, and can switch modes. It can be configured so that the operator chooses whether to enter the download mode within N seconds (N seconds can be set arbitrarily) when the system is powered on. In this mode, the bootloader will not continue to start the operating system kernel, but is specified by the developer. The work of the bootloader, such as downloading the operating system image through the serial port, and starting the image through the network, etc. enter download modeinsert image description here
The above two pictures are the serial port printing information of the wildfire Linux development board when it is powered on. The first picture is the download mode, and the second picture is the normal startup mode.

2 .Kernel

2.1 Linux Kernel

KernelIt is the Linux kernel. Linux adopts the macro-kernel architecture, that is, most of the functions of Linux will be implemented in the kernel. Such as process management, memory management, device management, file management and network management functions.

2.2 Composition of Linux system

The Linux system is mainly composed of 5 parts, namely: process management subsystem, memory management subsystem, file subsystem, network subsystem, and device subsystem, as shown in the following figure:
Linux Kernel CompositionAs can be seen from the above figure, the entire system kernel consists of 5 It consists of parts and is called by the system layer (system call)

3.dtb

Before 2011, there was a lot of garbage code in ARM Linux that described the chip platform and board-level differences.
They were located in the kernel/arch/arm/plat-xxx directory and the kernel/arch/arm/mach-xxx directory. Hardware, such as registering the platform device, declaring the resource of the device, etc., but these codes are garbage for the Linux kernel, so Linux founder Linus Torvalds sent an email to the Linux community in March 2011, he proposed that the ARM architecture platform should be Referring to other platforms such as PowerPC's Device Tree system to describe hardware, there is no need for a lot of redundant coding in the Linux kernel, and many hardware and chip platform details can be passed to the Linux kernel through the device tree.

In fact, the device tree is a data structure that describes hardware. It describes the information of these hardware devices with a non-C language
scripting language, and this script file is the legendary Device Tree (device tree). The device tree includes Device Tree Source (DTS) file, Device Tree Compiler (DTC) and Device Tree Blob (DTB) in binary format. The header file format included in DTS is DTSI. The DTS file is a human-readable encoding format. It consists of nodes (Node) and properties (Property). The node may contain child nodes, and the property can be easily understood. It is a pair of names and values.
Because Uboot and Linux cannot directly recognize DTS files, they can only recognize binary files, so it is necessary to
compile DTS files into DTB files, and DTC is the device tree source file (.dts / .dtsi ) is a compilation tool that compiles into a binary format device tree file (.dtb). It is located in the scripts/dtc directory of the Linux kernel source code. When the device tree is enabled in the Linux configuration, the kernel will automatically compile the corresponding device tree. Of course, The user can also compile the device tree individually.
DTB can be recognized and parsed by the kernel and BootLoader. Usually, when making a NAND Flash and SD Card boot image, a part of the storage area is usually reserved for the DTB file to store the DTB. When the BootLoader starts the kernel, it will first read the DTB to the memory.
Loading process of DTS
In the Linux device tree, the hardware information that can be described includes the following categories:

  1. Number and class of CPUs
  2. memory base address and size
  3. Buses and Bridges
  4. Peripheral connection
  5. Interrupt Controller and Interrupt Usage
  6. GPIO controller and GPIO usage
  7. Clock Controller and Clock Usage

4. Root file system

The English name of the root file system is called rootfs. This is the first file system loaded by Linux during the initialization phase. The root file system includes the root directory and the real file system. The root file system is named because a "root" is added in front of it. It is because he is the root for loading other file systems. Without this root, other file systems cannot be loaded.

The above is part of the tutorial for learning the wildfire i.mx6ull development board. For detailed knowledge, you can follow the WeChat public account "Wildfire Electronics" for complete information.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324345248&siteId=291194637