November 23rd Wei Dongshan Hongmeng transplantation 02_ Essential basic knowledge November 23rd use HiBurn to burn Hongmeng.bin file

1. Basic knowledge

The technical requirements for transplanting the kernel are relatively high and fine.

1.1 SCM related knowledge

  • The role of the stack

  • Load address, link address

  • reset

  • A few simple hardware knowledge

   Serial port

   Timer

  • Timer

  • The concept of interruption

1.2 Knowledge about Linux operation

  • Linux commonly used commands

  • Simple script: Script is to write commands in a file

  • Makefile

  • GCC compilation command

1.3 Chip related knowledge

  • Able to read the chip manual (English): When transplanting the smallest system, there is not much manual content involved

  • Able to understand hardware schematics: when transplanting the smallest system, there are not many schematics involved

2. Driver knowledge

How to operate the hardware for people with only MCU knowledge?

  • Directly read and write registers

  • Use library functions

In RTOS, the essence is to read and write registers, but a unified driver framework is required.
So: RTOS driver = driver framework + hardware operation

2.1 Take lighting as an example

2.1.1 Hardware principle

Insert picture description here

2.1.2 Singlechip lighting

  • Method 1: Read and write registers directly

Insert picture description here

  • Method 2: Use the manufacturer's HAL library

Insert picture description here

2.1.3 FreeRTOS lights up

Insert picture description here

2.1.4 rt-thread lighting

  • Method 1: Direct manipulation of registers

Insert picture description here

  • Method 2: Use the driver

  The driving model is as follows:
Insert picture description here

  The driving example is as follows:
Insert picture description here

  Call process framework
Insert picture description here

  Example of calling process

Insert picture description here

2.1.5 How to light up Liteos-a/Linux

When using MMU, generally APP and kernel are isolated from each other. APP uses standard open/read/write and other file operation functions to call the driver.
As shown below:

Insert picture description here

Why is it unnecessary?

  • They support MMU (Memory Management Unit)

  • The user program is separated from the kernel, and the user program cannot directly read and write registers

  • The user program accesses the driver through a standard interface

  • The software based on these cores is generally more complex than the software of the single-chip microcomputer.

  • People who write apps should not be allowed to look at schematics, write drivers, and write registers

  • Software and hardware are isolated, no matter how the hardware changes, only the driver needs to be changed, the APP does not need to be changed

2.1.6 How to light on Android

Insert picture description here

  • Android is a set of operating systems on the Linux operating system

  • Android uses Linux to access hardware, which is essentially a Linux driver

  • General C programs and C++ programs can directly call functions such as open/read/write

  • Programs written in java need to access C functions through JNI

2.2 Take LCD as an example

2.2.1 Hardware principle

Insert picture description here

  • Set up the LCD controller, it will automatically read the data of each pixel from the FrameBuffer and send it to the LCD

  • Put the text and image to be displayed into FrameBuffer

2.2.2 How to operate LCD with Liteos-a/Linux

Insert picture description here

Why is it unnecessary?

  • They support MMU (Memory Management Unit)

  • The user program is separated from the kernel, and the user program cannot directly read and write registers

  • The user program accesses the driver through a standard interface

  • The software based on these cores is generally more complex than the software of the single-chip microcomputer.

  • People who write apps should not be allowed to look at schematics, write drivers, and write registers

  • Software and hardware are isolated, no matter how the hardware changes, only the driver needs to be changed, the APP does not need to be changed

2.2.3 How to operate LCD on Android

Insert picture description here

In GUI systems such as Android/QT:

  • LCD will be used by multiple APPs, if it is not managed uniformly, it will be messy

  • So, there must be a management software, or service software

  • APP constructs its own interface and submits it to display service software

  • Display service software: merge the final display image according to the front and back levels of multiple APPs

  • Then call the driver to display

2.2.4 How does Hongmeng operate LCD

Hongmeng supports Liteos and Linux kernel, how to manage the only display device for multiple APPs on the kernel?
Hongmeng also supports soft buses, which can theoretically support more LCDs, how to do it?
Service software:

  • According to the front and back levels of multiple apps
  • Merge the final display image
  • Then call the driver to display

Original link:https://developer.huawei.com/consumer/cn/forum/topic/0201396913445810055?fid=0101303901040230869
author: Wei Dongshan

Guess you like

Origin blog.51cto.com/14772288/2553654