Orange Pi Zero Plus2

OS/Orange PI 2018.01.06 00:28 Posted by 파란크리스마스

Orange Pi Zero Plus2

출처 : 스터디메이크 :: 오렌지파이 제로 보드 간단 사용기
Xunlong Orange Pi Zero

 

 

OS 설치

OS 다운로드 - Orange Pi Zero 2+ H5

부팅후 계정 설정

Ubuntu 16.04.3 LTS orangepizeroplus2 ttyS0
 
orangepizeroplus2 login: root
Password: [1234]
You are required to change your password immediately (root enforced)
Changing password for root.
(current) UNIX password: [1234]
Enter new UNIX password: [orangepi]
Retype new UNIX password: [orangepi]
  ___  ____  _   _____                ____  _             ____
 / _ \|  _ \(_) |__  /___ _ __ ___   |  _ \| |_   _ ___  |___ \
| | | | |_) | |   / // _ \ '__/ _ \  | |_) | | | | / __|   __) |
| |_| |  __/| |  / /|  __/ | | (_) | |  __/| | |_| \__ \  / __/
 \___/|_|   |_| /____\___|_|  \___/  |_|   |_|\__,_|___/ |_____|
 
 
Welcome to ARMBIAN 5.34.171121 nightly Ubuntu 16.04.3 LTS 4.13.14-sunxi64
System load:   0.42 0.12 0.04   Up time:       0 min
Memory usage:  8 % of 482MB     IP:
CPU temp:      27°C
Usage of /:    4% of 29G
 
[ General system configuration (beta): armbian-config ]
 
New to Armbian? Check the documentation first: https://docs.armbian.com
 
 
You are using an Armbian nightly build meant only for developers to provide
constructive feedback to improve build system, OS settings or user experience.
If this does not apply to you, STOP NOW!. Especially don't use this image for
daily work since things might not work as expected or at all and may break
anytime with next update. YOU HAVE BEEN WARNED!
 
This image is provided AS IS with NO WARRANTY and NO END USER SUPPORT!.
 
Creating a new user account. Press <Ctrl-C> to abort
 
Please provide a username (eg. your forename): pi
Trying to add user pi
Adding user `pi' ...
Adding new group `pi' (1000) ...
Adding new user `pi' (1000) with group `pi' ...
Creating home directory `/home/pi' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: [orangepi]
Retype new UNIX password: [orangepi]
passwd: password updated successfully
Changing the user information for pi
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n]
 
 
 
Dear pi, your account pi has been created and is sudo enabled.
Please use this account for your daily work from now on.
 
root@orangepizeroplus2:~#

Wifi 설정

armbian 와이파이 설정

출처 : 오렌지파이 제로 무선인터넷 설정 1.2 암비안 와이파이 설정

$ sudo nmtui

eMMC os 설치

출처 : #Test: Orange Pi Plus 2e: unpacking and installing Armbian on eMMC memory • DIY Projects

$ sudo nand-sata-install

JDK 설치

출처 : Install Java 8 on Armbian (Orange Pi Lite or higher) • DIY Projects

저장소 추가

$ sudo add-apt-repository ppa:webupd8team/java

추가한 저장소 반영

$ sudo apt-get update

JDK 설치

$ sudo apt-get install oracle-java8-installer

JAVA_HOME 환경변수 추가

$ sudo vi /etc/profile

내용 추가 export JAVA_HOME=/usr/lib/jvm/java-8-oracle

export JAVA_HOME=/usr/lib/jvm/java-8-oracle

JDK 설치 확인

$ $JAVA_HOME/bin/java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) Client VM (build 25.151-b12, mixed mode)

SD 추가

출처 : Setting up the bootable SD card - Orange Pi

디스크 확인

$ sudo fdisk -l
Disk /dev/mmcblk2: 7.3 GiB, 7818182656 bytes, 15269888 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2e3d2df2
 
Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk2p1       8192 15117183 15108992  7.2G 83 Linux
 
 
Disk /dev/mmcblk2boot1: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
 
 
Disk /dev/mmcblk2boot0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
 
 
Disk /dev/zram0: 60.3 MiB, 63270912 bytes, 15447 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 
 
Disk /dev/zram1: 60.3 MiB, 63270912 bytes, 15447 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 
 
Disk /dev/zram2: 60.3 MiB, 63270912 bytes, 15447 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 
 
Disk /dev/zram3: 60.3 MiB, 63270912 bytes, 15447 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 
 
Disk /dev/mmcblk0: 29.7 GiB, 31914983424 bytes, 62333952 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x67c048bb
 
Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       8192 61710591 61702400 29.4G 83 Linux

기존 파이션 삭제 및 파티션 생성

pi@orangepizeroplus2:~$ sudo fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
Partition number (1,2, default 2): [Enter]

Partition 2 has been deleted.

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): [Enter]

Using default response p.
Partition number (1-4, default 1): [Enter]
First sector (2048-62333951, default 2048): [Enter]
Last sector, +sectors or +size{K,M,G,T,P} (2048-62333951, default 62333951): [Enter]

Created a new partition 1 of type 'Linux' and of size 29.7 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

pi@orangepizeroplus2:~$ 

디스크 포맷

$ sudo mkfs.ext4 /dev/mmcblk0p1
mke2fs 1.42.13 (17-May-2015)
Discarding device blocks: done                            
Creating filesystem with 7791488 4k blocks and 1949696 inodes
Filesystem UUID: 620c3235-2471-45b6-bd2e-5ead5fc11350
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000
 
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

마운트

$ sudo mount /dev/mmcblk0p1 /mnt

마운트 확인

$ df -k
Filesystem     1K-blocks    Used Available Use% Mounted on
udev              178792       0    178792   0% /dev
tmpfs              49432    2440     46992   5% /run
/dev/mmcblk2p1   7304800 1201820   5708872  18% /
tmpfs             247148       0    247148   0% /dev/shm
tmpfs               5120       0      5120   0% /run/lock
tmpfs             247148       0    247148   0% /sys/fs/cgroup
tmpfs             247148       0    247148   0% /tmp
log2ram            51200    1320     49880   3% /var/log
tmpfs              49432       0     49432   0% /run/user/0
tmpfs              49432       0     49432   0% /run/user/1000
/dev/mmcblk0p1  30545420   44992  28925748   1% /mnt

eMMC 백업

$ sudo dd bs=4M if=/dev/mmcblk2 of=/mnt/emmc_backup.img
1864+0 records in
1864+0 records out
7818182656 bytes (7.8 GB, 7.3 GiB) copied, 474.25 s, 16.5 MB/s


Orange Pi Zero - node.js 설치

OS/Orange PI 2017.12.17 20:18 Posted by 파란크리스마스

출처 : orange-pi-gpio - npm
GitHub - BorisKotlyarov/orange-pi-gpio
Arduino Slovakia - Orange Pi Zero and Node.js

node.js 6.X 설치

$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs

node.js 8.X 설치

$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt-get install -y nodejs

node.js 설치 확인

$ node -v
v8.9.3
$ npm -v
5.5.1

orange-pi-gpio 라이브러리 설치

출처 : GitHub - BorisKotlyarov/orange-pi-gpio

$ npm i orange-pi-gpio
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN pi No description
npm WARN pi No repository field.
npm WARN pi No README data
npm WARN pi No license field.
 
+ orange-pi-gpio@1.0.2
added 1 package in 6.975s

LED 제어

소스

const Gpio = require('orange-pi-gpio');

let gpio14 = new Gpio({pin:14, mode: 'out', ready: ()=>{
    let value = 1;

    setInterval(function() {
        process.stdout.write('\x1B[2J\x1B[0f\u001b[0;0H');

        if(value){
            console.log('\x1b[32m%s\x1b[0m', `ON`);
        } else {
            console.log('\x1b[31m%s\x1b[0m', `OFF`);
        }
        
        gpio14.write(value);
        value = +!value;
    }, 50);

}});

실행

$ node LEDDemo.js 

Orange Pi Zero - pi4j

OS/Orange PI 2017.12.17 19:19 Posted by 파란크리스마스

출처 : ORANGE PI ZERO PIN · Issue #333 · Pi4J/pi4j · GitHub

pi4 다운로드

$ wget http://get.pi4j.com/download/pi4j-1.2-SNAPSHOT.zip

pi4 압축풀기

$ unzip pi4j-1.2-SNAPSHOT.zip

LED 제어

소스

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;

public class LEDDemo {

	public static void main(String[] args) throws InterruptedException {
		
		// GPIO controller
		final GpioController gpio = GpioFactory.getInstance();
		
		// 14번 핀 모드 변경
		GpioPinDigitalOutput myLed = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_14, // PIN NUMBER
				"My LED", // PIN FRIENDLY NAME (optional)
				PinState.LOW); // PIN STARTUP STATE (optional)
		
		// LED 켜기
		myLed.setState(PinState.HIGH);

		// 5초 대기
		Thread.sleep(5000);

		// LED 끄기
		myLed.setState(PinState.LOW);

		// GPIO controller 리스스 반환
		gpio.shutdown();
	}
}

컴파일

$ javac -cp .:pi4j-1.2-SNAPSHOT/lib/* -d . LEDDemo.java

실행

$ sudo java -cp .:pi4j-1.2-SNAPSHOT/lib/* -Dpi4j.linking=dynamic LEDDemo

Orange Pi Zero - WiringOP

OS/Orange PI 2017.12.17 00:05 Posted by 파란크리스마스

출처 : GitHub - xpertsavenue/WiringOP-Zero: WiringPi / WiringPi / WiringOP libary for the Orange Pi Zero with 26 pin GPIO header

WiringOP-Zero 설치

WiringOP-Zero 소스 다운로드

$ git clone https://github.com/xpertsavenue/WiringOP-Zero.git

WiringOP-Zero 컴파일및 설치

$ cd WiringOP-Zero
$ chmod +x ./build
$ sudo ./build
 
.. 생략 ...
 
[Install Headers]
[Install Dynamic Lib]
 
WiringPi Devices Library
[UnInstall]
make: Nothing to be done for 'all'.
[Install Headers]
[Install Dynamic Lib]
 
GPIO Utility
[Link]
[Install]
 
All Done.
 
NOTE: To compile programs with wiringBP v2, you need to add:
    -lwiringPi
  to your compile line(s) To use the Gertboard, MaxDetect, etc.
  code (the devLib), you need to also add:
    -lwiringPiDev
  to your compile line(s).

설치 확인

$ gpio readall
 +-----+-----+----------+------+--Orange Pi Zero--+---+------+---------+-----+--+
 | H2+ | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | H2+ |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
 |  12 |   8 |    SDA.0 | ALT5 | 0 |  3 || 4  |   |      | 5V       |     |     |
 |  11 |   9 |    SCL.0 | ALT5 | 0 |  5 || 6  |   |      | 0v       |     |     |
 |   6 |   7 |   GPIO.7 | ALT3 | 0 |  7 || 8  | 0 | ALT5 | TxD3     | 15  | 198 |
 |     |     |       0v |      |   |  9 || 10 | 0 | ALT5 | RxD3     | 16  | 199 |
 |   1 |   0 |     RxD2 | ALT5 | 0 | 11 || 12 | 0 | ALT3 | GPIO.1   | 1   | 7   |
 |   0 |   2 |     TxD2 | ALT5 | 0 | 13 || 14 |   |      | 0v       |     |     |
 |   3 |   3 |     CTS2 | ALT3 | 0 | 15 || 16 | 0 | ALT4 | GPIO.4   | 4   | 19  |
 |     |     |     3.3v |      |   | 17 || 18 | 0 | ALT4 | GPIO.5   | 5   | 18  |
 |  15 |  12 |     MOSI | ALT5 | 0 | 19 || 20 |   |      | 0v       |     |     |
 |  16 |  13 |     MISO | ALT5 | 0 | 21 || 22 | 0 | ALT3 | RTS2     | 6   | 2   |
 |  14 |  14 |     SCLK | ALT5 | 0 | 23 || 24 | 0 | ALT5 | CE0      | 10  | 13  |
 |     |     |       0v |      |   | 25 || 26 | 0 | ALT3 | GPIO.11  | 11  | 10  |
 +-----+-----+----------+------+---+---LEDs---+---+------+----------+-----+-----+
 |  17 |  30 | STAT-LED |  OUT | 0 | 27 || 28 |   |      | PWR-LED  |     |     |
 +-----+-----+----------+------+---+-----+----+---+------+----------+-----+-----+
 | H2+ | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | H2+ |
 +-----+-----+----------+------+--Orange Pi Zero--+---+------+---------+-----+--+

LED 제어

GPIO 모드 변경

$  gpio mode 14 out

LED 켜기

$ gpio write 14 1

LED 끄기

$ gpio write 14 0

Orange Pi Zero 512MB

OS/Orange PI 2017.12.15 00:58 Posted by 파란크리스마스

Orange PI Zero

출처 : 스터디메이크 :: 오렌지파이 제로 보드 간단 사용기
Xunlong Orange Pi Zero

 

OS 설치

OS 다운로드 - Orange Pi Zero – armbian

UART USB 케이블 연결

부팅후 계정 설정

Ubuntu 16.04.3 LTS orangepizero ttyS0

orangepizero login: root
Password: [1234]
You are required to change your password immediately (root enforced)
Changing password for root.
(current) UNIX password: [1234]
Enter new UNIX password: [orangepi]
Retype new UNIX password: [orangepi]
  ___                               ____  _   _____              
 / _ \ _ __ __ _ _ __   __ _  ___  |  _ \(_) |__  /___ _ __ ___  
| | | | '__/ _` | '_ \ / _` |/ _ \ | |_) | |   / // _ \ '__/ _ \ 
| |_| | | | (_| | | | | (_| |  __/ |  __/| |  / /|  __/ | | (_) |
 \___/|_|  \__,_|_| |_|\__, |\___| |_|   |_| /____\___|_|  \___/ 
                       |___/                                     

Welcome to ARMBIAN 5.35 user-built Ubuntu 16.04.3 LTS 3.4.113-sun8i   
System load:   0.03 0.14 0.07   Up time:       4 min
Memory usage:  6 % of 494MB     IP:            
CPU temp:      46°C           
Usage of /:    71% of 1.4G   

[ General system configuration (beta): armbian-config ]

Warning: a reboot is needed to finish resizing the filesystem  
Please reboot the system as soon as possible  
New to Armbian? Check the documentation first: https://docs.armbian.com


Thank you for choosing Armbian! Support: www.armbian.com

Creating a new user account. Press  to abort

Please provide a username (eg. your forename): pi
Trying to add user pi
Adding user `pi' ...
Adding new group `pi' (1000) ...
Adding new user `pi' (1000) with group `pi' ...
Creating home directory `/home/pi' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: [orangepi]
Retype new UNIX password: [orangepi]
passwd: password updated successfully
Changing the user information for pi
Enter the new value, or press ENTER for the default
        Full Name []: pi
        Room Number []: 
        Work Phone []: 
        Home Phone []: 
        Other []: 
Is the information correct? [Y/n] 

Dear pi, your account pi has been created and is sudo enabled.
Please use this account for your daily work from now on.



Warning: a reboot is needed to finish resizing the filesystem  
Please reboot the system now  

root@orangepizero:~# 

Wifi 설정

출처 : 014. Raspberry Pi 라즈베리 파이 - wheezy무선랜 ... - Tsunami - Tistory

$ cd /etc/ifplugd/action.d/
$ sudo mv ifupdown ifupdown.bk
$ sudo cp /etc/wpa_supplicant/ifupdown.sh ./ifupdown

armbian 와이파이 설정

출처 : 오렌지파이 제로 무선인터넷 설정 1.2 암비안 와이파이 설정

$ sudo nmtui

SD 확장

SD 확장전 용량확인

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            181M     0  181M   0% /dev
tmpfs            50M  1.2M   49M   3% /run
/dev/mmcblk0p1  7.2G  1.1G  6.1G  15% /
tmpfs           248M     0  248M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           248M     0  248M   0% /sys/fs/cgroup
tmpfs           248M     0  248M   0% /tmp
log2ram          50M  1.3M   49M   3% /var/log
tmpfs            50M     0   50M   0% /run/user/1000

SD FDisk

pi@orangepizero:~$ sudo fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa3a6ea09

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       8192 15213343 15205152  7.3G 83 Linux

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-31116287, default 2048): 8192
Last sector, +sectors or +size{K,M,G,T,P} (8192-31116287, default 31116287): 

Created a new partition 1 of type 'Linux' and of size 14.9 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

pi@orangepizero:~$ sudo shutdown -r now

SD 확장

$ sudo resize2fs /dev/mmcblk0p1
[sudo] password for pi: 
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mmcblk0p1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p1 is now 3888512 (4k) blocks long.

SD 확장 확인

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            181M     0  181M   0% /dev
tmpfs            50M  1.2M   49M   3% /run
/dev/mmcblk0p1   15G  1.1G   14G   8% /
tmpfs           248M     0  248M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           248M     0  248M   0% /sys/fs/cgroup
tmpfs           248M     0  248M   0% /tmp
log2ram          50M  1.5M   49M   3% /var/log
tmpfs            50M     0   50M   0% /run/user/1000

JDK 설치

출처 : Install Java 8 on Armbian (Orange Pi Lite or higher) • DIY Projects

저장소 추가

$ sudo add-apt-repository ppa:webupd8team/java

추가한 저장소 반영

$ sudo apt-get update

JDK 설치

$ sudo apt-get install oracle-java8-installer

JAVA_HOME 환경변수 추가

$ sudo vi /etc/profile

내용 추가 export JAVA_HOME=/usr/lib/jvm/java-8-oracle

export JAVA_HOME=/usr/lib/jvm/java-8-oracle

JDK 설치 확인

$ $JAVA_HOME/bin/java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) Client VM (build 25.151-b12, mixed mode)

Orange PI Zero - pi4j로 PWM 제어

OS/Orange PI 2017.03.25 12:10 Posted by 파란크리스마스

Orange PI Zero - pi4j로 PWM 제어

Orange PI Zero는 하나의 PWM만 지원

배선

Java 소스

import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.OrangePiZeroGpioProvider;
import com.pi4j.wiringpi.Gpio;
import com.pi4j.wiringpi.SoftPwm;

public class SG90PWMMain {

	private static int PIN_NUMBER = 7;

	public static void main(String[] args) throws Exception {
		//
		//GpioFactory.setDefaultProvider(new RaspiGpioProvider(RaspiPinNumberingScheme.BROADCOM_PIN_NUMBERING));
		//GpioFactory.setDefaultProvider(new OrangePiPc2GpioProvider());
		//GpioFactory.setDefaultProvider(new NanoPiNEOAirGpioProvider());
		GpioFactory.setDefaultProvider(new OrangePiZeroGpioProvider());

		// initialize wiringPi library, this is needed for PWM
		Gpio.wiringPiSetup();

		// softPwmCreate(int pin, int value, int range)
		// the range is set like (min=0 ; max=100)
		SoftPwm.softPwmCreate(PIN_NUMBER, 0, 50);
		int counter = 0;
		while (counter < 3) {
			// fade LED to fully ON
			for (int i = 0; i <= 100; i++) {
				// softPwmWrite(int pin, int value)
				// This updates the PWM value on the given pin. The value is
				// checked to be in-range and pins
				// that haven't previously been initialized via softPwmCreate
				// will be silently ignored.
				SoftPwm.softPwmWrite(PIN_NUMBER, i);
				Thread.sleep(25);
			}
			// fade LED to fully OFF
			for (int i = 100; i >= 0; i--) {
				SoftPwm.softPwmWrite(PIN_NUMBER, i);
				Thread.sleep(25);
			}
			counter++;
		}
	}

}

실행

$ sudo java -cp .:pi4j-core.jar:pi4j-gpio-extension.jar SG90PWMMain

실행 영상

Orange PI Zero GPIO 설치, pi4j

OS/Orange PI 2017.03.25 03:01 Posted by 파란크리스마스

Orange PI Zero GPIO 설치

출처 : WiringOP for Orange pi zero - Beginners - OrangePi - Powered by

현재 pi4j는 Orange PI PC2 지원하지 않아 수정한 jar를 배포합니다.

pi4j-core.jar

$ sudo apt-get install build-essential
$ git clone https://github.com/zhaolei/WiringOP.git -b h3
$ cd WiringOP
$ chmod +x ./build
$ sudo ./build
$ gpio -v
gpio version: 2.20
Copyright (c) 2012-2014 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
 
Banana Pro Details:
  Type: Banana Pro, Revision: 1.2, Memory: 1024MB, Maker: LeMaker 
orangepi@OrangePizero:~/WiringOP$ gpio readall
 +-----+-----+----------+------+---+-Orange Pi+---+---+------+---------+-----+--+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
 |  12 |   8 |    SDA.0 | ALT5 | 0 |  3 || 4  |   |      | 5V       |     |     |
 |  11 |   9 |    SCL.0 | ALT5 | 0 |  5 || 6  |   |      | 0v       |     |     |
 |   6 |   7 |   GPIO.7 | ALT3 | 0 |  7 || 8  | 0 | ALT3 | TxD3     | 15  | 13  |
 |     |     |       0v |      |   |  9 || 10 | 0 | ALT3 | RxD3     | 16  | 14  |
 |   1 |   0 |     RxD2 | ALT5 | 0 | 11 || 12 | 0 | ALT3 | GPIO.1   | 1   | 110 |
 |   0 |   2 |     TxD2 | ALT5 | 0 | 13 || 14 |   |      | 0v       |     |     |
 |   3 |   3 |     CTS2 | ALT3 | 0 | 15 || 16 | 0 | ALT3 | GPIO.4   | 4   | 68  |
 |     |     |     3.3v |      |   | 17 || 18 | 0 | ALT3 | GPIO.5   | 5   | 71  |
 |  64 |  12 |     MOSI | ALT4 | 0 | 19 || 20 |   |      | 0v       |     |     |
 |  65 |  13 |     MISO | ALT4 | 0 | 21 || 22 | 0 | ALT3 | RTS2     | 6   | 2   |
 |  66 |  14 |     SCLK | ALT4 | 0 | 23 || 24 | 0 | ALT4 | CE0      | 10  | 67  |
 |     |     |       0v |      |   | 25 || 26 | 0 | ALT3 | GPIO.11  | 11  | 21  |
 |  19 |  30 |    SDA.1 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.1    | 31  | 18  |
 |   7 |  21 |  GPIO.21 | ALT3 | 0 | 29 || 30 |   |      | 0v       |     |     |
 |   8 |  22 |  GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | RTS1     | 26  | 200 |
 |   9 |  23 |  GPIO.23 | ALT3 | 0 | 33 || 34 |   |      | 0v       |     |     |
 |  10 |  24 |  GPIO.24 |  OUT | 0 | 35 || 36 | 0 | ALT3 | CTS1     | 27  | 201 |
 |  20 |  25 |  GPIO.25 |  OUT | 1 | 37 || 38 | 0 | ALT5 | TxD1     | 28  | 198 |
 |     |     |       0v |      |   | 39 || 40 | 0 | ALT5 | RxD1     | 29  | 199 |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+

C언어 샘플 소스

#include <wiringPi.h>
  
int main()
{
  wiringPiSetup();
  pinMode(7, OUTPUT);
  while(1) {
    digitalWrite(7,HIGH);
    delay(500);
    digitalWrite(7,LOW);
    delay(500);
  }
  return 0;
}

컴파일

$ gcc -Wall -o blink blink.c -lwiringPi -lpthread

실행

$ sudo ./blink

java 샘플 소스

/*
 * #%L
 * **********************************************************************
 * ORGANIZATION  :  Pi4J
 * PROJECT       :  Pi4J :: Java Examples
 * FILENAME      :  ControlGpioExample.java
 *
 * This file is part of the Pi4J project. More information about
 * this project can be found here:  http://www.pi4j.com/
 * **********************************************************************
 * %%
 * Copyright (C) 2012 - 2016 Pi4J
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 *
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
 * #L%
 */
 
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.OrangePiZeroGpioProvider;
import com.pi4j.io.gpio.OrangePiZeroPin;
import com.pi4j.io.gpio.PinState;
 
/**
 * This example code demonstrates how to perform simple state
 * control of a GPIO pin on the Raspberry Pi.
 *
 * @author Robert Savage
 */
public class ControlGpioExample {
 
    public static void main(String[] args) throws InterruptedException {

        //GpioFactory.setDefaultProvider(new OrangePiPc2GpioProvider());
        //GpioFactory.setDefaultProvider(new NanoPiNEOAirGpioProvider());
    	GpioFactory.setDefaultProvider(new OrangePiZeroGpioProvider());

        System.out.println("<--Pi4J--> GPIO Control Example ... started.");
 
        // create gpio controller
        final GpioController gpio = GpioFactory.getInstance();
 
        // provision gpio pin #01 as an output pin and turn on
        final GpioPinDigitalOutput pin = gpio.provisionDigitalOutputPin(OrangePiZeroPin.GPIO_07, "MyLED", PinState.HIGH);
 
        // set shutdown state for this pin
        pin.setShutdownOptions(true, PinState.LOW);
 
        System.out.println("--> GPIO state should be: ON");
 
        Thread.sleep(5000);
 
        // turn off gpio pin #01
        pin.low();
        System.out.println("--> GPIO state should be: OFF");
 
        Thread.sleep(5000);
 
        // toggle the current state of gpio pin #01 (should turn on)
        pin.toggle();
        System.out.println("--> GPIO state should be: ON");
 
        Thread.sleep(5000);
 
        // toggle the current state of gpio pin #01  (should turn off)
        pin.toggle();
        System.out.println("--> GPIO state should be: OFF");
 
        Thread.sleep(5000);
 
        // turn on gpio pin #01 for 1 second and then off
        System.out.println("--> GPIO state should be: ON for only 1 second");
        pin.pulse(1000, true); // set second argument to 'true' use a blocking call
 
        // stop all GPIO activity/threads by shutting down the GPIO controller
        // (this method will forcefully shutdown all GPIO monitoring threads and scheduled tasks)
        gpio.shutdown();
 
        System.out.println("Exiting ControlGpioExample");
    }
}

실행

$ sudo java -cp .:pi4j-core.jar:pi4j-gpio-extension.jar ControlGpioExample

실행결과

Orange PI Zero

OS/Orange PI 2017.03.25 02:01 Posted by 파란크리스마스

Orange PI Zero

출처 : 스터디메이크 :: 오렌지파이 제로 보드 간단 사용기
Xunlong Orange Pi Zero

OS 설치

OS 다운로드 - Orange Pi Zero – armbian

vi 설치

$ sudo apt-get install vim

armbian 와이파이 설정

출처 : 오렌지파이 제로 무선인터넷 설정 1.2 암비안 와이파이 설정

$ sudo nmtui

SD 확장

SD 확장전 용량확인

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.6G  1.2G  349M  78% /
devtmpfs        168M     0  168M   0% /dev
tmpfs           224M     0  224M   0% /dev/shm
tmpfs           224M  8.5M  216M   4% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           224M     0  224M   0% /sys/fs/cgroup
tmpfs           224M  4.0K  224M   1% /tmp
/dev/mmcblk0p1   63M  4.6M   59M   8% /media/boot
tmpfs            45M     0   45M   0% /run/user/107
tmpfs            45M     0   45M   0% /run/user/1000

SD FDisk

orangepi@OrangePizero:~$ sudo fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000b04ea

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1       40960  172031  131072   64M  b W95 FAT32
/dev/mmcblk0p2      172032 3514367 3342336  1.6G 83 Linux


Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-15523839, default 2048): 172032
Last sector, +sectors or +size{K,M,G,T,P} (172032-15523839, default 15523839): 

Created a new partition 2 of type 'Linux' and of size 7.3 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

orangepi@OrangePizero:~$ sudo shutdown -r now

SD 확장

$ sudo resize2fs /dev/mmcblk0p2
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p2 is now 1918976 (4k) blocks long.

SD 확장 확인

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       7.3G  1.2G  5.8G  17% /
devtmpfs        168M     0  168M   0% /dev
tmpfs           224M     0  224M   0% /dev/shm
tmpfs           224M  8.5M  216M   4% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           224M     0  224M   0% /sys/fs/cgroup
tmpfs           224M  4.0K  224M   1% /tmp
/dev/mmcblk0p1   63M  4.6M   59M   8% /media/boot
tmpfs            45M     0   45M   0% /run/user/107
tmpfs            45M     0   45M   0% /run/user/1000

vnc 설치

출처 : Armbian: Access the Remote Desktop of Orange Pi with VNC

vnc 설치

$ sudo apt-get update && apt-get upgrade
$ sudo apt-get install tightvncserver

vnc 사용자 추가

$ su - 
# adduser vnc
Adding user `vnc' ...
Adding new group `vnc' (1001) ...
Adding new user `vnc' (1001) with group `vnc' ...
Creating home directory `/home/vnc' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for vnc
Enter the new value, or press ENTER for the default
        Full Name []: VNCuser
        Room Number []: 
        Work Phone []: 
        Home Phone []: 
        Other []: 
Is the information correct? [Y/n] 

vnc 사용자 추가

# gpasswd -a vnc sudo
Adding user vnc to group sudo

vnc 서버 실행

# su - vnc
$ vncserver :1
 
You will require a password to access your desktops.
 
Password: 
Verify:   
Would you like to enter a view-only password (y/n)? 
*** buffer overflow detected ***: vncpasswd terminated
xauth:  file /home/vnc/.Xauthority does not exist
 
New 'X' desktop is OrangePizero:1
 
Creating default startup script /home/vnc/.vnc/xstartup
Starting applications specified in /home/vnc/.vnc/xstartup
Log file is /home/vnc/.vnc/OrangePizero:1.log

JDK 설치

$ sudo apt install -t jessie-backports openjdk-8-jre openjdk-8-jre-headless openjdk-8-jdk openjdk-8-jdk-headless ca-certificates-java

JAVA_HOME 환경변수 추가

$ sudo vi /etc/profile

내용 추가 export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-armhf

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-armhf

Orange PI PC2 GPIO 설치, pi4j

OS/Orange PI 2017.03.17 01:53 Posted by 파란크리스마스

Orange PI PC2 GPIO 설치

출처 : This is a modified WiringPi for OrangePi. We call it WiringOP. Test fo Orangepi pc
OrangePi-PCを使ってみる WiringPiとWiringOP
Orange PI PC 2 GPIO доступ через sysfs

현재 pi4j는 Orange PI PC2 지원하지 않아 수정한 jar를 배포합니다.

pi4j-core.jar

$ git clone https://github.com/kazukioishi/WiringOP.git -b h5
$ cd WiringOP
$ chmod +x ./build
$ sudo ./build
$ gpio -v
gpio version: 2.20
Copyright (c) 2012-2014 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
 
Banana Pro Details:
  Type: Banana Pro, Revision: 1.2, Memory: 1024MB, Maker: LeMaker 
$ gpio readall
 +-----+-----+----------+------+---+-Orange Pi+---+---+------+---------+-----+--+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
 |  12 |   8 |    SDA.0 | ALT5 | 0 |  3 || 4  |   |      | 5V       |     |     |
 |  11 |   9 |    SCL.0 | ALT5 | 0 |  5 || 6  |   |      | 0v       |     |     |
 |   6 |   7 |   GPIO.7 | ALT3 | 0 |  7 || 8  | 0 | ALT5 | TxD3     | 15  | 13  |
 |     |     |       0v |      |   |  9 || 10 | 0 | ALT5 | RxD3     | 16  | 14  |
 |   1 |   0 |     RxD2 | ALT5 | 0 | 11 || 12 | 0 | ALT3 | GPIO.1   | 1   | 110 |
 |   0 |   2 |     TxD2 | ALT5 | 0 | 13 || 14 |   |      | 0v       |     |     |
 |   3 |   3 |     CTS2 | ALT5 | 0 | 15 || 16 | 0 | ALT3 | GPIO.4   | 4   | 68  |
 |     |     |     3.3v |      |   | 17 || 18 | 0 | ALT3 | GPIO.5   | 5   | 71  |
 |  64 |  12 |     MOSI | ALT4 | 0 | 19 || 20 |   |      | 0v       |     |     |
 |  65 |  13 |     MISO | ALT0 | 0 | 21 || 22 | 0 | ALT5 | RTS2     | 6   | 2   |
 |  66 |  14 |     SCLK | ALT4 | 0 | 23 || 24 | 0 | ALT4 | CE0      | 10  | 67  |
 |     |     |       0v |      |   | 25 || 26 | 0 | ALT3 | GPIO.11  | 11  | 21  |
 |  19 |  30 |    SDA.1 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.1    | 31  | 18  |
 |   7 |  21 |  GPIO.21 | ALT3 | 0 | 29 || 30 |   |      | 0v       |     |     |
 |   8 |  22 |  GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT5 | RTS1     | 26  | 200 |
 |   9 |  23 |  GPIO.23 | ALT3 | 0 | 33 || 34 |   |      | 0v       |     |     |
 |  10 |  24 |  GPIO.24 | ALT3 | 0 | 35 || 36 | 0 | ALT5 | CTS1     | 27  | 201 |
 |  20 |  25 |  GPIO.25 |  OUT | 1 | 37 || 38 | 0 | ALT5 | TxD1     | 28  | 198 |
 |     |     |       0v |      |   | 39 || 40 | 0 | ALT5 | RxD1     | 29  | 199 |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+

C언어 샘플 소스

#include <wiringpi.h>
 
int main()
{
  wiringPiSetup();
  pinMode(7, OUTPUT);
  while(1) {
    digitalWrite(7,HIGH); 
    delay(500);
    digitalWrite(7,LOW); 
    delay(500);
  }
  return 0;
}

컴파일

$ gcc -Wall -o blink blink.c -lwiringPi -lpthread

실행

$ sudo ./blink
wiringPi: wiringPiSetup called
piboardRev: Hardware string: Hardware   : sun50iw2
Hardware:Hardware       : sun50iw2
piboardRevH3:  3
piboardRev: Hardware string: Hardware   : sun50iw2
Hardware:Hardware       : sun50iw2
piboardRevH3:  3
piboardRev: Hardware string: Hardware   : sun50iw2
Hardware:Hardware       : sun50iw2
piboardId: Revision string: 0000
pinMode,1947,pin:7,mode:1
func:sunxi_set_gpio_mode pin:6, MODE:1 bank:0 index:6 phyaddr:0x1c20800
read reg val: 0x71222222 offset:24
Out mode ready set val: 0x71222222
Out mode set over reg val: 0x71222222
digitalWrite,2270
func:sunxi_digitalWrite pin:6, value:1 bank:0 index:6 phyaddr:0x1c20810
befor write reg val: 0x100040,index:6
HIGH val set over reg val: 0x100040
digitalWrite,2270
func:sunxi_digitalWrite pin:6, value:0 bank:0 index:6 phyaddr:0x1c20810
befor write reg val: 0x100040,index:6
LOW val set over reg val: 0x100000
digitalWrite,2270
func:sunxi_digitalWrite pin:6, value:1 bank:0 index:6 phyaddr:0x1c20810
befor write reg val: 0x100000,index:6
HIGH val set over reg val: 0x100040
digitalWrite,2270
func:sunxi_digitalWrite pin:6, value:0 bank:0 index:6 phyaddr:0x1c20810
befor write reg val: 0x100040,index:6
LOW val set over reg val: 0x100000
digitalWrite,2270
func:sunxi_digitalWrite pin:6, value:1 bank:0 index:6 phyaddr:0x1c20810
befor write reg val: 0x100000,index:6
HIGH val set over reg val: 0x100040

java 샘플 소스

import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.OrangePiPc2GpioProvider;
import com.pi4j.wiringpi.Gpio;

public class Blink {

	public static void main(String[] args) throws InterruptedException {
		
		GpioFactory.setDefaultProvider(new OrangePiPc2GpioProvider());

		// setup wiring pi
		if (Gpio.wiringPiSetup() == -1) {
			System.out.println(" ==>> GPIO SETUP FAILED");
			return;
		}

		Gpio.pinMode(7, Gpio.OUTPUT);
		while (true) {
			Gpio.digitalWrite(7, Gpio.HIGH);
			Gpio.delay(500);
			Gpio.digitalWrite(7, Gpio.LOW);
			Gpio.delay(500);
		}
	}
}

실행

$ sudo java -cp .:pi4j-core.jar:pi4j-gpio-extension.jar Blink

실행결과

Orange PI PC2 mjpg-streamer

OS/Orange PI 2017.03.14 23:14 Posted by 파란크리스마스

Orange PI PC2 mjpg-streamer

출처 : 【BPI-M2+】之mjpg-streamer测试和体验- Bananap讨论区- 烽火社区 ...
MJPG-Streamer › Wiki › ubuntuusers.de
라즈베리파이에서 웹캠 mjpg-streamer 따라하기|작성자 서리
mjpg-streamer 웹캠 영상 스트리밍 | Mungrrr

관련 라이브러리 설치

$ sudo apt-get install libjpeg8-dev libv4l-dev subversion
$ sudo apt-get install imagemagick

mjpg-streamer 컴파일 및 설치

출처 : http://www.lavrsen.dk/svn/motion/tags/3.2.9/picture.c

$ svn co https://svn.code.sf.net/p/mjpg-streamer/code/mjpg-streamer mjpg-streamer
$ cd mjpg-streamer
$ make USE_LIBV4L2=true clean all
$ sudo make install
install --mode=755 mjpg_streamer /usr/local/bin
install --mode=644 input_ov5640.so input_gc2035.so input_uvc.so output_file.so output_udp.so output_http.so input_testpicture.so input_file.so /usr/local/lib/
install --mode=755 -d /usr/local/www
install --mode=644 -D www/* /usr/local/www

input_gc2035.so

input_gc2035.tar.gz

mjpg-streamer의 input_uvc.so는 YUV만 지원하고, Orange PI PC2의 카메라인 GC2035는 YUV420코덱만 지원하기 때문에, mjpg-streamer에서 사용 할 수 없습니다.

제가 작업한 GC2035의 YUV420코덱을 지원하는 so 파일을 공개 합니다.
Orange PI PC2의 카메라인 GC2035를 사용해서 mjpg-streamer로 스트리밍 하시려면 첨부한 파일을 사용하세요.

LD_LIBRARY_PATH 경로 추가

$ echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/mjpg-streamer" | sudo tee -a /etc/profile

mjpg-streamer 실행

$ ./mjpg_streamer -i "./input_gc2035.so -y -n" -o "./output_http.so -w ./www"
MJPG Streamer Version: svn rev: 3:172M
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 5
 i: Format............: YUV420
 i: JPEG Quality......: 80
 o: www-folder-path...: ./www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled

서비스등록

$ sudo vi /etc/init.d/mjpg_streamer

mjpg_streamer 파일 내용

#! /bin/bash
# /etc/init.d/mjpg_streamer.sh
# v0.2 phillips321.co.uk
### BEGIN INIT INFO
# Provides:         mjpg_streamer.sh
# Required-Start:    $network
# Required-Stop:     $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: mjpg_streamer for webcam
# Description:       Streams /dev/video0 to http://IP/?action=stream
### END INIT INFO

#
export width=640
export height=480
export fps=24
export SHUTDOWN_WAIT=2
export QUALITY=75

if [ -n "$2" ]; then
  width=$2 
fi

if [ -n "$3" ]; then
  height=$3
fi

if [ -n "$4" ]; then
  fps=$4
fi

export LD_MJPG_STREAMER=/usr/local/lib

f_message(){
        echo "[+] $1"
}

mjpg_streamer_pid() {
  echo `ps aux | grep input_gc2035 | grep -v grep | awk '{ print $2 }'`
}

start() {
  pid=$(mjpg_streamer_pid)
  if [ -n "$pid" ] 
  then
    echo "mjpg_streamer is already running (pid: $pid)"
  else
    # Start mjpg_streamer
                f_message "Starting mjpg_streamer"
                mjpg_streamer -b -i "$LD_MJPG_STREAMER/input_gc2035.so -r "$width"x"$height" -f $fps -q $QUALITY -y" -o "$LD_MJPG_STREAMER/output_http.so -p 8080 -w /usr/local/www"
                sleep 2
                f_message "mjpg_streamer started"
  fi

  return 0
}

stop() {
  pid=$(mjpg_streamer_pid)
  if [ -n "$pid" ]
  then
    f_message "Stopping mjpg_streamer... (pid: $pid)"
    kill -9 $pid

    let kwait=$SHUTDOWN_WAIT
    let count=0;
    until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]
    do
      echo -n -e "\nwaiting for processes to exit\n";
      sleep 1
      let count=$count+1;
    done

    if [ $count -gt $kwait ]; then
      echo -n -e "\nkilling processes which didn't stop after $SHUTDOWN_WAIT seconds\n"
      kill -9 $pid
    fi
  else
    echo "mjpg_streamer is not running"
  fi
 
  return 0
}

# Carry out specific functions when asked to by the system
case "$1" in
        start)
                 start
                 ;;
        stop)
                 stop
                 ;;
        restart)
                 stop
                 sleep 2
                 start
                 ;;
        resolution)
                resolution=`ps axu | grep input_gc2035 | grep -v grep | awk '{ print $16 }'`
                currfps=`ps axu | grep input_gc2035 | grep -v grep | awk '{ print $18 }'`
                if [ -n "$resolution" ];
                then
                        echo "${resolution}"x"$currfps"
                else
                        echo "0x0x0"
                fi
                ;;
        status)
                pid=`ps -A | grep mjpg_streamer | grep -v "grep" | grep -v mjpg_streamer. | awk '{print $1}' | head -n 1`
                if [ -n "$pid" ];
                then
                        f_message "mjpg_streamer is running with pid ${pid}"
                        f_message "mjpg_streamer was started with the following command line"
                        cat /proc/${pid}/cmdline ; echo ""
                else
                        f_message "Could not find mjpg_streamer running"
                fi
                ;;
        *)
                f_message "Usage: $0 {start|stop|status|restart}"
                exit 1
                ;;
esac
exit 0

등록

$ sudo chmod u+x /etc/init.d/mjpg_streamer
$ sudo update-rc.d mjpg_streamer defaults

서비스 실행 및 실행 확인

$ sudo service mjpg_streamer start
$ sudo service mjpg_streamer status
● mjpg_streamer.service - LSB: mjpg_streamer for webcam
   Loaded: loaded (/etc/init.d/mjpg_streamer; bad; vendor preset: enabled)
   Active: active (running) since Wed 2017-03-15 05:05:09 UTC; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 8045 ExecStop=/etc/init.d/mjpg_streamer stop (code=exited, status=0/SUCCESS)
  Process: 8113 ExecStart=/etc/init.d/mjpg_streamer start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/mjpg_streamer.service
           └─8122 mjpg_streamer -b -i /usr/local/lib/input_gc2035.so -r 640x480 -f 24 -q 75 -y -o /usr/local/lib/output_htt
 
Mar 15 05:05:07 Orangepi mjpg_streamer[8122]: MJPG-streamer [8122]: Format............: YUV420
Mar 15 05:05:07 Orangepi mjpg_streamer[8122]: MJPG-streamer [8122]: JPEG Quality......: 75
Mar 15 05:05:08 Orangepi mjpg_streamer[8122]: MJPG-streamer [8122]: www-folder-path...: /usr/local/www/
Mar 15 05:05:08 Orangepi mjpg_streamer[8122]: MJPG-streamer [8122]: HTTP TCP port.....: 8080
Mar 15 05:05:08 Orangepi mjpg_streamer[8122]: MJPG-streamer [8122]: username:password.: disabled
Mar 15 05:05:08 Orangepi mjpg_streamer[8122]: MJPG-streamer [8122]: commands..........: enabled
Mar 15 05:05:08 Orangepi mjpg_streamer[8122]: MJPG-streamer [8122]: starting input plugin /usr/local/lib/input_gc2035.so
Mar 15 05:05:08 Orangepi mjpg_streamer[8122]: MJPG-streamer [8122]: starting output plugin: /usr/local/lib/output_http.so (
Mar 15 05:05:09 Orangepi mjpg_streamer[8113]: [+] mjpg_streamer started
Mar 15 05:05:09 Orangepi systemd[1]: Started LSB: mjpg_streamer for webcam.

실행


Orange PI PC2 Camera(GC2035), motion

OS/Orange PI 2017.03.14 22:43 Posted by 파란크리스마스

Orange PI PC2 Camera(GC2035), motion

출처 : How to Use Orange Pi Camera in Linux (with Motion)

Camera 모듈 설치

$ sudo vi /etc/modules

내용 추가

gc2035
vfe_v4l2

Camera 설치 확인

$ dmesg | grep gc2035
[   11.157004] [VFE]Find sensor name is "gc2035", i2c address is 78, type is "YUV" !
[   11.157006] [VFE]Sub device register "gc2035" i2c_addr = 0x78 start!
[   11.701914] [VFE]Sub device register "gc2035" is OK!
$ ls /dev/video*
/dev/video0

Camera 정보

$ modinfo gc2035
filename:       /lib/modules/3.10.65/kernel/drivers/media/platform/sunxi-vfe/device/gc2035.ko
license:        GPL
description:    A low-level driver for GalaxyCore gc2035 sensors
author:         raymonxiu
srcversion:     3B1ED5B0A55C98A6E316274
alias:          i2c:gc2035
depends:        vfe_io
intree:         Y
vermagic:       3.10.65 SMP preempt mod_unload modversions aarch64

motion

출처 : How to Use Orange Pi Camera in Linux (with Motion)

$ sudo apt-get install motion
$ sudo motion
[4743584] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf
[4743584] [NTC] [ALL] motion_startup: Motion 3.2.12+git20140228 Started with SDL support
[4743584] [NTC] [ALL] motion_startup: Logging to file (/var/log/motion/motion.log)

motion deamon 실행 수정

$ sudo vi /etc/default/motion

내용 수정

# set to 'yes' to enable the motion daemon
start_motion_daemon=no

Orange Pi PC 2

OS/Orange PI 2017.02.17 22:28 Posted by 파란크리스마스

Orange pi 업그레이드

$ sudo apt-get update && apt-get upgrade
$ sudo shutdown -r now

SD 용량 확인(확장전)

$ df -l
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/mmcblk0p2   3536592 3448920         0 100% /
devtmpfs          492596       0    492596   0% /dev
tmpfs             501596       4    501592   1% /dev/shm
tmpfs             501596   13540    488056   3% /run
tmpfs               5120       4      5116   1% /run/lock
tmpfs             501596       0    501596   0% /sys/fs/cgroup
/dev/mmcblk0p1     51082   13062     38020  26% /boot
tmpfs             100320       4    100316   1% /run/user/0
tmpfs             100320       0    100320   0% /run/user/1002

파티션 늘리기

출처 : Orange PI resize SD-card root partition on Debian
Partitioning with fdisk

root@Orangepi:~# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000ebed2

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       40960   143359   102400   50M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      143360 31116287 30972928 14.8G 83 Linux

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-31116287, default 2048): 143360
Last sector, +sectors or +size{K,M,G,T,P} (143360-31116287, default 31116287): 

Created a new partition 2 of type 'Linux' and of size 14.8 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

d - to delete partition
2 - second partition
n - create partition
p - primary partition type
2 - partition number
143360 - Same start as current 2th partition
enter - Default is last block
w - write partition table

리눅스 용량 확장

# resize2fs /dev/mmcblk0p2
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p2 is now 3871616 (4k) blocks long.

리눅스 용량 확인

# df -l
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/mmcblk0p2  15213236 3434452  11137696  24% /
devtmpfs          492596       0    492596   0% /dev
tmpfs             501596       0    501596   0% /dev/shm
tmpfs             501596    7092    494504   2% /run
tmpfs               5120       4      5116   1% /run/lock
tmpfs             501596       0    501596   0% /sys/fs/cgroup
/dev/mmcblk0p1     51082   13062     38020  26% /boot
tmpfs             100320       0    100320   0% /run/user/1002.

Using SSH

출처 : Login to the Orange Pi

사용자추가

$ sudo groupadd pi        
$ sudo useradd -g pi pi -m -s /bin/bash
$ sudo passwd pi   
Enter new UNIX password: [raspberry]
Retype new UNIX password: [raspberry] 
passwd: password updated successfully

sudo 권한 부여

# vi /etc/sudoers

내용 추가

pi      ALL=(ALL:ALL) ALL

Orange pi 정보 조회

# uname -a        
Linux Orangepi 3.10.65 #55 SMP PREEMPT Fri Nov 18 16:17:28 CST 2016 aarch64 aarch64 aarch64 GNU/Linux
# nmcli device
DEVICE   TYPE      STATE      CONNECTION 
eth0     ethernet  unmanaged  --         
gretap0  gretap    unmanaged  --         
ifb0     ifb       unmanaged  --         
ifb1     ifb       unmanaged  --         
gre0     iptunnel  unmanaged  --         
sit0     iptunnel  unmanaged  --         
tunl0    iptunnel  unmanaged  --         
lo       loopback  unmanaged  --         




이하 작성중...





USB Wifi

출처 : OrangePi PC 2上使用USB WIFI

$ git clone https://github.com/orangepi-xunlong/OrangePi_H5SDK.git
$ cd OrangePi_H5SDK
$ cp kernel/arch/arm64/configs/OrangePiH5_PC2_linux_defconfig kernel/.config

내용추가

# CONFIG_MAC80211 is not set
CONFIG_MAC80211=y
CONFIG_RTLWIFI=m
CONFIG_RTL8192CU=m

빌드

$ sudo ./build.sh

Orange pi 업그레이드

pi@Orangepi:~$ cd /usr/src/
pi@Orangepi:/usr/src$ sudo git clone https://github.com/jwrdegoede/rtl8189ES_linux/
[sudo] password for pi: 
Cloning into 'rtl8189ES_linux'...
remote: Counting objects: 818, done.
remote: Total 818 (delta 0), reused 0 (delta 0), pack-reused 818
Receiving objects: 100% (818/818), 2.75 MiB | 780.00 KiB/s, done.
Resolving deltas: 100% (437/437), done.
Checking connectivity... done.
pi@Orangepi:/usr/src$ cd rtl8189ES_linux
pi@Orangepi:/usr/src/rtl8189ES_linux$ git checkout 080f2aaf6bc8e08eeb3b51f0b8c377eae1ea7ed7
fatal: Unable to create '/usr/src/rtl8189ES_linux/.git/index.lock': Permission denied
pi@Orangepi:/usr/src/rtl8189ES_linux$

Orange pi - Wifi 드라이버 설치

출처 : How to properly compile device drivers for OrangePi?
Armbian missibg headers
pvaret/rtl8192cu-fixes
Orange PI PC Wireless Module (8192cu)
apt-get --reinstall install linux-headers-`uname -r` fails


$ cd /usr/src
$ sudo git clone https://github.com/pvaret/rtl8192cu-fixes
$ sudo make ARCH=armv7l CROSS_COMPILE= -C /lib/modules/3.10.65/build M=/usr/src/rtl8192cu-fixes modules
make: *** /lib/modules/3.10.65/build: No such file or directory.  Stop.


$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo apt-get install gcc build-essential
$ sudo apt-get install subversion
$ cd /usr/src
$ sudo svn checkout https://github.com/loboris/OrangePI-Kernel.git/trunk/linux-3.4
$ zcat /proc/config.gz > .config
$ make oldconfig





$ sudo apt-get install git linux-headers-generic build-essential dkms


Orange pi - Wifi 드라이버 설치

출처 : Install rtl8188etv/rtl8188eu driver on Orange-Pi
rebuild rtl8189es from GIT for OPI+
loboris/OrangePI-Kernel

$ sudo mkdir /usr/src/linux-kernel-$(uname -r)
$ cd /usr/src/linux-kernel-$(uname -r)
$ sudo git clone https://github.com/silentcreek/bananapi-kernel --depth 1


-

-

Armbian

출처 : Orange Pi – armbian

# apt-get update
# apt-get upgrade
# source /etc/armbian-release
# dpkg -r linux-u-boot-bananapi-${BRANCH} linux-$(lsb_release -cs)-root-${BRANCH}-bananapi
# apt-get -y install linux-u-boot-orangepi-${BRANCH} linux-$(lsb_release -cs)-root-${BRANCH}-orangepi
# ln -fs bin/orangepi.bin /boot/script.bin
# echo orangepi > /etc/hostname
# reboot

Kernel – armbian

출처 : Kernel – armbian

# echo "deb http://apt.armbian.com $(lsb_release -cs) main utils $(lsb_release -cs)-desktop" > /etc/apt/sources.list.d/armbian.list
# apt-key adv --keyserver keys.gnupg.net --recv-keys 0x93D6889F9F0E78D5
# apt-get update

Armbian build tools (igorpecovnik/lib)

출처 : Armbian build tools (igorpecovnik/lib)
Docs » Developer Guide » Building Armbian
Orange Pi PC - Armbian build

# apt-get -y install git
# git clone https://github.com/igorpecovnik/lib --depth 1
# cp lib/compile.sh .
# ./compile.sh


Orange Pi One Board Quick Start Guide with Armbian Debian based Linux Distribution


Orange Pi Camera

출처 : How to Use Orange Pi Camera in Linux (with Motion)

$ lsmod
Module                  Size  Used by
sunxi_ir_rx             8607  0
sunxi_keyboard          6962  0
ss                     34925  0
vfe_v4l2              779470  0
gc2035                 19147  0
vfe_io                 39108  2 vfe_v4l2,gc2035
videobuf2_dma_contig     9982  1 vfe_v4l2
videobuf2_memops        2691  1 videobuf2_dma_contig
videobuf2_core         31877  1 vfe_v4l2

$ dmesg
[   11.016560] [VFE]cci probe end cci_sel = 0!
[   11.022389] systemd[1]: Mounted Debug File System.
[   11.027676] [VFE]cci_init end
[   11.057297] systemd[1]: Started Remount Root and Kernel File Systems.
[   11.116467] systemd[1]: Started Create list of required static device nodes for the current kernel.
[   11.153733] systemd[1]: Started Nameserver information manager.
[   11.211515] systemd[1]: Reached target Network (Pre).
[   11.242083] systemd[1]: Starting Create Static Device Nodes in /dev...
[   11.283933] [VFE]Welcome to Video Front End driver
[   11.289701] [VFE]csi0 probe end!
[   11.293761] [VFE]csi_init end
[   11.297958] [ISP] isp platform_id = 3!
[   11.301463] systemd[1]: Starting udev Coldplug all Devices...
[   11.308437] [VFE]isp0 probe end!
[   11.312839] [VFE]sunxi_isp_platform_register end
[   11.322221] [VFE]mipi_init end
[   11.327704] [VFE]flash_init end
[   11.333422] [VFE]pdev->id = 0
[   11.336709] [VFE]dev->cci_sel = 0
[   11.343181] systemd[1]: Starting Load/Save Random Seed...
[   11.349636] [VFE]dev->csi_sel = 0
[   11.355996] [VFE]dev->mipi_sel = 0
[   11.360828] [VFE]dev->isp_sel = 0
[   11.364549] [VFE_WARN]fetch csi0_dev0_twi_id from device_tree failed
[   11.371634] [VFE_WARN]fetch csi0_dev0_iovdd from device_tree failed
[   11.378606] [VFE_WARN]fetch csi0_dev0_avdd from device_tree failed
[   11.379874] systemd[1]: Started Set console keymap.
[   11.391171] [VFE_WARN]fetch csi0_dev0_dvdd from device_tree failed
[   11.399505] [VFE_WARN]fetch csi0_dev0_afvdd from device_tree failed
[   11.409014] [VFE_WARN]fetch csi0_dev0_flash_en from device_tree failed
[   11.417687] systemd[1]: Started Load/Save Random Seed.
[   11.423755] [VFE_WARN]fetch csi0_dev0_flash_mode from device_tree failed
[   11.432635] [VFE_WARN]fetch csi0_dev0_flvdd from device_tree failed
[   11.442193] [VFE_WARN]fetch csi0_dev0_flvdd_vol from device_tree failed
[   11.449587] [VFE_WARN]fetch csi0_dev0_af_pwdn from device_tree failed
[   11.457381] [VFE]vfe_init end
[   11.465440] [VFE]probe_work_handle start!
[   11.469683] systemd[1]: Started Load Kernel Modules.
[   11.478053] [VFE]vfe_runtime_resume
[   11.494262] [VFE]..........................vfe clk open!.......................
[   11.502562] [VFE]v4l2 subdev register input_num = 0
[   11.508032] [VFE]vfe sensor detect start! input_num = 0
[   11.509449] systemd[1]: Started Create Static Device Nodes in /dev.
[   11.520743] [VFE]Find sensor name is "gc2035", i2c address is 78, type is "YUV" !
[   11.528982] [VFE]Sub device register "gc2035" i2c_addr = 0x78 start!
[   11.536002] [VFE]v4l2_device_register_subdev return 0
[   11.541547] [VFE]registered sensor subdev is OK!
[   11.548166] [VFE]Check sensor!
[   11.566077] [VFE]mclk on
[   11.575928] systemd[1]: Started Journal Service.
[   11.623105] [VFE CCI_0 ERR] Status error at addr_8bit = 78, wr_flag = 1, val = 3efa1cf0
[   11.632196] [VFE CCI_0 ERR] Status error at addr_8bit = 78, wr_flag = 1, val = 3efa00f0
[   11.642227] [VFE CCI_0 ERR] Status error at addr_8bit = 78, wr_flag = 1, val = 3efa00f0
[   11.653632] gc2035 sensor read retry=2
[   11.659085] [CSI_ERR][GC2035]sensor_read err at sensor_detect!
[   11.665513] [CSI_ERR][GC2035]chip found is not an target chip.
[   11.713421] [VFE]mclk off
[   11.740054] [VFE]vfe sensor subdev unregister!
[   11.745042] [VFE]Sub device register "gc2035" failed!
[   11.750592] [VFE_ERR]vfe sensor register check error at input_num = 0
[   11.757685] [VFE]V4L2 device registered as (null)
[   11.762915] [VFE]vfe_runtime_suspend
[   11.766841] [VFE]..........................vfe clk close!.......................
[   11.772987] [VFE]probe_work_handle end!




 

티스토리 툴바