K1 JOH5.0 System Debugging Guide
Debugging Tools and Methods
Serial Port Debugging
Available, baud rate 115200, can be used directly to view uboot, kernel, and OpenHarmony init process related prints.
hdc
hdc is similar to Android's adb, supporting both USB and TCP connection modes. TCP mode is used with default port set to 55555. The configuration file is device/board/spacemit/xxx/cfg's default.para, as shown below:
persist.hdc.mode=usb,tcp
persist.hdc.port=55555
Host hdc Support
Windows System
For Windows systems, place hdc.exe (Download here) in a specific directory and set up the environment variable path.
Ubuntu System
-
Install dependencies: Open terminal and enter the following commands to update package list and install necessary development tools and libraries
sudo apt-get update
sudo apt-get install build-essential libstdc++6 libc++1· -
Download HDC toolkit: Visit OpenHarmony official website to download the latest HDC toolkit for Linux platform. Place it in a suitable location and perform extraction operation. Adjust extraction path as needed.
tar -zxvf hdc_std_<version>_linux.tar.gz -C /opt/hdc/
-
Set environment variables: Edit the user's shell initialization script (e.g.,
.bashrc
), add the following lines to the end of the file:export PATH=$PATH:/opt/hdc/bin
source ~/.bashrc -
Verify installation success: In a new terminal window, try running a simple help command to confirm everything is ready. If you can see detailed help documentation, the process is complete.
hdc help
hdc Connection
Network Connection
Ensure hdc's server and client are in the same local area network. Connection method is as follows:
D:\>hdc tconn 10.0.90.142:55555
Connect OK
D:\>hdc shell
#
USB Connection
D:\>hdc list targets
0123456789ABCDEF
D:\>hdc shell
#
Multiple Device Connection
Specify the device using the -t
parameter, as shown below:
D:\>hdc list targets
0123456789ABCDEF
ABCDEF
D:\>hdc -t 0123456789ABCDEF shell
#
Common hdc Commands
Command | Purpose |
hdc list targets | View all current devices |
hdc shell reboot | Reboot |
hdc uninstall com.example.myapp | Uninstall hap package |
hdc install -r xxx.hap | Reinstall hap package |
hdc shell aa start -a EntryAbility -b com.example.myapp | Start hap |
hdc file recv /xxx D:/ | Copy file from device to local |
hdc file send D:/xxx /data/ | Send local file to device |
hdc start -r | Restart server |
hdc Connection Ports for Devices
MUSEPaper&MUSEPaper2

MUSEPi

MUSECard

MUSEBook

hilog
Basic Usage
hilog is similar to Android's logcat. Basic usage is as follows:
hilog
hilog -r
Common Commands
Command | Purpose | Example |
hilog -h | Get help | |
hilog -t app|core|kmsg|init | - Blocking real-time query of module logs - Can be used with other parameters | hilog -t core |
hilog -t app|core|kmsg|init -x | - Non-blocking real-time query of module logs - Can be used with other parameters | hilog -t core -x |
hilog -T <tag> | - Specify tag within module - Can be used with other parameters | hilog -T Launcher_Default |
hilog -L D|I|W|E|F | - Specify level query - D:debug, I:info, W:warning, E:error, F:fatal | hilog -L I |
hilog -D <domain> | - Log service domain for specifying output log's business domain - A hexadecimal integer ranging from 0x0 to 0xFFFFF. - Recommended format: 0xAAABB, where AAA represents subsystem, BB represents module - Specify domain query - Can be used with other parameters | hilog -D 0x0 |
^ | - Exclude | hilog -t ^app -T ^BatteryThread |
Log Persistence
Log persistence means saving logs to a file for later viewing.
Command | Purpose |
hilog -w start [-f "xxx"] [-l <length>] [-j <jobid>] [-m <algorithm>] [-n <number>] | Start persistence task |
hilog -w query [-j <jobid>] | Query persistence task |
hilog -w stop [-j <jobid>] | Stop persistence task |
Example:
# hilog -w query
#
#hilog -w start -f "hilog" -l 66k -j 222 -m zlib -n 2
Persist task [jobid:222] started successfully
#cd /data/log/hilog
# ls -al
total 100
drwxr-x--- 2 logd log 4096 1970-01-02 03:34 .
drwxrwx--- 6 system log 4096 1970-01-01 00:38 ..
-rw-r----- 1 logd system 65540 1970-01-02 03:34 .persisterInfo_222
-rw-r----- 1 logd system 132 1970-01-02 03:34 .persisterInfo_222.info
-rw-r----- 1 logd system 12239 1970-01-02 03:34 hilog.002.19700102-033431.gz
-rw-r----- 1 logd system 6883 1970-01-02 03:34 hilog.003.19700102-033431.gz
#
# hilog -w query -j 222 #Specify jobid query
222 core,app zlib /data/log/hilog/hilog 67584 2
#
# hilog -w query #Query all persistence tasks
222 core,app zlib /data/log/hilog/hilog 67584 2
#
# hilog -w stop -j 222
Persist task [jobid:222] stopped successfully
#
# ls -al
total 36
drwxr-x--- 2 logd log 4096 1970-01-02 03:35 .
drwxrwx--- 6 system log 4096 1970-01-01 00:38 ..
-rw-r----- 1 logd system 12239 1970-01-02 03:34 hilog.002.19700102-033431.gz
-rw-r----- 1 logd system 13000 1970-01-02 03:35 hilog.003.19700102-033431.gz
hidumper
hidumper is a unified system information retrieval tool in OpenHarmony for developers, testers, and IDE tools, helping users analyze and locate issues.
Command | Purpose |
hidumper -h | Get help |
hidumper --cpuusage [pid] | View CPU usage information of a process |
hidumper --mem [pid] | View memory usage of a process |
hidumper --cpufreq | View CPU frequency |
hidumper --storage | View storage information |
hidumper --net | View network information |
Parameter Management
Command | Purpose |
param -h | Get help |
param ls -r | View all system parameters |
param ls -r persist.sys.hilog.debug.on | View system parameter |
param get persist.sys.hilog.debug.on | Get system parameter |
param set persist.sys.hilog.debug.on true | Set system parameter |
Simulated Key Press
Mouse Operations
# uinput -?
Usage: uinput <option> <command> <arg>...
The option are:
-M --mouse
commands for mouse:
-m <dx> <dy> --move <dx> <dy> -move to relative position (dx,dy),
<dx1> <dy1> <dx2> <dy2> [smooth time] --trace -dx1 dy1 to dx2 dy2 smooth movement
-d <key> --down key -press down a button,
0 is the left button, 1 is the right,
2 is the middle
-u <key> --up <key> -release a button
-c <key> --click <key> -press the left button down,then raise
-b <dx1> <dy1> <id> [press time] [click interval time] --double click
[press time] the time range is more than 1ms but less than 300ms,
[click interval time] the time range is more than 1ms but less than 450ms,
Otherwise the operation result may produce error or invalid operation
-press the left button down,then raise
key value:0 - button left
key value:1 - button right
key value:2 - button middle
key value:3 - button side
key value:4 - button extra
key value:5 - button forward
key value:6 - button back
key value:7 - button task
-s <key> --scroll <key> -positive values are sliding backwards
-g <dx1> <dy1> <dx2> <dy2> [total time] --drag <dx1> <dy1> <dx2> <dy2> [total time],
dx1 dy1 to dx2 dy2 smooth drag
-i <time> --interval <time> -the program interval for the (time) milliseconds
negative values are sliding forwards
Command Examples
Command | Purpose |
uinput -M -m 50 50 | Move mouse cursor to position (50,50) |
Uinput -M -b 50 200 0 100 300 | Double-click left mouse button at (50,200), click event duration 100ms, double-click interval 300ms |
Keyboard Operations
# uinput -?
Usage: uinput <option> <command> <arg>...
The option are:
-K --keyboard
commands for keyboard:
-d <key> --down <key> -press down a key
-u <key> --up <key> -release a key
-l <key> [long press time] --long_press <key> [long press time] -press and hold the key
-i <time> --interval <time> -the program interval for the (time) milliseconds
Key Values
Key | Keycode |
KEYCODE_HOME | 1 |
KEYCODE_BACK | 2 |
KEYCODE_VOLUME_UP | 16 |
KEYCODE_VOLUME_DOWN | 17 |
KEYCODE_POWER | 18 |
KEYCODE_VOLUME_MUTE | 22 |
KEYCODE_DPAD_UP | 2012 |
KEYCODE_DPAD_DOWN | 2013 |
KEYCODE_DPAD_LEFT | 2014 |
KEYCODE_DPAD_RIGHT | 2015 |
KEYCODE_DPAD_CENTER | 2016 |
KEYCODE_TAB | 2049 |
Command Examples
Command | Purpose |
uinput -K -d 1 -u 1 | Press HOME key to return to main screen |
uinput -K -d 1 -u 1 | Increase volume |
Touchscreen Operations
# uinput -?
Usage: uinput <option> <command> <arg>...
The option are:
-T --touch
commands for touch:
-d <dx1> <dy1> --down <dx1> <dy1> -press down a position dx1 dy1,
-u <dx1> <dy1> --up <dx1> <dy1> -release a position dx1 dy1,
-m <dx1> <dy1> <dx2> <dy2> [smooth time] --smooth movement
<dx1> <dy1> <dx2> <dy2> [smooth time] -smooth movement,
dx1 dy1 to dx2 dy2 smooth movement
-c <dx1> <dy1> [click interval] -touch screen click dx1 dy1
Command Examples
To be completed.
Service Management
Command | Purpose |
service_control start pulseaudio | Start pulseaudio service |
service_control stop pulseaudio | Stop pulseaudio service |
hiperf
https://device.harmonyos.com/cn/docs/documentation/guide/subsys-toolchain-hiperf-0000001186316470
bytrace
To obtain trace using hdc:
- Capture trace:
D:\>hdc shell
# param set const.security.developermode.state true
# param set persist.hdc.root 1
# echo > /sys/kernel/debug/tracing/trace
# echo 4096 > /sys/kernel/debug/tracing/saved_cmdlines_size
# bytrace -t 10 -b 4096 --overwrite ohos zimage zmedia zcamera zaudio ability distributeddatamgr graphic freq irq mdfs workq mmc idle notification sync pagecache ace app > /mnt/mynewtrace.ftrace
# echo > /sys/kernel/debug/tracing/trace
# exit
D:\>hdc file recv /mnt/mynewtrace.ftrace
View trace:
https://ui.perfetto.dev (requires internet access)
View trace:
bootchart
Usage:
1. hdc shell
2. begetctl bootchart enable
3. reboot or power cycle
4. begetctl bootchart stop
5. begetctl bootchart disable
6. Check if the following files exist in /data/service/el0/startup/init/ directory:
header, proc_diskstats.log, proc_ps.log, proc_stat.log
7. Execute command in /data/service/el0/startup/init/: tar -czf bootchart.tgz * # Package files
8. hdc_std file recv /data/service/el0/startup/init/bootchart.tgz ./ # Export files
9. Generate boot performance image: java -jar bootchart.jar bootchart.tgz
glmark
Usage:
Run the following three commands to perform glmark aging test:
power-shell setmode 602
cd /system/bin
./glmark2-es2 --run-forever --size 720x720
wpa_supplicant&wpa_cli
Usage:
1. Enable and disable WiFi
2. cd /vendor/bin/
3. ./wpa_supplicant -B -i wlan0 -c /data/service/el1/public/wifi/wpa_supplicant/wpa_supplicant.conf
4. ps -ef | grep wpa to check if wpa_supplicant is running
5. /wpa_cli -p /data/service/el1/public/wifi/sockets/wpa
6. > scan
7. > scan_results
8. > add_network, returns an ID
9. > set_network ID ssid "WiFi name"
10. > set_network ID psk "WiFi password"
11. > enable_network ID
snapshot_display
param set const.security.developermode.state true
param set persist.hdc.root 1
snapshot_display -f /data/local/tmp/test1.jpeg
wukong
To be completed.
power-shell
power-shell setmode 602 # Performance mode, disable sleep
power-shell suspend # Sleep
power-shell display -s xxx # Set brightness
Remount system/vendor partition as read-write
The system/vendor partition is mounted as read-only (ro) by default. When debugging and using hdc file send
to push files, remount it as read-write as follows:
mount -o remount,rw /vendor
mount -o remount,rw /
This setting is lost after system reboot and needs to be remounted.
gdb Debugging
To be added.
Common Testing Methods
Monkey Testing
To be added.
Loop Reboot
To be added.
Loop Music Playback
To be added.
Loop Video Playback
To be added.
Common Issue Debugging Methods
Peripherals
Screen Backlight Adjustment Failure
- Check and set the node
sys/class/backlight/backlight/brightness
to confirm if the driver is functioning properly. - If setting the above node brightness has no effect, the driver has issues. Investigate the driver, focusing on whether the PWM corresponding to the backlight is functioning correctly.
- If setting the above node brightness has an effect, the issue lies in the OH upper layer. Use the command power-shell display -s xxx (100>xxx>0) to check if brightness changes.
System
cppcrash
To be added.
Referenced from Spacemit Developer Documentation