1e41f4b71Sopenharmony_ci# Installing Tools Specially Required by the Hi3861 Development Board 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ciIn addition to the general [libraries and tools](quickstart-pkg-install-package.md) and [compilation tools](quickstart-pkg-install-tool.md), the Hi3861 development board requires the tools listed in this topic for source code building. 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci## Required Tools 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci **Table 1** Tools required by the Hi3861 WLAN module 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci| Tool| Function| 12e41f4b71Sopenharmony_ci| -------- | -------- | 13e41f4b71Sopenharmony_ci| SCons3.0.4+ | Executes script compilation.| 14e41f4b71Sopenharmony_ci| Python modules: setuptools, Kconfiglib, PyCryptodome, six, and ecdsa| Executes script compilation.| 15e41f4b71Sopenharmony_ci| gcc riscv32 | Executes script compilation.| 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci## Procedure 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ciPerform the following steps in Ubuntu. 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci### Installing Scons 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci1. Run the following command to install the SCons installation package: 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci ``` 28e41f4b71Sopenharmony_ci python3 -m pip install scons 29e41f4b71Sopenharmony_ci ``` 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci2. Run the following command to check whether SCons is successfully installed. If the installation is successful, the query result as shown below is displayed. 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci ``` 34e41f4b71Sopenharmony_ci scons -v 35e41f4b71Sopenharmony_ci ``` 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci **Figure 1** Successful SCons installation (the version must be 3.0.4 or later) 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci  40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci### Installing Python Modules 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci1. Install setuptools. 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci ``` 47e41f4b71Sopenharmony_ci pip3 install setuptools 48e41f4b71Sopenharmony_ci ``` 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci2. Install the GUI menuconfig tool (Kconfiglib). You are advised to install Kconfiglib 13.2.0 or later. 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci - **Command line:** 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci ``` 55e41f4b71Sopenharmony_ci sudo pip3 install kconfiglib 56e41f4b71Sopenharmony_ci ``` 57e41f4b71Sopenharmony_ci - **Installation package:** 58e41f4b71Sopenharmony_ci 1. Download the .whl file, for example, **kconfiglib-13.2.0-py2.py3-none-any.whl**. 59e41f4b71Sopenharmony_ci Download path: [https://pypi.org/project/kconfiglib#files](https://pypi.org/project/kconfiglib#files) 60e41f4b71Sopenharmony_ci 2. Install the .whl file. 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci ``` 63e41f4b71Sopenharmony_ci sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl 64e41f4b71Sopenharmony_ci ``` 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci3. Install PyCryptodome using either of the following methods: 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci Install the Python component packages on which the file signature depends, including **PyCryptodome**, **six**, and **ecdsa**. As the installation of **ecdsa** depends on that of **six**, install **six** first. 69e41f4b71Sopenharmony_ci - **Command line:** 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci ``` 72e41f4b71Sopenharmony_ci sudo pip3 install pycryptodome 73e41f4b71Sopenharmony_ci ``` 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci - **Installation package:** 76e41f4b71Sopenharmony_ci 1. Download the .whl file, for example, **pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl**. 77e41f4b71Sopenharmony_ci Download path: [https://pypi.org/project/pycryptodome/#files](https://pypi.org/project/pycryptodome/#files) 78e41f4b71Sopenharmony_ci 2. Install the .whl file. 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci ``` 81e41f4b71Sopenharmony_ci sudo pip3 install pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl 82e41f4b71Sopenharmony_ci ``` 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci4. Install **six** using either of the following methods: 85e41f4b71Sopenharmony_ci - **Command line:** 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci ``` 88e41f4b71Sopenharmony_ci sudo pip3 install six --upgrade --ignore-installed six 89e41f4b71Sopenharmony_ci ``` 90e41f4b71Sopenharmony_ci - **Installation package:** 91e41f4b71Sopenharmony_ci 1. Download the .whl file, for example, **six-1.12.0-py2.py3-none-any.whl**. 92e41f4b71Sopenharmony_ci Download path: [https://pypi.org/project/six/#files](https://pypi.org/project/six/#files) 93e41f4b71Sopenharmony_ci 2. Install the .whl file. 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci ``` 96e41f4b71Sopenharmony_ci sudo pip3 install six-1.12.0-py2.py3-none-any.whl 97e41f4b71Sopenharmony_ci ``` 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci5. Install **ecdsa** using either of the following methods: 100e41f4b71Sopenharmony_ci - **Command line:** 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci ``` 103e41f4b71Sopenharmony_ci sudo pip3 install ecdsa 104e41f4b71Sopenharmony_ci ``` 105e41f4b71Sopenharmony_ci - **Installation package:** 106e41f4b71Sopenharmony_ci 1. Download the .whl file, for example, **ecdsa-0.14.1-py2.py3-none-any.whl**. 107e41f4b71Sopenharmony_ci Download path: [https://pypi.org/project/ecdsa/#files](https://pypi.org/project/ecdsa/#files) 108e41f4b71Sopenharmony_ci 2. Install the .whl file. 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci ``` 111e41f4b71Sopenharmony_ci sudo pip3 install ecdsa-0.14.1-py2.py3-none-any.whl 112e41f4b71Sopenharmony_ci ``` 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_ci### Installing gcc_riscv32 (Compiler Toolchain for the WLAN Module) 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci>  **NOTICE** 118e41f4b71Sopenharmony_ci> - Hi3861 supports only the static link of the libgcc library. The dynamic link is not recommended because version 3 of the GNU General Public License (GPLv3) will be polluted during commercial distribution. 119e41f4b71Sopenharmony_ci> 120e41f4b71Sopenharmony_ci> - Steps 2 to 14 of the following procedure are used to build the **gcc_riscv32** image. You can directly [download the image](https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz) and skip these steps. 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci1. Start the Linux server. 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci2. Download the **RISC-V GNU** toolchain. 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ci ``` 127e41f4b71Sopenharmony_ci git clone --recursive https://gitee.com/mirrors/riscv-gnu-toolchain.git 128e41f4b71Sopenharmony_ci ``` 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci3. Open the **riscv-gnu-toolchain** folder and delete empty folders to prevent conflicts during the download of Newlib, Binutils, and GCC. 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci ``` 133e41f4b71Sopenharmony_ci cd riscv-gnu-toolchain && rm -rf riscv-newlib && rm -rf riscv-binutils && rm -rf riscv-gcc 134e41f4b71Sopenharmony_ci ``` 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci4. Download RISC-V Newlib 3.0.0. 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci ``` 139e41f4b71Sopenharmony_ci git clone -b riscv-newlib-3.0.0 https://github.com/riscv/riscv-newlib.git 140e41f4b71Sopenharmony_ci ``` 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci5. Download RISC-V Binutils 2.31.1. 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ci ``` 145e41f4b71Sopenharmony_ci git clone -b riscv-binutils-2.31.1 https://github.com/riscv/riscv-binutils-gdb.git 146e41f4b71Sopenharmony_ci ``` 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci6. Download RISC-V GCC 7.3.0. 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci ``` 151e41f4b71Sopenharmony_ci git clone -b riscv-gcc-7.3.0 https://github.com/riscv/riscv-gcc 152e41f4b71Sopenharmony_ci ``` 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci7. Add the RISC-V GCC 7.3.0 patch. 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci Visit the GCC official patch links [89411](https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=026216a753ef0a757a9e368a59fa667ea422cf09;hp=2a23a1c39fb33df0277abd4486a3da64ae5e62c2) and [86724](https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=gcc/graphite.h;h=be0a22b38942850d88feb159603bb846a8607539;hp=4e0e58c60ab83f1b8acf576e83330466775fac17;hb=b1761565882ed6a171136c2c89e597bc4dd5b6bf;hpb=fbd5f023a03f9f60c6ae36133703af5a711842a3), and manually add the changes to the .c and .h files based on the requirements in the patch links. Note that the number of rows may not match because of the differences in the patch and GCC versions. If this is the case, search for the keyword in the patch to locate the corresponding row. 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci8. Download, decompress, and install [GMP 6.1.2](https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2). 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_ci ``` 161e41f4b71Sopenharmony_ci tar -xvf gmp-6.1.2.tar.bz2 && mkdir build_gmp && cd build_gmp && ../gmp-6.1.2/configure --prefix=/usr/local/gmp-6.1.2 --disable-shared --enable-cxx && make && make install 162e41f4b71Sopenharmony_ci ``` 163e41f4b71Sopenharmony_ci 164e41f4b71Sopenharmony_ci9. Download, decompress, and install [mpfr-4.0.2](https://www.mpfr.org/mpfr-4.0.2/mpfr-4.0.2.tar.gz). 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci ``` 167e41f4b71Sopenharmony_ci tar -xvf mpfr-4.0.2.tar.gz && mkdir build_mpfr && cd build_mpfr && ../mpfr-4.0.2/configure --prefix=/usr/local/mpfr-4.0.2 --with-gmp=/usr/local/gmp-6.1.2 --disable-shared && make && make install 168e41f4b71Sopenharmony_ci ``` 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ci10. Download, decompress, and install [mpc-1.1.0](https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz). 171e41f4b71Sopenharmony_ci 172e41f4b71Sopenharmony_ci ``` 173e41f4b71Sopenharmony_ci tar -xvf mpc-1.1.0.tar.gz && mkdir build_mpc && cd build_mpc && ../mpc-1.1.0/configure --prefix=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 --disable-shared && make && make install 174e41f4b71Sopenharmony_ci ``` 175e41f4b71Sopenharmony_ci 176e41f4b71Sopenharmony_ci11. Open the **riscv-gnu-toolchain** folder and create a directory for toolchain output. 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci ``` 179e41f4b71Sopenharmony_ci cd /opt && mkdir gcc_riscv32 180e41f4b71Sopenharmony_ci ``` 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci12. Build Binutils. 183e41f4b71Sopenharmony_ci 184e41f4b71Sopenharmony_ci ``` 185e41f4b71Sopenharmony_ci mkdir build_binutils && cd build_binutils && ../riscv-binutils-gdb/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --bindir=/opt/gcc_riscv32/bin --libexecdir=/opt/gcc_riscv32/riscv32 --libdir=/opt/gcc_riscv32 --includedir=/opt/gcc_riscv32 && make -j16 && make install && cd .. 186e41f4b71Sopenharmony_ci ``` 187e41f4b71Sopenharmony_ci 188e41f4b71Sopenharmony_ci13. Build Newlib. 189e41f4b71Sopenharmony_ci 190e41f4b71Sopenharmony_ci ``` 191e41f4b71Sopenharmony_ci mkdir build_newlib && cd build_newlib && ../riscv-newlib/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" \CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --bindir=/opt/gcc_riscv32/bin --libexecdir=/opt/gcc_riscv32 --libdir=/opt/gcc_riscv32 --includedir=/opt/gcc_riscv32 && make -j16 && make install && cd .. 192e41f4b71Sopenharmony_ci ``` 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci14. Build GCC. 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ci ``` 197e41f4b71Sopenharmony_ci mkdir build_gcc && cd build_gcc && ../riscv-gcc/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" LDFLAGS="-Wl,-z,relro,-z,now,-z,noexecstack" CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --with-headers="/opt/gcc-riscv32/riscv32-unknown-elf/include" --with-mpc=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 && make -j16 && make install 198e41f4b71Sopenharmony_ci ``` 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ci15. Set an environment variable. 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci >  **NOTE** 203e41f4b71Sopenharmony_ci > 204e41f4b71Sopenharmony_ci > If you are using the riscv32 gcc package, run the following command to decompress the package to the root directory: 205e41f4b71Sopenharmony_ci > 206e41f4b71Sopenharmony_ci > ``` 207e41f4b71Sopenharmony_ci > tar -xvf gcc_riscv32-linux-7.3.0.tar.gz -C ~ 208e41f4b71Sopenharmony_ci > ``` 209e41f4b71Sopenharmony_ci > Note that the path used for setting the environment variables is the root directory. 210e41f4b71Sopenharmony_ci 211e41f4b71Sopenharmony_ci Open the .bashrc file. 212e41f4b71Sopenharmony_ci 213e41f4b71Sopenharmony_ci ``` 214e41f4b71Sopenharmony_ci vim /opt/.bashrc 215e41f4b71Sopenharmony_ci ``` 216e41f4b71Sopenharmony_ci 217e41f4b71Sopenharmony_ci Copy the following command to the last line of the file, save the file, and exit. 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_ci ``` 220e41f4b71Sopenharmony_ci export PATH=/opt/gcc_riscv32/bin:$PATH 221e41f4b71Sopenharmony_ci ``` 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci16. Validate the environment variable. 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci ``` 226e41f4b71Sopenharmony_ci source /opt/.bashrc 227e41f4b71Sopenharmony_ci ``` 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ci17. Check whether the compiler is successfully installed. If the compiler version number is correctly displayed, the installation is successful. 230e41f4b71Sopenharmony_ci 231e41f4b71Sopenharmony_ci ``` 232e41f4b71Sopenharmony_ci riscv32-unknown-elf-gcc -v 233e41f4b71Sopenharmony_ci ``` 234e41f4b71Sopenharmony_ci<!--no_check-->