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.
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
Leveraged Mali GPU's open-source Panfrost driver, implemented HAL against OpenHarmony's Display Composer VDI interface
HDMI output with dual-screen support, involving framebuffer management and VSync synchronization
V4L2 drivers for USB and MIPI CSI cameras, ALSA audio and HDMI audio output
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.shprovides one-click compilation: pull OpenHarmony source → apply 43 patches → full buildformatSD310B.shSD flashing tool for direct Linux flashing or img generation for Windows BalenaEtcher
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.
Dual inference engines
Both CPU and NPU inference paths were implemented as part of the full-stack exercise:
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.
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
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
From kernel patches and HAL adaptation to ArkUI application development — the complete embedded system chain.
MindSpore Lite (CPU) and CANN ACL (NPU) both verified, with the NPU offering significantly lower inference latency.
X-ray analysis demands privacy and low latency — edge NPU inference addresses both requirements naturally.
Successfully ran Qwen3-0.6B via MindIE on the Ascend 310B, validating small LLM viability on embedded NPUs.
build.sh automates source pull, patch application, and full compilation for streamlined reproduction.
C++ CANN inference engine seamlessly integrated into the ArkTS application layer via NAPI.