Go to file
Haryslee d75383400e feat: 支持native动态加载组件
1.【需求描述】
动态库开发部分:
gcc的sample code。
提供生成暴露接口生成机制,并允许产品新增需要暴露的接口。
提供可以判断库允许资源大小的能力,并提供相关工具辅助开发者确定开发的库要求的资源是否可以满足。

动态库运行部分:
提供elf load的api,可以加载指定路径下的库,并完成符号重映射等运行准备。
提供elf 暴露符号调用的api,用于调用库的api。
elf加载&链接异常时,有明确错误记录,返回明确错误类型。
提供elf 卸载的api。

2.【方案描述】
(1) 通过灌段的形式记录需要导出符号的地址信息,用于暴露内核对外的接口,在加载链接器中通过查询
对应的符号信息获取符号地址。
(2) 加载链接时,解析共享库并将共享库中可加载段通过文件系统读入内存中,并对共享库中未定义的、
需要重定位的符号进行重定位。需要调用符号时,根据符号名通过哈希表即可查询共享库提供的对应符号
的地址。

BREAKING CHANGE:
新增4个对外接口,声明在los_dynlink.h文件中,分别为:
(1) LOS_DynlinkInit: 动态加载模块初始化。
(2) LOS_SoLoad: 加载指定路径的共享库。
(3) LOS_FindSym: 根据共享库句柄查找指定符号。
(4) LOS_SoUnload: 卸载共享库。

close #I418HJ

Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: I7669b7ef20096294f9d1094c85ac6602fefad354
2021-08-10 20:26:40 +08:00
.gitee add issue and pr template 2021-04-07 14:49:54 +08:00
components feat: 支持native动态加载组件 2021-08-10 20:26:40 +08:00
figures update openharmony 1.0.1 2021-03-11 20:30:40 +08:00
kal feat: 支持native动态加载组件 2021-08-10 20:26:40 +08:00
kernel feat: 支持native动态加载组件 2021-08-10 20:26:40 +08:00
targets fix: riscv_nuclei 编译失败 2021-07-21 14:56:33 +08:00
testsuits feat: 支持native动态加载组件 2021-08-10 20:26:40 +08:00
utils feat: L0 支持Trace 2021-07-30 09:29:37 +08:00
.gitignore update openharmony 1.0.1 2021-03-11 20:30:40 +08:00
BUILD.gn feat: 支持native动态加载组件 2021-08-10 20:26:40 +08:00
LICENSE update openharmony 1.0.1 2021-03-11 20:30:40 +08:00
NOTICE update openharmony 1.0.1 2021-03-11 20:30:40 +08:00
OAT.xml chore(oat): 新增OAT配置文件,用作oat扫描 2021-08-06 00:29:03 +08:00
README.md feat: 支持native动态加载组件 2021-08-10 20:26:40 +08:00
README_zh.md feat: 支持native动态加载组件 2021-08-10 20:26:40 +08:00
arch_spec.md feat: 支持native动态加载组件 2021-08-10 20:26:40 +08:00
arch_spec_zh.md feat: 支持native动态加载组件 2021-08-10 20:26:40 +08:00
config.gni feat: 支持native动态加载组件 2021-08-10 20:26:40 +08:00

README.md

LiteOS Cortex-M

Introduction

The OpenHarmony LiteOS Cortex-M is the kernel designed for the lightweight operating system OS for the Internet of Things IoT field. It features small size, low power consumption, and high performance. In addition, it has a simple code structure, including the minimum kernel function set, kernel abstraction layer, optional components, and project directory, and is divided into the hardware-related and hardware-irrelevant layers. The hardware-related layers provide unified hardware abstraction layer HAL interfaces to improve hardware adaptability. The combination and classification of different compilation toolchains and chip architectures meet the requirements of the Artificial Intelligence of Things AIoT field for rich hardware and compilation toolchains. Figure1 shows the architecture of the OpenHarmony LiteOS Cortex-M kernel.

Figure 1 Architecture of OpenHarmony the LiteOS Cortex-M kernel

Directory Structure

The directory structure is listed as below, for the detailed directories, please refer to arch_spec.md.

/kernel/liteos_m
├── components           # Optional components
│   ├── backtrace        # Backtrace support
│   ├── cppsupport       # C++ support
│   ├── cpup             # CPU possession (CPUP)
│   ├── dynlink          # Dynamic loader & linker
│   ├── exchook          # Exception hook
│   ├── fs               # File system
│   └── net              # Network support
├── kal                  # Kernel abstraction layer
│   ├── cmsis            # CMSIS-compliant API support
│   └── posix            # POSIX API support
├── kernel               # Minimum function set support
│   ├── arch             # Code of the kernel instruction architecture layer
│   │   ├── arm          # Code of the ARM32 architecture
│   │   └── include      # APIs exposed externally
│   ├── include          # APIs exposed externally
│   └── src              # Source code of the minimum function set of the kernel
├── targets              # Board-level projects
├── utils                # Common code

Constraints

Programming languages: C and C++

Currently applicable architectures: Cortex-M3, Cortex-M4, Cortex-M7, and RISC-V

Usage

LiteOS Cortex-M provides projects for three chip architectures, which are located in the targets directory. The methods of compiling and using these projects are as follows:

  • Cortex-M3:

The kernel/liteos_m/targets/cortex-m3_stm32f103_simulator_keil directory is the Keil project directory created based on the STM32F103 chip architecture. You can download and install Keil development tools from the Internet. To compile the Cortex-M3 project, go to the cortex-m3_stm32f103_simulator_keil/project directory and double-click the los_demo.uvproj file to open the desired project. After the compilation is successful, burn the file to the corresponding board using JLINK or STM32 ST-LINK Utility.

  • Cortex-M4:

The kernel/liteos_m/targets/cortex-m4_stm32f429ig_fire-challenger_iar directory is the IAR project directory created based on the STM32F429IG chip architecture. You can download and install IAR development tools from the Internet. To compile the Cortex-M4 project, go to the cortex-m4_stm32f429ig_fire-challenger_iar/project directory and double-click the los_demo.eww file to open the desired project. After the compilation is successful, burn the file to the corresponding board using JLINK or STM32 ST-LINK Utility.

  • Cortex-M7:

The kernel/liteos_m/targets/cortex-m7_nucleo_f767zi_gcc directory is the Makefile project directory created based on the STM32F767ZI chip architecture. The compilation commands are as follows:

cd kernel/liteos_m/targets/cortex-m7_nucleo_f767zi_gcc
make clean; make

After the compilation is successful, the executable file NUCLEO-F767.hex is generated in the cortex-m7_nucleo_f767zi_gcc/build directory. Burn the file to the corresponding board using STM32 ST-LINK Utility.

Repositories Involved

Kernel subsystem

kernel_liteos_m