04-Expansion_Pins_Testing
GPIO
WiringKP Tool Usage
Check whether the system has WiringKP tools
which gpio
If not, download and copy it from the network disk to the board system
Tool download path:
h618_data\3-SoftwareData\GPIO_tools
Extract wiringKP.tar.gz on the board. Place executables and libraries into /usr/bin and /usr/lib.
Example Usage

**Set PH5 to output mode and output high level **
(Note: PC pins output 1.8V, PH pins output 3.3V):
Use a multimeter to verify PH5 is high. Set PH5 to input mode with pull-down
Set PH2 to PWM mode

Adjust duty cycle
PWM duty cycle = CCR/ARR
CCR range: 0~65535 (default 512)
ARR range: 1~65536 (default 1024)


Adjust frequency


sys GPIO Control
Step 1: Release GPIO via /sys/class/gpio
Ensure the target GPIO is in UNCLAIMED state:
If pins are claimed (e.g., PH2/PH3 used as UART5), modify the device tree to disable default functions:

Edit device tree files:

Step 2: Rebuild and flash the firmware. Step 3: Confirm GPIO is unclaimed:

Step 4: Export and control GPIO (e.g., PH2=226, PH3=227):

Set direction:
Read/write value:
Example Configurations
GPIO Output Default GPIO outputs on K2B: PC12 (pin 12) and PC7 (pin 14). Note: Other pins may require disabling default functions.
Control methods: gpio-leds (Linux kernel driver) or gpio_para (Allwinner driver).
gpio-leds Example (Heartbeat LED):
gpio_para Example (PC7/PC12 Control):
Control commands:
GPIO Key Example:
Serial Port
Test Tools
Use USB-to-TTL cable.

TTL Standard Serial Port
Connect using a serial port tool.

Software Testing Methods
ttyAS5 corresponds to serial port 5 (pins PH2 and PH3) with a baud rate of 115200.
Send data to the serial port:
Receive data:
Modify UART Control Port
Change debug_uart to an unused UART (e.g., UART0 is reserved for U-Boot logs):
Add UART2 Support
PH6/PH7/PH8/PH9 default to SPI. PH4/PH5 default to I2C. To use PH5/PH6 as UART2:
Disable default functions.
Enable UART2 in the device tree.

TTL-to-485 Module Wiring
Connect to UART5:

TTL-to-232 Module Wiring
Connect to UART5:

Last updated