Ascend AI Full-Stack

Qizhi01 · Ascend AI Full-Stack
—— OpenHarmony on Ascend 310B, plus an NPU-powered X-ray app

Ported OpenHarmony 5.0.3 to the Huawei Ascend 310B developer kit, then built Ascend X-Ray Expert — a HarmonyOS app that runs YOLOv5s on the NPU to analyze chest radiographs. From kernel patch adaptation to ArkUI, this project spans the complete embedded system stack.

At a glance

Qizhi01 covers the full chain from operating system to application: porting OpenHarmony 5.0.3 to the Huawei Ascend 310B development kit, then building an X-ray chest radiograph analysis application on top of that system. The first half is kernel, driver and build-chain adaptation; the second half is an ArkTS interface with YOLOv5s inference. To put the on-board NPU to actual use, the application implements both a CPU and an NPU inference path.

About this project

What it addresses

The Ascend 310B ships with a Linux SDK only, while the on-board NPU is worth using. The project verifies two things: whether OpenHarmony can run on this hardware, and whether NPU inference can be wired into a usable application on top of it.

Hardware support added

GPU support is implemented at the HAL layer on the open-source Panfrost driver; HDMI and dual-display output are working; USB/MIPI camera and ALSA audio are connected. bash and busybox were also ported to supply the tools the HDK installer depends on.

What it uses

The system side is OpenHarmony 5.0.3 compiled together with around 20 kernel modules. The application side uses ArkTS and ArkUI, with inference running through MindSpore Lite (CPU) and CANN ACL (NPU) on a YOLOv5s model.

Current status

The 43 patches are merged into the OpenHarmony mainline; the application runs on the board and completes five-class inference, with both the CPU and NPU paths verified. The X-ray classification is a technical demonstration and is not intended for clinical use.

Background

Our lab has a Qizhi01 developer kit equipped with a Huawei Ascend 310B NPU. Out of the box it only came with a Linux SDK — I wanted to run OpenHarmony on it and put that NPU to real use. The project naturally split into two layers: the bottom layer is a system-level port of OpenHarmony 5.0.3, and the top layer is Ascend X-Ray Expert — a HarmonyOS app built with ArkTS that uses YOLOv5s inference to detect conditions like pneumonia and tuberculosis in chest X-rays. Two inference paths were implemented: MindSpore Lite on CPU and CANN ACL on NPU, both verified and functional.

OpenHarmony System Porting

The Ascend 310B chipset differs from any officially supported OpenHarmony board, requiring adaptation from the ground up

What was adapted

GPU Graphics

Leveraged Mali GPU's open-source Panfrost driver, implemented HAL against OpenHarmony's Display Composer VDI interface

HDMI & Dual Display

HDMI output with dual-screen support, involving framebuffer management and VSync synchronization

Camera & Audio

V4L2 drivers for USB and MIPI CSI cameras, ALSA audio and HDMI audio output

NPU Inference Environment

Set up CANN inference, validated YOLOv5 models, and successfully ran MindIE Qwen3-0.6B LLM on-device

Technical details

  • Applied 43 patches to OpenHarmony mainline, covering the build system, HDF driver framework, GPU 2D/3D, SELinux, Camera V4L2, Audio ALSA, multi-display, HDC debugging, power management, and more
  • Built/ported 20+ kernel modules: panfrost.ko (GPU), svm.ko (NPU), Bluetooth/WiFi, various V4L2 drivers
  • Since OpenHarmony's built-in toybox lacks awk, tr, etc. needed by Ascend HDK, I also ported bash-5.1 and busybox-1.36.1
  • build.sh provides one-click compilation: pull OpenHarmony source → apply 43 patches → full build
  • formatSD310B.sh SD flashing tool for direct Linux flashing or img generation for Windows BalenaEtcher
Linux 5.10 Panfrost GPU GBM Gralloc DRM/KMS OpenHarmony 5.0.3 HDF Drivers GN + Ninja 43 Patches V4L2 Camera ALSA Audio HDMI Display SELinux

Ascend X-Ray Expert

HarmonyOS 5.0.3 (API15) · ArkTS + ArkUI · Dual inference engines

Five-class detection

YOLOv5s object detection on chest X-rays, classifying into five categories. Medical imaging is a natural fit for edge NPU inference — hospitals cannot send patient data to the cloud due to privacy and latency constraints.

Pneumonia (Bacteria)
Pneumonia (Virus)
Sick (Other)
Healthy
Tuberculosis

Dual inference engines

Both CPU and NPU inference paths were implemented as part of the full-stack exercise:

MindSpore Lite (CPU)

Uses HarmonyOS's built-in MindSpore Lite Kit to load .ms model files, 2-thread CPU inference.
Preprocessing (RGBA → float normalization) and postprocessing (NMS, IoU) all implemented in ArkTS.

CANN ACL (NPU)

C++ side: dlopen loads libacl_runtime.so, then aclInit → aclrtSetDevice → aclrtCreateContext → aclrtCreateStream, with aclmdlLoadFromFile loading the .om offline model.
Exposes initYoloEngine and runYoloInference to ArkTS via NAPI.

Inference pipeline

Select image

PhotoViewPicker → resize to 640×640 with letterbox padding

Preprocess

RGBA → float32 → normalize → feed to inference engine

Inference

NPU via CANN ACL, CPU via MindSpore Lite

Postprocess

NMS + IoU → filter low-confidence overlapping detections

Display

Canvas renders detection boxes, three-column layout — image, stats, history

HarmonyOS 5.0.3 API15 ArkTS ArkUI Stage Model YOLOv5s CANN ACL MindSpore Lite NMS NAPI C++ CMake

Architecture Overview

Complete four-layer stack from hardware to application

Hardware

Ascend 310B
ARM CPU + Mali GPU
NPU AI Accelerator

Kernel Drivers

Linux 5.10
panfrost + svm
20+ .ko modules

HAL Layer

OpenHarmony 5.0.3
Display Composer VDI
Gralloc / Audio / V4L2

Application

ArkUI + ArkTS
Ascend X-Ray Expert
CANN NPU + MindSpore Lite

Key Takeaways

End-to-end full stack

From kernel patches and HAL adaptation to ArkUI application development — the complete embedded system chain.

Dual inference engines

MindSpore Lite (CPU) and CANN ACL (NPU) both verified, with the NPU offering significantly lower inference latency.

Medical use case

X-ray analysis demands privacy and low latency — edge NPU inference addresses both requirements naturally.

LLM on edge NPU

Successfully ran Qwen3-0.6B via MindIE on the Ascend 310B, validating small LLM viability on embedded NPUs.

One-click build

build.sh automates source pull, patch application, and full compilation for streamlined reproduction.

NAPI bridge

C++ CANN inference engine seamlessly integrated into the ArkTS application layer via NAPI.

Back to projects