subsys-build-chip_solution.md 4.7 KB
Newer Older
A
Annie_wang 已提交
1 2 3 4
# Chipset Solution
### Configuration Rules

- The chipset solution is a special component. It is built based on a development board, including the drivers, device API adaptation, and SDK.
A
Annie_wang 已提交
5
- The source code path is named in the **device/{Development_board}/{Chipset_solution_vendor}** format.
A
Annie_wang 已提交
6
- The chipset solution component is built by default based on the development board selected.
A
Annie_wang 已提交
7 8

The chipset solution directory structure is as follows:
A
Annie_wang 已提交
9 10 11 12

```shell
  device                                      
  └── board                                   
A
Annie_wang 已提交
13 14 15 16 17 18 19 20
      └── company                           # Chipset solution vendor
           └──  hispark_aries               # Development board name
                 ├── BUILD.gn               # Build script
                 ├── hals                   # OS device API adaptation
                 ├── linux                  # (Optional) Linux kernel version
                 │   └── config.gni         # Linux build configuration
                 └── liteos_a               # (Optional) LiteOS kernel version
                     └── config.gni         # LiteOS_A build configuration
A
Annie_wang 已提交
21 22 23 24 25 26 27 28 29 30 31
```

![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The **config.gni** file contains the configuration related to the build of the development board. The parameters in this file are used to compile all OS components and are globally visible during the build process.

- The **config.gni** file contains the following key parameters:

```shell
  kernel_type:            Kernel used by the development board, for example, LiteOS_A, LiteOS_M, or Linux.
  kernel_version:         Kernel version of the development board, for example, 4.19.
  board_cpu:              CPU of the development board, for example, Cortex-A7 or RISCV32.
  board_arch:             Chipset architecture of the development board, for example, ARMv7-A or RV32IMAC.
A
Annie_wang 已提交
32
  board_toolchain:        Name of the customized build toolchain used by the development board, for example, gcc-arm-none-eabi. If this field is not specified, ohos-clang will be used.
A
Annie_wang 已提交
33 34 35 36 37 38 39 40 41 42 43
  board_toolchain_prefix: Prefix of the toolchain, for example, gcc-arm-none-eabi.
  board_toolchain_type:   Toolchain type. Currently, only GCC and clang are supported.
  board_cflags:           Build options of the .c file configured for the development board.
  board_cxx_flags:        Build options of the .cpp file configured for the development board.
  board_ld_flags:         Linking options configured for the development board.
```

###  Adding and Building a Chipset Solution

The following uses the RTL8720 development board provided by Realtek as an example. The procedure is as follows:

A
Annie_wang 已提交
44 45 46
1. Create a directory for the chipset solution.

   Run the following command in the root code directory:
A
Annie_wang 已提交
47 48 49 50 51

   ```shell
   mkdir -p device/board/realtek/rtl8720
   ```

A
Annie_wang 已提交
52 53 54 55 56
   

2. Create a directory for kernel adaptation and configure the **config.gni** file of the development board.

   For example, to adapt the LiteOS-A kernel to the RTL8720 development board, configure the **device/board/realtek/rtl8720/liteo_a/config.gni** file as follows:
A
Annie_wang 已提交
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92

   ```shell
   # Kernel type, e.g. "linux", "liteos_a", "liteos_m".
   kernel_type = "liteos_a"
   
   # Kernel version.
   kernel_version = "3.0.0"
   
   # Board CPU type, e.g. "cortex-a7", "riscv32".
   board_cpu = "real-m300"
   
   # Board arch, e.g. "armv7-a", "rv32imac".
   board_arch = ""
   
   # Toolchain name used for system compiling.
   # E.g. gcc-arm-none-eabi, arm-linux-harmonyeabi-gcc, ohos-clang, riscv32-unknown-elf.
   # Note: The default toolchain is "ohos-clang". It's not mandatory if you use the default toochain.
   board_toolchain = "gcc-arm-none-eabi"
   
   # The toolchain path instatlled, it's not mandatory if you have added toolchian path to your ~/.bashrc.
   board_toolchain_path =
       rebase_path("//prebuilts/gcc/linux-x86/arm/gcc-arm-none-eabi/bin",
                   root_build_dir)
   
   # Compiler prefix.
   board_toolchain_prefix = "gcc-arm-none-eabi-"
   
   # Compiler type, "gcc" or "clang".
   board_toolchain_type = "gcc"
   
   # Board related common compile flags.
   board_cflags = []
   board_cxx_flags = []
   board_ld_flags = []
   ```

A
Annie_wang 已提交
93 94 95
3. Write the build script.

   Create the **BUILD.gn** file in the development board directory. The target name must be the same as that of the development board. The following is an example of the **device/board/realtek/rtl8720/BUILD.gn** file for the RTL8720 development board:
A
Annie_wang 已提交
96 97 98 99

   ```shell
   group("rtl8720") { # The build target can be shared_library, static_library, or an executable file.
     # Content
A
Annie_wang 已提交
100
     ...
A
Annie_wang 已提交
101 102 103
   }
   ```

A
Annie_wang 已提交
104 105 106 107
4. Build the chipset solution.

   Run the **hb build** command in the development board directory to start the build.