1e41f4b71Sopenharmony_ci# Product 2e41f4b71Sopenharmony_ci### Configuration Rules 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ciThe product solution is a special component. It is a product built based on a development board. It includes the OS adaptation, component assembly and configuration, startup configuration, and file system configuration. The source code path of a product solution is in the **vendor/{Product_solution_vendor}/{Product_name}** format. 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciThe product solution directory structure is as follows: 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci```shell 9e41f4b71Sopenharmony_civendor 10e41f4b71Sopenharmony_ci└── company # Product solution vendor 11e41f4b71Sopenharmony_ci ├── product # Product name 12e41f4b71Sopenharmony_ci │ ├── init_configs 13e41f4b71Sopenharmony_ci │ │ ├── etc # Startup configuration of the init process (only required for the Linux kernel) 14e41f4b71Sopenharmony_ci │ │ └── init.cfg # System service startup configuration 15e41f4b71Sopenharmony_ci │ ├── hals # OS adaptation 16e41f4b71Sopenharmony_ci │ ├── BUILD.gn # Product build script 17e41f4b71Sopenharmony_ci │ └── config.json # Product configuration file 18e41f4b71Sopenharmony_ci │ └── fs.yml # File system packaging configuration 19e41f4b71Sopenharmony_ci └── ...... 20e41f4b71Sopenharmony_ci``` 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci> **NOTE**<br>Directories and files must be created for new products based on the preceding rules. The Compilation and Building subsystem scans the configured products based on the rules. 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ciThe key directories and files are described as follows: 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci1. **vendor/company/product/init_configs/etc**<br>This folder contains the rcS, Sxxx, and fstab scripts. The init process runs the rcS, fstab, and S00xxx scripts in sequence before starting system services. The Sxxx script is used to create device nodes and directories, scan device nodes, and change file permissions for the development board and product. These scripts are copied from the **BUILD.gn** file to the **out** directory of the product as required and packaged into the **rootfs** image. 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci2. **vendor/company/product/init_configs/init.cfg**<br>**init.cfg** defines how the init process starts services. Currently, the following commands can be parsed: 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci - **start**: starts a service. 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci - **mkdir**: creates a folder. 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci - **chmod**: changes the permission on a specified directory or file. 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci - **chown**: changes the owner group of a specified directory or file. 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci - **mount**: mounts a device. 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci The fields in the file are described as follows: 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci ```shell 43e41f4b71Sopenharmony_ci { 44e41f4b71Sopenharmony_ci "jobs" : [{ # An array of jobs. A job corresponds to a command set. Jobs are executed in the following sequence: pre-init > init > post-init. 45e41f4b71Sopenharmony_ci "name" : "pre-init", 46e41f4b71Sopenharmony_ci "cmds" : [ 47e41f4b71Sopenharmony_ci "mkdir /storage/data", # Create a directory. 48e41f4b71Sopenharmony_ci "chmod 0755 /storage/data", # Modify the permissions. The format of the permission value is 0xxx, for example, 0755. 49e41f4b71Sopenharmony_ci "mkdir /storage/data/log", 50e41f4b71Sopenharmony_ci "chmod 0755 /storage/data/log", 51e41f4b71Sopenharmony_ci "chown 4 4 /storage/data/log", # Change the owner group. The first number is the user ID (UID), and the second number is the group ID (GID). 52e41f4b71Sopenharmony_ci ...... 53e41f4b71Sopenharmony_ci "mount vfat /dev/mmcblock0 /sdcard rw,umask=000" # The command format is mount [File system type] [source] [target] [flags] [data]. 54e41f4b71Sopenharmony_ci # The value of flags can be nodev, noexec, nosuid, or rdonly. 55e41f4b71Sopenharmony_ci ] 56e41f4b71Sopenharmony_ci }, { 57e41f4b71Sopenharmony_ci "name" : "init", 58e41f4b71Sopenharmony_ci "cmds" : [ # Start services based on the sequence in the cmds array. 59e41f4b71Sopenharmony_ci "start shell", # There is only one space between start and the service name. 60e41f4b71Sopenharmony_ci ...... 61e41f4b71Sopenharmony_ci "start service1" 62e41f4b71Sopenharmony_ci ] 63e41f4b71Sopenharmony_ci }, { 64e41f4b71Sopenharmony_ci "name" : "post-init", # Job that is finally executed. Operations performed after the init process is started, for example, mounting a device after the driver initialization). 65e41f4b71Sopenharmony_ci "cmds" : [] 66e41f4b71Sopenharmony_ci } 67e41f4b71Sopenharmony_ci ], 68e41f4b71Sopenharmony_ci "services" : [{ # An array of services. A service corresponds to a process. 69e41f4b71Sopenharmony_ci "name" : "shell", # Service name. 70e41f4b71Sopenharmony_ci "path" : ["/sbin/getty", "-n", "-l", "/bin/sh", "-L", "115200", "ttyS000", "vt100"], # Full path of the executable file. It must start with "path". 71e41f4b71Sopenharmony_ci "uid" : 0, # Process UID, which must be the same as that in the binary file. 72e41f4b71Sopenharmony_ci "gid" : 0, # Process GID, which must be the same as that in the binary file. 73e41f4b71Sopenharmony_ci "once" : 0, # Whether the process is a one-off process. The value 1 indicates a one-off process, and the value 0 indicates the opposite. The init process does not restart the one-off process after the process exits. 74e41f4b71Sopenharmony_ci "importance" : 0, # Whether the process is a key process. The value 1 indicates a key process, and the value 0 indicates the opposite. If a key process exits, the init process will restart the board. 75e41f4b71Sopenharmony_ci "caps" : [4294967295] 76e41f4b71Sopenharmony_ci }, 77e41f4b71Sopenharmony_ci ...... 78e41f4b71Sopenharmony_ci ] 79e41f4b71Sopenharmony_ci } 80e41f4b71Sopenharmony_ci ``` 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci3. **vendor/company/product/init_configs/hals**<br>This folder contains the OS adaptation of the product. For details about the interfaces to be implemented, see readme of each component. 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci4. **vendor/company/product/config.json**<br>The **config.json** file is the main entry for compilation and build. It contains the configuration of the development board, OS components, and kernel. 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci The following example shows the **config.json** file of the IP camera developed based on the hispark_taurus board: 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci ```shell 89e41f4b71Sopenharmony_ci { 90e41f4b71Sopenharmony_ci "product_name": "ipcamera", # Product name 91e41f4b71Sopenharmony_ci "version": "3.0", # Version of config.json. The value must be 3.0. 92e41f4b71Sopenharmony_ci "type": "small", # System type. The value can be mini, small, or standard. 93e41f4b71Sopenharmony_ci "ohos_version": "OpenHarmony 1.0", # OS version 94e41f4b71Sopenharmony_ci "device_company": "hisilicon", # Chipset vendor 95e41f4b71Sopenharmony_ci "board": "hispark_taurus", # Name of the development board 96e41f4b71Sopenharmony_ci "kernel_type": "liteos_a", # Kernel type 97e41f4b71Sopenharmony_ci "kernel_version": "3.0.0", # Kernel version 98e41f4b71Sopenharmony_ci "subsystems": [ 99e41f4b71Sopenharmony_ci { 100e41f4b71Sopenharmony_ci "subsystem": "aafwk", # Subsystem 101e41f4b71Sopenharmony_ci "components": [ 102e41f4b71Sopenharmony_ci { "component": "ability", "features":[ "ability_lite_enable_ohos_appexecfwk_feature_ability = true" ] } # Selected component and feature configuration 103e41f4b71Sopenharmony_ci ] 104e41f4b71Sopenharmony_ci }, 105e41f4b71Sopenharmony_ci { 106e41f4b71Sopenharmony_ci ...... 107e41f4b71Sopenharmony_ci } 108e41f4b71Sopenharmony_ci ...... 109e41f4b71Sopenharmony_ci More subsystems and components 110e41f4b71Sopenharmony_ci } 111e41f4b71Sopenharmony_ci } 112e41f4b71Sopenharmony_ci ``` 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci5. **vendor/company/product/fs.yml**<br>The **fs.yml** file defines the process for creating a file system image, for example, **rootfs.img** (user-space root file system) and **userfs.img** (readable and writable file). It consists of multiple lists, and each list corresponds to a file system. The fields are described as follows: 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci ```shell 117e41f4b71Sopenharmony_ci fs_dir_name: (mandatory) specifies the name of the file system, for example, rootfs or userfs. 118e41f4b71Sopenharmony_ci fs_dirs: (optional) specifies the mapping between the file directory in the out directory and the system file directory. Each file directory corresponds to a list. 119e41f4b71Sopenharmony_ci source_dir: (optional) specifies the target file directory in the out directory. If this field is not specified, an empty directory will be created in the file system based on target_dir. 120e41f4b71Sopenharmony_ci target_dir: (mandatory) specifies the file directory in the file system. 121e41f4b71Sopenharmony_ci ignore_files: (optional) declares ignored files during the copy operation. 122e41f4b71Sopenharmony_ci dir_mode: (optional) specifies the file directory permissions. The default value is 755. 123e41f4b71Sopenharmony_ci file_mode: (optional) specifies the permissions of all files in the directory. The default value is 555. 124e41f4b71Sopenharmony_ci fs_filemode: (optional) specifies the files that require special permissions. Each file corresponds to a list. 125e41f4b71Sopenharmony_ci file_dir: (mandatory) specifies the detailed file path in the file system. 126e41f4b71Sopenharmony_ci file_mode: (mandatory) declares file permissions. 127e41f4b71Sopenharmony_ci fs_symlink: (optional) specifies the soft link of the file system. 128e41f4b71Sopenharmony_ci fs_make_cmd: (mandatory) creates the file system script. The script provided by the OS is located in the build/lite/make_rootfs directory. Linux, LiteOS, ext4, jffs2, and vfat are supported. Chipset vendors can also customize the script as required. 129e41f4b71Sopenharmony_ci fs_attr: (optional) dynamically adjusts the file system based on configuration items. 130e41f4b71Sopenharmony_ci ``` 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci The **fs_symlink** and **fs_make_cmd** fields support the following variables: 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ci - Code root directory, which corresponds to **{ohos_root_path}** of GN. 135e41f4b71Sopenharmony_ci - **out** directory of the product, which corresponds to **{root_out_dir}** of GN. 136e41f4b71Sopenharmony_ci - File system directory **${fs_dir}**, which consists of variables **${root_path}** and **${fs_dir_name}**. 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci> **NOTE**<br>**fs.yml** is optional. You do not need to configure it for devices without a file system. 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci6. **vendor/company/product/BUILD.gn**<br>**BUILD.gn** provides the entry for product build. It is used to compile the source code of the solution vendor and copy the startup configuration file. The **BUILD.gn** file in the corresponding product directory will be built by default if a product is selected. The following is an example of the **BUILD.gn** file of a product: 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci ```shell 143e41f4b71Sopenharmony_ci group("product") { # The name must be the same as the product name (level-3 directory name under the product directory). 144e41f4b71Sopenharmony_ci deps = [] 145e41f4b71Sopenharmony_ci deps += [ "init_configs" ] # Copy init configuration. 146e41f4b71Sopenharmony_ci ... # Others 147e41f4b71Sopenharmony_ci } 148e41f4b71Sopenharmony_ci ``` 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci### Adding and Building a Product 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ciYou can customize a product solution by assembling any chipset solution and components. The procedure is as follows: 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci1. Create a directory for the product. <br>The following uses the Wi-Fi IoT module on the RTL8720 development board as an example. <br>Run the following command in the root directory of the code: 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci ```shell 157e41f4b71Sopenharmony_ci mkdir -p vendor/my_company/wifiiot 158e41f4b71Sopenharmony_ci ``` 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_ci2. Configure the product. <br>Create a **config.json** file for the product (for example, wifiiot) in the product directory. <br>The **vendor/my_company/wifiiot/config.json** file is as follows: 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ci ```shell 163e41f4b71Sopenharmony_ci { 164e41f4b71Sopenharmony_ci "product_name": "wifiiot", # Product name 165e41f4b71Sopenharmony_ci "version": "3.0", # Version of config.json. The value must be 3.0. 166e41f4b71Sopenharmony_ci "type": "small", # System type. The value can be mini, small, or standard. 167e41f4b71Sopenharmony_ci "ohos_version": "OpenHarmony 1.0", # OS version 168e41f4b71Sopenharmony_ci "device_company": "realtek", # Name of the chipset solution vendor 169e41f4b71Sopenharmony_ci "board": "rtl8720", # Name of the development board 170e41f4b71Sopenharmony_ci "kernel_type": "liteos_m", # Kernel type 171e41f4b71Sopenharmony_ci "kernel_version": "3.0.0", # Kernel version 172e41f4b71Sopenharmony_ci "subsystems": [ 173e41f4b71Sopenharmony_ci { 174e41f4b71Sopenharmony_ci "subsystem": "kernel", # Subsystem 175e41f4b71Sopenharmony_ci "components": [ 176e41f4b71Sopenharmony_ci { "component": "liteos_m", "features":[] } # Component and its features 177e41f4b71Sopenharmony_ci ] 178e41f4b71Sopenharmony_ci }, 179e41f4b71Sopenharmony_ci ... 180e41f4b71Sopenharmony_ci { 181e41f4b71Sopenharmony_ci More subsystems and components 182e41f4b71Sopenharmony_ci } 183e41f4b71Sopenharmony_ci ] 184e41f4b71Sopenharmony_ci } 185e41f4b71Sopenharmony_ci ``` 186e41f4b71Sopenharmony_ci 187e41f4b71Sopenharmony_ci >**NOTE**<br>Before the build, the Compilation and Building subsystem checks the validity of the fields in **config.json**. The **device_company**, **board**, **kernel_type**, and **kernel_version** fields must match the chipset solution, and the **subsystem** and **component** fields must match the component description in **build/lite/components**. 188e41f4b71Sopenharmony_ci 189e41f4b71Sopenharmony_ci3. Implement OS adaptation APIs. Create the **hals** directory in the product directory and save the source code as well as the build script for OS adaptation in the **hals** directory. 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_ci4. Create the **init_configs** directory in the product directory and then the **init.cfg** file in the **init_configs** directory, and configure the system services to be started. 192e41f4b71Sopenharmony_ci 193e41f4b71Sopenharmony_ci5. (Optional) Configure the init process for the Linux kernel. Create the **etc** directory in the **init_configs** directory, and then create the **init.d** folder and the **fstab** file in the **etc** directory. Then, create the **rcS** and **S***xxx* files in the **init.d** file and edit them based on product requirements. 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ci6. (Optional) Configure the file system image for the development board that supports the file system.<br> Create the **fs.yml** file in the product directory, and configure it as required. A typical **fs.yml** file is as follows: 196e41f4b71Sopenharmony_ci 197e41f4b71Sopenharmony_ci ```shell 198e41f4b71Sopenharmony_ci - 199e41f4b71Sopenharmony_ci fs_dir_name: rootfs # Image name 200e41f4b71Sopenharmony_ci fs_dirs: 201e41f4b71Sopenharmony_ci - 202e41f4b71Sopenharmony_ci # Copy the files in the out/my_board/my_product/bin directory to the rootfs/bin directory and ignore the .bin files related to testing. 203e41f4b71Sopenharmony_ci source_dir: bin 204e41f4b71Sopenharmony_ci target_dir: bin 205e41f4b71Sopenharmony_ci ignore_files: 206e41f4b71Sopenharmony_ci - Test.bin 207e41f4b71Sopenharmony_ci - TestSuite.bin 208e41f4b71Sopenharmony_ci - 209e41f4b71Sopenharmony_ci # Copy the files in the out/my_board/my_product/libs directory to the rootfs/lib directory, ignore all .a files, and set the file permissions to 644 and folder permissions to 755. 210e41f4b71Sopenharmony_ci source_dir: libs 211e41f4b71Sopenharmony_ci target_dir: lib 212e41f4b71Sopenharmony_ci ignore_files: 213e41f4b71Sopenharmony_ci - .a 214e41f4b71Sopenharmony_ci dir_mode: 755 215e41f4b71Sopenharmony_ci file_mode: 644 216e41f4b71Sopenharmony_ci - 217e41f4b71Sopenharmony_ci source_dir: usr/lib 218e41f4b71Sopenharmony_ci target_dir: usr/lib 219e41f4b71Sopenharmony_ci ignore_files: 220e41f4b71Sopenharmony_ci - .a 221e41f4b71Sopenharmony_ci dir_mode: 755 222e41f4b71Sopenharmony_ci file_mode: 644 223e41f4b71Sopenharmony_ci - 224e41f4b71Sopenharmony_ci source_dir: config 225e41f4b71Sopenharmony_ci target_dir: etc 226e41f4b71Sopenharmony_ci - 227e41f4b71Sopenharmony_ci source_dir: system 228e41f4b71Sopenharmony_ci target_dir: system 229e41f4b71Sopenharmony_ci - 230e41f4b71Sopenharmony_ci source_dir: sbin 231e41f4b71Sopenharmony_ci target_dir: sbin 232e41f4b71Sopenharmony_ci - 233e41f4b71Sopenharmony_ci source_dir: usr/bin 234e41f4b71Sopenharmony_ci target_dir: usr/bin 235e41f4b71Sopenharmony_ci - 236e41f4b71Sopenharmony_ci source_dir: usr/sbin 237e41f4b71Sopenharmony_ci target_dir: usr/sbin 238e41f4b71Sopenharmony_ci - 239e41f4b71Sopenharmony_ci # Create an empty proc directory. 240e41f4b71Sopenharmony_ci target_dir: proc 241e41f4b71Sopenharmony_ci - 242e41f4b71Sopenharmony_ci target_dir: mnt 243e41f4b71Sopenharmony_ci - 244e41f4b71Sopenharmony_ci target_dir: opt 245e41f4b71Sopenharmony_ci - 246e41f4b71Sopenharmony_ci target_dir: tmp 247e41f4b71Sopenharmony_ci - 248e41f4b71Sopenharmony_ci target_dir: var 249e41f4b71Sopenharmony_ci - 250e41f4b71Sopenharmony_ci target_dir: sys 251e41f4b71Sopenharmony_ci - 252e41f4b71Sopenharmony_ci source_dir: etc 253e41f4b71Sopenharmony_ci target_dir: etc 254e41f4b71Sopenharmony_ci - 255e41f4b71Sopenharmony_ci source_dir: vendor 256e41f4b71Sopenharmony_ci target_dir: vendor 257e41f4b71Sopenharmony_ci - 258e41f4b71Sopenharmony_ci target_dir: storage 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci fs_filemode: 261e41f4b71Sopenharmony_ci - 262e41f4b71Sopenharmony_ci file_dir: lib/ld-uClibc-0.9.33.2.so 263e41f4b71Sopenharmony_ci file_mode: 555 264e41f4b71Sopenharmony_ci - 265e41f4b71Sopenharmony_ci file_dir: lib/ld-2.24.so 266e41f4b71Sopenharmony_ci file_mode: 555 267e41f4b71Sopenharmony_ci - 268e41f4b71Sopenharmony_ci file_dir: etc/init.cfg 269e41f4b71Sopenharmony_ci file_mode: 400 270e41f4b71Sopenharmony_ci fs_symlink: 271e41f4b71Sopenharmony_ci - 272e41f4b71Sopenharmony_ci # Create the soft link ld-musl-arm.so.1 -> libc.so in the rootfs/lib directory. 273e41f4b71Sopenharmony_ci source: libc.so 274e41f4b71Sopenharmony_ci link_name: ${fs_dir}/lib/ld-musl-arm.so.1 275e41f4b71Sopenharmony_ci - 276e41f4b71Sopenharmony_ci source: mksh 277e41f4b71Sopenharmony_ci link_name: ${fs_dir}/bin/sh 278e41f4b71Sopenharmony_ci - 279e41f4b71Sopenharmony_ci source: mksh 280e41f4b71Sopenharmony_ci link_name: ${fs_dir}/bin/shell 281e41f4b71Sopenharmony_ci fs_make_cmd: 282e41f4b71Sopenharmony_ci # Run the script to create an ext4 image from rootfs. 283e41f4b71Sopenharmony_ci - ${root_path}/build/lite/make_rootfs/rootfsimg_linux.sh ${fs_dir} ext4 284e41f4b71Sopenharmony_ci - 285e41f4b71Sopenharmony_ci fs_dir_name: userfs 286e41f4b71Sopenharmony_ci fs_dirs: 287e41f4b71Sopenharmony_ci - 288e41f4b71Sopenharmony_ci source_dir: storage/etc 289e41f4b71Sopenharmony_ci target_dir: etc 290e41f4b71Sopenharmony_ci - 291e41f4b71Sopenharmony_ci source_dir: data 292e41f4b71Sopenharmony_ci target_dir: data 293e41f4b71Sopenharmony_ci fs_make_cmd: 294e41f4b71Sopenharmony_ci - ${root_path}/build/lite/make_rootfs/rootfsimg_linux.sh ${fs_dir} ext4 295e41f4b71Sopenharmony_ci ``` 296e41f4b71Sopenharmony_ci 297e41f4b71Sopenharmony_ci7. (Optional) Configure patches if the product and components need to be patched.<br>Create a **patch.yml** file in the product directory. A typical **patch.yml** file is as follows: 298e41f4b71Sopenharmony_ci 299e41f4b71Sopenharmony_ci ```shell 300e41f4b71Sopenharmony_ci # Directory in which the patch is to be installed 301e41f4b71Sopenharmony_ci foundation/communication/dsoftbus: 302e41f4b71Sopenharmony_ci # Directory in which the patch is stored 303e41f4b71Sopenharmony_ci - foundation/communication/dsoftbus/1.patch 304e41f4b71Sopenharmony_ci - foundation/communication/dsoftbus/2.patch 305e41f4b71Sopenharmony_ci third_party/wpa_supplicant: 306e41f4b71Sopenharmony_ci - third_party/wpa_supplicant/1.patch 307e41f4b71Sopenharmony_ci - third_party/wpa_supplicant/2.patch 308e41f4b71Sopenharmony_ci - third_party/wpa_supplicant/3.patch 309e41f4b71Sopenharmony_ci ... 310e41f4b71Sopenharmony_ci ``` 311e41f4b71Sopenharmony_ci 312e41f4b71Sopenharmony_ci Add **--patch** when running the **hb build** command. Then, the patch files can be added to the specified directory before the build. 313e41f4b71Sopenharmony_ci 314e41f4b71Sopenharmony_ci ```shell 315e41f4b71Sopenharmony_ci hb build -f --patch 316e41f4b71Sopenharmony_ci ``` 317e41f4b71Sopenharmony_ci 318e41f4b71Sopenharmony_ci8. Write the build script. <br>Create a **BUILD.gn** file in the product directory and write the script. The following **BUILD.gn** file uses the Wi-Fi IoT module in Step 1 as an example: 319e41f4b71Sopenharmony_ci 320e41f4b71Sopenharmony_ci ```shell 321e41f4b71Sopenharmony_ci group("wifiiot") { # The target name must be the same as the product name. 322e41f4b71Sopenharmony_ci deps = [] 323e41f4b71Sopenharmony_ci deps += [ "init_configs" ] # Copy init configuration. 324e41f4b71Sopenharmony_ci deps += [ "hals" ] # Add hals. 325e41f4b71Sopenharmony_ci ... # Others 326e41f4b71Sopenharmony_ci } 327e41f4b71Sopenharmony_ci ``` 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci9. Build the product.<br> You can start the build by using the [CLI or hb tool](subsys-build-all.md#build-commands). The following uses the CLI as an example. For example, the product name is **hispark_taurus_standard**. Run the following command: 330e41f4b71Sopenharmony_ci 331e41f4b71Sopenharmony_ci ``` 332e41f4b71Sopenharmony_ci ./build.sh --product-name hispark_taurus_standard --ccache 333e41f4b71Sopenharmony_ci ``` 334e41f4b71Sopenharmony_ci 335e41f4b71Sopenharmony_ci 336