Kickpi-Book
  • KICKPI Document
  • K5/K5C(A133)
    • A133中文文档
      • 01-主板介绍
        • 01-KICKPI-K5硬件介绍
        • 02-KICKPI-K5C硬件介绍
      • 02-入门必读
        • 01-网盘目录说明
        • 02-快速使用
        • 03-功能测试
        • 04-扩展引脚
      • 03-镜像烧录
        • 01-获取镜像文件
        • 02-SD卡烧录
        • 02-USB线烧录
      • 04-SDK编译
        • 01-编译环境搭建
        • 02-LINUX_SDK源码编译
        • 03-ANDROID_SDK源码编译
      • 05-外设驱动
        • LCD功能调试
        • LRADC按键配置
      • 06-ANDROID系统定制
        • 01-Android常用系统定制
      • 07-LINUX系统定制
        • 02-Linux常用系统定制
      • 08-进阶
        • K5C主板供电
        • 安卓休眠唤醒
        • 13-硬件工厂测试
    • en
      • 01-Development_board_Introduction
        • 01-KICKPI-K5_Hardware_Introduction
        • 02-KICKPI-K5C_Hardware_Introduction
      • 02-Getting_Started_Guide
        • 01-KICKPI_Cloud_Storage_Introduction
        • 02-Quick_Start_Guide
        • 03-Functional_Testing
        • 04-Expansion_Pins_Testing
      • 03-Image_Flashing_Guide
        • 01-How_to_Get_Image_File
        • 02-SD Card Burning
        • 03-USB_Cable_Flashing
      • 04-SDK_Compilation_Guide
        • 01-Compilation_Environment_Setup
        • 02-Linux_SDK_Compilation
        • 03-Android_SDK_Compilation
      • 06-Android_System_Customization
        • 01-Android_Common_System_Customization
      • 07-Linux_System_Customization
        • ADB_Tutorial
  • K2B/K2C(H618)
    • en
      • 01-Development_board_Introduction
        • 01-KICKPI-K2B_Hardware_Introduction
        • 02-KICKPI-K2B_Hardware_Introduction
      • 02-Getting_Started_Guide
        • 01-KICKPI_Cloud_Storage_Introduction
        • 02-Quick_Start_Guide
        • 03-Functional_Testing
        • 04-Expansion_Pins_Testing
      • 03-Image_Flashing_Guide
        • 01-SD_Card_Flashing
        • 02-USB_Cable_Flashing
      • 04-SDK_Compilation_Guide
        • 01-Compilation_Environment_Setup
        • 02-Linux_SDK_Compilation
        • 03-Android_SDK_Compilation
      • 05-Drivers_Development
        • RTC
      • 06-Android_System_Customization
        • 01-Android_Common_System_Customization
      • 07-Linux_System_Customization
        • 01-Linux_Common_System_Customization
      • 08-Advanced_Topics
        • Hardware_Factory_Testing
        • Keybox
    • zh
      • 01-主板介绍
        • 01-KICKPI-K2B硬件介绍
        • 02-KICKPI-K2C硬件介绍
      • 02-入门必读
        • 01-网盘目录说明
        • 02-快速使用
        • 03-功能测试
        • 04-扩展引脚
      • 03-镜像烧录
        • 01-SD卡烧录
        • 02-USB线烧录
      • 04-SDK编译
        • 01-编译环境搭建
        • 02-LINUX_SDK源码编译
        • 2. Android SDK编译
      • 05-外设驱动
        • RTC
      • 06-Android系统定制
        • Android常用系统定制
      • 07-Linux系统定制
        • 01-Linux常用系统定制
        • 02-Linux_QT开发环境搭建
      • 08-进阶
        • Keybox
        • Secure Boot
        • Windows_QT开发环境搭建
        • 扩展引脚功能定制
        • 硬件工厂测试
  • K1/K1B/K3/K8(RK356x-RK3588)
    • en
      • 01-Development_board_Introduction
        • 01-RK_Chip_Comparison_Introduction
        • 02-KICKPI-K1_Hardware_Introduction
        • 03-KICKPI-K1B_Hardware_Introduction
        • 04-KICKPI-K3_Hardware_Introduction
        • 05-KICKPI-K8_Hardware_Introduction
      • 02-Getting_Started_Guide
        • 01-Cloud_Storage_Directory_Description
        • 02-K1-Quick_Start_Guide
        • 02-K1B-Quick_Start_Guide
        • 02-K3-Quick_Start_Guide
        • 02-K8-Quick_Start_Guide
        • 03-Functional_Testing
        • 04-Expansion_Pins
      • 03-Image_Flashing_Guide
        • 01-USB_Cable_Flashing
      • 04-SDK_Compilation_Guide
        • 01-Compilation_Environment_Setup
        • 02-LINUX_SDK_Compilation
        • 03-ANDROID_SDK_Compilation
      • 05-Drivers_Development
        • GPIO
        • Kernel
        • LCD
        • PWM
        • RTC
      • 06-Android_System_Customization
        • 01-Common_Android_System_Customizations
        • 01-Common_Android_System_Customizations
      • 07-Linux_System_Customization
        • 01-Common_Linux_System_Customization
        • 02-Installing_VNC_on_Linux
        • 03-Linux_Docker
        • 04-Linux_QT_Environment_Setup
        • 05-Linux_NPU_YOLOV5S_object_detection
      • 08-Advanced_Topics
        • 01-Hardware_Factory_Test
        • 02-Hardware_Aging_Test
        • 03-Firmware_Unpacking_and_Packing
    • zh
      • 01-主板介绍
        • 01-RK芯片对比介绍
        • 02-KICKPI-K1硬件介绍
        • 03-KICKPI-K1B硬件介绍
        • 04-KICKPI-K3硬件介绍
        • 05-KICKPI-K8硬件介绍
      • 02-入门必读
        • 01-网盘目录说明
        • 02-K1-快速使用
        • 02-K1B-快速使用
        • 02-K3-快速使用
        • 02-K8-快速使用
        • 03-功能测试
        • 04-拓展引脚
      • 03-镜像烧录
        • 01-获取镜像文件
        • 02-USB线烧录
      • 04-SDK编译
        • 01-编译环境搭建
        • 02-LINUX_SDK编译
        • 03-ANDROID_SDK编译
      • 05-外设驱动
        • GPIO
        • Kernel
        • LCD
        • PWM
        • RTC
      • 06-ANDROID系统定制
        • 01-Android常用系统定制
        • 07-Android NPU YOLOV5 目标检测
      • 07-LINUX系统定制
        • 01-Linux常用系统定制
        • 02-Linux安装VNC
        • 03-Linux Docker环境搭建
        • 04-Linux QT环境搭建
        • 05-Linux NPU YOLOV5S 目标检测
      • 08-进阶
        • 01-硬件工厂测试
        • 02-硬件老化测试
        • 03-固件解包和打包
  • K7(RK3576)
    • en
      • 01-Development_board_Introduction
        • 01-KICKPI-K7_Hardware_Introduction
      • 02-Getting_Started_Guide
        • 01-KICKPI_Cloud_Storage_Introduction
        • 02-Quick_Start_Guide
        • 03-Functional_Testing
        • 04-Expansion_Pins_Testing
      • 03-Image_Flashing_Guide
        • 01-How_to_Get_Image_File
        • 02-USB_Cable_Flashing
      • 04-SDK_Compilation_Guide
        • 01-Compilation_Environment_Setup
        • 02-Linux_SDK_Compilation
        • 03-Android_SDK_Compilation
      • 05-Drivers_Development
        • ADC
        • PWM
      • 06-Android_System_Customization
        • 01-Android_Common_System_Customization
      • 07-Linux_System_Customization
        • 01-Linux_Common_System_Customization
        • 02-Linux_Docker_Environment_Setup
        • 03-Linux_NPU_YOLOv5s_Object_Detection
        • 04-Linux_DeepSeek_Large_Model
        • 05-Linux_VNC_Remote_Control
      • 08-Advanced_Topics
        • Advanced_Testing
    • zh
      • 01-主板介绍
        • 01-KICKPI-K7硬件介绍
      • 02-入门必读
        • 01-网盘目录说明
        • 02-快速使用
        • 03-功能测试
        • 04-拓展引脚
      • 03-镜像烧录
        • 01-获取镜像文件
        • 02-USB线烧录
      • 04-SDK编译
        • 01-编译环境搭建
        • 02-Linux_SDK编译
        • 03-Android_SDK编译
      • 05-外设驱动
        • ADC
        • PWM
      • 06-ANDROID系统定制
        • 01-Android常用系统定制
      • 07-LINUX系统定制
        • 01-Linux常用系统定制
        • 02-Linux Docker环境搭建
        • 03-Linux NPU YOLOV5S 目标检测
        • 04-Linux_Deepseek大模型
        • 05-Linux_VNC远程控制
      • 08-进阶
        • 进阶测试
  • K4B(T113-S3)
    • T113-S3中文文档
      • 01-KICKPI-K4B硬件介绍
      • 10-系统镜像烧录
      • 11-SDK源码编译
      • 12-硬件功能测试
      • 13-硬件工厂测试
      • LCD功能调试
      • 20-Ubuntu20.04系统定制
      • Buildroot_QT5配置
      • Buildroot系统定制
  • common
    • en
      • adb
        • ADB_Tutorial
      • allwinner_burnning
        • SD_Card_Flashing
        • USB_Cable_Flashing
      • debug
        • 01 - Log Collection
      • display
        • FPC_Interface_Introduction
      • linux
        • SSH
    • zh
      • adb
        • ADB教程
      • android
        • qt
      • debug
        • 01-日志抓取
        • 常见问题
      • display
        • FPC接口介绍
      • linux
        • SSH
        • VNC
        • qt
      • 全志烧录
        • SD卡烧录
        • USB线烧录
Powered by GitBook
On this page
  • GPIO
  • WiringKP Tool Usage
  • sys GPIO Control
  • Example Configurations
  • Serial Port
  • Modify UART Control Port
  • Add UART2 Support
  • TTL-to-485 Module Wiring
  • TTL-to-232 Module Wiring
  1. K2B/K2C(H618)
  2. en
  3. 02-Getting_Started_Guide

04-Expansion_Pins_Testing

Last updated 1 day ago

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

gpio readall // Get all pin status
gpio read <wPi>        // Read pin level
gpio mode <wPi> <mode> // Set pin mode (supports out/in/up/down/pwm)
gpio write <wPi> <val> // Set pin output level

pwm related command
gpio pwmr <wPi> <val>    //Setting ARR
gpio pwm <wPi> <val>     //Setting CCR
gpio pwmc <wPi> <val>    //Setting Frequency Dividing Coefficient
gpio pwmTone <wPi> <val> //Setting Frequency

**Set PH5 to output mode and output high level **

(Note: PC pins output 1.8V, PH pins output 3.3V):

kickpi@kickpi:~$ gpio mode 0 out
kickpi@kickpi:~$ gpio read 0
0
kickpi@kickpi:~$ gpio write 0 1
kickpi@kickpi:~$ gpio read 0
1

Use a multimeter to verify PH5 is high. Set PH5 to input mode with pull-down

kickpi@kickpi:~$ gpio mode 0 in
kickpi@kickpi:~$ gpio mode 0 down
kickpi@kickpi:~$ gpio read 0
0
kickpi@kickpi:~$ // Short pins 3 and 4
kickpi@kickpi:~$ gpio read 0
1

Set PH2 to PWM mode

root@kickpi:~# gpio mode 3 pwm #Default output frequency 23475Hz Square wave with duty cycle 50%

Adjust duty cycle

PWM duty cycle = CCR/ARR

CCR range: 0~65535 (default 512)

ARR range: 1~65536 (default 1024)

gpio pwmr 3 2048 //Set ARR to 2048 Duty cycle to 512/2048=25%
gpio pwm 3 1024 //Set CCR to 1024 Duty cycle to 1024/2048=50%

Adjust frequency

gpio mode 3 pwm //The default output frequency is 23475Hz
//Set the frequency division coefficient to 5, then the output frequency is 23475/5=4695Hz, the actual frequency is 4688Hz, the error can be ignored
gpio pwmc 3 5   
gpio pwmTone 3 20000 //Directly set the frequency to 20000Hz

sys GPIO Control

Step 1: Release GPIO via /sys/class/gpio Ensure the target GPIO is in UNCLAIMED state:

cat /sys/kernel/debug/pinctrl/300b000.pinctrl/pinmux-pins

If pins are claimed (e.g., PH2/PH3 used as UART5), modify the device tree to disable default functions:

Edit device tree files:

vim longan/device/config/chips/h618/configs/p2/linux-5.4/board-*.dts  // Android
vim source/kernel/linux-5.4-h618/arch/arm64/boot/dts/sunxi/sun50iw9-kickpi-k2b.dts // Linux

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

cat /sys/kernel/debug/pinctrl/300b000.pinctrl/pinmux-pins | grep PH

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

Set direction:

echo in > /sys/class/gpio/gpio226/direction
echo out > /sys/class/gpio/gpio226/direction

Read/write value:

cat /sys/class/gpio/gpio226/value      // Read
echo 1 > /sys/class/gpio/gpio226/value // Set high
echo 0 > /sys/class/gpio/gpio226/value // Set low

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-leds {
        compatible = "gpio-leds";
        status = "okay";
        sys_led {
            label="sys_led";
            gpio = <&pio PI 16 GPIO_ACTIVE_HIGH>;
            linux,default-trigger = "heartbeat";
        };
    };
};

gpio_para Example (PC7/PC12 Control):

&soc {
    gpio_para {
        gpio_num = <2>;
        gpio_pin_1 = <&pio PC 7 GPIO_ACTIVE_HIGH>;
        gpio_pin_2 = <&pio PC 12 GPIO_ACTIVE_HIGH>;
        status = "okay";
    };
};

Control commands:

echo 1 > /sys/class/gpio_sw/PC12/data  // High
echo 0 > /sys/class/gpio_sw/PC12/data  // Low

GPIO Key Example:

/{ 
    gpio-keys {
        compatible = "gpio-keys";
        status = "okay";
        autorepeat;
        power {
            label = "Power Key";
            linux,code = <KEY_POWER>;
            gpio = <&pio PC 2 GPIO_ACTIVE_LOW>; // PC7
            wakeup-source;
            debounce-interval = <100>;
        };
    };
};

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.

stty -F /dev/ttyAS5 ispeed 115200 ospeed 115200 cs8 

Send data to the serial port:

echo kickpi > /dev/ttyAS5  

Receive data:

cat /dev/ttyAS5 

Modify UART Control Port

Change debug_uart to an unused UART (e.g., UART0 is reserved for U-Boot logs):

+++ b/source/kernel/linux-5.4-h618/arch/arm64/boot/dts/sunxi/uEnv/uEnv.txt
@@ -4,4 +4,4 @@ console=both
 disp_mode=1080p60
 fb0_width=1920
 fb0_height=1080
-debug_uart=ttyAS0
+debug_uart=ttyAS3

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.


TTL-to-485 Module Wiring


TTL-to-232 Module Wiring

image-20250314150200725
image-20250514115200103
image-20250514115347443
image-20250514115517926
image-20250514115800211
image-20250514115920195
image-20250326115428401
image-20250326133713399
image-20250326142700157
image-20250326142738724
image-20241231145656021
66637824ee48c91b31130503a4400149
cf9c366bb88d7214bc93412cbc0accb3

Connect to UART5:

Connect to UART5: