Hongmeng System Development Tutorial_Wei Dongshan 2-1 What needs to be done to transplant RTOS

Online class: https://www.100ask.net/index (course viewing)
Forum: http://bbs.100ask.net/ (Academic Q&A)
Development Board: https://100ask.taobao.com/ (Taobao)
     https://weidongshan.tmall.com/ (
Tmall ) Exchange Group 1: QQ Group: 869222007 (Hongmeng Development/Linux/Embedded/Driver/Data Download)
Exchange Group 2: QQ Group: 536785813 (SCM-Embedded)
Public number: Baiwen Technology


version date Author Description
V1 2020 Wei Dongshan Wei Dongshan Hongmeng System Development Tutorial

>>>Watch the video tutorial online<<<:

https://www.100ask.net/detail/p_5fcf586ae4b04db7c0939c82/8

1. Framework

Insert picture description here

Hongmeng is a complete operating system that ordinary people can directly use, similar to Windows, Android, and IOS.
A common misconception is to compare Hongmeng with Linux. This is wrong:

  • Linux is just a kernel, ordinary people cannot use it

    • Also need to install various programs on Linux
    • For example, distributions such as Ubuntu, which are on top of the Linux kernel, as well as desktop and various office software
  • Hongmeng supports multiple kernels: Linux, Liteos (subdivided into Liteos-a, Liteos-m)

  • On top of the kernel, Hongmeng also has various subsystems, and on top of the subsystems there are desktop and other software

2. Composition of Embedded Software System

Insert picture description here

We can simply call the software above the kernel APP (in fact, it can be subdivided, such as various subsystems, desktops, etc. APP).
Booting the kernel is not complicated, just use U-boot.

3. Several things to do to transplant the smallest system

  • Serial port related

    • Print (just print debugging information)
    • Serial port driver (can send or receive, when APP executes printf, you can print from the serial port, so you need to drive )
  • MMU (Memory Management Unit, memory management unit) settings: virtual address and physical address

  • Improve the interrupt subsystem

    • Provide system tick clock
    • Implement interrupt-based read character function for serial port driver
  • Implement storage device driver

  • Burn the file system on the storage device

3.1 Serial port related

Compared with the Linux serial port driver, Hongmeng's serial port driver is greatly simplified.
For output: do not use interrupt, directly use query mode output.
For input: To use interrupts, we only need to provide the code related to the underlying hardware.
Note: The virtual address is used.

3.2 MMU settings

MMU has 2 major functions:

3.2.1 Rights Management

  • For example, the address space of processes A and B can be completely isolated, and they do not affect each other
  • Poorly written processes, malicious processes, cannot affect other processes
  • The user program and the kernel address space are completely separated: users are not allowed to directly access the hardware
  • Examples are as follows
    Insert picture description here

3.2.2 Address mapping

  • After the MMU is enabled, the address sent by the CPU is called the "virtual address", which is not sent directly to the hardware, but to the MMU
  • MMU according to page table
    • Make permission judgment
    • Convert to physical address and send to peripheral

When running app1, the addr sent by the CPU is mapped to paddr1 through the MMU;
when running app2, the same addr sent by the CPU is mapped to paddr2 through the MMU;
although app1 and app2 use the same address, the corresponding memory is different, as shown in the following figure:

Insert picture description here

  • During the migration process, we don’t need to pay attention to "permissions", only "address mapping"

3.3 Interrupt subsystem

The biggest difference between an operating system and a microcontroller program is multitasking, that is, running multiple programs at the same time .
At the same time , for humans, it seems that multiple programs can run at the same time, but in fact they run in turn .

3.3.1 The operating system "simultaneously" run multiple tasks

Take turns:

Insert picture description here

3.3.2 Interruption of serial port receiving data

When using the serial port to receive data, if you use the "query" method, it is inefficient and consumes electricity.
Generally use interrupt mode.

3.4 Drivers for storage devices

Generally, there are storage devices such as EMMC, SD/TF card, Nor Flash, and Nand Flash on the board.
The drivers of Nor Flash and Nand Flash are relatively simple, but these devices are relatively rare.
And the driver of EMMC, SD/TF card is too complicated, enough for a topic.
We focus on the transplantation of the smallest system , and let the process go through: use memory to simulate Flash.

3.5 Root file system

A storage device alone is not enough, there needs to be a file on it: this is the root file system.
For a program to run, it needs other libraries if you write the program itself. For example, printfit is not written by you, it is in the library file.
There will be these contents in the root file system:

  • program
  • Library
  • Configuration file
  • User data (optional)
  • Driver (optional)

4. Want to do more

  • LCD and touch screen drivers can be transplanted for better human-computer interaction
  • To facilitate development, transplant EMMC drivers and network card drivers
  • To connect various peripherals, I2C, SPI, GPIO, UART drivers are also required (
    optional)
  • Driver (optional)

5. Want to do more

  • LCD and touch screen drivers can be transplanted for better human-computer interaction
  • To facilitate development, transplant EMMC drivers and network card drivers
  • To connect various peripherals, I2C, SPI, GPIO, UART drivers are also required
  • Camera, sound card driver

Guess you like

Origin blog.csdn.net/thisway_diy/article/details/110919525