当前位置:网站首页>How to modify / display GPIO status through ADB shell
How to modify / display GPIO status through ADB shell
2022-06-27 16:30:00 【zz_ nj】
[DESCRIPTION]
adopt adb shell modify / Show GPIO state
[KEYWORD]
GPIO
[SOLUTION]
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]
2. 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"
边栏推荐
- Nemo of pulseaudio (22)
- Solving Poisson equation by tensorflow
- localDateTime类型的时间(2019-11-19T15:16:17) 用oracle的时间范围查询
- LeetCode每日一练(无重复字符的最长子串)
- A large number of missing anchor text
- 域名绑定动态IP最佳实践
- The time of localdatetime type (2019-11-19t15:16:17) is queried with the time range of Oracle
- logstash排除特定文件或文件夹不采集上报日志数据
- EMQ helps Qingdao Yanbo build a smart water platform
- The interview lasted for half a year. Last month, I successfully got Alibaba p7offer. It was all because I chewed the latest interview questions in 2020!
猜你喜欢
#yyds干货盘点#简述chromeV8引擎垃圾回收
EMQ 助力青岛研博建设智慧水务平台
LeetCode每日一练(无重复字符的最长子串)
P. Simple application of a.r.a method in Siyuan (friendly testing)
Li Chuang EDA learning notes 16: array copy and array distribution
Redis Series 2: data persistence improves availability
等保三级密码复杂度是多少?多久更换一次?
【牛客刷题】NowCoder号称自己已经记住了1-100000之间所有的斐波那契数。 为了考验他,我们随便出一个数n,让他说出第n个斐波那契数。如果第n个斐波那契大于6位则只取后6位。
Array represents a collection of several intervals. Please merge all overlapping intervals and return a non overlapping interval array. The array must exactly cover all the intervals in the input. 【Le
Cesium realizes satellite orbit detour
随机推荐
深耕数字化,引领云原生,服务更多开发者
A large number of missing anchor text
Weekly snapshot of substrate technology 20220411
Does polardb-x open source support mysql5.7?
利用Redis实现订单30分钟自动取消
Redis系列2:数据持久化提高可用性
LeetCode每日一练(两数之和)
QT5 之信号与槽机制(信号与槽的基本介绍)
About how vs2019c # establishes the login interface, the user name and password entered must match the records in the access database
LeetCode每日一练(主要元素)
Handling of difficult and miscellaneous problems during the installation and configuration of qt5.5.1 desktop version (configuring arm compilation Kit)
国家食品安全风险评估中心:不要盲目片面追捧标签为“零添加”“纯天然”食品
Hongmeng makes efforts! HDD Hangzhou station · offline salon invites you to build ecology
SQL parsing practice of Pisa proxy
List to table
C语言集合运算
NFT双币质押流动性挖矿dapp合约定制
Etcd visualization tool: kstone deployment (I), rapid deployment based on Helm
#yyds干货盘点#简述chromeV8引擎垃圾回收
Principle Comparison and analysis of mechanical hard disk and SSD solid state disk