04-Expansion_Pins_Testing

GPIO

WiringKP Tool Usage

Check whether the system has WiringKP tools

which gpio
image-20250514102207335

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

image-20250314150200725

**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

image-20250514115200103

Adjust duty cycle

PWM duty cycle = CCR/ARR

CCR range: 0~65535 (default 512)

ARR range: 1~65536 (default 1024)

image-20250514115347443
image-20250514115517926

Adjust frequency

image-20250514115800211
image-20250514115920195

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:

image-20250326115428401

Edit device tree files:

image-20250326133713399

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

image-20250326142700157

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

image-20250326142738724

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.

image-20241231145656021

TTL Standard Serial Port

Connect using a serial port tool.

66637824ee48c91b31130503a4400149

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:

  1. Disable default functions.

  2. Enable UART2 in the device tree.

cf9c366bb88d7214bc93412cbc0accb3

TTL-to-485 Module Wiring

Connect to UART5: image-20250324195428239


TTL-to-232 Module Wiring

Connect to UART5: image-20250324195442978

Last updated