3 HDC Debugging
HDC (OpenHarmony Device Connector) is a command-line tool provided for developers to connect and debug devices. This tool needs to support deployment on Windows/Linux/Mac systems to communicate with OpenHarmony devices (or emulators) for connection debugging.
In simple terms, HDC is a command-line tool provided by OpenHarmony for developers to debug hardware and applications. It is used for interaction between the computer and development board. It is suitable for OpenHarmony application, hardware development, and testing personnel, and is an essential and entry-level tool for every developer.
3.1 Environment Preparation
This document uses Windows11 PC and RK development board as examples for explanation.
3.1.1 Installing USB Driver
Baidu Netdisk Link: ShiMetaPi Supporting Netdisk Resources - Baidu Netdisk, Extraction code: smcc
DriverAssitant is the USB driver that comes with the RK development board.
- Extract the Rockchip USB driver compression package (DriverAssitant_v5.1.1) from the resource package.

Note:
Driver Path: ShiMetaPi Supporting Netdisk Resources>02-Software Tools>Rockchip>RKTools>windows>DriverAssitant_v5.1.1.zip
After extracting the compression package, click driver installation (DriverInstall.exe) in the folder.
Check in Device Manager whether the driver is installed successfully. If successful, it will display "HDC Device" as shown in the following figure.

3.1.2 HDC Tool Download
- Download the HDC tool from the resource package. The files contained in the HDC folder are shown in the following figure.

This document places the above two files in the D:\tools\HDC path

Note:
Tool Path: ShiMetaPi Supporting Netdisk Resources>02-Software Tools>Rockchip>OpenHarmony>HDC Tool
- HDC PATH environment configuration:
HDC PATH environment configuration is shown in the figure:
Right-click "My Computer", select "Properties", select "Advanced System Settings -> Environment Variables -> Double-click PATH in System Environment Variables -> New input "D:\tools\HDC" -> Click "OK" all the way.



Note:
The path in the environment variable should be the path where HDC exists on your own computer, without Chinese characters
3.3 Connecting the Device
- M4-R1's USB-OTG is already in device mode by default.
- Connect the device OTG port to the computer using a USB cable.
- Open the command-line tool on the computer and enter "hdc list targets". If connected successfully, it will print the device as follows:
hdc list targets
d6290343394135353110d2d800002b00- Enter "hdc shell" to enter the terminal.

3.4 Common Commands
The following highlights some commonly used HDC commands. Others can be searched through search engines.
- Device Query
hdc list targets- Remount
hdc shell mount -o remount,rw /- Start APP
hdc shell aa start -a MainAbility -b com.example.sampledemo- Reboot
hdc shell reboot- Install APP
hdc install -r path.hap- Copy Computer File to Device
hdc file send "D:\D-backup\temp_work\xxx.hap" data/xxx.hap- Copy Device File to Computer (Capture Log)
hdc file recv /data/log ./openharmony_log- Query Application Information
bm dump -n com.example.mydemo |grep system3.5 bn Tool
Bundle Manager (package management tool, abbreviated as bm) is a tool that implements functions such as application installation, uninstallation, updating, and querying. bm provides developers with basic debugging capabilities for application installation packages, such as: installing applications, uninstalling applications, querying installation package information, etc.
For detailed introduction, see the official document: bm tool - OpenAtom OpenHarmony
3.6 aa Tool
Ability Assistant (Ability Assistant, abbreviated as aa) is a tool that implements application and test case startup functions. It provides developers with basic application debugging and testing capabilities, such as starting application components, forcibly stopping processes, printing application component related information, etc.
For detailed introduction, see the official document: aa tool - OpenAtom OpenHarmony
