Chapter 5 System Debugging -- HDC Debugging
1. Preface
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, used for interaction between computers and development boards. It is suitable for OpenHarmony application, hardware development, and testing personnel, and is an essential entry-level tool for every developer.
2. Environment Preparation
Supported Operating Environment
This article uses Windows 11 computer and RK development board as examples for explanation
2.1 Install USB Driver
DriverAssistant is the USB driver that comes with the RK development board. Double-click DriverInstall.exe to select driver installation.
- Download the Rockchip USB driver compression package (DriverAssitant_v5.1.1) from the Baidu Netdisk materials
https://pan.baidu.com/s/1ZUn2BNg-Sb6M-fWhDqAFMw?pwd=smcc Extraction code: smcc
- After extracting the compression package, click driver installation (DriverInstall.exe) in the folder
Tips
Driver compression package path: ShiMetaPi supporting Netdisk materials > 02-Software Tools > Rockchip > RKTools > windows > DriverAssitant_v5.1.1.zip
- Check in Device Manager whether the driver is installed successfully:

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

Tips
Tool path: ShiMetaPi supporting Netdisk materials > 02-Software Tools > OpenHarmony > HDC Tool
- hdc path environment configuration:
hdc path environment configuration as shown: My Computer, right-click to select Properties, select "Advanced System Settings" --> Environment Settings --> Double-click path in System Environment Variables --> New input "D:\tools\HDC" --> Confirm all the way



Note:
The path in the environment variable should be the path where hdc exists on your computer, without Chinese characters
3. Connect Device
M4-R1's USB-OTG is already in device mode by default.
Connect the computer to the device OTG port using a USB cable.
Open the command line tool on the computer, enter
hdc list targets. If connected successfully, it will print the device as follows:
hdc list targets
150100414a54443452069035fa308800
```
4) Enter 'hdc shell' to enter the terminal
<img src="./../../picture-M4-R1/hdc8.png" alt="TOOL" style="zoom:100%;" />
## 4. Common Commands
The following introduces some commonly used HDC commands. Others can be searched through search engines
1) Device Query
```typescript
hdc list targets
```
2) remount
```typescript
hdc shell mount -o remount,rw /
```
3) Start APP
```typescript
hdc shell aa start -a MainAbility -b com.example.sampledemo
```
4) Reboot
```typescript
hdc shell reboot
```
5) Install APP
```typescript
hdc install -r path.hap
```
6) Copy Computer File to Device
```typescript
hdc file send "D:\D-backup\temp_work\xxx.hap" data/xxx.hap
```
7) Copy Device File to Computer (Capture Log)
```typescript
hdc file recv /data/log ./openharmony_log
```
8) Query Application Information
```typescript
bm dump -n com.example.mydemo |grep system
```
## 5. bn Tool
Bundle Manager (package management tool, abbreviated as bm) is a tool that implements functions such as application installation, uninstallation, update, and query. bm provides developers with basic debugging capabilities for application installation packages, such as installing applications, uninstalling applications, querying installation package information, etc.
::: tip See details
<https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/tools/bm-tool.md/>
:::
## 6. aa Tool
Ability Assistant (abbreviated as aa) is a tool that implements application and test case startup functions, providing developers with basic application debugging and testing capabilities, such as starting application components, forcibly stopping processes, printing application component related information, etc.
::: tip See details
<https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/tools/aa-tool.md/>
:::
---