Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Download the source code and build the environment for compiling harmonyos

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Compilation harmonyos download source code and build environment process, for this problem, this article details the corresponding analysis and solution, hoping to help more want to solve this problem of small partners to find a simpler and easier way.

1. Environmental construction

Compiling Hongmeng source code is recommended under Ubuntu 20.04, windows will appear under a variety of strange problems, not recommended to use.

1.1 VirtualBox virtual machine installation

VirtualBox official website download address: www.virtualbox.org/

Ubuntu 20.04 official website download address: https://ubuntu.com/download/desktop

About VirtualBox and Ubuntu installation and use is not expanded, Baidu a lot of information.

1.2 Change sh to bash

ls -l /bin/sh #If "/bin/sh -> bash" is displayed, it is normal, otherwise modify it as follows: sudo dpkg-reconfigure dash #Then choose no

1.3 Install packaging tools mkfs.vfat mtools

sudo apt-get install dosftools mtools #2 tools officially required sudo apt-get install zip #The official documentation is not written, but the rootfs process requires sudo apt-get install python 3-distutils #The official documentation is not written, but the build process requires

1.4 Download and install compilation tool gn ninja llvm hc-gen

hc-gen: Hongmeng driver hdf framework, etc., used to generate files corresponding to Hongmeng driver configuration

#download gn/ninja/LLVM/hc-gen package: URL_PREFIX=https: repo.huaweicloud.com/harmonyos/compiler URL/gn/1523/linux/gn.1523.tar was not found on this server. linux/ninja.1.9.0.tar wget $URL_PREFIX/clang/9.0.0- 34042/linux/llvm-linux-9.0.0 - 34042.tar wget $URL_PREFIX/hccms The requested URL/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux was not found on this server. 7.3.0.tar.gz #[Optional] Required to compile riscv, such as wifiiot #Decompress gn/ninja/LLM/hc-gen package: tar -C ~/ -xvf gn.1523.tar tar -C ~/ -xvf ninja.1.9.0.tar tar -C ~/ -xvf llvm-linux-9.0.0-34042.tar tar -C ~/ -xvf hc-gen-0.65-linux.tar tar -C ~/ -xvf gcc_riscv32-linux-7.3.0.tar.gz #【Optional] Required to compile riscv, such as wifiot #appending gn/ninja/LLVM/hc-gen path configuration to ~/.bashrc: cat ~/.bashrc export PATH=~/build_tools/gn:\$PATH export PATH=~/build_tools/ninja:\$PATH export PATH =~/build_tools/llvm/bin:\$PATH export PATH =~/gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux/bin:\$PATH export PATH=~/gcc_riscv32/bin:\$PATH #[Optional] Required to compile riscv, such as wifiiot #export PATH=~/.local/bin:\$PATH #effective environment variable source ~/.bashrc

1.5 Install Python 3.8 and pip

To compile Hongmeng source code hi3861 target platform, you need to use scons. The default installed version of scons needs python version>=3.7:

a, if it is ubuntu20.04, because the default python is 3.8, just meet the requirements, just need to install pip, you can go to step 6.

sudo apt-get install python3-pip

Note: If pip download is slow, configure pip package download source to accelerate domestic installation of pip package:

mkdir~/.pip/ cat /usr/local/bin/repo chmod a+x /usr/local/bin/repo #Set repo file a+x is all users can execute pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests

2.3 Download source code

repo is a python script for downloading multiple git libraries. Refer to repo usage: blog.csdn.net/nwpushuai/article/details/78778602

repo init

-u #specifies the URL of the manifests remote git library, which is a manifest of the entire project, usually including the default.xml file

-b #Specifies a version of the manifest.xml file, commonly known as a "branch." Running this command creates a new.repo subdirectory in the current directory.

repo sync

-j12 #Turns on multithreaded synchronization, which speeds up sync command execution. By default, sync occurs concurrently using 4 threads

- no-repo-verify: The repo source code is checked when downloading the repo library. If you specify a third-party repo library by-repo-url, it may cause the check to fail, so you can use this parameter with it to force no check.

-c, -current-branch: Synchronizes only specified remote branches. By default, sync synchronizes all remote branches, and when there are more remote branches, the amount of code downloaded is large. Use this parameter to reduce download time and save local disk space

-d, -detach: Detach from the current local branch and switch to the branch set in manifest.xml. In practice, this parameter is useful, as we often switch to dev branch for development after we sync our code for the first time. Using sync without this parameter triggers the local dev branch to merge with the remote branch set by manifest, which will likely cause sync to fail.

sync -c#Sync only specified remote branches

repo init -u https://gitee.com/openharmony/manifest.git-b master --no-repo-verify repo sync -c#From now on, synchronize the modification of remote warehouse every day. Just execute this command. You can lock OpenHarmony-1.0 version first in the early stage to avoid problems caused by frequent upgrades. The migration of Raspberry Pi is carried out on the branch of OpenHarmony-1.0 repo init -u https://gitee.com/openharmony/manifest.git-b OpenHarmony-1.0 repo sync -c -j12.

2.4, compile test

You can first execute the official compilation command to test whether the compilation environment is normal. After compilation, the folder out will be generated under the home directory.

-b debug Build debug version, without this parameter, normal version is unable to enter shell

python3 build.py ipcamera_hi3516dv300 -b debug python3 build.py ipcamera_hi3518ev300 -b debug python build.py wifiiot -b debug

3. Start the process

3.1 Start mode

Raspberry Pi comes with BootLoader, boot the image file on the SD card to start the kernel, you can use the BootLoader that comes with Raspberry Pi to start the kernel directly, but this is not convenient for us to debug the code. SD cards need to be inserted and removed frequently. So I first load u-boot through BootLoader, and then load the kernel image directly into memory through TFTP of u-boot, so that when debugging, there is no need to frequently insert SD card. When debugging is finished, copy the image file to SD card and boot the kernel.

TFTP boot kernel u-boot environment variable settings: setenv bootcmd "tftp 80000 OHOS_Image.bin;tftp 80000 OHOS_Image.bin;tftp 80000 OHOS_Image.bin;go 80000" SD card boot kernel u-boot environment variable settings: setenv bootcmd "fatload mmc 0:1 100000 liteos.bin;fatload mmc 0:1 100000 liteos.bin;mw.l 0x10100000 ffffffff 1000000;fatload mmc 0:1 10100000 rootfs.jffs2;go 100000 - 10100000"

3.2 Start file

OHOS_image_1.0 This folder contains the Hongmeng image I have compiled, which can be used directly.

About the compilation of harmonyos download source code and build environment process questions to share here, I hope the above content can be of some help to everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report