강의할 기회가 없어지는 아쉬움에 강의시 사용한 라즈베리파이 강의 자료를 업로드 합니다.
SBC 인 Raspberry Pi 에 OS 설치, 원격 개발 환경 구성 및 개발 환경까지 완료 할 수 있고 기본 전기전자 소자와 GPIO Header pin을 통한 연결까지 다룹니다.
20. Raspberry Pi Model A
21
USB Ports
Ethernet
GPIO
3.5mm Audio &
Composite Output Jack
HDMI Out5V Micro USB
Power
CSI Camera
connector
SMSC LAN9514 USB
Ethernet controller
DSI Display
connector
MicroSD Card
slot (밑면)
Less power
consumption
Power Regulator
Pi reset
Run Header
Broadcom
BCM2835
RaspberryPi
21. Raspberry Pi 2 Model B v1.1
22
4 USB Ports
Ethernet
GPIO
3.5mm Audio &
Composite Output JackHDMI Out5V Micro USB
Power
CSI Camera
connector
SMSC LAN9514 USB
Ethernet controller
DSI Display
connector
(밑면) MicroSD
Card Slot
Less power
consumption
Power Regulator
Pi reset
Run Header
Broadcom
BCM2836
RaspberryPi
참조 http://elinux.org/RPi_Hardware
22. Raspberry Pi 2 Model B v1.2
23
Serial In (Rx)
4 USB Ports
Ethernet
GPIO
3.5mm Audio &
Composite Output JackHDMI Out5V Micro USB
Power
CSI Camera
connector
SMSC LAN9514 USB
Ethernet controller
DSI Display
connector
(밑면)
MicroSD Slot
Less power
consumption
Power Regulator
Pi reset
Run Header
Broadcom
BCM2837
23. Raspberry Pi 3 Model B
24
Serial In (Rx)
4 USB Ports
Ethernet
GPIO
3.5mm Audio &
Composite Output Jack
HDMI Out5V Micro USB
Power up to 2.5A
CSI Camera
connector
SMSC LAN9514 USB
Ethernet controller
DSI Display
connector
MicroSD Card
slot (밑면)
Less power
consumption
Power Regulator
On board
BT 4.1, WiFi
Chip Antenna
Broadcom
BCM2837 64bit
Quad core CPU
at 1.2Ghz
24. Raspberry Pi Zero
25
GPIO
Micro USBMini-HDMI 1080p
Video & Audio
Output
5V Micro USB
Power
CSI Camera
connector
Micro SDCard
Pi reset
Run Header
Broadcom BCM2835 SoC
Dual core 1Ghz
VideoCore IV GPU
512MB Onboard RAM
RCA Composite
Video Output
65 x 30 x 5 mm
25. Raspberry Pi Table
26
항목 Pi 1 Model B+ Pi 2 Model B Pi Zero Pi 3 Model B Pi 2 v1.2
SoC SoC BCM 8235 SoC BCM 8236 SoC BCM 8335 SoC BCM 2837 SoC BCM 2837
CPU ARM11 @700Mhz
Quad Coretex A7
@900Mhz
ARM11 @1Ghz
Quad Coretex A53
@1.2Ghz
Quad Coretex A53
@900Mhz
IS Set ARMv6 ARMv7-A ARMv6 ARMv8-A ARMv8-A
GPU
250Mhz VideoCore
IV
250Mhz VideoCore
IV
250Mhz VideoCore
IV
400Mhz VideoCore
IV
250Mhz VideoCore
IV
Memory 512MB Ram 1GB Ram 512MB Ram 1GB Ram 1GB Ram
Network 10/100 10/100 N/A
10/100, WiFi, BL
4.1
10/100
USB 2 x USB2.0 4 x USB2.0 1 Micro USB 4 x USB2.0 4 x USB 2.0
GPIO 40 40 40 40 40
Video
640×350 to
1920×1200,
1080p, PAL &
NTSC
640×350 to
1920×1200,
1080p, PAL &
NTSC
640×350 to
1920×1200,
1080p, PAL &
NTSC
640×350 to
1920×1200,
1080p, PAL &
NTSC
640×350 to
1920×1200,
1080p, PAL &
NTSC
26. Raspberry Pi ARM core
Raspberry Pi 2는 Broadcom BCM2836 칩셋을 사용.
- ARMv7 Cortex-A7
- https://goo.gl/nLAhZH
- BCM2836은 대부분 BCM2835와 동일
- https://goo.gl/IqF2TW
- BCM2835 ARM Peripherals reference
- https://goo.gl/Zh9SeO
- 32bit 구성의 레지스터를 제공하고 있다.
Raspberry Pi 3는 Broadcom BCM2837
- ARMv8 Cortex-A53
Raspberry Pi 2 v1.2는 Broadcom BCM2837
- ARMv8 Cortex-A53
27
27. 소비전력
USB 2.0 표준 허브는 포트당 5V에 500mA 제공
USB 3 표준 허브는 포트당 5 V에 900 mA 제공
28
Product
Recommended
PSU current
capacity
Maximum total
USB peripheral
current draw
Typical bare-
board active
current
consumption
Raspberry Pi Model A 700mA 500mA 200mA
Raspberry Pi Model B 1.2A 500mA 500mA
Raspberry Pi Model A+ 700mA 500mA 180mA
Raspberry Pi Model B+ 1.8A
600mA/1.2A
(switchable)
330mA
Raspberry Pi 2 Model B 1.8A
600mA/1.2A
(switchable)
Raspberry Pi 3 Model B 800mA~2.5A 1.2A ~400mA
https://www.raspberrypi.org/help/faqs/
30. 주요 공개 노트
2017-03-02:
* NOOBS installs now checks for presence of 'ssh' file on the NOOBS partition
2017-01-11:
* Re-release of the 2016-11-25 image with a FAT32-formatted boot partition
2016-11-25:
* SSH disabled by default; can be enabled by creating a file with name "ssh" in boot
partition
2016-09-23:
* New PIXEL desktop environment
* RealVNC server and viewer included
31 http://downloads.raspberrypi.org/raspbian/release_notes.txt
31. Writing OS Image
Format SDCard
-SD Association 제공 sdFormater
Writing image
- Etcher, Win32DiskImager
- dd command
32
jessie-raspbian Ubuntu OSMC
NOOB
RaspberryPi
SDHC Class 6 이상
37. ssh 활성화
2016-11-25-raspbian-jessie는 ssh 비활성화
- http://downloads.raspberrypi.org/raspbian/release_notes.txt
ssh는 /boot 밑에 빈 ssh 파일 추가하면 활성화
Linux/Mac:
$ touch ssh
Window
type NUL > ssh
38
ssh 통해 원격 접
속해서 설정을 계
속한다.
38. Expand Filesystem
부팅후 자동으로 disk resize 된다.
39
pi@raspberrypi:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 3.6G 3.3G 114M 97% /
devtmpfs 459M 0 459M 0% /dev
tmpfs 463M 0 463M 0% /dev/shm
pi@raspberrypi:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 3.3G 11G 24% /
devtmpfs 459M 0 459M 0% /dev
tmpfs 463M 0 463M 0% /dev/shm
tmpfs 463M 6.2M 457M 2% /run
Expand
Filesystem 실
행 후
최신 raspbian은
처음 부팅시 자동으
로 확장
39. Raspberry Pi Updates
1. Wheezy 배포본 최신 상태로 Upgrade
- apt-get 유틸리티 이용
- 가까운 미러사이트 이용
2. Raspberry Pi Firmware Upgrade
- 펌웨어를 최신 버전으로 유지
40
40. Raspbian Update
미러사이트를 가까운 곳으로 설정
apt-get을 이용 배포본을 최신 상태로 유지
41
pi@raspberrypi ~ $ sudo vi /etc/apt/sources.list
#deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
deb http://ftp.neowiz.com/raspbian/raspbian wheezy main contrib non-free rpi
deb http://ftp.kaist.ac.kr/raspbian/raspbian/ wheezy main contrib non-free rpi
41. Raspberry Pi 원격지 환경
원격 개발환경
USB serial이용 접속
dhcp 원격접속 설정
raspi-config
무선랜 설정
48. ssh auto login
ssh 자동 로그인
1)ssh용 개인용-공개용 key 생성
$ ssh-keygen -t rsa -C "Pi user"
2) 원격 서버에 키 복사
$ scp .ssh/id_rsa.pub userid@111.111.111.11:~/.ssh/userid_rsa.pub
원격 서버에 로그인
$ ssh userid@111.111.111.11
복사한 공개키를 authorized_keys에 복사
(111.111.111.11)$ cat .ssh/userid_rsa.pub >> .ssh/authorized_keys
(111.111.111.11)$ exit
서버에 로그인
$ ssh -i ~/.ssh/id_rsa myuser@111.111.111.11
50
49. scp 이용
대상 서버에 복사
scp FILE USERID@HOST_NAME:PATH
$scp test.txt pi@192.168.1.1:/home/pi/
서버에서 복사해 오기
scp USERID@HOST_NAME:PATH FILEPATH
$scp pi@192.168.1.1:/home/pi/test.txt ~/temp
scp 포트 변경
scp -P PORT USERID@HOST_NAME:PATH FILEPATH
폴더 단위 복사
scp -r USERID@HOST_NAME:FOLDER_PATH FOLDER_PATH
$scp -r pi@192.168.1.1:/home/pi/folder ~/temp/
51
50. X forward
ssh 를 이용해 원격 X server를 사용해 GUI 실행
52
Server
RaspberryPi
X11 Tunnel
X11 forwarding over ssh connection
http://bahndal.egloos.com/534415
http://talkingaboutme.tistory.com/409
52. sshfs 설치
원격 호스트에 sshfs 설치
- Raspberry Pi / Linux sshfs 설치
$sudo apt-get install sshfs
54
53. sshfs usage
sshfs 옵션은 다음 같다:
sshfs -pXXXX -o [options] user@remotehost:/path /local/path/
Useful options:
-pXXXXX – tells sshfs to use port number XXXXX.
-o Ciphers=arcfour – speeds up for the connection.
-o ro – read only.
-o nonempty – allow nonempty mount point.
-o cache_timeout=N – set default cache timeout (in seconds)
-o cache=no – disable cache.
-o intr – allows to interrupt file access.
-o reconnect – automatically reconnect
-o idmap=user – helps with file ownership conflicts
55
54. sshfs 이용 마운트
개발 호스트 컴퓨터에서 다음 같이 원격 볼륨을 마운트 한다.
$sudo sshfs USER_ID@xxx.xxx.xxx.xxx:/ /Volume/remote
예)
$ sshfs user@host:/example ~/example -
oauto_cache,reconnect,defer_permissions,negative_vncache,noappledouble,volna
me=Example
사용후 언마운트는 다음과 같다.
$sudo umount /Volume/remote
56
60. PL2303HX
Windows Driver
- Prolific: https://goo.gl/p5EDh
- Adafurits: https://www.adafruit.com/product/954
Mac OS Driver
- Prolific: https://goo.gl/nw5zgk
- Adafurits: https://www.adafruit.com/product/954
62 https://www.adafruit.com/product/954
Adafurit가 공개한
- PL2303TA USB TTL to RS232 Converter
- Black : GND
- Green : TXD
- White : RXD
- Red : VCC
62. 시리얼 터미널 연결
터미널 프로그램 : putty, MobaXterm, Hyperterminal...
64
63. Mac serial terminal
Mac OS X에서 screen 시리얼 터미널 프로그램
$ screen <디바이스 이름> <전송속도>
예)
$ screen /dev/tty.usbserial-XXXXXXXX 115200
시리얼 터미널에서 빠져나오려면
'ctrl-a, ctrl-'를 순서데로 입력
혹은 외부 터미널에서 'pkill SCREEN' 혹은 -R 옵션을 주고
다시 연다
$ screen -R /dev/tty.usbserial-XXXXXXXX 115200
65
64. Static IP Address
ifconfig 명령으로 IP 확인
Static IP 입력: /etc/network/interfaces
67
$ sudo vi /etc/network/interfaces
auto lo
iface lo inet loopback
# auto eth0
# iface eth0 inet dhcp
# manual
auto eth0
iface eth0 inet static
address 192.168.0.204
netmask 255.255.255.0
netwrok 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
dns-nameservers 8.8.8.8 8.8.4.4
```
65. Serial console
Raspberry Pi는 Jessie 까지 기본적으로 UART 핀을 Host
machine의 Serial로 연결해서 Console로 사용할 수 있다.
- 라즈비안의 UART 는 기본으로 Serial console로 지정되어 있
다.
만약 serial communication으로 사용하려면 raspi-config로 해제
한다.
68
67. 부팅시 static ip 설정
라즈베리 파이의 boot process 단계 설정 파일을 이용
1. 보드에 전원이 들어오고 GPU가 활성화된다.
2. SoC 내 ROM에 있는 첫번째 부트로더(Firmware)를 읽어
들인다.
3. 첫번째 부트로더가 SD카드에 있는 두번째 부트로더
(bootcode.bin)을 호출한다.
4. 두번째 부트로더가 SD카드에 있는 config.txt를 읽고 실행
한다.
4. 두번째 부트로더가 세번째 부트로더(start.elf)를 호출 및
실행하여, ARM Core를 활성화한다.
6. ARM Core가 활성화되면 네번째 부트로더(kernel.img)를
70
74. Windows용 nmap
네트워크 안의 호스트를 고속으로 검색하는 도구
- Windows nmap: nmap.org/download.html
- Microsoft Visual C++ 2013 Redistributable Package
- WinCap Library: wincap.org
77
76. ssh pi@192.168.0.20
nmap, arp 등으로 IP 검색후 ssh 로그인.
$ ssh pi@192.168.11.100
The authenticity of host '192.168.11.100 (192.168.11.100)' can't be established.
ECDSA key fingerprint is SHA256:G8MGJDNGJeYqF123aYlKj4MMQF9aevRhF/aO2ldWo6E.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.11.100' (ECDSA) to the list of known hosts.
pi@192.168.11.100's password:
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: Fri Mar 3 16:24:26 2017
SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a
new password.79
78. raspi-config
raspi-config는 라즈비안 시스템을 설정하는 유틸리티입니다.
$sudo raspi-config
다음 1번은 꼭 실행해 주어야 SD카드 용량을 모두 사용합니다.
1. Expand Filesystem 사용을 허용합니다. 라즈베리파이는 SD card
를 4GB까지만 인식하도록 설정되어 있습니다. 그래서 8GB이상의
SD Card를 사용중이라면 (대부분...) Exapnd Filesystem 설정을
해야 합니다.
2. ssh 접속을 허용하기 위해서 Advanced Options -> SSH enable 을
실행합니다.
81 http://www.raspberrypi.org/documentation/configuration/raspi-config.md
82. VNC server
Raspbian 2016-11-25 일 버전 이후 VNC server 내장
RealVNC 등 클라이언트를 사용해 접속
raspi-config 혹은 GUI menu
- Select Menu > Preferences > Raspberry Pi Configuration >
Interfaces.
• Ensure VNC is Enabled.
85 https://www.raspberrypi.org/documentation/remote-access/vnc/
87. WiFi 설정
무선랜 동글 확인
$iwconfig
wlan0 ...
lo
eth0
주변 공유기 확인후 ESSID, 암호방식 메모
$iwlist wlan0 scan
Cell 02 - Address: 98:5A:EB:8D:5C:36
ESSID:"macbook_pro"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.462 GHz (Channel 11)
Encryption key:on
Bit Rates:144 Mb/s
90
88. WiFi 설정
AP 인증 설정 : /etc/wpa_supplicant/wpa_supplicant.conf
wpa_passphrase 명령으로 설정 가능
$sudo -s
#wpa_passphrase "SSID_NAME" SSID_PASSWORD
>> /etc/wpa_supplicant/wpa_supplicant.conf
파일: wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="SSID_NAME"
psk="SSID_PASSWORD"
key_mgmt=WPA-PSK
}91
89. WiFi 설정
wlan0 랜카드 재시작
$sudo ifdown wlan0
$sudo ifup wlan0
잠시후 ip 할당 확인
$ifconfig wlan0
92
91. Bluetooth package
bluez 패키지를 설치한다.
$sudo apt install bluez bluez-firmware
bluez 를 설치하면 'pi-bluetooth' 가 설치된다. 혹은 직접 설치;
$sudo apt install pi-bluetooth
'pi-bluetooth'는 BCM43430A1 칩의 펌웨어를 부팅할 때 적재한
다.
bluez 패키지는 블루투스를 다룰 수 있는 명령행이 설치된다.
94
92. bluetoothctl
$ bluetoothctl
[NEW] Controller B8:27:EB:62:F5:E1 homepi [default]
[bluetooth]# help
Available commands:
list List available controllers
show [ctrl] Controller information
select <ctrl> Select default controller
devices List available devices
paired-devices List paired devices
power <on/off> Set controller power
pairable <on/off> Set controller pairable mode
discoverable <on/off> Set controller discoverable mode
agent <on/off/capability> Enable/disable agent with given capability
default-agent Set agent as the default one
scan <on/off> Scan for devices
info <dev> Device information
pair <dev> Pair with device
trust <dev> Trust device
untrust <dev> Untrust device
block <dev> Block device
unblock <dev> Unblock device
remove <dev> Remove device
connect <dev> Connect device
disconnect <dev> Disconnect device
version Display version
quit Quit program
[bluetooth]#95
bluetoothctl은 단말의
블루투스 장치를 제어할
수 있다.
93. bluetoothctl
bluetoothctl에서 장치 정보 확인
$ bluetoothctl
[NEW] Controller A8:27:EB:62:D5:E1 homepi [default]
[bluetooth]# show A8:27:EB:62:D5:E1
Controller B8:27:EB:62:F5:E1
Name: homepi
Alias: homepi
Class: 0x000000
Powered: yes
Discoverable: no
Pairable: yes
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
Modalias: usb:v1D6Bp0246d0517
Discovering: no96
94. bluetoothctl
bluetoothctl에서 장치를 켜고 연결할 수 있다.
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# agent on
Agent registered
[bluetooth]# scan on
Discovery started
[CHG] Controller A8:27:EB:62:D5:E1 Discovering: yes
97
Raspberry Pi 장치 on
scan 가능 on
카메라/휴대폰
paring
101. 유용한 SysFS 정보
보드 모델
CPU Max frequency
Debian 계열 시스템 정보:
104
$ cat /sys/firmware/devicetree/base/model
Raspberry Pi 3 Model B Rev 1.2
$ cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
1200000
$ getconf -a
104. GPIO Overview
GPIO는 INPUT, OUTPUT 기능을 수행
모든 pin은 Pull-up & down 저항을 내장
모든 pin은 3.3v (5v가 아니다.)
GPIO에 최대 전류는 50mA 정도
107 http://elinux.org/RPi_Low-level_peripherals
109. 전기전자 부품
112
Push Button Digital Input Switch - Closes or
opens circuit
Polarized, needs
resistor
Trim
potentiometer
Analog Input Variable resistor Also called a
Trimpot.
Photoresistor Analog Input Light Dependent
Resistor (LDR)
Resistance varies
with light.
Relay Digital Output Switch driven by
a small signal
Used to control
larger voltages
Temp Sensor Analog Input Temp Dependent
Resistor
Flex Sensor Analog Input Variable resistor
Soft Trimpot Analog Input Variable resistor Careful of shorts
RGB LED Dig & Analog
Output
16,777,216
different colors
Ooh... So pretty.
Name Image Type Function Notes
115. 저항의 기능과 용도
전류의 흐름을 제한하는 것으로 전기회로를 순조롭게 동
작하도록 하는 기능을 가지고 있는 것이 저항이며 전기
회로에서 중요한 부품 중 하나이다.
118
발광하지 않는다 전류가 너무 흐른다 이상적인 동작 상태
LED에 흐르는 전류( )가
15[mA]인 경우 저항값
저항의 양단에
걸리는 전압
116. LED와 저항
5V를 LED에 안전하게 사용하기 위해서는
R = (5 - 2.6) / 0.02 = 150
보유한 220ohm 저항을 활용할 수 있다.
119
구동 저항 계산
http://www.gst-lcd.com/test_led3.htm
118. sysfs
sysfs는 리눅스 커널 2.4에서 /proc 에 복잡하게 사용하던 디바
이스 관련 정보를 커널 2.6 이후에 sysfs로 체계적으로 재 배
치했다.
- 가상 파일시스템으로 /sys 디렉토리에 마운트
- 사용자가 읽기/쓰기/변경 등 권한
- 하드웨어 구성 정보, 디바이스 드라이버 정보가 통합적인 계
층으로 보여주게 하기 위해 kobject라는 구조체 이용.
- 사용자 프로그램이 시스템 버스 드라이버, 플랫폼 드라이버
등의 상위 드라이버와 데이터 교환을 위해 export 용도로 제
공
121 http://egloos.zum.com/moonkh/v/4841757
https://www.kernel.org/doc/Documentation/gpio/sysfs.txt
120. GPIO 드라이버
라즈베리파이의 GPIO는 arch/arm/mach-
bcm2708/bcm2708_gpio.c 소스의 디바이스 드라이버 모델
을 기반으로 플랫폼 드라이버로 작성되어 있다.
사용자는 sysfs를 통해서 GPIO 포트에 접근할 수 있다.
$ cd /sys/class/gpio/
pi@raspberrypi /sys/class/gpio $ ls -l
total 0
-rwxrwx--- 1 root gpio 4096 Jan 1 1970 export
lrwxrwxrwx 1 root gpio 0 Jan 1 1970 gpiochip0 ->
../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0
-rwxrwx--- 1 root gpio 4096 Jan 1 1970 unexport
123
121. GPIO17 활성화
예를 들어 Pin 17을 활성화 하고자 하면
pi@raspberrypi /sys/class/gpio $ echo "17" > export
pi@raspberrypi /sys/class/gpio $ ls -l
total 0
-rwxrwx--- 1 root gpio 4096 Nov 19 21:41 export
lrwxrwxrwx 1 root gpio 0 Nov 19 21:41 gpio17 ->
../../devices/platform/soc/3f200000.gpio/gpio/gpio11
lrwxrwxrwx 1 root gpio 0 Jan 1 1970 gpiochip0 ->
../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0
-rwxrwx--- 1 root gpio 4096 Jan 1 1970 unexport
124
123. Pin 상태
이제 GPIO 17번 포트에 대해서 활성, 엣지, 값을 파일 시스템을
통해서 접근할 수 있다.
pi@raspberrypi /sys/class/gpio $ cd gpio17/
pi@raspberrypi /sys/class/gpio/gpio17 $ ls -l
total 0
-rw-r--r-- 1 root root 4096 Nov 19 21:42 active_low
lrwxrwxrwx 1 root root 0 Nov 19 21:42 device -> ../../../3f200000.gpio
-rw-r--r-- 1 root root 4096 Nov 19 21:42 direction
-rw-r--r-- 1 root root 4096 Nov 19 21:42 edge
lrwxrwxrwx 1 root root 0 Nov 19 21:41 subsystem ->
../../../../../../class/gpio
-rw-r--r-- 1 root root 4096 Nov 19 21:41 uevent
-rw-r--r-- 1 root root 4096 Nov 19 21:42 value
126
124. 출력
Pin 11번에 HIGH 출력을 하려면 gpio17/direction을 'out'으로
전환한다.
$ echo "out" > /sys/class/gpio/gpio17/direction
-bash: /sys/class/gpio/gpio11/direction: Permission denied
그리고 LED를 on/off 하려면 gpio17/value에 '1', '0' 값을 쓴다.
127
126. sysfs 쉘 코드
sysfs_23.sh
129
# the pin to control
PIN=23
# make this pin available through the SysFS
echo $PIN > /sys/class/gpio/export
# now, set this pin to output
echo out > /sys/class/gpio/gpio${PIN}/direction
# write a value to this pin
echo 1 > /sys/class/gpio/gpio${PIN}/value
# wait for some seconds
sleep 3s
# write a value to this pin
echo 0 > /sys/class/gpio/gpio${PIN}/value
# make this pin unavailable through the SysFS
echo $PIN > /sys/class/gpio/unexport
131. Creat My Own Parts
http://fritzing.org/learning/tutorials/creating-custom-parts/
https://embeddist.wordpress.com/2014/10/24/create-my-
part-on-fritzing/
134
sysfs 지원 확인
$ sudo sh -c "cat /lib/modules/`uname -r`/build/.config | fgrep SYSFS"
cat: /lib/modules/4.4.38-v7+/build/.config: No such file or directory