Chapter 5 System Debugging -- HDC Debugging
1. Preface
hdc (OpenHarmony Device Connector) is a command-line tool for developers to connect and debug devices. This tool needs to support deployment on Windows/Linux/Mac and other systems to connect and debug communicate with OpenHarmony devices (or emulators).
In short, hdc is a command-line tool provided by OpenHarmony for developers to debug hardware and applications. It is used for interaction between computer and development board. It is suitable for OpenHarmony application, hardware development, and testing personnel. It is an essential and entry-level tool for every developer.
2. Environment Preparation
Supported operating environments
This article uses window11 computer and Rk development board as examples for explanation.
2.1 Install USB Driver
DriverAssitant is the USB driver that comes with the RK development board. Double-click DriverInstall.exe to select driver installation.
- Download Rockchip USB driver compressed package (DriverAssitant_v5.1.1) from Baidu Cloud data.
https://pan.baidu.com/s/1ZUn2BNg-Sb6M-fWhDqAFMw?pwd=smcc Extraction code: smcc
- After extracting the compressed package, click driver installation (DriverInstall.exe) in the folder.
Tips
Driver compressed package path: ShiMetaPi matching cloud data > 02-Software Tools > Rockchip > RKTools > windows > DriverAssitant_v5.1.1.zip
- Check if driver is installed successfully in Device Manager:

2.2 hdc Tool Download
- Download HDC tool from Baidu Cloud data. Link: https://pan.baidu.com/s/1nD6d__hYqQhQKyXvVfKoJg Extraction code: smcc

Tips
Tool path: ShiMetaPi matching cloud data > 02-Software Tools > OpenHarmony > HDC Tool
- hdc path environment configuration:
hdc path environment configuration as shown in the figure: My computer, right-click to select Properties, select "Advanced System Settings" → Environment Settings → double-click Path in System Environment Variables → New, enter "D:\tools\HDC" → confirm 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. Connect 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
150100414a54443452069035fa308800- Enter 'hdc shell' to enter the terminal.

4. Common Commands
The following focuses on 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- Restart
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 (grab log)
hdc file recv /data/log ./openharmony_log- Query Application Information
bz dump -n com.example.mydemo |grep system5. bm Tool
Bundle Manager (package management tool, abbreviated as bm) is a tool that implements application installation, uninstallation, update, query, and other functions. bm provides developers with basic application installation package debugging capabilities, such as: installing applications, uninstalling applications, querying installation package information, etc.
6. aa Tool
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.
