HarmonyOS device development - environment construction

Posted by eggradio on Sat, 01 Jan 2022 12:14:02 +0100

Bought a Runhe Hongmeng development board, but the environment was not built well for several times. The main reason is that the official documents are very confused. Record the successful construction process

Based on the tutorials of the following three websites, the system is Ubuntu 20.04. This article is to build the environment under Ubuntu, compile the source code, and Windows is only responsible for burning.

  1. Hongmeng official website
  2. Little bear open source community
  3. Runhe software

1, Software installation

Tool nameDescription of useVersion requirementsAccess channel
Visual Studio CodeCode editing toolV1.53 and above 64 bit version.https://code.visualstudio.com/Download
PythonCompile build tool3.8.x 64 bit versionUse the command line tool for installation, refer to Install Python.
Node.jsProvide npm environmentv12.0.0 and above 64 bit versionhttps://nodejs.org/zh-cn/download/
hpmPackage management toolsthe latest versionPlease refer to Install Hpm.
DevEco Device ToolHarmonyOS source code compilation, burning and debugging plug-in toolsv2.2 Beta1https://device.harmonyos.com/cn/ide#download To download, please log in with Huawei developer account. If not registered, please log in first Register Huawei developer account.

1. You need to change the shell to dash

  1. Open the terminal tool, execute the following command, enter the password, and then select No to change the Ubuntu shell to bash.

    sudo dpkg-reconfigure dash
    
  2. Execute the following command to confirm that the output result is bash

    ls -l /bin/sh
    

2 install Python

  1. Ubuntu 20 installs Python 3.8 by default, so python does not need to be installed separately, but pip is not installed

    sudo apt-get install python3-pip && python3 -m pip install --upgrade pip
    
  2. Source change

    pip3 config set global.trusted-host repo.huaweicloud.com
    pip3 config set global.index-url https://repo.huaweicloud.com/repository/pypi/simple
    pip3 config set global.timeout 120
    
  3. Set soft connection

    sudo ln -s /usr/bin/python3.8  /usr/bin/python3
    sudo ln -s /usr/bin/python3.8  /usr/bin/python
    sudo ln -s /usr/bin/pip3  /usr/bin/pip
    #Test whether the installation is complete
    python --version
    pip --version
    

3. Install node js

 tar -xvf node-v1x.xx.x-linux-x64.tar.xz   #Change to your own node name
 sudo mv node-v1x.xx.x-linux-x64 /usr/local/nodejs
 sudo ln -s /usr/local/nodejs/bin/npm  /usr/bin/
 sudo ln -s /usr/local/nodejs/bin/node  /usr/bin/
 node -v  #Test whether the installation is complete

4 installation of Hpm

npm config set registry https://repo.huaweicloud.com/repository/npm/
npm install -g @ohos/hpm-cli
hpm -V  #Test whether the installation is complete

5 install Visual Studio Code

sudo dpkg -i code_1.xx.x-1615806378_amd64.deb
code --version

6 installation of other

sudo pip3 install setuptools
sudo pip3 install kconfiglib
sudo pip3 install pycryptodome
sudo pip3 install six --upgrade --ignore-installed six
sudo pip3 install ecdsa
#Install scons
sudo apt-get install scons -y
scons -v  #Test for successful installation

7. Install DevEco Device Tool

Note: please close Visual Studio Code before installing DevEco Device Tool.

unzip devicetool-linux-tool-2.1.0.0.zip
chmod u+x deveco-device-tool-2.1.0+241710.14bbf65d.run
./deveco-device-tool-2.1.0+241710.14bbf65d.run
#There may be warnings after installation. Execute the command according to the prompt. You can continue to execute the previous command to test whether there are warnings

2, Tool chain installation

Kit nameGet addressPath set in Tools
gnhttps://repo.huaweicloud.com/harmonyos/compiler/gn/1717/linux/gn-linux-x86-1717.tar.gzFolder of gn execution file
ninjahttps://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tarFolder of ninjia execution file
gcc_riscv32https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gzgcc_riscv32 folder
mkdir ~/HarmonyOS 
mkdir ~/HarmonyOS/HarmonyOSTools~/HarmonyOS/HarmonyOSTools
#Put the downloaded installation package under ~ / HarmonyOS/HarmonyOSTools
#Unzip the installation package
tar -xvf gn.1523.tar
tar -xvf ninja.1.9.0.tar
tar -xvf gcc_riscv32-linux-7.3.0.tar.gz
#Setting environment variables
vim ~/.bashrc
#. bashrc last added
export PATH=~/HarmonyOS/HarmonyOSTools/gcc_riscv32/bin:$PATH
export PATH=~/HarmonyOS/HarmonyOSTools/ninja:$PATH
export PATH=~/HarmonyOS/HarmonyOSTools/gn:$PATH

Now that the Ubuntu compilation environment has been installed, the code can be compiled directly. However, burning requires a window environment

3, Windows environment setup

1 mapping project source code

Execute the following command at = = ubuntu = =:

#Installing samba
sudo apt install samba
#Configuring samba
sudo vim /etc/samba/smb.conf
#----------------------------------------------------------
[HarmonyOS]
path = /home/noob/HarmonyOS
available = yes
valid users = yes
read only = no
browsable = yes
public = yes
writable = yes
#----------------------------------------------------------
sudo smbpasswd -a noob
sudo service smbd restart 

2 install Windows driver

development toolpurposeAccess
CH341SER.EXEUSB to serial driver.http://www.wch.cn/search?q=ch340g&t=downloads
Hiburn burning toolCode burning tool.https://pan.baidu.com/s/1bp2ypAfH2HaNPTY2KwEhEA Password: 1234

3 mapping network drivers

Right click this computer to map network drives

Fill in \ \ ip\HarmonyOS

Topics: Embedded system harmonyos