kernel-standard-build.md 1.9 KB
Newer Older
M
mamingshuai 已提交
1 2
# Guidelines for Compiling and Building the Linux Kernel<a name="EN-US_TOPIC_0000001076416924"></a>

D
duangavin123 已提交
3 4 5
-   [Example 1](#section19369206113115)
    -   [Scenario 1: Building the Native Kernel at the Version Level](#section1025111193220)
    -   [Scenario 2: Building the Modified Kernel Separately](#section17446652173211)
M
mamingshuai 已提交
6 7


D
duangavin123 已提交
8
## Example 1<a name="section19369206113115"></a>
M
mamingshuai 已提交
9

D
duangavin123 已提交
10 11 12
The following uses the Hi3516D V300 board and Ubuntu x86 server as an example.

### Scenario 1: Building the Native Kernel at the Version Level<a name="section1025111193220"></a>
M
mamingshuai 已提交
13 14 15 16 17 18 19

Perform a full build for the project to generate the  **uImage**  kernel image.

```
./build.sh --product-name Hi3516DV300 # Build the uImage kernel image of the Hi3516D V300 board.
```

D
duangavin123 已提交
20
### Scenario 2: Building the Modified Kernel Separately<a name="section17446652173211"></a>
M
mamingshuai 已提交
21 22 23

1.  Set up the build environment.

D
duangavin123 已提交
24
    1.  Merge the required patch by referring to  [guidelines for using patches on development boards](kernel-standard-patch.md).
M
mamingshuai 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    2.  Prepare for the build environment. You can use the Arm Clang or GCC compiler.

    Enter the root directory of the project and configure environment variables:

    ```
    export PATH=`pwd`/prebuilts/clang/host/linux-x86/clang-r353983c/bin:`pwd`/prebuilts/gcc/linux-x86/arm/gcc-linaro-7.5.0-arm-linux-gnueabi/bin/:$PATH # Configure the build environment.
    MAKE_OPTIONES="ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- CC=clang HOSTCC=clang" # Use Clang provided by the project.
    ```

2.  Modify the kernel code or kernel configuration \(**defconfig**  file provided by OpenHarmony can be used for reference\).
3.  Create a build directory and generate the  **.config**  file of the kernel.

    ```
    make ${MAKE_OPTIONES} hi3516dv300_emmc_smp_hos_l2_defconfig # Use the defconfig file to build the kernel.
    ```

4.  Build the kernel image.

    ```
    make ${MAKE_OPTIONES} -j32 uImage # Build the uImage kernel image.
    ```