接上文[【飞腾派4G版免费试用】2飞腾派 openkylin 固件烧录(https://bbs.elecfans.com/jishu_2404663_1_1.html)
进行IO控制其实不需要上显示和openkylin这么大的系统,
实时性也不十分好。
转接网线,在com打nmcli
可以根据此ip
接ssh
导出GPIO3_1(GPIO3_1 的编号为 448+1=449)引脚进行IO控制
openkylin@openkylin:~$ cd /sys
openkylin@openkylin:/sys$ ls
block bus class dev devices firmware fs kernel kylin_authentication kylin_kmod module power
openkylin@openkylin:/sys$ cd class
openkylin@openkylin:/sys/class$ dir
ata_device devfreq gpio iommu nvme pps sas_device scsi_host udc
ata_link devfreq-event graphics lcd nvme-fabrics ptp sas_end_device sound uio
ata_port dma hwmon leds nvme-subsystem pwm sas_expander spi_master usb_role
backlight drm i2c-adapter mdio_bus pci_bus rapidio_port sas_host tcmdev vc
bdi drm_dp_aux_dev i2c-dev mem pci_epc regulator sas_phy tee virtio-ports
block extcon ieee80211 misc phy remoteproc sas_port thermal vtconsole
bluetooth fc infiniband mmc_host pktcdvd rfkill scsi_device tpm wakeup
bsg fcloop infiniband_cm mtd powercap rpmsg scsi_disk tpmrm watchdog
devcoredump firmware input net power_supply rtc scsi_generic tty
openkylin@openkylin:/sys/class$ cd gpio
openkylin@openkylin:/sys/class/gpio$ didr
-bash: didr:未找到命令
openkylin@openkylin:/sys/class/gpio$ ls
export gpiochip416 gpiochip432 gpiochip448 gpiochip464 gpiochip480 gpiochip496 unexport
Last login: Fri Aug 25 14:38:38 2023 from 192.168.2.201
openkylin@openkylin:~$ sudo su
[sudo] openkylin 的密码:
对不起,请重试。
[sudo] openkylin 的密码:
root@openkylin:/home/openkylin# ls
led.sh
led.sh
#!/bin/sh
LED_GPIO=/sys/class/gpio/gpio449
if test -d $LED_GPIO; then
echo "GPIO449 already exported"
else
echo 449 > /sys/class/gpio/export
fi
echo out > $LED_GPIO/direction
while true; do
echo 0 > $LED_GPIO/value
sleep 0.5
echo 1 > $LED_GPIO/value
sleep 0.5
done
root@openkylin:/home/openkylin# bash ./led.sh
灯正常闪
文件加X执行
root@openkylin:/home/openkylin# ./led.sh
GPIO449 already exported
达到预期。
更多回帖