Openharmony's L0 and L2 system environment construction, compilation and burning

How to get the source code

There are four ways to obtain the source, as described below. Method 1 and 3 are commonly used. The following mainly explains the steps and precautions for obtaining through the first method.

  • Obtaining method 1: Obtain from the code cloud code warehouse. Download from the code repository through repo or git tool, this method can obtain the latest code.

  • Obtaining method 2: Obtain through the DevEco Marketplace website. Visit the DevEco Marketplace website, find the open source distribution that meets your needs, download it directly (or download it after customization), and then download and install the required components and tool chain locally through the hpm-cli command tool.

  • Obtaining method 3: Download the archived release compressed file from the mirror site. If you want to obtain the source code of an older version, you can also obtain it through this method, which has a faster download speed.

  • Obtaining method 4: Obtain from the github code repository. Download from the code repository through repo or git tool, this method can obtain the latest code.

Obtaining method 1: Obtain from code cloud warehouse

1. Preconditions

1. Register a code cloud gitee account.

2. Registration code cloud SSH public key. The following link is for help with the registration steps.

https://gitee.com/help/articles/4191#article-header0

3. Install git client and git-lfs and configure user information.

# 安装git客户端
sudo dnf install git-all
# git-lfs 工具按如下网页所示安装即可
# https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading
# 配置用户信息
git config --global user.name "yourname"
git config --global user.email "your-email-address"
git config --global credential.helper store

4. Install the code cloud repo tool

# 安装curl python pip3本机linux有curl,略过
apt-get install curl
sudo apt install python-pip
# python安装版本需要3.7及以上 如报错python找不到或链接错误时,重定向python
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1
# 如果没有权限,可下载至其他目录,并将其配置到环境变量中
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo  
chmod a+x /usr/local/bin/repo
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests

5. Add repo to environment variables.

vim ~/.bashrc               # 编辑环境变量
export PATH=~/bin:$PATH     # 在环境变量的最后添加一行repo路径信息
source ~/.bashrc            # 应用环境变量

2. Obtain the Openharmony code

The master base code obtained below. [email protected] :openharmony/manifest.git

The base code of other versions such as Openharmony V3.1 Release or V3.2 can be obtained through https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire .md website to get the base address to obtain.

  • Method 1 (recommended): Download via repo + ssh

repo init -u [email protected]:openharmony/manifest.git -b master --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
  • Method 2: Download via repo + https.

repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
  • Precautions:

# 当repo不可用时,更换其它的repo,以下以清华的源为例
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
sudo curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o /usr/bin/repo
sudo chmod +x /usr/bin/repo
# 如果repo init下载时,中途出现中断不载不下来,在命令中添加 --depth=1 如再不行再添加–no-clone-bundle
repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony-v3.1-Release --no-repo-verify --depth=1

Compile Openharmony

1. Standard equipment L2

# 下载预编译工具
./build/prebuilts_download.sh
# 编译rockchip的标准设备 rk3568
./build.sh --product-name rk3568
# 关于编译会专门列一个章节进行讲解,静请期待......
# rk3568烧录通过RKDevTool.exe 进行烧录,此工具由瑞芯微提供。

2. Lightweight equipment L0

The compilation methods for lightweight devices and small devices are basically the same, except that the cross-compilation tools used for downloading are different. Here, the Hengxuan chip bes2600 is used as an example:

https://gitee.com/openharmony/device_soc_bestechnic

Since Hengxuan has created a new sub-warehouse for Openharmony's master's main warehouse, it is necessary to re-download the source code of Openharmony. In later Openharmony, Hengxuan was also integrated into the master's main warehouse. This was only reflected in Openharmony's V3.2 version. Because the V3.2 version distinguishes soc from chip name, product_name, etc. in directories such as /device and /vendor. Later, if readers are involved in this aspect, they will open another chapter to explain it in detail, which is not shown here.

  1. Get source code

mkdir openharmony_bestechnic

cd openharmony_bestechnic

repo init -u https://gitee.com/openharmony/manifest --no-repo-verify

repo sync -c

repo forall -c 'git lfs pull'
  1. Installed libraries and tools

sudo apt-get install build-essential gcc g++ make zlib* libffi-dev e2fsprogs pkg-config flex bison perl bc openssl libssl-dev libelf-dev libc6-dev-amd64 binutils binutils-dev libdwarf-dev u-boot-tools mtd-utils gcc-arm-linux-gnueabi

3. Install hb

# 运行如下命令安装hb
pip3 uninstall ohos-build # 如果安装了hb,先卸载
pip3 install build/lite
# 设置环境变量
vim ~/.bashrc
# 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。
export PATH=~/.local/bin:$PATH
# 执行如下命令更新环境变量。
source ~/.bashrc
# 执行"hb -h",有打印以下信息即表示安装成功:
usage: hb

OHOS build system

positional arguments:
  {build,set,env,clean}
    build               Build source code
    set                 OHOS build settings
    env                 Show OHOS build env
    clean               Clean output

optional arguments:
  -h, --help            show this help message and exit

4. Cross-compilation tool installation

# 安装arm-none-eabi-gcc
# 下载arm-none-eabi-gcc 编译工具下载 https://gitee.com/link?target=https%3A%2F%2Fdeveloper.arm.com%2F-%2Fmedia%2FFiles%2Fdownloads%2Fgnu-rm%2F10.3-2021.10%2Fgcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
# 解压 gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 安装包至~/toolchain/路径下。
mkdir -p ~/toolchain/
tar -jxvf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 -C ~/toolchain/
# 设置环境变量。
vim ~/.bashrc
# 将以下命令拷贝到.bashrc文件的最后一行,保存并退出
export PATH=~/toolchain/gcc-arm-none-eabi-10.3-2021.10/bin:$PATH
# 生效环境变量
source ~/.bashrc

5. Compilation process

hb set -root .
hb set -p

bestechnic
 > display_demo
   iotlink_demo
   xts_demo

选择display_demo

hb build -f

6. Burning

https://gitee.com/openharmony/device_soc_bestechnic#%E7%83%A7%E5%BD%95%E6%89%93%E5%8D%B0

Precautions:

1. After the compilation is completed, use the tar -zxvf command to directly decompress write_flash_gui-display_demo-2022-11-11-17-26-51.tar.gz in the directory after compilation. Enter write_flash_gui to open the burning software. line burning.

2. When xshell serial port debugging printout, the baud rate must be set to 1500000, and the terminal ---- advanced ---- use CR+LF to receive LF(R) is checked.

follow-up more exciting

1. About the past and present life of service ability

2. Hongmeng compilation and build process

3.Openharmony driver development and HDF

4. Development examples of L0 devices on Openharmony base

Guess you like

Origin blog.csdn.net/procedurecode/article/details/128719158