07 Test Commands
The command operations in this chapter are all executed in the board terminal.
1 Explore /sys Directory
Similar to the /proc directory, files/folders under the /sys directory provide users with some information about devices, kernel modules, file systems, and other kernel components. For example, the subdirectory block stores all block devices; the subdirectory bus stores all bus types in the system, such as i2c, usb, sdio, pci, etc.; the subdirectory class classifies devices by type, such as leds, lcd, mtd, pwm, etc.
Try executing the following commands in the board terminal to view the directory contents of each level of sys:
# Execute the following commands in the terminal on the board to view
ls /sys
ls /sys/class
ls /sys/class/leds
ls /sys/class/leds/work
As can be seen, under the /sys/class/leds directory of this board, there is: work, which is the green light beating like a heart on the development board.
Taking the /sys/class/leds/work directory as an example, it contains files such as brightness, device, max_brightness, power, subsystem, trigger, uevent, etc. Among them, brightness represents the brightness of the LED light, and trigger represents the triggering method of the LED light. We can modify or view these files through commands such as echo and cat to achieve the purpose of controlling the LED light. The following explains with examples.
2 Control Heartbeat LED
Before controlling the heartbeat LED, you need to switch to the root user for operation.
Before controlling the heartbeat LED, we can first look at the triggering method of the heartbeat LED.
cat /sys/class/leds/work/triggerAs can be seen, the selected state is heartbeat.

The brightness file under the LED light device represents its brightness value. In the kernel driver provided by this board, the heartbeat light is directly IO controlled. Its brightness range is 1 and 0, representing on and off.
# Turn off heartbeat LED
echo 0 > /sys/class/leds/work/brightness
# Turn on heartbeat LED
echo 1 > /sys/class/leds/work/brightness
# When we complete this operation, we can check the current trigger method of the heartbeat light, which is now in an uncontrolled state
If you want to switch the light to heartbeat mode, after execution, the heartbeat light re-enters the heartbeat state.
# Perform the following operations under root permission
echo heartbeat > /sys/class/leds/work/trigger3 Explore /dev Directory
In addition to the /proc and /sys directories, the /dev directory also contains very rich device information. This directory contains all external devices used in the Linux system, such as /dev/tty for serial port devices, /dev/ram for memory. Through these device files, we can also access the corresponding hardware devices.
Try using the following commands to view the contents of the dev directory:
ls /dev
ls /dev/input
Taking the content under the /dev/input directory in the figure above as an example, event0 above is the event file interface of the input device. Through them, we can know the input events reported by the device. The number after event is not bound to the device. You can view the file /proc/bus/input/devices to understand what they represent respectively.
Execute the following command in the board terminal:
cat /proc/bus/input/devices
As shown in the figure above, it can be seen that the current board contains multiple input devices. There may be differences on specific boards:
event0: Name isrk805 pwrkey, it corresponds to the power key on/off, input0. Some boards may not have this function.event1: Name isgoodix-ts, it corresponds to the gt9xx touch screen, input1. Some boards may not have this function.event2: Name ishdmi_cec_key, it corresponds to receiving and processing HDMI CEC key events, input2. Some boards may not have this function.event3: Name isadc-keys, it corresponds to the Recovery key, input3. Some boards may not have this function.event4: Name isrk-headset, it corresponds to headset insertion detection, input4. Some boards may not have this function.
Tips
The flashing function of the Recovery key only works when the kernel starts. After entering the system, this key loses its function. We can operate this key, taking this key as an example below.
4 Detect Keys
In the board, we can use the evtest tool to more conveniently view the input devices currently connected to the hardware and detect them in real time.
Install evtest tool via apt:
sudo apt install evtestNote: Before using the apt install command for the first time, you need to execute the following to refresh the mirror source:
sudo apt updateUse evtest tool:
sudo evtestAfter executing the command, it will scan the event device input event files under the /dev/input directory and list them to the terminal.

It prompts us that we can select the corresponding device for testing by number. Please select according to the output on your own board.
We select "adc-keys", that is, press '3' and then press Enter to confirm. You can execute "Ctrl" + "c" to exit.

adc-keys corresponds to the Recovery button. After I perform a press and release operation, as shown in the figure below:

