• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 安装Hi3861开发板环境
2
3
4## Hi3861工具要求
5
6
7### 硬件要求
8
9- Linux工作台
10
11- Hi3861 WLAN模组
12
13- USB Type-C线(Linux工作台通过USB与Hi3861开发板连接)
14
15
16### 软件要求
17
18
19Hi3861 WLAN模组需要的工具如下表所示。
20
21
22  **表1** Hi3861 WLAN模组需要安装的编译工具
23
24| 开发工具 | 用途 |
25| -------- | -------- |
26| SCons3.0.4+ | 编译构建工具 |
27| python模块:setuptools、kconfiglib、pycryptodome、six、ecdsa | 编译构建工具 |
28| gcc riscv32 | 编译构建工具 |
29
30
31## 安装编译工具
32
33编译Hi3861 WLAN模组需要一些特定的编译工具,在Ubuntu下通过以下步骤安装。
34
35
36### 安装Scons
37
381. 运行如下命令,安装SCons安装包。
39
40   ```
41   python3 -m pip install scons
42   ```
43
442. 运行如下命令,查看是否安装成功。如果安装成功,查询结果下图所示。
45
46   ```
47   scons -v
48   ```
49
50     **图1** SCons安装成功界面,版本要求3.0.4以上
51
52     ![zh-cn_image_0000001271234749](figures/zh-cn_image_0000001271234749.png)
53
54
55### 安装python模块
56
571. 运行如下命令,安装python模块setuptools。
58
59   ```
60   pip3 install setuptools
61   ```
62
632. 安装GUI menuconfig工具(Kconfiglib),建议安装Kconfiglib 13.2.0+版本,任选如下一种方式。
64
65   - **命令行方式:**
66
67      ```
68      sudo pip3 install kconfiglib
69      ```
70   - **安装包方式:**
71
72      1. 下载.whl文件(例如:kconfiglib-13.2.0-py2.py3-none-any.whl)。
73
74          下载路径:“[https://pypi.org/project/kconfiglib#files](https://pypi.org/project/kconfiglib#files)75
76      2. 运行如下命令,安装.whl文件。
77
78          ```
79          sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl
80          ```
81
823. 安装pycryptodome,任选如下一种方式。
83
84     安装升级文件签名依赖的Python组件包,包括:pycryptodome、six、ecdsa。安装ecdsa依赖six,请先安装six,再安装ecdsa。
85
86   - **命令行方式:**
87
88     ```
89     sudo pip3 install pycryptodome
90     ```
91
92   - **安装包方式:**
93
94     1. 下载.whl文件(例如:pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl)。
95
96        下载路径:“[https://pypi.org/project/pycryptodome/#files](https://pypi.org/project/pycryptodome/#files)”。
97
98     2. 运行如下命令,安装.whl文件。
99
100         ```
101         sudo pip3 install pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl
102         ```
103
1044. 安装six,任选如下一种方式。
105
106   - **命令行方式:**
107
108      ```
109      sudo pip3 install six --upgrade --ignore-installed six
110      ```
111
112   - **安装包方式:**
113
114      1. 下载.whl文件(例如:six-1.12.0-py2.py3-none-any.whl)。
115
116         下载路径:“[https://pypi.org/project/six/#files](https://pypi.org/project/six/#files)117
118      2. 运行如下命令,安装.whl文件。
119
120          ```
121          sudo pip3 install six-1.12.0-py2.py3-none-any.whl
122          ```
123
1245. 安装ecdsa,任选如下一种方式。
125
126   - **命令行方式:**
127
128      ```
129      sudo pip3 install ecdsa
130      ```
131
132   - **安装包方式:**
133
134      1. 下载.whl文件(例如:ecdsa-0.14.1-py2.py3-none-any.whl)。
135
136         下载路径:“[https://pypi.org/project/ecdsa/#files](https://pypi.org/project/ecdsa/#files)137
138      2. 运行如下命令,安装.whl文件。
139
140          ```
141          sudo pip3 install ecdsa-0.14.1-py2.py3-none-any.whl
142          ```
143
144
145### 安装gcc_riscv32(WLAN模组类编译工具链)
146
147> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:**
148> - Hi3861开发板平台仅支持使用libgcc运行时库的静态链接,不建议开发者使用libgcc运行时库的动态链接,以免产品需遵从GPLV3许可证。
149>
150> - 通过下述步骤2-14,我们编译好了gcc_riscv32镜像,提供给开发者[直接下载](https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz)使用。直接下载gcc_riscv32镜像的开发者可省略下述2-14步。
151
1521. 打开Linux编译服务器终端。
153
1542. 下载riscv-gnu-toolchain交叉编译工具链。
155
156   ```
157   git clone --recursive https://gitee.com/mirrors/riscv-gnu-toolchain.git
158   ```
159
1603. 打开文件夹riscv-gnu-toolchain,先删除空文件夹,以防止下载newlib,binutils,gcc时冲突。
161
162   ```
163   cd riscv-gnu-toolchain && rm -rf riscv-newlib && rm -rf riscv-binutils && rm -rf riscv-gcc
164   ```
165
1664. 下载riscv-newlib-3.0.0。
167
168   ```
169   git clone -b riscv-newlib-3.0.0 https://github.com/riscv/riscv-newlib.git
170   ```
171
1725. 下载riscv-binutils-2.31.1。
173
174   ```
175   git clone -b riscv-binutils-2.31.1 https://github.com/riscv/riscv-binutils-gdb.git
176   ```
177
1786. 下载riscv-gcc-7.3.0。
179
180   ```
181   git clone -b riscv-gcc-7.3.0 https://github.com/riscv/riscv-gcc
182   ```
183
1847. 添加riscv-gcc-7.3.0补丁。
185
186   访问gcc官方补丁链接[89411](https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=026216a753ef0a757a9e368a59fa667ea422cf09;hp=2a23a1c39fb33df0277abd4486a3da64ae5e62c2),[86724](https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=gcc/graphite.h;h=be0a22b38942850d88feb159603bb846a8607539;hp=4e0e58c60ab83f1b8acf576e83330466775fac17;hb=b1761565882ed6a171136c2c89e597bc4dd5b6bf;hpb=fbd5f023a03f9f60c6ae36133703af5a711842a3),按照补丁链接中要求的修改,手动将变更添加到对应的.c和.h文件中,注意由于patch版本与下载的gcc版本有所偏差,行数有可能对应不上,请自行查找patch中的关键字定位到对应行。
187
1888. 下载[GMP 6.1.2](https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2),并解压安装。
189
190   ```
191   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
192   ```
193
1949. 下载[mpfr-4.0.2 ](https://www.mpfr.org/mpfr-4.0.2/mpfr-4.0.2.tar.gz),并解压安装。
195
196   ```
197   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
198   ```
199
20010. 下载[mpc-1.1.0](https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz) ,并解压安装。
201
202    ```
203    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
204    ```
205
20611. 打开文件夹riscv-gnu-toolchain,新建工具链输出目录。
207
208    ```
209    cd /opt && mkdir gcc_riscv32
210    ```
211
21212. 编译binutils。
213
214    ```
215    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 ..
216    ```
217
21813. 编译newlib。
219
220    ```
221    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 ..
222    ```
223
22414. 编译gcc。
225
226    ```
227    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
228    ```
229
23015. 设置环境变量。
231
232    > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
233    >   如果直接采用编译好的riscv32 gcc包,请先执行以下命令将压缩包解压到根目录:
234    >
235    > ```
236    > tar -xvf gcc_riscv32-linux-7.3.0.tar.gz -C ~
237    > ```
238
239
240
241    ```
242    vim ~/.bashrc
243    ```
244
245    将以下命令拷贝到.bashrc文件的最后一行,保存并退出。
246
247
248    ```
249    export PATH=~/gcc_riscv32/bin:$PATH
250    ```
251
25216. 生效环境变量。
253
254    ```
255    source ~/.bashrc
256    ```
257
25817. Shell命令行中输入如下命令,如果能正确显示编译器版本号,表明编译器安装成功。
259
260    ```
261    riscv32-unknown-elf-gcc -v
262    ```
263