1
2
|
pi@raspberrypi ~ $
sudo
su
root@raspberrypi:
/home/pi
#
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
root@raspberrypi:~
# apt-get update
Get:1 http:
//mirrordirector
.raspbian.org jessie InRelease [15.0 kB]
Get:2 http:
//archive
.raspberrypi.org jessie InRelease [13.3 kB]
Get:3 http:
//mirrordirector
.raspbian.org jessie
/main
armhf Packages [8,962 kB]
Get:4 http:
//archive
.raspberrypi.org jessie
/main
Sources [31.2 kB]
Get:5 http:
//archive
.raspberrypi.org jessie
/ui
Sources [5,197 B]
Get:6 http:
//archive
.raspberrypi.org jessie
/main
armhf Packages [101 kB]
Get:7 http:
//archive
.raspberrypi.org jessie
/ui
armhf Packages [7,639 B]
Ign http:
//archive
.raspberrypi.org jessie
/main
Translation-en_GB
Ign http:
//archive
.raspberrypi.org jessie
/main
Translation-en
Ign http:
//archive
.raspberrypi.org jessie
/ui
Translation-en_GB
Ign http:
//archive
.raspberrypi.org jessie
/ui
Translation-en
Get:8 http:
//mirrordirector
.raspbian.org jessie
/contrib
armhf Packages [37.5 kB]
Get:9 http:
//mirrordirector
.raspbian.org jessie
/non-free
armhf Packages [70.2 kB]
Get:10 http:
//mirrordirector
.raspbian.org jessie
/rpi
armhf Packages [1,356 B]
Ign http:
//mirrordirector
.raspbian.org jessie
/contrib
Translation-en_GB
Ign http:
//mirrordirector
.raspbian.org jessie
/contrib
Translation-en
Ign http:
//mirrordirector
.raspbian.org jessie
/main
Translation-en_GB
Ign http:
//mirrordirector
.raspbian.org jessie
/main
Translation-en
Ign http:
//mirrordirector
.raspbian.org jessie
/non-free
Translation-en_GB
Ign http:
//mirrordirector
.raspbian.org jessie
/non-free
Translation-en
Ign http:
//mirrordirector
.raspbian.org jessie
/rpi
Translation-en_GB
Ign http:
//mirrordirector
.raspbian.org jessie
/rpi
Translation-en
Fetched 9,244 kB
in
15min 48s (9,742 B
/s
)
Reading package lists... Done
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
root@raspberrypi:~
# apt-get -y install python-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libpython-dev libpython2.7-dev python2.7-dev
The following NEW packages will be installed:
libpython-dev libpython2.7-dev python-dev python2.7-dev
0 upgraded, 4 newly installed, 0 to remove and 56 not upgraded.
Need to get 18.2 MB of archives.
After this operation, 25.7 MB of additional disk space will be used.
Get:1 http:
//mirrordirector
.raspbian.org
/raspbian/
jessie
/main
libpython2.7-dev armhf 2.7.9-2
Get:2 http:
//mirrordirector
.raspbian.org
/raspbian/
jessie
/main
python-dev armhf 2.7.9-1 [1,188 B]
13% [1 libpython2.7-dev 2,376 kB
/17
.9 MB 13%] [2 python-dev 1,188 B
/1
,188 Get:3 http:
//mirrordirector
.raspbian.org
/raspbian/
jessie
/main
libpython-dev armhf 2.7.9-1 [19.6 kB]
Get:4 http:
//mirrordirector
.raspbian.org
/raspbian/
jessie
/main
python2.7-dev armhf 2.7.9-2 [281 kB]
Fetched 18.2 MB
in
13s (1,306 kB
/s
)
Selecting previously unselected package libpython2.7-dev:armhf.
(Reading database ... 118460 files and directories currently installed.)
Preparing to unpack ...
/libpython2
.7-dev_2.7.9-2_armhf.deb ...
Unpacking libpython2.7-dev:armhf (2.7.9-2) ...
Selecting previously unselected package libpython-dev:armhf.
Preparing to unpack ...
/libpython-dev_2
.7.9-1_armhf.deb ...
Unpacking libpython-dev:armhf (2.7.9-1) ...
Selecting previously unselected package python2.7-dev.
Preparing to unpack ...
/python2
.7-dev_2.7.9-2_armhf.deb ...
Unpacking python2.7-dev (2.7.9-2) ...
Selecting previously unselected package python-dev.
Preparing to unpack ...
/python-dev_2
.7.9-1_armhf.deb ...
Unpacking python-dev (2.7.9-1) ...
Processing triggers
for
man
-db (2.7.0.2-5) ...
Setting up libpython2.7-dev:armhf (2.7.9-2) ...
Setting up libpython-dev:armhf (2.7.9-1) ...
Setting up python2.7-dev (2.7.9-2) ...
Setting up python-dev (2.7.9-1) ...
root@raspberrypi:~
#
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
root@raspberrypi:~
# mkdir /home/gpio
root@raspberrypi:~
# cd /home/gpio
root@raspberrypi:
/home/gpio
# wget https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.5.11.tar.gz
--2015-09-24 16:38:10-- https:
//pypi
.python.org
/packages/source/R/RPi
.GPIO
/RPi
.GPIO-0.5.11.
tar
.gz
Resolving pypi.python.org (pypi.python.org)... 43.249.72.223
Connecting to pypi.python.org (pypi.python.org)|43.249.72.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27060 (26K) [application
/octet-stream
]
Saving to: ‘RPi.GPIO-0.5.11.
tar
.gz’
RPi.GPIO-0.5.11.
tar
.gz 100%[======================>] 26.43K 94.0KB
/s
in
0.3s
2015-09-24 16:38:15 (94.0 KB
/s
) - ‘RPi.GPIO-0.5.11.
tar
.gz’ saved [27060
/27060
]
|
1
2
3
4
5
6
7
8
9
|
可以看到下载的GPIO库文件只有27K
root@raspberrypi:
/home/gpio
# ls -lh
-rw-r--r-- 1 root root 27K May 14 18:27 RPi.GPIO-0.5.11.
tar
.gz
解压并进入目录
root@raspberrypi:
/home/gpio
# tar xf RPi.GPIO-0.5.11.tar.gz
root@raspberrypi:
/home/gpio
# cd RPi.GPIO-0.5.11
root@raspberrypi:
/home/gpio/RPi
.GPIO-0.5.11
#
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
root@raspberrypi:
/home/gpio/RPi
.GPIO-0.5.11
# python setup.py install
running
install
running build
running build_py
creating build
creating build
/lib
.linux-armv7l-2.7
creating build
/lib
.linux-armv7l-2.7
/RPi
copying RPi
/__init__
.py -> build
/lib
.linux-armv7l-2.7
/RPi
running build_ext
building
'RPi.GPIO'
extension
creating build
/temp
.linux-armv7l-2.7
creating build
/temp
.linux-armv7l-2.7
/source
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=
format
-security -fPIC -I
/usr/include/python2
.7 -c
source
/py_gpio
.c -o build
/temp
.linux-armv7l-2.7
/source/py_gpio
.o
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=
format
-security -fPIC -I
/usr/include/python2
.7 -c
source
/c_gpio
.c -o build
/temp
.linux-armv7l-2.7
/source/c_gpio
.o
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=
format
-security -fPIC -I
/usr/include/python2
.7 -c
source
/cpuinfo
.c -o build
/temp
.linux-armv7l-2.7
/source/cpuinfo
.o
source
/cpuinfo
.c: In
function
‘get_rpi_info’:
source
/cpuinfo
.c:41:7: warning: ignoring
return
value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
fgets(buffer, sizeof(buffer) , fp);
^
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=
format
-security -fPIC -I
/usr/include/python2
.7 -c
source
/event_gpio
.c -o build
/temp
.linux-armv7l-2.7
/source/event_gpio
.o
source
/event_gpio
.c: In
function
‘gpio_export’:
source
/event_gpio
.c:75:5: warning: ignoring
return
value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(fd, str_gpio, len);
^
source
/event_gpio
.c: In
function
‘gpio_unexport’:
source
/event_gpio
.c:90:5: warning: ignoring
return
value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(fd, str_gpio, len);
^
source
/event_gpio
.c: In
function
‘gpio_set_direction’:
source
/event_gpio
.c:106:9: warning: ignoring
return
value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(fd,
"in"
, 3);
^
source
/event_gpio
.c:108:9: warning: ignoring
return
value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(fd,
"out"
, 4);
^
source
/event_gpio
.c: In
function
‘gpio_set_edge’:
source
/event_gpio
.c:124:5: warning: ignoring
return
value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(fd, stredge[edge], strlen(stredge[edge]) + 1);
^
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=
format
-security -fPIC -I
/usr/include/python2
.7 -c
source
/soft_pwm
.c -o build
/temp
.linux-armv7l-2.7
/source/soft_pwm
.o
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=
format
-security -fPIC -I
/usr/include/python2
.7 -c
source
/py_pwm
.c -o build
/temp
.linux-armv7l-2.7
/source/py_pwm
.o
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=
format
-security -fPIC -I
/usr/include/python2
.7 -c
source
/common
.c -o build
/temp
.linux-armv7l-2.7
/source/common
.o
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=
format
-security -fPIC -I
/usr/include/python2
.7 -c
source
/constants
.c -o build
/temp
.linux-armv7l-2.7
/source/constants
.o
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=
format
-security -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=
format
-security build
/temp
.linux-armv7l-2.7
/source/py_gpio
.o build
/temp
.linux-armv7l-2.7
/source/c_gpio
.o build
/temp
.linux-armv7l-2.7
/source/cpuinfo
.o build
/temp
.linux-armv7l-2.7
/source/event_gpio
.o build
/temp
.linux-armv7l-2.7
/source/soft_pwm
.o build
/temp
.linux-armv7l-2.7
/source/py_pwm
.o build
/temp
.linux-armv7l-2.7
/source/common
.o build
/temp
.linux-armv7l-2.7
/source/constants
.o -o build
/lib
.linux-armv7l-2.7
/RPi/GPIO
.so
running install_lib
creating
/usr/local/lib/python2
.7
/dist-packages/RPi
copying build
/lib
.linux-armv7l-2.7
/RPi/GPIO
.so ->
/usr/local/lib/python2
.7
/dist-packages/RPi
copying build
/lib
.linux-armv7l-2.7
/RPi/__init__
.py ->
/usr/local/lib/python2
.7
/dist-packages/RPi
byte-compiling
/usr/local/lib/python2
.7
/dist-packages/RPi/__init__
.py to __init__.pyc
running install_egg_info
Writing
/usr/local/lib/python2
.7
/dist-packages/RPi
.GPIO-0.5.11.egg-info
root@raspberrypi:
/home/gpio/RPi
.GPIO-0.5.11
# echo $?
0
可以看到,没有错误
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
root@raspberrypi:
/home/gpio/RPi
.GPIO-0.5.11
# cd
root@raspberrypi:~
# vim test.py
#!/user/bin/python
import
RPi.GPIO as GPIO
import
time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11,GPIO.OUT)
while
True:
GPIO.output(11,True)
time
.
sleep
(1)
GPIO.output(11,False)
time
.
sleep
(1)
运行程序
root@raspberrypi:~
# python test.py
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
root@raspberrypi:~
# vim test2.py
#!/user/bin/python
import
RPi.GPIO as GPIO
import
time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(12,GPIO.IN)
while
True:
in_value= GPIO.input(12)
if
in_value ==False:
GPIO.output(11,False)
time
.
sleep
(1)
GPIO.output(11,True)
while
in_value == False:
in_value = GPIO.input(12)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
root@raspberrypi:
/home/pi
# cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5
processor : 1
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5
processor : 2
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5
processor : 3
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5
Hardware : BCM2709
Revision : a21041
Serial : 000000000f4c5cc4
BCM2708
/9
属于处理器的家族
BCM2835
/6
属于处理的具体型号
|
1
2
3
4
|
root@raspberrypi:
/home/pi
# passwd root
Enter new UNIX password:haha
Retype new UNIX password: haha
passwd
: password updated successfully
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
安装vim编辑器
root@raspberrypi:
/home/pi
# apt-get -y install vim
开启vim语法高亮
root@raspberrypi:
/home/pi
# vim /etc/vim/vimrc +19
去掉前面的引号“syntax on,改为下面的,按ESC,按
shift
+zz保存退出
syntax on
开启root远程登录
root@raspberrypi:
/home/pi
# vim /etc/ssh/sshd_config +28
把PermitRootLogin without-password改为下面的,按ESC,按
shift
+zz保存退出
PermitRootLogin
yes
重启sshd服务
root@raspberrypi:
/home/pi
# service sshd restart
root@Ubuntu:~
# ssh 10.11.12.100 -l root
The authenticity of host
'10.11.12.100 (10.11.12.100)'
can't be established.
ECDSA key fingerprint is 42:6a:d5:02:d4:23:46:a6:da:00:24:8f:16:2c:c4:49.
Are you sure you want to
continue
connecting (
yes
/no
)?
yes
Warning: Permanently added
'10.11.12.100'
(ECDSA) to the list of known hosts.
[email protected]'s password: haha
The programs included with the Debian GNU
/Linux
system are
free
software;
the exact distribution terms
for
each program are described
in
the
individual files
in
/usr/share/doc/
*
/copyright
.
Debian GNU
/Linux
comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Sep 24 16:15:36 2015 from 10.11.12.14
root@raspberrypi:~
#
root远程 登录成功!
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
root@raspberrypi:~
# vim .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
# umask 022
# You may uncomment the following lines if you want `ls' to be colorized:
export
LS_OPTIONS=
'--color=auto'
eval
"`dircolors`"
alias
ls
=
'ls $LS_OPTIONS'
alias
ll=
'ls $LS_OPTIONS -lh'
alias
l=
'ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
alias
rm
=
'rm -i'
alias
cp
=
'cp -i'
alias
mv
=
'mv -i'
使配置立即生效,注意两个点之间的空格
root@raspberrypi:~
# . .bashrc
|
1
2
3
4
|
root@raspberrypi:
/home/pi
# cat /etc/apt/sources.list
deb http:
//mirrordirector
.raspbian.org
/raspbian/
jessie main contrib non-
free
rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
root@raspberrypi:~
# cat /proc/meminfo
MemTotal: 948120 kB
MemFree: 789508 kB
MemAvailable: 862084 kB
Buffers: 17436 kB
Cached: 79256 kB
SwapCached: 0 kB
Active: 85240 kB
Inactive: 46372 kB
Active(anon): 35252 kB
Inactive(anon): 6476 kB
Active(
file
): 49988 kB
Inactive(
file
): 39896 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 102396 kB
SwapFree: 102396 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 35016 kB
Mapped: 37816 kB
Shmem: 6812 kB
Slab: 13516 kB
SReclaimable: 6344 kB
SUnreclaim: 7172 kB
KernelStack: 1136 kB
PageTables: 1868 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 576456 kB
Committed_AS: 521112 kB
VmallocTotal: 1105920 kB
VmallocUsed: 1188 kB
VmallocChunk: 900580 kB
CmaTotal: 8192 kB
CmaFree: 3740 kB
|
1
2
3
4
5
|
root@raspberrypi:~
# free -m
total used
free
shared buffers cached
Mem: 925 172 752 7 25 82
-/+ buffers
/cache
: 65 860
Swap: 99 0 99
|
1
2
3
4
5
6
7
8
9
10
11
|
root@raspberrypi:~
# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/root
ext4 3.9G 3.2G 515M 87% /
devtmpfs devtmpfs 459M 0 459M 0%
/dev
tmpfs tmpfs 463M 0 463M 0%
/dev/shm
tmpfs tmpfs 463M 6.3M 457M 2%
/run
tmpfs tmpfs 5.0M 4.0K 5.0M 1%
/run/lock
|