Hongmeng of China, Hongmeng of the world

At 18:18 on September 10, 2020, Huawei Hongmeng HarmonyOS 2.0 open source code, the code donated to the Open Atom Open Source Foundation for open source incubation, Hongmeng OS 2.0 officially debuted.

OpenHarmony
open source project:https://www.openatom.org/openharmony
code repository: https://openharmony.gitee.com

The first version currently released supports 128KB-128MB terminal devices such as large screens, watches, cars, etc. The mobile phone version of the SDK, tools, documents and simulators will be released in December this year; 128MB-4GB terminal devices will be supported in April 2021 ; All devices above 4GB will be supported in October 2021. In 2021, Huawei smartphones will be fully upgraded to support Hongmeng 2.0.
Hongmeng of China, Hongmeng of the world
It is reported that Huawei will release the Mate 40 series of mobile phones at 20 o'clock on October 22, which will be equipped with EMUI11 and Hongmeng system test versions.

HarmonyOS is a distributed operating system facing the future and facing all scenarios. HarmonyOS not only supports mobile phones, but also supports tablets, cars, smart screens, PCs, watches, speakers, headsets, glasses and other more terminal devices (Huawei 1+8+N strategy) flexible deployment on demand, supports one-time development, multiple terminals deploy. HarmonyOS takes people as the core and mobile phones as the center, creating new hardware, new interactions, and new services, which will open up a whole new world of scenes.

HarmonyOS and LiteOS

letters

LiteOS is Huawei's lightweight IoT operating system for the IoT field. It follows the BSD-3 open source license agreement and has the capabilities of lightweight (minimum kernel size is only 6KB), low power consumption, interconnection, rich components, and rapid development. , Can be widely used in smart home, personal wear, car networking, urban public services, manufacturing and other fields, providing developers with a "one-stop" complete software platform, effectively lowering the development threshold and shortening the development cycle. Started in 2012, LiteOS is an embedded operating system developed to support Huawei terminal products. It was later applied in batches on Huawei Mate series, P series, Honor series mobile phones, and wearable products. It was launched in Huawei HNC on May 20, 2015. Officially announced at the web conference. The open source version of Huawei LiteOS was released in September 2016, the V2.1 version and LiteOS SDK were released in May 2018, and the LiteOS IDE development tool LiteOS Studio V1.0 was released in September 2018.
Hongmeng of China, Hongmeng of the world

HarmonyOS kernel

HarmonyOS follows a layered design as a whole, from bottom to top: kernel layer, system service layer, framework layer and application layer.
Hongmeng of China, Hongmeng of the world
HarmonyOS adopts a multi-core design and supports the selection of different OS kernels for different resource-constrained devices. The Kernel Abstract Layer (KAL) provides basic kernel capabilities to the upper layer by shielding multi-core differences, including process/thread management, memory management, file system, network management and peripheral management.

Currently, OpenHarmony provides two kernels, liteos-a and liteos-m, which also have the features of RTOS and Linux ease of use. Among them, liteos_a is mainly for Cortex-A series processors, which is suitable for embedded devices with richer resources; liteos_m is mainly for Cortex-M series processors, and is suitable for various devices with minimal resources such as MCUs. In December, Linux Kernel will be supported, compatible with more devices.

HarmonyOS integrates LiteOS and is not built on PPT. It has many years of technology precipitation from Huawei. HarmonyOS 1.0 has been applied to Honor Smart Screen, EMUI 10.0, and realizes applications such as multi-screen collaboration, HiCar, and smooth connection of devices. The upcoming EMUI 11 borrows the technology of HarmonyOS 2.0, which will bring a more convenient and richer experience. Interested students can compare the two codes: kernel_liteos_a and LiteOS .

HarmonyOS和Fuchsia OS

Google Fuchsia OS is an operating system equivalent to HarmonyOS. Fuchsia first appeared on Github in August 2016. Unlike Android and Chrome OS, Fuchsia is not based on the Linux kernel, but based on the newly developed Zircon microkernel by Google. Fuchsia is mainly developed in C/C++ and Dart languages, and most of the user interface is built using Flutter.

HarmonyOS and Fuchsia OS are both a new generation of smart operating systems, and Android and iOS are bound to decline. The primary goal of HarmonyOS is to replace Android, but not only to replace Android, but a future-oriented, full-scene, multi-device operating system, which will usher in a new era of interconnection of everything, which is the key to victory. After 15 years of accumulation, Android occupies nearly 87% of the global smartphone market share, and Hongmeng must have a clear advantage to replace it.

Huawei is committed to building a full-scenario smart ecosystem with two-wheel-drive software and hardware. Compared with competitors, Huawei has its own software and hardware application ecosystem with 700 million+ end users. Huawei watches and wrist wearable devices have the largest market share in the world, watches are second in the world, and tablets are third in the world. This ensures that HarmonyOS can It is widely used. Huawei's AppGallery has distributed apps in more than 190 countries and regions, and has over 400 million monthly active users worldwide. At the same time, Huawei will fully open its core technologies, software and hardware capabilities to developers and ecosystem partners to build an open ecosystem. Hongmeng will be the world's first commercially available all-scene distributed operating system.
Hongmeng of China, Hongmeng of the world

OpenHarmony source code

Get the source code

OpenHarmony code is open in the form of components, and currently contains 17 subsystems, 134 code repositories, and 3 reference implementations. Therefore, if you want to understand the overall code structure, it is recommended to download the full code of OpenHarmony from the mirror site . For other needs, you can also obtain it in the following ways:

  • Find a solution that meets your needs from the hpm website , select/cut components and download.
  • Use HPM's hpm-cli command line tool to obtain it.
  • Obtain from the code repository through repo or git tools.

For specific methods, please refer to the download instructions for obtaining the OpenHarmony source code .

Currently, the version of Hongmeng OS is 2.0 and the version of OpenHarmony is 1.0. I wonder if this correspondence will be maintained in the future.

Source directory

Directory structure of OpenHarmony full code
Directory name description
applications Sample applications, including wifi-iot, camera, etc.
base Basic software service subsystem & hardware service subsystem set
build Componentized compilation, build and configuration scripts
domains Enhanced software service subsystem set
drivers Drive subsystem
foundation System Basic Capability Subsystem Set
kernel Kernel subsystem
prebuilts Compiler and tool chain subsystem
test Test subsystem
third_party Open source third-party components
utils Common tools
vendor Software provided by the manufacturer
build.py Compile script file

The format of the project naming in the code warehouse is: [directory name] + [subdirectory name], for example, the project names of the two LiteOS kernels are kernel_liteos_a and kernel_liteos_m, and the project name of the third-party lightweight JavaScript engine JerryScript is third_party_jerryscript. Among them, the project names under base, domains, foundation, and test (parts) omit the top-level directory, such as startup_frameworks_syspara_lite, startup_hals_syspara_lite under base. The naming of some projects is not standardized. For example, the JS application development framework under the foundation is named ace_lite_jsfwk, and the corresponding path is ace/frameworks/lite. I hope Huawei can unify the naming method.

Main subsystem
system Introduction table of Contents
JS application development framework Lightweight implementation of JS application development framework, cross-platform web-like application development framework, through Toolkit to compile and package HTML, CSS and JS files written by developers into JS Bundle, and then parse the JS Bundle into C++ UIKit View components. Rendering. Support declarative application development and data-driven view updates. /foundation/ace
DFX Mainly include DFR (Design for Reliability, reliability) and DFT (Design for Testability, testability) features. Provide componentized and customizable DFX framework for different hardware architectures and resources. According to different hardware platforms of RISC-V, Cortex-M, Cortex-A, two different lightweight DFX frameworks are provided / base / hiviewdfx
XTS certification Certification test suite collection /test/xts
Globalization Mainly provide multi-language resource backtracking and multi-language support / base / global
Public foundation Common base component library /utils/native/lite、/base/iot_hardware、 vendor/hisi/hi3861/hi3861_adapter/hals/iot_hardware
Kernel OpenHarmony内核,当前包含liteos_a和liteos_m /kernel、/drivers/liteos
分布式任务调度 管理跨设备组件,提供访问和控制远程组件的能力,支持分布式场景下的应用协同 /foundation/distributedschedule
分布式通信 实现近场设备间统一的分布式通信能力管理,提供不区分链路的设备发现和传输接口。包含服务发布、数据传输、安全等功能 /foundation/communication
启动恢复 负责在内核启动之后、应用启动之前的操作系统中间层的启动。支持使用LiteOS-A内核的平台 /base/startup
图形 主要包括UI组件、布局、动画、字体、输入事件、窗口管理、渲染绘制等模块,满足硬件资源较小的物联网设备的应用开发 /foundation/graphic/lite
媒体 提供多媒体应用开发接口,包括audio、camera、player、recorder等 /foundation/multimedia
安全 包括安全OS、秘钥管理和证书管理、加解密、签名验签、设备认证、应用权限管理等 /base/security
测试 开发测试框架 /test/developertest、/test/xdevice
用户程序框架 包含Ability子系统和包管理子系统 /foundation/aafwk、/foundation/appexecfwk
系统服务框架 屏蔽不同硬件架构和资源,提供统一的系统服务开发框架 /foundation/distributedschedule/interfaces/kits/samgr_lite、/foundation/distributedschedule/services/samgr_lite
编译构建 提供了在GN与ninja基础上的编译构建框架,支持构建不同芯片平台的产品、构建HPM包管理配置生成的自定义产品 /build/lite
驱动 提供弹性的框架、规范的驱动接口、组件化的驱动模型、统一的配置界面 /drivers/hdf

HarmonyOS开发

HarmonyOS采用C/C++、JS语言开发,应用开发支持Java、C/C++、JS等语言,设备开发支持C/C++、JS等语言。应用开发也称为北向开发,设备开发也称为南向开发。为什么这么称呼呢?想想地图方位,上北下南。

应用开发

华为开发者帐号
华为开发者帐号分为两种类型:个人开发者和企业开发者。

开发者类型 享受的服务/权益
个人开发者 应用市场、主题、商品管理、帐号、PUSH、新游预约、互动评论、社交、HUAWEI HiAI、手表应用市场等。
企业开发者 应用市场、主题、首发、支付、游戏礼包、应用市场推广、商品管理、游戏、帐号、PUSH、新游预约、互动评论、社交、HUAWEI HiAI、手表应用市场、运动健康、云测、智能家居等。
  1. 注册开发者帐号
    登录HarmonysOS应用开发门户,点击右上角注册按钮。如果您使用华为手机已有华为帐号,直接点击登录按钮,然后扫码登录即可。
  2. 实名认证
    使用DevEco Studio远程模拟器需要华为帐号进行实名认证。登录后点击头像->帐号设置->实名认证,个人开发者支持个人银行卡认证和身份证人工审核认证两种方式,推荐使用银行卡认证。

开发工具HUAWEI DevEco Studio
DevEco Studio基于IntelliJ IDEA Community开源版本打造,是面向华为终端全场景多设备的一站式集成开发环境。DevEco Studio支持Java、C/C++ 、JavaScript等多种语言,支持 FA(Feature Ability)和 PA(Particle Ability)快速开发,支持分布式多端开发、分布式多端调测、多端模拟仿真。DevEco Studio当前仅支持Windows10 64 位操作系统,即将支持macOS。

另外,若使用JS语言开发HarmonyOS应用需要安装Node.js,建议安装LTS版本。为提升npm安装速度,建议执行如下命令设置npm仓库地址:

npm config set registry https://mirrors.huaweicloud.com/repository/npm/

HarmonyOS SDK
HarmonyOS提供C/C++、JS、Java SDK包,Devco Studio提供SDK Manager统一管理SDK及工具链,下载SDK包时会自动下载其依赖的工具链。

点击菜单File > Settings,打开Settings配置界面,进入Appearance&Behavior > System Settings > HarmonyOS SDK,配置SDK和工具链。
Hongmeng of China, Hongmeng of the world

SDK:

  • Native:C/C++语言SDK包,默认不自动下载,需手动勾选。
  • JS:JS语言SDK包,默认不自动下载,需手动勾选。
  • Java:Java语言SDK包,默认自动下载。

SDK工具链(SDK Tools):

  • Toolchains:应用开发必备工具集,包括编译、打包、签名、数据库管理等工具,首次下载SDK时默认下载。
  • Previewer:Lite Wearable预览器,在开发过程中可以动态预览Lite Wearable应用的界面,需手动勾选下载。

仿真模拟器
DevEco Studio提供远程模拟器(Remote Emulator)功能,可以在模拟器上运行TV、Wearable应用(Lite Wearable暂不支持在模拟器中运行,可以选择预览器运行和调试应用)。模拟器每次使用时长为1小时,到期后会自动释放资源。

在DevEco Studio菜单栏,点击Tools > HVD Manager,打开模拟器管理界面。首次使用模拟器,需下载相关资源。在浏览器弹出的华为帐号登录界面,输入已实名认证的华为帐号,登录授权后即可进入HVD Manager:
Hongmeng of China, Hongmeng of the world
在设备列表中,选择设备,点击Hongmeng of China, Hongmeng of the world按钮,运行模拟器。

HarmonyOS APP
DevEco Studio当前支持智慧屏、智能穿戴和轻量级智能穿戴三种设备的应用开发,可以根据工程向导创建各类设备的工程,并自动生成对应的代码和资源模板。
Hongmeng of China, Hongmeng of the world

HarmonyOS应用发布形态为APP Pack(Application Package),它由一个或多个HAP(HarmonyOS Ability Package)包以及描述APP Pack属性的pack.info文件组成。
Hongmeng of China, Hongmeng of the world

一个HAP在工程目录中对应一个Module,它由代码、资源、第三方库及应用清单文件组成,可以分为Entry和Feature两种类型。

  • Entry:应用的主模块。一个APP中,对于同一设备类型必须有且只有一个entry类型的HAP,可独立安装运行。
  • Feature:应用的动态特性模块。一个APP可以包含一个或多个feature类型的HAP,也可以不含。

Ability分为两种类型:FA(Feature Ability)和PA(Particle Ability)。其中,FA有UI界面,提供与用户交互的能力;PA无UI界面,提供后台运行任务的能力以及统一的数据访问抽象。FA/PA是应用的基本组成单元,能够实现特定的业务功能,支持跨设备调度与分发。

了解了基础知识来运行一个Hello World吧。

设备开发

开发工具 HUAWEI DevEco Device Tool
DevEco Device Tool是HarmonyOS面向智能设备开发者提供的Visual Studio Code插件,支持按需定制组件,支持代码编辑、烧录和调试等功能,支持C/C++语言,支持ARM架构的Hi3516/Hi3518系列和RISC-V架构的Hi3861系列开发板。

安装DevEco Device Tool插件前需先安装JDK 1.8、Node.js(请选择LTS版本)和hpm。

注意,安装Node.js后需配置NODE_PATH环境变量,值为:C:\Users{userName}\AppData\Roaming\npm\node_modules。

执行如下命令安装hpm:

npm install -g @ohos/hpm-cli

下载DevEco Device Tool安装包解压后,打开VS Code,点击Extensions -> Install from VSIX...,从本地磁盘安装DevEco Device Tool插件。
Hongmeng of China, Hongmeng of the world
安装成功后,界面如下图所示:
Hongmeng of China, Hongmeng of the world

HarmonysOS设备开发采用C/C++语言,还需为VS Code安装C/C++语言的插件。在VS Code的插件市场,输入“C/C++”,然后点击“Install”即可在线安装。

工具链
执行如下命令安装烧录依赖工具:

npm install -g tftp
npm install -g serialport
npm install -g @serialport/parser-readline

ARM系列开发板使用串口烧录时需安装Zadig工具。RISC-V系列开发板(Hi3861系列)支持使用Jlink和HiBurn工具两种烧录方式。其中使用Jlink工具烧录,开发者需自行下载安装Jlink工具;使用HiBrun工具烧录,DevEco Device Tool已预置HiBrun工具。

ARM系列(Hi3516和Hi3518)开发板使用GDB和LLDB两种调试方式,在启动代码调试前需安装调试工具:

调试类型 工具名称 获取说明
GDB OpenOCD 自动通过hpm进行安装
GDB gcc-arm-none-eabi 下载地址:https://www.gnu.org/software/gdb/download/ ,9.1及以上版本
LLDB llvm 从HarmonyOS源码包中获取

说明,经测试目前OpenOCD不能自动安装。

RSIC-V系列Hi3861开发板使用Jlink方式进行调试,需安装以下工具:

工具名称 获取说明
JlinkGDBServer 安装Jlink工具包时自动安装
hcc_riscv32 执行npm install -g @ohos/gcc_riscv32命令进行安装

导入工程
HarmonyOS暂不支持Windows系统源码,只能在Linux系统中进行编译,需将Linux下的工程目录映射到Windows下,然后使用DevEco Device Tool打开,并在Windows环境下进行烧录和调试。

映射配置好后,在Visual Studio Code中导入项目:
Hongmeng of China, Hongmeng of the world

配置工程

  1. 点击底部工具栏中的“Board”按钮,选择开发板的配置模板,例如:Hi3516DV300:

Hongmeng of China, Hongmeng of the world

Once selected, the bundle.json file will be created automatically.

  1. Click the Configure button in the left menu bar to set the "Default installation path" path to store the tool chain for automatic installation of hpm.

Hongmeng of China, Hongmeng of the world

  1. Click the "Dependent tools incorrectly installed" button in the bottom toolbar to check whether the tools that the project depends on are set correctly.
    • If the tool whose "Auto-install" is "Yes" is not installed, DevEco Device Tool will be automatically downloaded from hpm
    • If the tool whose "Auto-install" is "No" is not installed, a prompt box will pop up in the lower right corner, requiring the developer to manually set it in Build, Burn and Debug.
Tool Auto-install Installed
harmonyeabi Yes No
mtd-utils-tool Yes No
mingw Yes No
python No No
openocd Yes No
gcc-arm-none-eabi Yes No

Note: After testing, none of the above tools are provided in hpm. The current version does not support source code compilation under the Windows environment, and you don’t need to pay attention even if the download fails.

For more information about device development, please check the HarmonyOS official website.

"Harmony" means harmony, world unity, harmony and symbiosis, which is the philosophy that Chinese civilization has always upheld. "Hongmeng" has the meaning of Pangu's creation. "Hongmeng is the original innocent, breaking the stubborn emptiness and Wukong". Hongmeng's ecology has just started. It needs the joint efforts of Huawei and domestic and foreign enterprises, and the joint promotion of many Wukongs to build a more colorful world . Huawei's Hongmeng, China's Hongmeng, will surely become the world's Hongmeng.

Hongmeng of China, Hongmeng of the world

Reference

Hongmeng HarmonyOS official website
Open Atom Open Source Foundation-OpenHarmony Project

Guess you like

Origin blog.51cto.com/7308310/2541796