Raspberry Pi

오픈소스 비즈니스 컨설팅
둘러보기로 가기 검색하러 가기

Raspberry Pi 정리

Raspberry 개요

영국 Raspberry Pi 재단에서 만든 초소형 PC (2012.03), $35 (모델 B)
700 MHz * ARM * GPU / 512 MB Memory / SD 카드 / 100 M bits Network
영상 출력 : 컴포지트, HDMI, DSI
음성 출력 : 잭, HDMI
USB, GPIO
OS : NO OBS, 라즈비안, Apache Linux, Pidora, RISC OS

IoT-rpi2-board_InvariantCulture_Default.png

Raspberry Pi 3 B 사양

  • 4 Core (1.2 GHz) / 1 GB Memory / 16 GB Disk
  • CentOS Linux release 7.5.1804 (AltArch), 32 bits

싱글 보드 컴퓨터의 종류

싱글 보드 컴퓨터 상세

Arduino
(arduino.cc)

$27

  • 오픈소스 마이크로 컨트롤러 보드
    • 다수의 스위치 또는 센서로부터 입력
    • LED 또는 모터와 같은 외부 장치를 제어
    • USB 또는 별도의 전원 필요
  • Atmel의 AVR 기반 제품
    • Arduino Uno                  : 16 MHz, 2 KB SRAM, $27
    • Arduino Zero
  • Cortex-M3 기반 제품           : Arduino Due
  • 통합 개발 환경 (IDE)
    • 어도비 플래시, Processing (Java 기반), Max/MSP
    • Linux, Windows, Mac OS X 지원
  • Arduino 1.0.6 (2013.05.15)
  • Arduino 1.5.8 Beta (Arduino Due)
  • Shield : 확장 부품. 유무선 통신, GPS 수신, 음악 재생 등

Raspberry Pi

(www.raspberrypi.org)

$35

  • 영국 Raspberry Pi 재단에서 만든 초소형 PC (2012.03), $35 (모델 B)
  • 700 MHz * ARM * GPU / 512 MB Memory / SD 카드 / 100 M bits Network
  • 영상 출력 : 컴포지트, HDMI, DSI
  • 음성 출력 : 잭, HDMI
  • USB, GPIO
  • OS : NO OBS, 라즈비안, Apache Linux, Pidora, RISC OS
  • Raspberry Pi 2 Model B
  • Raspberry Pi 1 Model B+ : 2015년 2월 출시

BeagleBone Black (BBB)

(beagleboard.org)

$55

  • ARM 기반의 오픈소스 하드웨어
  • 1 GHz / 512 MB DDR3 RAM / 4 GB eMMC 저장 공간
  • USB, Ethernet, HDMI, 2 * 46 pin headers
  • Linux kernel (3.10.x, 3.8.x) 지원
    • Debian, Angstrom Linux, Android, Ubuntu

Intel Gallireo

$60

Intel Edison

$50

  • SD 카드 모양의 소형 컴퓨터, 2014.01.08
    • 400 MHz * 듀얼 코어, 512 KB SRAM, 2 GB Storage
    • 장치 : 내장그래픽, 블루투스, WiFi
    • Yocto Linux 1.6으로 구동
  • 에디슨 (2014.09), $50
    • 500 MHz * 듀얼코아 Atom * 듀얼 스레드 + 100 MHz 32 bits 쿼크 프로세스
    • 1 GB LPDDR3 (Memory) / 4 GB eMMC 플래시 메모리 (Disk)
    • 무선랜, 블루투스 4.0LE
    • 개발 환경 : Arduino, C, C++, 파이선 등
  • 보드 : Breakout Board ($75), Arduino Kit ($100, 아두이노와 호환)

OS 설치

Raspberry Pi 3에 CentOS 7 설치

  • 압축을 풀어 CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw 파일을 만든다.
  • CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw 파일은 SD에 굽는다.
  • Etcher을 사용하여 SD에 굽는다.

root / centos 로 로그인하여 사용 한다.

  • 설치된 사양
  • CentOS Linux release 7.5.1804 (Core), 32 bits
  • 4 cores

Disk resize

rootfs-expand
df -h

Network 설정

# systemctl  stop     NetworkManager.service
# systemctl  disable  NetworkManager.service
# systemctl  status   NetworkManager.service
#
# systemctl stop     firewalld.service
# systemctl disable  firewalld.service
# systemctl status   firewalld.service
#
# getenforce
# vi  /etc/sysconfig/selinux
#     SELINUX=disabled
# setenforce 0
# shutdown  -r  now
#
# cd  /etc/sysconfig/network-scripts
# mv  ifcfg-link  nouse_ifcfg-link
# vi  ifcfg-eth0
#     DEVICE=eth0
#     TYPE="Ethernet"
#     BOOTPROTO="dhcp"
#     ONBOOT="yes"
#     NM_CONTROLLED="no"
# shutdown  -r  now
# systemctl  restart  network.service
# ping -c 3 google -v

WiFi 설정

yum -y install wpa_supplicant NetworkManager NetworkManager-wifi
systemctl enable  NetworkManager.service
systemctl disable NetworkManager-wifi.service
systemctl start   NetworkManager.service
systemctl stop    NetworkManager-wifi.service 

nmcli dev wifi rescan
nmcli dev wifi list                                         #--- WiFi 이름 확인
nmcli --ask dev wifi connect ${와이파이_이름}                    #--- WiFi 연결

# cd  /etc/sysconfig/network-scripts
# vi  ifcfg-wlan0
#     DEVICE=wlan0
#     TYPE="Ethernet"
#     BOOTPROTO="dhcp"
#     ONBOOT="yes"
#     NM_CONTROLLED="no"
# wpa_cli reconfigure
# ifdown wlan0
# ifup   wlan0
# 
# vi /etc/sysconfig/wpa_supplicant
# wpa_passphrase ${SSID} ${비밀번호}                              #--- WPA2 등을 사용할 경우 psk 값을 생성
# vi  /etc/wpa_supplicant/wpa_supplicant.conf
#     ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev     #--- netdev, wheel
#     network={
#         ssid="접속하고자 하는 wifi 이름"
#         psk="접속하고자 하는 wifi 비밀번호"                     
#         # psk=NONE                                              #--- 비밀번호 없음
#         scan_ssid=1                                             #--- SSID를 자동으로 찾기
#         # key_mgmt=WPA-PSK
#         priority=1
#     }

Bluetooth 설정

# yum -y install NetworkManager-bluetooth
# # systemctl enable NetworkManager-bluetooth.service
# # systemctl start  NetworkManager-bluetooth.service
# systemctl restart  NetworkManager.service

기본 S/W 설치

yum -y install which
# yum -y install wireless-tools wpa_supplicant dhcpcd    

timedatectl list-timezones | grep -i seoul
timedatectl set-timezone Asia/Seoul

참고 문헌

Raspberry Pi 3에 GNOME 설치

yum -y install "GNOME Desktop"

#--- 대기 모드 끄기
vi  /etc/systemd/logind.conf
    HandleLidSwitch=ignore

systemctl  restart  systemd-logind.service

Raspberry Pi 2에 CentOS 7 설치

  • 압축을 풀어 CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw 파일을 만든다.
  • CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw 파일은 SD에 굽는다.
  • Etcher을 사용하여 SD에 굽는다.

root / centos 로 로그인하여 사용 한다.

  • 설치된 사양
  • CentOS Linux release 7.5.1804 (Core), 32 bits
  • 4 cores

Network 설정

systemctl  stop     NetworkManager.service
systemctl  disable  NetworkManager.service
systemctl  status   NetworkManager.service

# systemctl stop     firewalld.service
# systemctl disable  firewalld.service
# systemctl status   firewalld.service
#
# getenforce
# vi  /etc/sysconfig/selinux
#     SELINUX=disabled
# setenforce 0
# shutdown  -r  now

cd  /etc/sysconfig/network-scripts
mv  ifcfg-link  nouse_ifcfg-link
vi  ifcfg-eth0
    DEVICE=eth0
    TYPE="Ethernet"
    BOOTPROTO="dhcp"
    ONBOOT="yes"
    NM_CONTROLLED="no"
shutdown  -r  now
# systemctl  restart  network.service
ping -c 3 google -v

Disk resize

rootfs-expand
lsblk
df -h
# [root@localhost ~]# lsblk -l
# NAME      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
# mmcblk0   179:0    0 14.7G  0 disk
# mmcblk0p2 179:2    0  488M  0 part [SWAP]
# mmcblk0p3 179:3    0  1.4G  0 part /
# mmcblk0p1 179:1    0  668M  0 part /boot
#  
#  
# fdisk /dev/mmcblk0
# #--- p d 3
# #--- n p 3 엔터 엔터
# #--- w
# shutdown -r now

기본 S/W 설치

yum -y install which

참고 문헌

Raspberry Pi에 Raspbian 설치

  • 2018-10-09-raspbian-stretch-lite.img : Text 모드
  • 2018-10-09-raspbian-stretch.img : GUI 모드
  • Win32 Disk Imager로 Micro SD 카드에 img 파일을 설치 합니다.
  • Raspberry Pi로 부팅해서 다음 작업을 진행 합니다. pi / raspberry 로 로그인 한다.
raspi-config
    #--- "4 Localisation Options" 선택 

    #--- "1 Change Locale" :
    #---     en_GB.UTF-8, en_US.UTF-8, ko_KR.UTF8 (디폴트), ko_KR.ECU-KR 선택
    #--- "2 Change Timezone" : Asia > Seoul
    #--- "3 Change Keyboard Layout"
    #---     Generic 105-key (Intl) PC > Other > Korean > Korean - Korean (101/104 key compatible) > The default for the keyboard layout > No compose key
    #--- "4 Change Wi-fi Country" : US Unite States     (KR Korea (South) 사용 않음)

#--- 업데이트
apt-get update
apt-get upgrade
reboot

#--- 한글이 깨어지는 경우
apt-get install ibus  
apt-get install ibus-hangul
apt-get install fonts-unfonts-core
reboot

X11 (X-Window) 환경 구성

apt  install  lxde  lightdm  xinit	
# export DISPLAY=0.0
startx

IP 확인

mkdir  -p  /work/bin
cd  /work/bin
vi  raspberrypi.bash
    #!/usr/bin/env bash
    IPADDR=`/usr/sbin/ip addr list eth0 | /usr/bin/grep 'inet ' | /usr/bin/awk '{print \$2}'`
    /usr/bin/curl http://www.obcon.biz/raspberrypi.php?ip=raspberrypi_2_${IPADDR}
chmod  755  raspberrypi.bash

crontab -e
    * * * * * /work/bin/raspberrypi.bash

S/W 설치

Node.js 설치

  • Node.js 8.9.4
# yum list | grep nodejs
# yum -y install nodejs

yum -y install which wget
uname -m                                                    #--- ARM 아키텍처 확인
mkdir -p /work/install
cd /work/install
#--- https://nodejs.org/dist/
# wget https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-armv7l.tar.xz
# tar -xvf node-v10.9.0-linux-armv7l.tar.xz
# cd node-v10.9.0-linux-armv7l
wget https://nodejs.org/dist/v8.9.4/node-v8.9.4-linux-armv7l.tar.xz
tar -xvf node-v8.9.4-linux-armv7l.tar.xz
cd node-v8.9.4-linux-armv7l 

/usr/bin/rm CHANGELOG.md LICENSE README.md
/usr/bin/cp -R * /usr/local/
node -v
npm -v

Python 설치

Python 2.7 설치

yum -y install python python-IPy python-backports python-backports-ssl_match_hostname python-chardet python-cheetah python-configobj python-decorator python-firewall python-iniparse python-javapackages python-jsonpatch python-jsonpointer python-libs python-lxml python-markdown python-perf python-pillow python-prettytable python-progressbar python-pycurl python-pygments python-pyudev python-requestbuilder python-requests python-setuptools python-six python-slip python-slip-dbus python-urlgrabber python-urllib3

python -V


Python 3.4 설치

vi /etc/yum.repos.d/epel.repo
   [epel]
   name=Epel rebuild for armhfp
   baseurl=https://armv7.dev.centos.org/repodir/epel-pass-1/
   enabled=1
   gpgcheck=0

yum -y install python34 python34-pip
python3 -V

GNOME에 VNC Server 설치

  • Raspberry Pi 7인치 Touch Screen Display
  • LCD
  • 해상도 : 800 * 480
  • Raspberry Pi 7inch HDMI LCD (C)의 경우 1024*600의 해상도를 지원하며 /boot/config.txt 파일을 수정하여야 합니다.
  • 접속시 "IP:5901"로 접속 한다.
yum -y install tigervnc-server
cp  /lib/systemd/system/vncserver@.service  /lib/systemd/system/vncserver@:1.service
vi  /lib/systemd/system/vncserver@:1.service
    [Service]
    Type=forking

    # Clean any existing files in /tmp/.X11-unix environment
    ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
    ExecStart=/usr/sbin/runuser -l centos -c "/usr/bin/vncserver %i"
    PIDFile=/home/centos/.vnc/%H%i.pid
    ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

systemctl enable  firewalld.service
systemctl restart firewalld.service
systemctl status  firewalld.service

firewall-cmd  --permanent  --zone=public  --add-service  vnc-server
firewall-cmd  --reload

su - centos                                            #--- 일반 사용자로 vncserver 시작
vncserver -geometry 800x480
    You will require a password to access your desktops.

    Password:
    Verify:
    Would you like to enter a view-only password (y/n)? y
    Password:
    Verify:
    xauth:  file /home/centos/.Xauthority does not exist

    New 'localhost.localdomain:1 (centos)' desktop is localhost.localdomain:1

    Creating default startup script /home/centos/.vnc/xstartup
    Creating default config /home/centos/.vnc/config
    Starting applications specified in /home/centos/.vnc/xstartup
    Log file is /home/centos/.vnc/localhost.localdomain:1.log
# vncserver                                          #--- vncserver 실행
# vncserver -geometry 1920x1080                      #--- 해상도를 지정한 후 vncserver 실행
# vncserver -kill :포트번호                          #--- vncserver 종료
exit

systemctl daemon-reload
systemctl enable vncserver@:1.service
systemctl status vncserver@:1.service
reboot

관리자 가이드

화면 로테이션

화면을 180도 로테이션을 한다. 로테이션에 따라 터치 스크린 정보가 같이 수정 한다.

참조

  • /sys/class/graphics/fbcon/rotate 파일

GNOME용 한글 폰트 설치

GNOME에서 한글이 깨어지면 아래와 같이 작업 한다.

# yum -y install kde-l10n-Korean
# yum -y install fonts-korean
yum -y install google-noto-sans-korean-fonts

참고 문헌