# Setting Up a Development Environment - [Environment Requirements](#section466851916410) - [Hardware](#section07318322310) - [Software](#section182305581332) - [Build Tools for Linux](#section20374218687) - [Development Tools for Windows](#section11161833102716) - [Installing Basic Compilation Environment](#section497484245614) - [Connecting to a Linux Server](#section15541530155711) - [Changing Linux Shell to Bash](#section182814544221) - [Installing a Python Environment](#section126831816258) - [Installing Scons](#section2462246562) - [Installing Compilation Tools](#section7227629152013) - [Installing gn](#section2024354014506) - [Installing ninjah](#section182441140185010) - [Installing gcc\_riscv32 \(Compilation Toolchain for WLAN Module\)](#section2014123416523) - [Installing the IDE Development Tool](#section1995840162515) ## Environment Requirements ## Hardware - Linux server - Windows workstation \(host computer\) - Hi3861 WLAN module - USB Type-C cable used to connect to Windows workstation and Hi3861 WLAN module [Figure 1](#fig1651211924914) shows the hardware connections. **Figure 1** Hardware connections ![](figures/hardware-connections.png "hardware-connections") ## Software **Table 1** Requirements on the development platform

Hardware

Software

Description

Remarks

Linux compile server

Operating system

Ubuntu 16.04 64-bit server or later (Use bash as the shell.)

You can develop programs on the Windows workstation or Linux server via a remote login.

Windows workstation

Operating system

Windows XP/Windows7/Windows10

## Build Tools for Linux The following table describes the tools required for setting up the general environment for a Linux server and how to obtain these tools. **Table 2** Development tools and obtaining methods

Development Tool

Description

How to Obtain

gcc_riscv32

Executes script cross compilation.

https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz

Python3.7+

Executes script compilation.

https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz

SCons3.0.4+

Executes script compilation.

Internet

bash

Executes commands.

Internet

build-essential

Provides basic software package for compilation.

Internet

gn

Generates ninja compilation scripts.

https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar

ninja

Executes ninja compilation scripts.

https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar

## Development Tools for Windows **Table 3** Development tools and obtaining methods

Development Tool

Description

How to Obtain

Visual Studio Code

Edits code.

https://code.visualstudio.com/

HUAWEI DevEco Device Tool

Supports code editing, compilation, burning, and debugging.

NOTE:

HUAWEI DevEco Device Tool is a one-stop integrated development environment (IDE) provided for developers of OpenHarmony-based smart devices. It supports C and C++ languages and is installed in Visual Studio Code as a plug-in.

https://device.harmonyos.com/en/ide

PuTTY, or other HyperTerminal

Remotely connects to a Linux compile server or a serial port.

Internet (for example, https://www.putty.org/)

CH341SER.EXE

Identifies serial port device to transmit data.

http://www.wch-ic.com/downloads/CH341SER_EXE.html

## Installing Basic Compilation Environment ## Connecting to a Linux Server Using PuTTY to log in to a Linux server from a PC running Windows 1. Open [PuTTY](https://www.putty.org/), enter the IP address of the Linux server, and click **Open**. **Figure 2** PuTTY configuration ![](figures/putty-configuration.png "putty-configuration") 2. Click **Yes** in the PuTTY **Security Alert** dialog box. 3. Enter the account and password. **Figure 3** Login ![](figures/login.png "login") 4. The login is successful. **Figure 4** Successful login ![](figures/successful-login.png "successful-login") ## Changing Linux Shell to Bash Run the following command to check whether bash is used as the shell: ``` ls -l /bin/sh ``` If **/bin/sh -\> bash** is not displayed, do as follows to change shell to bash. **Method 1:** Run the following command on the device and then click **No**. ``` sudo dpkg-reconfigure dash ``` **Method 2:** Run the **rm -rf /bin/sh** command to delete sh and then run the sudo **ln -s /bin/bash /bin/sh** command to create a new soft link. ``` sudo rm -rf /bin/sh sudo ln -s /bin/bash /bin/sh ``` ## Installing a Python Environment 1. Start a Linux server. 2. Run the following command to check the Python version \(Python 3.7 or later is required\): ``` python3 --version ``` Do as follows to install Python, for example, Python 3.8. 1. Run the following command to check the Ubuntu version: ``` cat /etc/issue ``` 1. Install Python based on the Ubuntu version. - If the Ubuntu version is 18 or later, run the following command: ``` sudo apt-get install python3.8 ``` - If the Ubuntu version is 16, download the installation package and install Python. 1. Run the following command to install Python environment dependencies \(gcc, g++, make, zlib, libffi\): ``` 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 ``` 1. Obtain the [Python3.8.5 installation package](https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz), save it to the Linux server, and run the following command: ``` tar -xvzf Python-3.8.5.tgz && cd Python-3.8.5 && sudo ./configure && sudo make && sudo make install ``` 3. After Python is installed, link the Python path to **/usr/bin/python**: Run the following command to check whether Python is soft linked to Python3: ``` python --version ``` If the command output is not **python 3.8.5**, run the following command to check the directory where Python3.8 is stored: ``` which python3.8 ``` Replace **python3.8-path** in the following command with the output path of the **which python3.8** command. ``` cd /usr/bin && sudo rm python && sudo ln -s python3.8-path python && python --version ``` 4. Install and upgrade the Python package management tool \(pip3\) using either of the following methods: - **Command line:** ``` sudo apt-get install python3-setuptools python3-pip -y sudo pip3 install --upgrade pip ``` - **Installation package:** ``` curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python get-pip.py ``` 5. Run the following command to install setuptools: ``` pip3 install setuptools ``` 6. Install the GUI menuconfig tool \(Kconfiglib\). You are advised to install Kconfiglib 13.2.0 or later. - **Command line:** ``` sudo pip3 install kconfiglib ``` - **Installation package:** 1. Download the .whl file \(for example, **kconfiglib-13.2.0-py2.py3-none-any.whl**\). Download path: [https://pypi.org/project/kconfiglib\#files](https://pypi.org/project/kconfiglib#files) 1. Run the following command to install the .whl file: ``` sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl ``` 7. 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:** ``` sudo pip3 install pycryptodome ``` - **Installation package:** 1. Download the .whl file, for example, **pycryptodome-3.7.3-cp37-cp37m-manylinux1\_x86\_64.whl** from [https://pypi.org/project/pycryptodome/\#files](https://pypi.org/project/pycryptodome/#files). 1. Run the following command to install the .whl file: ``` sudo pip3 install pycryptodome-3.7.3-cp37-cp37m-manylinux1_x86_64.whl ``` 8. 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** from [https://pypi.org/project/six/\#files](https://pypi.org/project/six/#files). 1. Run the following command to install the .whl file: ``` sudo pip3 install six-1.12.0-py2.py3-none-any.whl ``` 9. 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** from [https://pypi.org/project/ecdsa/\#files](https://pypi.org/project/ecdsa/#files). 1. Run the following command to install the .whl file: ``` sudo pip3 install ecdsa-0.14.1-py2.py3-none-any.whl ``` ## Installing Scons 1. Start a Linux server. 2. Run the following command to install the SCons installation package: ``` sudo apt-get install scons -y ``` If the installation package cannot be found in the software source, do as follows: 1. Download the source code package from [https://scons.org/pages/download.html](https://scons.org/pages/download.html). The recommended SCons version is 3.0.4 or later. 2. Decompress the source code package to any directory, for example, scons-3.1.2. ``` tar -xvf scons-3.1.2.tar.gz ``` 3. Go to the source code directory and run the following command to install the source code package: ``` sudo python3 setup.py install ``` 3. Run the following command to check whether the installation is successful. ``` scons -v ``` **Figure 5** Successful installation ![](figures/successful-installation.png "successful-installation") ## Installing Compilation Tools >![](public_sys-resources/icon-notice.gif) **NOTICE:** >- If you acquire the source code using an HPM component or HPM CLI tool, compilation tools like **gn**, **ninja**, **gcc\_riscv32** are not required. >- \(Recommended\) If you obtain the source code via the mirror site or code repository, install compilation tools such as **gn**, **ninja**, and **gcc\_riscv32**. > Ensure that only **gn**, **ninja**, and **gcc\_riscv32** are used for the compilation environment of Hi3861 WLAN module. ## Installing gn 1. Start a Linux server. 2. Download [gn](https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar). 3. Run the following command to decompress the gn installation package to **\~/gn**. ``` tar -xvf gn.1523.tar -C ~/ ``` 4. Set an environment variable by performing the following steps. Open the **\~/.bashrc** file in Vim first. ``` vim ~/.bashrc ``` Copy the following command to the last line of the **.bashrc** file, save the file, and exit. ``` export PATH=~/gn:$PATH ``` 5. Run the following command to validate the environment variable. ``` source ~/.bashrc ``` ## Installing ninjah 1. Start a Linux server. 2. Download [ninja](https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar). 3. Run the following command to decompress the ninja installation package to **\~/ninja**. ``` tar -xvf ninja.1.9.0.tar -C ~/ ``` 4. Set an environment variable by performing the following steps. Open the **\~/.bashrc** file in Vim first. ``` vim ~/.bashrc ``` Copy the following command to the last line of the **.bashrc** file, save the file, and exit. ``` export PATH=~/ninja:$PATH ``` 5. Run the following command to validate the environment variable. ``` source ~/.bashrc ``` ## Installing gcc\_riscv32 \(Compilation Toolchain for WLAN Module\) >![](public_sys-resources/icon-notice.gif) **NOTICE:** >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.** 1. Start a Linux server. 2. Download [gcc\_riscv32](https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz). 3. Run the following command to decompress the gcc\_riscv32 installation package to **\~/gcc\_riscv32**. ``` tar -xvf gcc_riscv32-linux-7.3.0.tar.gz -C ~/ ``` 4. Set an environment variable by performing the following steps. Open the **\~/.bashrc** file in Vim first. ``` vim ~/.bashrc ``` Copy the following command to the last line of the **.bashrc** file, save the file, and exit. ``` export PATH=~/gcc_riscv32/bin:$PATH ``` 5. Run the following command to validate the environment variable. ``` source ~/.bashrc ``` 6. Enter the following command to check whether the compiler is successfully installed. If the compiler version number is correctly displayed, the installation is successful. ``` riscv32-unknown-elf-gcc -v ``` ## Installing the IDE Development Tool The OpenHarmony IDE Development Tool \(HUAWEI DevEco Device Tool\) integrates the capabilities of terminal tools. For details about how to install the tool, see [Preparations ](https://device.harmonyos.com/en/docs/ide/user-guides/tool_install-0000001050164976)and [Importing and Configuring a Project](https://device.harmonyos.com/en/docs/ide/user-guides/import_project-0000001050164980).