当前位置:网站首页>[gpio] how to modify / display GPIO status through ADB shell
[gpio] how to modify / display GPIO status through ADB shell
2022-06-12 05:35:00 【bestwu0666】
1. Show GPIO state :
1.1 MT6983 after (kernel-5.10) The format is as follows
cat proc/mtk_gpio/soc.pinctrl
Same format MT6885 after , Note that reading requires root jurisdiction
1.2 MT6885 The following format is shown
cat /sys/devices/platform/pinctrl/mt_gpio
PIN: (MODE)(DIR)(DOUT)(DIN)(DRIVE)(SMT)(IES)(PULL_EN)(PULL_SEL)(R1 R0)
for example (kernel-4.14 DRIVE The column width is 2, List the others 1, other kernel Version column width is 1, Pay attention to correspondence ):
cat sys/devices/platform/pinctrl/mt_gpio
pins base: 285, pins count: 227
PIN: (MODE)(DIR)(DOUT)(DIN)(DRIVE)(SMT)(IES)(PULL_EN)(PULL_SEL)(R1 R0)
000: 0001001111
001: 0000001110
002: 0000001110
…
NOTE:
For each platform mt_gpio There may be differences in the paths of , You can use the following command to find
adb shell
find sys/ -name “mt_gpio”
for example :mt6763 platform
find sys/ -name “mt_gpio” Output is as follows
sys/devices/platform/10005000.pinctrl/mt_gpio
1.3 MT6763 The following format is shown
cat /sys/devices/platform/XXX.pinctrl/mt_gpio //XXX.pinctrl It's platform specific
PIN: [MODE] [DIR] [DOUT] [DIN] [PULL_EN] [PULL_SEL] [IES] [SMT] [DRIVE] ( [R1] [R0] )
for example :mt6763 platform
adb shell “cat /sys/devices/platform/10005000.pinctrl/mt_gpio” Output is as follows :
PIN: [MODE] [DIR] [DOUT] [DIN] [PULL_EN] [PULL_SEL] [IES] [SMT] [DRIVE] ( [R1] [R0] )
0: 000111110
1: 010000110
2: 000010110
…
1.4 Older platforms
cd /sys/class/misc/mtgpio perhaps cd /sys/devices/virtual/misc/mtgpio
cat pins
A、 If show The format is xx: x x x x x x x x ( The colon is followed by 8 A digital )
The corresponding meanings are as follows :
PIN: [MODE] [PULL_SEL] [DIN] [DOUT] [PULL_EN] [DIR] [IES] [SMT]
B、 If show The format is xx: x x x x x x x ( The colon is followed by 7 A digital ) // some kernel-3.10
The corresponding meanings are as follows :
PIN: [MODE] [PULL_SEL] [DOUT] [PULL_EN] [DIR] [IES]
- Meaning of each description item
PIN IO Number
[MODE] At present pin In mode
[DIR] 0:input pin, 1:output pin
[DOUT] Output value
[DIN] The input values
[PULL_EN] Only right input pin It works , Enable up / The drop-down
[PULL_SEL] Only right input pin It works ,1: Pull up 0: The drop-down
[IES] Input enable ,1:input Signal valid 0:input Invalid signal
[SMT] Enable Schmitt trigger
[DRIVE] Driving ability , Generally, it can be taken as 0~7
([R1] [R0]) At present GPIO pin Of ( Up and down ) Enable state of parallel resistance
1 0 Express enable R1,disable R0
0 1 Express disable R1,enable R0
1 1 Express enable R1, enable R0
Don't print it out , Represents the current GPIO pin I won't support it PUPD condition , That is, there is only one pull-up resistor 、 A pull-down resistor
DTS Settings related issues in :
Support PUPD Of GPIO pin Set up , give an example :
bias-pull-up=<MTK_PUPD_SET_R1R0_01>// Pull up R0
bias-pull-down=<MTK_PUPD_SET_R1R0_10> // The drop-down R1
bias-disabled;// Neither pull up nor pull down
I won't support it PUPD Of GPIO pin Set up , give an example :
bias-pull-up;// Pull up
bias-pull-down;// The drop-down
bias-disabled;// Neither pull up nor pull down
3. Set up GPIO state :
3.1 MT6885(kernel-4.14):
The setting method is the same as MT6885 identical , Write in the same way after changing permissions proc/mtk_gpio/soc.pinctrl that will do .
3.2 MT6885(kernel-4.14):
Set command and MT6779 equally , But pay attention to mt_gpio The node attribute is read-only , as follows ,
-r--r--r-- 1 root root 4096 2019-07-01 08:20 sys/devices/platform/pinctrl/mt_gpio
Before setting , need root(user Version not available root jurisdiction ) after ,chmod 0664 mt_gpio Change node properties .
3.3 MT6768,MT6779:
Single set command :
echo [option] $pin_num $value > /sys/devices/platform/pinctrl/mt_gpio
[option] Indicates the status to be set , Optional value :mode,dir,out,pullen,pullsel,ies,smt,driving
$pin_num Represents the setting of gpio Number
$value Indicates the value to be written
for example :
echo mode 99 6 > /sys/devices/platform/pinctrl/mt_gpio
echo dir 99 1 > /sys/devices/platform/pinctrl/mt_gpio
echo out 99 1 > /sys/devices/platform/pinctrl/mt_gpio
echo pullen 99 1 > /sys/devices/platform/pinctrl/mt_gpio
NOTE: Set up pullen when ,
For pin with 2 pull resistors, $value can be 0 (R1=0, R0=0), 1 (R1=0, R0=1), 2 (R1=1, R0=0), 3 (R1=1, R0=1)
For pin with 1 pull resistor, $value can be 0 or 1
Set all commands at once :
echo set $pin_num $mode $dir $dout $din $driving $smt $ies $pullen $pullsel > /sys/devices/platform/pinctrl/mt_gpio
echo set $pin_num $mode $dir $dout $din $driving $smt $ies $pullen $pullsel $r1 $r0 > /sys/devices/platform/pinctrl/mt_gpio
NOTE:
Set all attributes in a single command
Note1: all attributes shall not be separated with space
Note2: all attributes is 1 digit except $driving is 2 digits
Note3: din cannot be changed, $din is leaved here for convenience of command typing. Therefore, user can change fields from read string (obtained via cat mt_gpio) without removing $din
3.4 MT6763 Settings after :
Single set command ( Refer to the above description ):
echo mode $pin_num $value > /sys/devices/platform/10005000.pinctrl/mt_gpio
echo dir $pin_num $value > /sys/devices/platform/10005000.pinctrl/mt_gpio
echo dout $pin_num $value > /sys/devices/platform/10005000.pinctrl/mt_gpio
echo pullen $pin_num $value > /sys/devices/platform/10005000.pinctrl/mt_gpio
For pin with 2 pull resistors, $value can be 0 (R1=0, R0=0), 1 (R1=0, R0=1), 2 (R1=1, R0=0), 3 (R1=1, R0=1)
For pin with 1 pull resistor, $value can be 0 or 1
echo pullsel $pin_num $value > /sys/devices/platform/10005000.pinctrl/mt_gpio
One time settings are as follows :
echo set $pin_num $mode $dir $dout $din $pullen $pullsel $ies $smt $driving > /sys/devices/platform/10005000.pinctrl/mt_gpio
echo set $pin_num $mode $dir $dout $din $pullen $pullsel $ies $smt $driving $r1 $r0 > /sys/devices/platform/10005000.pinctrl/mt_gpio
Set all attributes in a single command
Note1: all all attributes shall not be separated with space
Note2: din cannot be changed, $din is leaved here for convenience of command typing. Therefore, user can change fields from read string (obtained via cat mt_gpio) without removing $din
for example :
Set up GPIO99 mode 3
#echo mode 99 3 > mt_gpio
Set up GPIO99 dir out
#echo dir 99 1 > mt_gpio
Set up GPIO99 dir in
#echo dir 99 0 > mt_gpio
…
MT6763 Set all at once :
#echo set 99 000011110 > /sys/devices/platform/10005000.pinctrl/mt_gpio
3.5 Settings for older platforms :
Set separately GPIO One of the information of is as follows :
echo -wmode num x > pin //num: pin number x: the mode 0~7
echo -wpsel num x > pin //x: 1,pull up; 0,pull down
echo -wdout num x > pin //x:1,high; 0,low
echo -wpen num x > pin //x: 1,pull enable; 0,pull disable
echo -wies num x > pin //x: 1,ies enable; 0, ies disable
echo -wdir num x > pin //x: 1,output; 0,input
One time settings GPIO All item values of are as follows :
echo -w=num:x x x x x x x > pin //x: [MODE] [PSEL] [DOUT] [PEN] [DIR] [IES] [SMT]
Like some of the above kenrel-3.10 Can only show Come out now pin Of 7 A number of GPIO One time settings for GPIO Values
echo -w=num:x x x x x x > pin //x: [MODE] [PSEL] [DOUT] [PEN] [DIR] [IES]
for example :
adb shell “echo “-w=99:0 1 0 0 0 1 0” >/sys/devices/virtual/misc/mtgpio/pin”
边栏推荐
- 43. Number of occurrences of 1 in 1 ~ n integers
- 关于架构(排名不分先后)
- Matlab: halftone and dither conversion
- Performance test - Analysis of performance test results
- yolov5
- WiFi band resources
- [road of system analyst] collection of wrong topics in software engineering chapters
- Qs100 at command mqtt access thingsboard
- Detailed explanation of data envelopment analysis (DEA) (taking the 8th Ningxia provincial competition as an example)
- 51. reverse order pairs in the array
猜你喜欢

Nature | make an account of the new crown casualties in the world

Computer network connected but unable to access the Internet

Nature | 给全球的新冠伤亡算一笔账

Stm32f4 ll library multi-channel ADC

week7

Classes and objects, methods and encapsulation

公司注册认缴资金多久

Matlab: image rotation and interpolation and comparison of MSE before and after

4.3 simulate browser operation and page waiting (display waiting and implicit waiting, handle)

Details of FPGA syntax
随机推荐
Multi thread learning 4. Sleep, wait, yield, join (), ThreadGroup control the running of threads
Introduction to Internet Protocol
Qs100 at command mqtt access thingsboard
Reason: Canonical names should be kebab-case (‘-‘ separated), lowercase alpha-numeric characters and
38. arrangement of strings
19. regular expression matching
Halcon 3D 1 读取3d数据
Optipng can optimize the compressed PNG picture file format
Redis cluster cluster capacity expansion and data migration
20000 word detailed reptile knowledge reserve, basic exercises of data collection and cleaning (I) reference answers to the first song
The most commonly used objective weighting method -- entropy weight method
arp timer and arptables
week7
ESP8266 Arduino OLED
38. 外观数列
按键精灵的简单入门
Detailed explanation of data envelopment analysis (DEA) (taking the 8th Ningxia provincial competition as an example)
Esp32-who face detection
【js小知识】轻松了解js防抖与节流
关于架构(排名不分先后)