setting-up-the-environment.md 18.9 KB
Newer Older
M
mamingshuai 已提交
1
# Setting Up the Environment<a name="EN-US_TOPIC_0000001105989316"></a>
N
NEEN 已提交
2

M
mamingshuai 已提交
3 4 5 6 7
-   [Environment Requirements](#section466851916410)
    -   [Hardware](#section19202111020215)
    -   [Software](#section727451210318)

-   [Install Linux Build Tools](#section497484245614)
N
NEEN 已提交
8
    -   [Installing Basic Software Used for Compilation and Building \(Required Only for Ubuntu 20+\)](#section45512412251)
M
mamingshuai 已提交
9
    -   [Installing Scons](#section7438245172514)
N
NEEN 已提交
10
    -   [Installing Python Modules](#section88701892341)
M
mamingshuai 已提交
11 12 13 14 15
    -   [Installing gcc\_riscv32 \(Compilation Toolchain for WLAN Module\)](#section34435451256)

-   [Installing the USB-to-Serial Driver](#section1027732411513)

## Environment Requirements<a name="section466851916410"></a>
N
NEEN 已提交
16

M
mamingshuai 已提交
17
### Hardware<a name="section19202111020215"></a>
N
NEEN 已提交
18

M
mamingshuai 已提交
19 20 21 22
-   Linux compile server
-   Windows workstation \(host computer\)
-   Hi3861 WLAN module
-   USB Type-C cable used to connect the Windows workstation to Hi3861 WLAN module
N
NEEN 已提交
23

M
mamingshuai 已提交
24
The following figure shows the hardware connections.
N
NEEN 已提交
25

M
mamingshuai 已提交
26 27 28 29
**Figure  1**  Hardware connections<a name="fig12122108211"></a>  
![](figures/hardware-connections.png "hardware-connections")

### Software<a name="section727451210318"></a>
N
NEEN 已提交
30

N
NEEN 已提交
31
>![](public_sys-resources/icon-notice.gif) **NOTICE:** 
M
mamingshuai 已提交
32
>The following part describes how to install tools using installation packages. If you use Docker to set up the build environment, you only need to install the Windows workstation described in  [Table 1](#table6299192712513).
N
NEEN 已提交
33

M
mamingshuai 已提交
34
The following table lists the tools required for the Hi3861 development board.
N
NEEN 已提交
35

M
mamingshuai 已提交
36
**Table  1**  Required tools
N
NEEN 已提交
37 38 39 40 41 42 43 44 45 46 47 48

<a name="table6299192712513"></a>
<table><thead align="left"><tr id="row122993276512"><th class="cellrowborder" valign="top" width="17.54%" id="mcps1.2.5.1.1"><p id="p162491657102110"><a name="p162491657102110"></a><a name="p162491657102110"></a>Platform</p>
</th>
<th class="cellrowborder" valign="top" width="19.89%" id="mcps1.2.5.1.2"><p id="p1829914271858"><a name="p1829914271858"></a><a name="p1829914271858"></a>Development Tool</p>
</th>
<th class="cellrowborder" valign="top" width="26.279999999999998%" id="mcps1.2.5.1.3"><p id="p429918274517"><a name="p429918274517"></a><a name="p429918274517"></a>Description</p>
</th>
<th class="cellrowborder" valign="top" width="36.29%" id="mcps1.2.5.1.4"><p id="p12997271757"><a name="p12997271757"></a><a name="p12997271757"></a>How to Obtain</p>
</th>
</tr>
</thead>
N
NEEN 已提交
49 50 51 52 53 54 55 56 57 58
<tbody><tr id="row935218593572"><td class="cellrowborder" valign="top" width="17.54%" headers="mcps1.2.5.1.1 "><p id="p105554418586"><a name="p105554418586"></a><a name="p105554418586"></a>Linux server</p>
</td>
<td class="cellrowborder" valign="top" width="19.89%" headers="mcps1.2.5.1.2 "><p id="p45551740589"><a name="p45551740589"></a><a name="p45551740589"></a>Basic software package for compilation and building (required only for Ubuntu 20+)</p>
</td>
<td class="cellrowborder" valign="top" width="26.279999999999998%" headers="mcps1.2.5.1.3 "><p id="p655594115814"><a name="p655594115814"></a><a name="p655594115814"></a>Provides a basic software package for compilation and building.</p>
</td>
<td class="cellrowborder" valign="top" width="36.29%" headers="mcps1.2.5.1.4 "><p id="p165558415589"><a name="p165558415589"></a><a name="p165558415589"></a>Internet</p>
</td>
</tr>
<tr id="row1397335913612"><td class="cellrowborder" valign="top" width="17.54%" headers="mcps1.2.5.1.1 "><p id="p3711468218"><a name="p3711468218"></a><a name="p3711468218"></a>Linux server</p>
N
NEEN 已提交
59 60 61 62 63 64 65 66
</td>
<td class="cellrowborder" valign="top" width="19.89%" headers="mcps1.2.5.1.2 "><p id="p097355911620"><a name="p097355911620"></a><a name="p097355911620"></a>SCons 3.0.4+</p>
</td>
<td class="cellrowborder" valign="top" width="26.279999999999998%" headers="mcps1.2.5.1.3 "><p id="p1973195917619"><a name="p1973195917619"></a><a name="p1973195917619"></a>Executes script compilation.</p>
</td>
<td class="cellrowborder" valign="top" width="36.29%" headers="mcps1.2.5.1.4 "><p id="p1722663441514"><a name="p1722663441514"></a><a name="p1722663441514"></a>Internet</p>
</td>
</tr>
N
NEEN 已提交
67 68 69 70 71 72 73 74 75 76
<tr id="row1968013216717"><td class="cellrowborder" valign="top" width="17.54%" headers="mcps1.2.5.1.1 "><p id="p2681632977"><a name="p2681632977"></a><a name="p2681632977"></a>Linux server</p>
</td>
<td class="cellrowborder" valign="top" width="19.89%" headers="mcps1.2.5.1.2 "><p id="p1991501391312"><a name="p1991501391312"></a><a name="p1991501391312"></a>Python modules: setuptools, Kconfiglib, PyCryptodome, six, and ecdsa</p>
</td>
<td class="cellrowborder" valign="top" width="26.279999999999998%" headers="mcps1.2.5.1.3 "><p id="p968120325715"><a name="p968120325715"></a><a name="p968120325715"></a>Executes script compilation.</p>
</td>
<td class="cellrowborder" valign="top" width="36.29%" headers="mcps1.2.5.1.4 "><p id="p268116326711"><a name="p268116326711"></a><a name="p268116326711"></a>Internet</p>
</td>
</tr>
<tr id="row020914491313"><td class="cellrowborder" valign="top" width="17.54%" headers="mcps1.2.5.1.1 "><p id="p20209749103116"><a name="p20209749103116"></a><a name="p20209749103116"></a>Linux server</p>
N
NEEN 已提交
77
</td>
N
NEEN 已提交
78
<td class="cellrowborder" valign="top" width="19.89%" headers="mcps1.2.5.1.2 "><p id="p7209104910317"><a name="p7209104910317"></a><a name="p7209104910317"></a>gcc riscv32</p>
N
NEEN 已提交
79
</td>
N
NEEN 已提交
80
<td class="cellrowborder" valign="top" width="26.279999999999998%" headers="mcps1.2.5.1.3 "><p id="p102093498311"><a name="p102093498311"></a><a name="p102093498311"></a>Executes script compilation.</p>
N
NEEN 已提交
81
</td>
N
NEEN 已提交
82
<td class="cellrowborder" valign="top" width="36.29%" headers="mcps1.2.5.1.4 "><p id="p321054953116"><a name="p321054953116"></a><a name="p321054953116"></a>Internet</p>
N
NEEN 已提交
83 84 85 86 87 88 89 90
</td>
</tr>
<tr id="row1596703610215"><td class="cellrowborder" valign="top" width="17.54%" headers="mcps1.2.5.1.1 "><p id="p071946112113"><a name="p071946112113"></a><a name="p071946112113"></a>Windows workstation</p>
</td>
<td class="cellrowborder" valign="top" width="19.89%" headers="mcps1.2.5.1.2 "><p id="p1044974291416"><a name="p1044974291416"></a><a name="p1044974291416"></a>CH341SER.EXE</p>
</td>
<td class="cellrowborder" valign="top" width="26.279999999999998%" headers="mcps1.2.5.1.3 "><p id="p94491342131413"><a name="p94491342131413"></a><a name="p94491342131413"></a>USB-to-Serial adapter driver</p>
</td>
M
mamingshuai 已提交
91
<td class="cellrowborder" valign="top" width="36.29%" headers="mcps1.2.5.1.4 "><p id="p6449184214148"><a name="p6449184214148"></a><a name="p6449184214148"></a><a href="http://www.wch-ic.com/search?t=downloads&amp;q=ch340g" target="_blank" rel="noopener noreferrer">http://www.wch-ic.com/search?t=downloads&amp;q=ch340g</a></p>
N
NEEN 已提交
92 93 94 95 96
</td>
</tr>
</tbody>
</table>

M
mamingshuai 已提交
97
## Install Linux Build Tools<a name="section497484245614"></a>
N
NEEN 已提交
98 99

>![](public_sys-resources/icon-notice.gif) **NOTICE:** 
M
mamingshuai 已提交
100 101
>-   If you acquire the source code using an HPM component or HPM CLI tool, you do not need to install  **gcc\_riscv32**.
>-   \(Recommended\) If you obtain the source code via the mirror site or code repository, install  **gcc\_riscv32**. When installing the compilation tool, ensure that its environment variable path is unique.
N
NEEN 已提交
102

N
NEEN 已提交
103 104 105 106 107 108 109 110
### Installing Basic Software Used for Compilation and Building \(Required Only for Ubuntu 20+\)<a name="section45512412251"></a>

Install the software.

```
sudo apt-get install build-essential && sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install make && sudo apt-get install zlib* && sudo apt-get install libffi-dev
```

M
mamingshuai 已提交
111
### Installing Scons<a name="section7438245172514"></a>
N
NEEN 已提交
112 113 114 115 116

1.  Start a Linux server.
2.  Install the SCons installation package.

    ```
N
NEEN 已提交
117 118 119 120 121 122 123
    python3 -m pip install scons
    ```

3.  Check whether the installation is successful.

    ```
    scons -v
N
NEEN 已提交
124 125
    ```

M
mamingshuai 已提交
126
    **Figure  2**  Successful installation \(SCons version requirement: 3.0.4 or later\)<a name="fig235815252492"></a>  
N
NEEN 已提交
127 128
    ![](figures/successful-installation-(scons-version-requirement-3-0-4-or-later).png "successful-installation-(scons-version-requirement-3-0-4-or-later)")

N
NEEN 已提交
129

N
NEEN 已提交
130 131 132 133 134 135 136 137 138 139
### Installing Python Modules<a name="section88701892341"></a>

1.  Install setuptools.

    ```
    pip3 install setuptools
    ```

2.  Install the GUI menuconfig tool \(Kconfiglib\). You are advised to install Kconfiglib 13.2.0 or later.
    -   **Command line:**
N
NEEN 已提交
140 141

        ```
N
NEEN 已提交
142
        sudo pip3 install kconfiglib
N
NEEN 已提交
143 144
        ```

N
NEEN 已提交
145 146 147

    -   **Installation package:**
        1.  Download the  **.whl**  file \(for example,  **kconfiglib-13.2.0-py2.py3-none-any.whl**\).
N
NEEN 已提交
148

N
NEEN 已提交
149 150 151 152
            Download path:  [https://pypi.org/project/kconfiglib\#files](https://pypi.org/project/kconfiglib#files)


        1.  Install the  **.whl**  file.
N
NEEN 已提交
153

N
NEEN 已提交
154 155 156 157 158 159 160 161 162 163 164
            ```
            sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl
            ```



3.  Install  **PyCryptodome**  using either of the following methods:

    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.

    -   **Command line:**
N
NEEN 已提交
165 166

        ```
N
NEEN 已提交
167
        sudo pip3 install pycryptodome
N
NEEN 已提交
168 169
        ```

N
NEEN 已提交
170 171
    -   **Installation package:**
        1.  Download the  **.whl**  file \(for example,  **pycryptodome-3.9.9-cp38-cp38-manylinux1\_x86\_64.whl**\).
N
NEEN 已提交
172

N
NEEN 已提交
173 174 175 176
            Download path:  [https://pypi.org/project/pycryptodome/\#files](https://pypi.org/project/pycryptodome/#files)


        1.  Install the  **.whl**  file.
N
NEEN 已提交
177

N
NEEN 已提交
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
            ```
            sudo pip3 install pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl
            ```



4.  Install  **six**  using either of the following methods:
    -   **Command line:**

        ```
        sudo pip3 install six --upgrade --ignore-installed six
        ```


    -   **Installation package:**
        1.  Download the  **.whl**  file, for example,  **six-1.12.0-py2.py3-none-any.whl**.
N
NEEN 已提交
194

N
NEEN 已提交
195 196 197 198
            Download path:  [https://pypi.org/project/six/\#files](https://pypi.org/project/six/#files)


        1.  Install the  **.whl**  file.
N
NEEN 已提交
199

N
NEEN 已提交
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
            ```
            sudo pip3 install six-1.12.0-py2.py3-none-any.whl
            ```



5.  Install  **ecdsa**  using either of the following methods:
    -   **Command line:**

        ```
        sudo pip3 install ecdsa
        ```

    -   **Installation package:**
        1.  Download the  **.whl**  file, for example,  **ecdsa-0.14.1-py2.py3-none-any.whl**.

            Download path:  [https://pypi.org/project/ecdsa/\#files](https://pypi.org/project/ecdsa/#files)


        1.  Install the  **.whl**  file.
N
NEEN 已提交
220

N
NEEN 已提交
221 222 223
            ```
            sudo pip3 install ecdsa-0.14.1-py2.py3-none-any.whl
            ```
N
NEEN 已提交
224 225 226 227




M
mamingshuai 已提交
228
### Installing gcc\_riscv32 \(Compilation Toolchain for WLAN Module\)<a name="section34435451256"></a>
N
NEEN 已提交
229 230

>![](public_sys-resources/icon-notice.gif) **NOTICE:** 
M
mamingshuai 已提交
231 232
>-   The Hi3861 platform 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.
>-   Steps 2 to 15 of the following procedure are used to build the  **gcc\_riscv32**  image. You can simply  [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.
N
NEEN 已提交
233 234 235 236 237 238 239 240 241 242 243

1.  Start a Linux server.
2.  Install the  **GCC**,  **G++**,  **Bison**,  **Flex**,  **Makeinfo**  tools to ensure that the toolchain can be correctly compiled.

    ```
    sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install flex bison && sudo apt-get install texinfo
    ```

3.  Download the RISC-V GNU toolchain.

    ```
N
NEEN 已提交
244
    git clone --recursive https://gitee.com/mirrors/riscv-gnu-toolchain.git
N
NEEN 已提交
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
    ```

4.  Open the  **riscv-gnu-toolchain**  folder and delete empty folders to prevent conflicts during the download of  **Newlib**,  **Binutils**, and  **GCC**.

    ```
    cd riscv-gnu-toolchain && rm -rf riscv-newlib && rm -rf riscv-binutils && rm -rf riscv-gcc
    ```

5.  Download RISC-V Newlib 3.0.0.

    ```
    git clone -b riscv-newlib-3.0.0 https://github.com/riscv/riscv-newlib.git
    ```

6.  Download RISC-V Binutils 2.31.1.

    ```
    git clone -b riscv-binutils-2.31.1 https://github.com/riscv/riscv-binutils-gdb.git
    ```

7.  Download RISC-V GCC 7.3.0.

    ```
    git clone -b riscv-gcc-7.3.0 https://github.com/riscv/riscv-gcc
    ```

8.  Add the RISC-V GCC 7.3.0 patch.

    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 different versions of the patch and GCC. You need to search for the keyword in the patch to locate the corresponding row.

9.  Download, decompress, and install  [GMP 6.1.2](https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2).

    ```
    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
    ```

10. Download, decompress, and install  [mpfr-4.0.2](https://www.mpfr.org/mpfr-4.0.2/mpfr-4.0.2.tar.gz).

    ```
    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
    ```

11. Download, decompress, and install  [mpc-1.1.0](https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz).

    ```
    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
    ```

12. Open the  **riscv-gnu-toolchain**  folder and create a directory for toolchain output.

    ```
    cd /opt && mkdir gcc_riscv32
    ```

N
NEEN 已提交
299
13. Compile  **binutils**.
N
NEEN 已提交
300 301 302 303 304 305 306 307

    ```
    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 ..
    ```

14. Build  **Newlib**.

    ```
N
NEEN 已提交
308
    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 ..
N
NEEN 已提交
309 310 311 312 313 314 315 316 317 318
    ```

15. Build  **GCC**.

    ```
    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
    ```

16. Set an environment variable.

M
mamingshuai 已提交
319 320 321 322
    >![](public_sys-resources/icon-note.gif) **NOTE:** 
    >If you use the compiled  **riscv32 gcc**  package, perform the following steps to set environment variables:
    >1.  Decompress the package to the root directory.
    >    ```
S
--amend  
shaunyoung 已提交
323
    >    tar -xvf gcc_riscv32-linux-7.3.0.tar.gz -C /opt
M
mamingshuai 已提交
324 325 326 327 328 329 330 331 332 333
    >    ```
    >2.  Set an environment variable.
    >    ```
    >    vim ~/.bashrc
    >    ```
    >3.  Copy the following command to the last line of the  **.bashrc**  file, save the file, and exit.
    >    ```
    >    export PATH=/opt/gcc_riscv32/bin:$PATH
    >    ```

N
NEEN 已提交
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
    ```
    vim ~/.bashrc
    ```

    Copy the following command to the last line of the  **.bashrc**  file, save the file, and exit.

    ```
    export PATH=/opt/gcc_riscv32/bin:$PATH
    ```

17. Validate the environment variable.

    ```
    source ~/.bashrc
    ```

18. Check whether the compiler is successfully installed. If the compiler version number is correctly displayed, the installation is successful.

    ```
    riscv32-unknown-elf-gcc -v
    ```


M
mamingshuai 已提交
357 358 359 360 361 362 363 364 365 366 367
## Installing the USB-to-Serial Driver<a name="section1027732411513"></a>

Perform the following operations on the Windows station.

1.  Download the USB-to-serial driver:  [CH341SER USB-to-serial driver](http://www.wch-ic.com/search?t=all&q=CH340g).
2.  Install the driver.
3.  After the driver is installed, remove and then insert the USB cable. The serial port entry should be displayed as shown in the following figure.

    ![](figures/en-us_image_0000001057235392.png)