BPI-Bit : Arduino 개발환경 구축하기

OS/Banana Pi /BPI-Bit 2018.09.21 21:12 Posted by 파란크리스마스

출처

BPI-Bit : Arduino 개발환경 구축하기

BPI-Bit는 몇가지 개발 언어가 있는데 Webduino 말고도 Arduino IDE로 개발할 수 있어서, Arduino IDE 개발환경을 구축하고 간단예제를 실행해보았습니다.

1. Arduino IDE 설치

Arduino IDE (arduino-1.8.7-windows.zip)를 다운로드받고, 설치

2. arduino-esp32 다운로드

Github 저장소(espressif / arduino-esp32)에서 arduino-esp32-master.zip 파일 다운로드

3. arduino-esp32 설치

다운로드 받은 파일 arduino-esp32-master.zip을 [Arduino IDE 설치경로]/hardware/espressif/esp32에 압축 해제

4. get 명령을 관리자 권한으로 실행

[Arduino IDE 설치경로]/hardware/espressif/esp32/tools 디렉토리에서 get 명령을 관리자 권한으로 실행 실행

5. Arduino IDE를 실행하고, 메뉴[툴] > [보드] > [NodeMCU -32S] 선택

예제 작성

//BIT NEW
//BPI - BIT test code
#include <Arduino.h>
#include <NeoPixelBus.h>

#define LEDC_CHANNEL_0 0
#define LEDC_TIMER_13_BIT 13
#define LEDC_BASE_FREQ 4500

const uint16_t PixelCount = 25;
const uint8_t PixelPin = 4;

#define colorSaturation 128
#define delay_ms 500

NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);

RgbColor red(colorSaturation, 0, 0);
RgbColor green(0, colorSaturation, 0);
RgbColor blue(0, 0, colorSaturation);
RgbColor white(colorSaturation);
RgbColor black(0);
RgbColor num1(0.8 * colorSaturation, 0, 0.2 * colorSaturation);
RgbColor num2(0.5 * colorSaturation, 0, 0.5 * colorSaturation);
RgbColor num3(0.25 * colorSaturation, 0, 0.75 * colorSaturation);

HslColor hslRed(red);
HslColor hslGreen(green);
HslColor hslBlue(blue);
HslColor hslWhite(white);
HslColor hslBlack(black);

#define ledPower 2
#define BottomA 35
#define BottomB 27

int brightness = 0;
int fadeAmount = 5;

void ledcAnalogWrite(uint8_t channel, uint32_t value) {
  // calculate duty, 8191 from 2 ^ 13 - 1 (2 ^ LEDC_TIMER_13_BIT - 1)
  //value_MAX = 255
  uint32_t duty = (8191 / 255) * value;
  // write duty to LEDC
  ledcWrite(channel, duty);
}

void setup() {
  Serial.begin(115200); //Serial Port Config 115200-8-N-1
  
  Serial.println();
  Serial.println("Initializing...");
  Serial.flush();
  
  // this resets all the neopixels to an off state
  strip.Begin();
  strip.Show();
  
  pinMode(ledPower,OUTPUT);
  pinMode(BottomA, INPUT);
  pinMode(BottomB, INPUT);
  digitalWrite(ledPower, HIGH);
  
  // strip.SetPixelColor(10, blue);
  // strip.SetPixelColor(11, blue);
  // strip.SetPixelColor(12, blue);
  // strip.SetPixelColor(13, blue);
  // strip.SetPixelColor(14, red);
  // strip.Show();
  
  // delay(1000);
  
  // int i;
  // for (i = 0; i <= PixelCount - 1; i++)
  // {
  //     strip.SetPixelColor(i, black);
  //     strip.Show();
  // }
}

void loop() {
  //signel map
  if (digitalRead(BottomA) == LOW) {
    delay(10);
    if (digitalRead(BottomA) == LOW) {
      strip.SetPixelColor(16, num1);
      strip.SetPixelColor( 7, num2);
      strip.SetPixelColor(18, num3);
      strip.Show();
    } else {
      int i;
      Serial.println("Turn Off");
      for (i = 0; i <= PixelCount - 1; i++) {
        strip.SetPixelColor(i, hslBlack);
        strip.Show();
      }
    }
  }
}

예제 실행

BPI-Bit 소개

OS/Banana Pi /BPI-Bit 2018.07.22 22:12 Posted by 파란크리스마스

출처

BPI-Bit

바나나파이를 만드는 회사에서 BPI-Bit를 출시 했는데, micro:bit 비슷한 개발 보드로,
micro:bit와 비슷한 부분이 많지만, 일부분은 micro:bit보다 개선된 기능이 보입니다.

개선된 기능으로 라디오기능은 빠져 있지만, Wifi가 추가 되어있고, 전면 LED도 RGB LED로 Full Color를 표현할 수 있습니다.

버튼의 간격이 조금 넒어서 micro:bit와 동일한 케이스를 사용할 수 없지만,
GPIO의 핀 배열은 micro:bit 동일하게 배열되어 있어, micro:bit의 확장보드는 동일하게 사용할 수 있을것 같습니다.

개발 언어로 바나나파이에서 만든 WebDuino를 지원하고 있어, AP 모드로 Wifi를 접속해서 공유기를 설정할 수 있고,
JavaScript로 개발된 언어를 내장된 웹서버에 복사해서 웹호출로 실행 해볼 수 있습니다.

Arduino IDE를 지원하고 있어서, Arduino와 동일한 소스를 사용 할 수 있습니다.

 

Interface

이미지 출처 : BPI-Bit - Banana Pi Wiki

Edge interface

BPI-M2+(H2) 운영체제(OS) 설치

OS/Banana Pi /BPI-Bit 2018.07.21 10:24 Posted by 파란크리스마스

출처

OS 이미지 다운로드

2018-05-04-ubuntu-16.04-mate-desktop-v1.1-bpi-m2p-sd-emmc.img.zip

OS 이미지 SD 메모리에 복사

SD 메모리 복사 프로그램인 Etcher를 이용해서 OS 이미지를 복사합니다.

버튼[Select image] 선택하고, 파일 선택 창에서 다운 받은 OS 이미지 선택

OS 이미지를 복사할 SD 메모리 선택하기 위해서 버튼[Select drive] 선택

버튼[Flash!] 선택해서 복사 시작

SD 확장

SD 확장전 용량확인

$ df -l
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/root        6993924 4796496   1842152  73% /
devtmpfs          408148       0    408148   0% /dev
tmpfs             510744     380    510364   1% /dev/shm
tmpfs             510744    7500    503244   2% /run
tmpfs               5120       4      5116   1% /run/lock
tmpfs             510744       0    510744   0% /sys/fs/cgroup
tmpfs             102152      32    102120   1% /run/user/1000
/dev/mmcblk0p1    261868    6648    255220   3% /media/pi/BPI-BOOT

SD FDisk

pi@bpi-iot-ros-ai:~$ 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: 0x8ef6c070

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1      204800   729087   524288  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      729088 14940159 14211072  6.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): 729088    
Last sector, +sectors or +size{K,M,G,T,P} (729088-31116287, default 31116287): 

Created a new partition 2 of type 'Linux' and of size 14.5 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@bpi-iot-ros-ai:~$ sudo shutdown -r now

SD 확장

$ sudo 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 3798400 (4k) blocks long.

SD 확장 확인

$ df -l
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/root       14958272 4577560   9706060  33% /
devtmpfs          408148       0    408148   0% /dev
tmpfs             510744     196    510548   1% /dev/shm
tmpfs             510744    7504    503240   2% /run
tmpfs               5120       4      5116   1% /run/lock
tmpfs             510744       0    510744   0% /sys/fs/cgroup
tmpfs             102152      28    102124   1% /run/user/1000
/dev/mmcblk0p1    261868    6648    255220   3% /media/pi/BPI-BOOT

How to burn Linux image to eMMC

출처 : How to burn Linux image to eMMC
bpi-copy command

이미지 복원

이미지 복원이 완료되면 SD 메모리를 제거하고 재부팅

$ sudo dd if=2018-05-04-ubuntu-16.04-mate-desktop-v1.1-bpi-m2p-sd-emmc.img of=/dev/mmcblk1 bs=10MB
765+1 records in
765+1 records out
7650410496 bytes (7.7 GB, 7.1 GiB) copied, 1054.11 s, 7.3 MB/s

eMMC 용량 확인

pi@bpi-iot-ros-ai:~$ uname -a
Linux bpi-iot-ros-ai 3.4.39-BPI-M2P-Kernel #1 SMP PREEMPT Wed May 2 11:02:30 CST 2018 armv7l armv7l armv7l GNU/Linux
pi@bpi-iot-ros-ai:~$ sudo fdisk -l
Disk /dev/mmcblk0: 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: 0x8ef6c070

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1      204800   729087   524288  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      729088 14940159 14211072  6.8G 83 Linux


Disk /dev/mmcblk0boot1: 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/mmcblk0boot0: 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

BPI-M2 Berry - I2C 이용 PCA9685 제어

OS/Banana Pi /BPI-Bit 2018.01.01 13:31 Posted by 파란크리스마스

출처 : Maker Projects: Banana Pi I2C Devices
BPI-M2,use wiringPi I2C to read mpu6050 - Banana Pi BPI-M2 / Linux - banana pi single board computer official forum SinoVoip BPI team
node.js - johntreacy/adafruit-pca9685
adafruit/Adafruit_Python_PCA9685: Python code to use the PCA9685 PWM servo/LED controller with a Raspberry Pi or BeagleBone black.

BPI-M2 Berry GPIO Pin define

출처 : BPI-M2 Ultra GPIO Pin define · banana pi BPI-M2 Ultra/Berry allwinner R40/V40 SBC

GPIO Pin Name Default Function Function2:GPIO Function3
CON1-P01 VCC-3V3
CON1-P02 DCIN
CON1-P03 TWI2-SDA PB21 PWM5
CON1-P04 DCIN
CON1-P05 TWI2-SCK PB20 PWM4
CON1-P06 GND
CON1-P07 PB3 PB3 PWM1
CON1-P08 UART2-TX PI18 SPI1_MOSI
CON1-P09 GND
CON1-P10 UART2-RX PI19 SPI1_MISO
CON1-P11 UART7-TX PI20 PWM2
CON1-P12 UART2-CTS PI17 SPI1_CLK
CON1-P13 UART7-RX PI21 PWM3
CON1-P14 GND
CON1-P15 PH25 PH25 CSI1-FIELD
CON1-P16 UART2-RTS PI16 SPI1_CS0
CON1-P17 VCC-3V3
CON1-P18 PH26 PH26 CSI1-HSYNC
CON1-P19 SPI0_MOSI PC0
CON1-P20 GND
CON1-P21 SPI0_MISO PC1
CON1-P22 PH27 PH27 CSI1-VSYNC
CON1-P23 SPI0_CLK PC2
CON1-P24 SPI0_CS PC23
CON1-P25 GND
CON1-P26 PH24 PH24 CSI1-PCLK
CON1-P27 TWI3-SDA PI1
CON1-P28 TWI3-SCK PI0
CON1-P29 PH0 PH0 CSI1-D0
CON1-P30 GND
CON1-P31 PH1 PH1 CSI1-D1
CON1-P32 PD20 PD20 CSI1-MCLK
CON1-P33 PH2 PH2 CSI1-D2
CON1-P34 GND
CON1-P35 PH3 PH3 CSI1-D3
CON1-P36 UART5-RX PH7 CSI1-D7
CON1-P37 UART4-TX PH4 CSI1-D4
CON1-P38 UART5-TX PH6 CSI1-D6
CON1-P39 GND
CON1-P40 UART4-RX PH5 CSI1-D5

I2C 목록 조회 - i2cdetect -l

$ i2cdetect -l
i2c-0   i2c             twi0                                    I2C adapter
i2c-1   i2c             twi1                                    I2C adapter
i2c-2   i2c             twi2                                    I2C adapter
i2c-4   i2c             twi4                                    I2C adapter

I2C 주소 확인 - i2cdetect -y

$ i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

gpio readall

 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |  53 |   8 |   SDA.1 | ALT5 | 0 |  3 || 4  |   |      | 5v      |     |     |
func:sunxi_get_pin_mode pin:53,  bank:1 index:21 phyaddr:0x1c2082c
read reg val: 0x22222233 offset:20  return: 0
read reg val: 0x22222233 offset:20  return: 2
func:sunxi_digitalRead pin:53,bank:1 index:21 phyaddr:0x1c20834
***** read reg val: 0x0,bank:1,index:21,line:850
 |  52 |   9 |   SCL.1 | ALT5 | 0 |  5 || 6  |   |      | 0v      |     |     |
func:sunxi_get_pin_mode pin:52,  bank:1 index:20 phyaddr:0x1c2082c
read reg val: 0x22222233 offset:16  return: 0
read reg val: 0x22222233 offset:16  return: 2
func:sunxi_digitalRead pin:52,bank:1 index:20 phyaddr:0x1c20834
***** read reg val: 0x0,bank:1,index:20,line:850
| 257 |  30 |   SDA.0  | ALT3 | 0 | 27
func:sunxi_get_pin_mode pin:257,  bank:8 index:1 phyaddr:0x1c20920
read reg val: 0x77703377 offset:4  return: 0
read reg val: 0x77703377 offset:4  return: 7
func:sunxi_digitalRead pin:257,bank:8 index:1 phyaddr:0x1c20930
***** read reg val: 0x0,bank:8,index:1,line:850
                                       || 28 | 0 | ALT3 | SCL.0   | 31  | 256 |
func:sunxi_digitalRead pin:256,bank:8 index:0 phyaddr:0x1c20930
***** read reg val: 0x0,bank:8,index:0,line:850
func:sunxi_get_pin_mode pin:256,  bank:8 index:0 phyaddr:0x1c20920
read reg val: 0x77703377 offset:0  return: 0
read reg val: 0x77703377 offset:0  return: 7

BPI-M2 Berry - I2C 이용 PCA9685 제어 소스 - PCA9685Gpio.java

import java.io.IOException;
/**
 * $ sudo java -cp .:pi4j/* PCA9685Gpio
 */
import java.math.BigDecimal;

import com.pi4j.gpio.extension.pca.PCA9685GpioProvider;
import com.pi4j.gpio.extension.pca.PCA9685Pin;
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinPwmOutput;
import com.pi4j.io.gpio.BPIM2BerryGpioProvider;
import com.pi4j.io.gpio.Pin;
import com.pi4j.io.i2c.I2CBus;
import com.pi4j.io.i2c.I2CFactory;
import com.pi4j.io.i2c.I2CFactory.UnsupportedBusNumberException;

public class PCA9685Gpio {
	
	public static final int SERVO_DURATION_MIN = 600;
	public static final int SERVO_DURATION_NEUTRAL = 1500;
	public static final int SERVO_DURATION_MAX = 2400;
	
	private static PCA9685Gpio instance = null;
	
	private PCA9685GpioProvider gpioProvider = null;
	
	// sudo java -cp .:pi4j-core.jar:pi4j-gpio-extension.jar PCA9685Gpio
	
	private PCA9685Gpio() throws IOException, UnsupportedBusNumberException {		
		
		//GpioFactory.setDefaultProvider(new BPIM2PGpioProvider());
		//GpioFactory.setDefaultProvider(new NanoPiNEOAirGpioProvider());
		GpioFactory.setDefaultProvider(new BPIM2BerryGpioProvider());
		
		System.out.println("<--Pi4J--> PCA9685 PWM Example ... started.");
		// This would theoretically lead into a resolution of 5 microseconds per
		// step:
		// 4096 Steps (12 Bit)
		// T = 4096 * 0.000005s = 0.02048s
		// f = 1 / T = 48.828125
		BigDecimal frequency = new BigDecimal("48.828");
		// Correction factor: actualFreq / targetFreq
		// e.g. measured actual frequency is: 51.69 Hz
		// Calculate correction factor: 51.65 / 48.828 = 1.0578
		// --> To measure actual frequency set frequency without correction
		// factor(or set to 1)
		BigDecimal frequencyCorrectionFactor = new BigDecimal("1.0578");
		// Create custom PCA9685 GPIO provider
		I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_2);
		gpioProvider = new PCA9685GpioProvider(bus, 0x40, frequency, frequencyCorrectionFactor);
		// Define outputs in use for this example
		GpioPinPwmOutput[] myOutputs = provisionPwmOutputs(gpioProvider);
		// Reset outputs
		gpioProvider.reset();
	}
	
	public static PCA9685Gpio getInstance() throws IOException, UnsupportedBusNumberException {
		if (instance==null) instance = new PCA9685Gpio();
		return instance;
	}
	
	public void setPwm(Pin pin, int duration) {
		gpioProvider.setPwm(pin, duration);
	}
	
	public void shutdown() {
		gpioProvider.shutdown();
	}
	
	private static GpioPinPwmOutput[] provisionPwmOutputs(final PCA9685GpioProvider gpioProvider) {
		GpioController gpio = GpioFactory.getInstance();
		GpioPinPwmOutput myOutputs[] = { 
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_00, "Pulse 00"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_01, "Pulse 01"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_02, "Pulse 02"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_03, "Pulse 03"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_04, "Pulse 04"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_05, "Pulse 05"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_06, "Pulse 06"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_07, "Pulse 07"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_08, "Pulse 08"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_09, "Pulse 09"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_10, "Always ON"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_11, "Always OFF"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_12, "Servo pulse MIN"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_13, "Servo pulse NEUTRAL"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_14, "Servo pulse MAX"),
				gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_15, "not used") };
		return myOutputs;
	}

	public static void main(String[] args) throws Exception {
		
		PCA9685Gpio test = PCA9685Gpio.getInstance();
		
		test.setPwm(PCA9685Pin.PWM_01, SERVO_DURATION_NEUTRAL);
		Thread.sleep(200);
		
		for (int i=SERVO_DURATION_MIN; i<=SERVO_DURATION_MAX; i+=30) {
			test.setPwm(PCA9685Pin.PWM_00, i);
			Thread.sleep(200);
		}
		
		for (int i=SERVO_DURATION_MAX; i>=(int)(SERVO_DURATION_MIN+(SERVO_DURATION_MAX-SERVO_DURATION_MIN)/2); i-=30) {
			test.setPwm(PCA9685Pin.PWM_00, i);
			Thread.sleep(200);
		}
				
		for (int i=SERVO_DURATION_MIN; i<=SERVO_DURATION_MAX; i+=30) {
			test.setPwm(PCA9685Pin.PWM_01, i);
			Thread.sleep(200);
		}
		
		for (int i=SERVO_DURATION_MAX-200; i>=(int)(SERVO_DURATION_MIN+(SERVO_DURATION_MAX-SERVO_DURATION_MIN)/2); i-=30) {
			test.setPwm(PCA9685Pin.PWM_01, i);
			Thread.sleep(200);
		}
		
		test.shutdown();

	}
	
}

컴파일

$ javac -cp .:pi4j/* -d . PCA9685Gpio.java

실행

$ sudo java -cp .:pi4j/* PCA9685Gpio

실행 영상


BPI-M2 ZERO - WiringOP 연동 node.js

OS/Banana Pi /BPI-Bit 2017.12.27 01:23 Posted by 파란크리스마스

출처 : github - bluexmas/node-wiring-bpi-zero

BPI-M2 ZERO에서 node.js용 gpio제어 가능한 패키지가 없어서 직접 제작해보았습니다.

node-wiring-bpi-zero 설치

$ cd ~
$ git clone https://github.com/bluexmas/node-wiring-bpi-zero.git
$ npm install node-wiring-bpi-zero

gpio 확인

$ gpio readall
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |  12 |   8 |   SDA.1 | ALT5 | 0 |  3 || 4  |   |      | 5v      |     |     |
 |  11 |   9 |   SCL.1 | ALT5 | 0 |  5 || 6  |   |      | 0v      |     |     |
 |   6 |   7 | GPIO. 7 | ALT3 | 0 |  7 || 8  | 0 | ALT4 | TxD     | 15  | 13  |
 |     |     |      0v |      |   |  9 || 10 | 0 | ALT4 | RxD     | 16  | 14  |
 |   1 |   0 | GPIO. 0 | ALT5 | 0 | 11 || 12 | 0 | ALT4 | GPIO. 1 | 1   | 16  |
 |   0 |   2 | GPIO. 2 | ALT5 | 0 | 13 || 14 |   |      | 0v      |     |     |
 |   3 |   3 | GPIO. 3 | ALT5 | 0 | 15 || 16 | 0 | ALT4 | GPIO. 4 | 4   | 15  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | ALT3 | GPIO. 5 | 5   | 68  |
 |  64 |  12 |    MOSI | ALT4 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |  65 |  13 |    MISO | ALT4 | 0 | 21 || 22 | 0 | ALT5 | GPIO. 6 | 6   | 2   |
 |  66 |  14 |    SCLK | ALT4 | 0 | 23 || 24 | 0 | ALT4 | CE0     | 10  | 67  |
 |     |     |      0v |      |   | 25 || 26 | 0 | ALT3 | CE1     | 11  | 71  |
 |  19 |  30 |   SDA.0 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.0   | 31  | 18  |
 |   7 |  21 | GPIO.21 | ALT3 | 0 | 29 || 30 |   |      | 0v      |     |     |
 |   8 |  22 | GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | GPIO.26 | 26  | 354 |
 |   9 |  23 | GPIO.23 | ALT3 | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  10 |  24 | GPIO.24 | ALT3 | 0 | 35 || 36 | 0 | ALT3 | GPIO.27 | 27  | 356 |
 |  17 |  25 | GPIO.25 | ALT3 | 0 | 37 || 38 | 0 | ALT3 | GPIO.28 | 28  | 21  |
 |     |     |      0v |      |   | 39 || 40 | 0 | ALT3 | GPIO.29 | 29  | 20  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+

blink 소스

var wpi = require('wiring-bpi-zero');

wpi.setup();

var pin = 25;

wpi.pinMode(pin, wpi.OUTPUT);

var value = 1;

setInterval(function() {
  wpi.digitalWrite(pin, value);
  value = +!value;
}, 500);

데모 실행

$ sudo node node-wiring-bpi-zero/examples/blink.js

BPI-M2 ZERO - node.js

OS/Banana Pi /BPI-Bit 2017.12.23 10:11 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

node-gyp 패키지 설치

$ sudo npm install -g node-gyp

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

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

BananaPI node.js용 GPIO 제어 라이브러리(andyhu/node-wiring-bpi)를 컴파일 해보았지만 컴파일 오류로 OrangePI용으로 받아서 실행 했으며, OrangePI 용도 단순하게 콘솔 커멘드를 실행해서 GPIO제어 하는 방법으로 BananaPI에서도 정상적으로 동작함

$ sudo npm i orange-pi-gpio
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/package.json'
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 4.444s

LED 제어

소스

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

let gpio25 = new Gpio({pin:25, 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`);
        }
        
        gpio25.write(value);
        value = +!value;
    }, 50);

}});

실행

$ node LEDDemo.js 

BPI-M2 ZERO - mjpg-streamer

OS/Banana Pi /BPI-Bit 2017.12.23 02:49 Posted by 파란크리스마스

BPI-M2 ZERO 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

input_ov5640.so 컴파일 관련 내용 추가

input_ov5640.so 소스는 누락되어 있습니다.(참고용)

$ vi Makefile

Makefile 내용 일부

# define the name of the program
APP_BINARY = mjpg_streamer

# define the names and targets of the plugins
PLUGINS = input_ov5640.so              # bluexmas : 추가
PLUGINS += input_uvc.so

... 생략 ...

# bluexmas : 추가
ifeq ($(USE_LIBV4L2),true)
input_ov5640.so: mjpg_streamer.h utils.h
	make -C plugins/input_ov5640 USE_LIBV4L2=true all
	cp plugins/input_ov5640/input_ov5640.so .
else
input_ov5640.so: mjpg_streamer.h utils.h
	make -C plugins/input_ov5640 all
	cp plugins/input_ov5640/input_ov5640.so .
endif

ifeq ($(USE_LIBV4L2),true)
input_uvc.so: mjpg_streamer.h utils.h

... 생략 ...

# cleanup
clean:
	make -C plugins/input_ov5640 $@           # bluexmas : 추가
	make -C plugins/input_uvc $@

mjpg-streamer 컴파일 및 설치

$ sudo make install
install --mode=755 mjpg_streamer /usr/local/bin
install --mode=644 input_ov5640.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_ov5640.so

input_ov5640.so

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

제가 작업한 OV5640의 YUV420코덱을 지원하는 so 파일을 공개 합니다.
BPI-M2 ZERO의 카메라인 OV5640를 사용해서 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_ov5640.so -y -n" -o "output_http.so -w /usr/local/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...: /usr/local/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
# 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=10
export SHUTDOWN_WAIT=2
export QUALITY=95

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 mjpg_service | 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_ov5640.so -r "$width"x"$height" -f $fps -q $QUALITY -y" -o "$LD_MJPG_STREAMER/output_http.so -p 8080 -w /usr/local/www" mjpg_service
		sleep 2
		f_message "mjpg_streamer started"
  fi

  return 0
}

stop() {
  pid=$(mjpg_streamer_pid)
  if [ -n "$pid" ]
  then
    f_message "Stopping mjpg_streamer..."
    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";
      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 mjpg_streamer | grep -v grep | awk '{ print $16 }'`
                currfps=`ps axu | grep mjpg_streamer | 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 Thu 2017-08-31 20:14:42 CST; 2min 28s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 5108 ExecStart=/etc/init.d/mjpg-streamer start (code=exited, status=0/SUCCESS)
   Memory: 1.0M
      CPU: 1min 18.585s
   CGroup: /system.slice/mjpg-streamer.service
           └─5117 mjpg_streamer -b -i /usr/local/lib/input_ov5640.so -r 640x480 -f 10 -q 95 -y -o /usr/local/lib/output_http.so -p 8080 -w /
 
Aug 31 20:14:40 bpi-iot-ros-ai mjpg_streamer[5117]: MJPG-streamer [5117]: Format............: YUV420
Aug 31 20:14:40 bpi-iot-ros-ai mjpg_streamer[5117]: MJPG-streamer [5117]: JPEG Quality......: 95
Aug 31 20:14:41 bpi-iot-ros-ai mjpg_streamer[5117]: MJPG-streamer [5117]: www-folder-path...: /usr/local/www/
Aug 31 20:14:41 bpi-iot-ros-ai mjpg_streamer[5117]: MJPG-streamer [5117]: HTTP TCP port.....: 8080
Aug 31 20:14:41 bpi-iot-ros-ai mjpg_streamer[5117]: MJPG-streamer [5117]: username:password.: disabled
Aug 31 20:14:41 bpi-iot-ros-ai mjpg_streamer[5117]: MJPG-streamer [5117]: commands..........: enabled
Aug 31 20:14:41 bpi-iot-ros-ai mjpg_streamer[5117]: MJPG-streamer [5117]: starting input plugin /usr/local/lib/input_ov5640.so
Aug 31 20:14:41 bpi-iot-ros-ai mjpg_streamer[5117]: MJPG-streamer [5117]: starting output plugin: /usr/local/lib/output_http.so (ID: 00)
Aug 31 20:14:42 bpi-iot-ros-ai mjpg-streamer[5108]: [+] mjpg_streamer started
Aug 31 20:14:42 bpi-iot-ros-ai systemd[1]: Started LSB: mjpg_streamer for webcam.
lines 1-20/20 (END)

-b 옵션 백드라운드로 실행

$ mjpg_streamer -b -i "input_ov5640.so -r "640"x"480" -f 10 -q 75 -y" -o "output_http.so -p 8080 -w /usr/local/www"
enabling daemon modeforked to background (10942)

motion

출처 : mjpegtoyuv420p patch for Logitech Quickcam Pro

$ svn co http://www.lavrsen.dk/svn/motion/trunk motion
$ cd motion
$ ./configure
$ make


BPI-M2 ZERO - CSI camera

OS/Banana Pi /BPI-Bit 2017.12.23 02:48 Posted by 파란크리스마스

BPI-M2 Berry CSI camera Camera(OV5640)

출처 : BPI-M2+ OV5640 camera linux driver is work fine
BPI-M2+ camera module

Camera 모듈 설치

$ sudo vi /etc/modules

내용 추가

ov5640
vfe_v4l2

Camera 설치 확인

$ dmesg | grep OV
[    9.147594] [OV5640@lex]init_sensor - frame_rate: 0, max_win_size: 11
[    9.252262] [OV5640@lex]CSI_SUBDEV_PWR_ON!
[    9.331910] [OV5640@lex]sensor_init 0x0
[    9.380640] [OV5640@lex]CSI_SUBDEV_PWR_OFF!
$ ls /dev/video*
/dev/video0

Camera 정보

$ modinfo ov5640
filename:       /lib/modules/3.4.113-BPI-M2Z-Kernel/kernel/drivers/media/video/sunxi-vfe/device/ov5640.ko
license:        GPL
description:    A low-level driver for ov5640 sensors (H3 / A20)
author:         @lex
author:         raymonxiu
alias:          i2c:ov5640
depends:        cci,vfe_subdev
intree:         Y
vermagic:       3.4.113-BPI-M2Z-Kernel SMP preempt mod_unload modversions ARMv7 p2v8 
parm:           frame_rate:frame_rate=0 (default with no parameters), frame_rate=1 (7.5 FPS), frame_rate=2 (15 FPS), frame_rate=3 (30 FPS) (default=0 - or no parms - default settings) (uint)

Camera 캡쳐 프로그램 컴파일 및 실행

출처 : https://github.com/avafinger/ov5640

$ git clone https://github.com/avafinger/cap-v4l2
$ cd cap-v4l2
$ sudo ./install_deps.sh
$ ./build_script.sh

캡쳐

$ ./cap 1280 768 4 1 -999 -1 -1
---- cap parameters -----
width: 1280
height: 768
v4l2 buffers: 4
exposure: -999
hflip: -1
vflip: -1
Mode: V4L2_MODE_VIDEO
Driver: "sunxi-vfe"
Card: "sunxi-vfe"
Bus: "sunxi_vfe sunxi_vfe.0"
Version: 1.0
Capabilities: 05000001
Input: 0
V4L2 pixel formats:
0: [0x50323234] '422P' (planar YUV 422)
1: [0x32315559] 'YU12' (planar YUV 420)
2: [0x32315659] 'YV12' (planar YVU 420)
3: [0x3631564E] 'NV16' (planar YUV 422 UV combined)
4: [0x3231564E] 'NV12' (planar YUV 420 UV combined)
5: [0x3136564E] 'NV61' (planar YUV 422 VU combined)
6: [0x3132564E] 'NV21' (planar YUV 420 VU combined)
7: [0x32314D48] 'HM12' (MB YUV420)
8: [0x56595559] 'YUYV' (YUV422 YUYV)
9: [0x55595659] 'YVYU' (YUV422 YVYU)
10: [0x59565955] 'UYVY' (YUV422 UYVY)
11: [0x59555956] 'VYUY' (YUV422 VYUY)
12: [0x31384142] 'BA81' (RAW Bayer BGGR 8bit)
13: [0x47524247] 'GBRG' (RAW Bayer GBRG 8bit)
14: [0x47425247] 'GRBG' (RAW Bayer GRBG 8bit)
15: [0x47425247] 'GRBG' (RAW Bayer RGGB 8bit)
16: [0x30314742] 'BG10' (RAW Bayer BGGR 10bit)
17: [0x30314247] 'GB10' (RAW Bayer GBRG 10bit)
18: [0x30314142] 'BA10' (RAW Bayer GRBG 10bit)
19: [0x30314142] 'BA10' (RAW Bayer RGGB 10bit)
20: [0x32314742] 'BG12' (RAW Bayer BGGR 12bit)
21: [0x32314247] 'GB12' (RAW Bayer GBRG 12bit)
22: [0x32314142] 'BA12' (RAW Bayer GRBG 12bit)
23: [0x32314142] 'BA12' (RAW Bayer RGGB 12bit)
V4L2 pixel sizes:
( 2592 x 1936 ) Pixels
( 2048 x 1536 ) Pixels
( 1920 x 1080 ) Pixels
( 1600 x 1200 ) Pixels
( 1280 x 960 ) Pixels
( 1280 x 720 ) Pixels
( 1024 x 768 ) Pixels
( 800 x 600 ) Pixels
( 640 x 480 ) Pixels
( 320 x 240 ) Pixels
( 176 x 144 ) Pixels
 
Sensor size adjusted to: 1280x720 pixels
Pixel Format: V4L2_PIX_FMT_YUV420 [0x32315559]
Frame #10 will be saved!
Length: 1384448         Bytesused: 1384448      Address: 0x395528
FPS[0]: 11.37
Length: 1384448         Bytesused: 1384448      Address: 0x395530
FPS[1]: 33.30
Length: 1384448         Bytesused: 1384448      Address: 0x395538
FPS[2]: 33.02
Length: 1384448         Bytesused: 1384448      Address: 0x395540
FPS[3]: 33.03
Length: 1384448         Bytesused: 1384448      Address: 0x395528
FPS[4]: 32.11
Length: 1384448         Bytesused: 1384448      Address: 0x395530
FPS[5]: 33.46
Length: 1384448         Bytesused: 1384448      Address: 0x395538
FPS[6]: 33.70
Length: 1384448         Bytesused: 1384448      Address: 0x395540
FPS[7]: 33.77
Length: 1384448         Bytesused: 1384448      Address: 0x395528
FPS[8]: 33.42
Length: 1384448         Bytesused: 1384448      Address: 0x395530
FPS[9]: 4.21
------- Avg FPS: 33.23 --------

PBI-M2 ZERO - pi4j

OS/Banana Pi /BPI-Bit 2017.12.23 02:18 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_25, // 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

BPI-M2 ZERO - WiringOP

OS/Banana Pi /BPI-Bit 2017.12.23 02:17 Posted by 파란크리스마스

출처 : GitHub - BPI-SINOVOIP/BPI-WiringPi2: (NEW) support all Banana Pi boards in one version(auto detect)

BPI-WiringPi2 설치

BPI-WiringPi2 소스 다운로드

$ git clone https://github.com/BPI-SINOVOIP/BPI-WiringPi2.git

BPI-WiringPi2 컴파일및 설치

$ cd BPI-WiringPi2
$ chmod +x ./build
$ sudo ./build
 
.. 생략 ...
 
[Install]
 
All Done.
 
NOTE: To compile programs with wiringPi, 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
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |  12 |   8 |   SDA.1 | ALT5 | 0 |  3 || 4  |   |      | 5v      |     |     |
 |  11 |   9 |   SCL.1 | ALT5 | 0 |  5 || 6  |   |      | 0v      |     |     |
 |   6 |   7 | GPIO. 7 | ALT3 | 0 |  7 || 8  | 0 | ALT4 | TxD     | 15  | 13  |
 |     |     |      0v |      |   |  9 || 10 | 0 | ALT4 | RxD     | 16  | 14  |
 |   1 |   0 | GPIO. 0 | ALT5 | 0 | 11 || 12 | 0 | ALT4 | GPIO. 1 | 1   | 16  |
 |   0 |   2 | GPIO. 2 | ALT5 | 0 | 13 || 14 |   |      | 0v      |     |     |
 |   3 |   3 | GPIO. 3 | ALT5 | 0 | 15 || 16 | 0 | ALT4 | GPIO. 4 | 4   | 15  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | ALT3 | GPIO. 5 | 5   | 68  |
 |  64 |  12 |    MOSI | ALT4 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |  65 |  13 |    MISO | ALT4 | 0 | 21 || 22 | 0 | ALT5 | GPIO. 6 | 6   | 2   |
 |  66 |  14 |    SCLK | ALT4 | 0 | 23 || 24 | 0 | ALT4 | CE0     | 10  | 67  |
 |     |     |      0v |      |   | 25 || 26 | 0 | ALT3 | CE1     | 11  | 71  |
 |  19 |  30 |   SDA.0 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.0   | 31  | 18  |
 |   7 |  21 | GPIO.21 | ALT3 | 0 | 29 || 30 |   |      | 0v      |     |     |
 |   8 |  22 | GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | GPIO.26 | 26  | 354 |
 |   9 |  23 | GPIO.23 | ALT3 | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  10 |  24 | GPIO.24 | ALT3 | 0 | 35 || 36 | 0 | ALT3 | GPIO.27 | 27  | 356 |
 |  17 |  25 | GPIO.25 | ALT3 | 0 | 37 || 38 | 0 | ALT3 | GPIO.28 | 28  | 21  |
 |     |     |      0v |      |   | 39 || 40 | 0 | ALT3 | GPIO.29 | 29  | 20  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+

LED 제어

GPIO 모드 변경

$  gpio mode 25 out

LED 켜기

$ gpio write 25 1

LED 끄기

$ gpio write 25 0

BPI-M2 ZERO

OS/Banana Pi /BPI-Bit 2017.12.23 02:17 Posted by 파란크리스마스

BPI-M2 ZERO

출처 : BPI-M2+/BPI-M2+(H2)/BPI-M2+(H5)/BPI-M2 ZERO - Banana Pi

OS 설치

출처 : BPI-M2+/BPI-M2+(H2)/BPI-M2+(H5)/BPI-M2 ZERO Image - Banana Pi

SD 확장

SD 확장전 용량확인

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            181M     0  181M   0% /dev
tmpfs            50M  3.5M   46M   8% /run
/dev/mmcblk0p2  6.7G  4.9G  1.6G  77% /
tmpfs           248M  384K  248M   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           248M     0  248M   0% /sys/fs/cgroup
tmpfs            50M   20K   50M   1% /run/user/1000
/dev/mmcblk0p1  256M  9.7M  247M   4% /media/pi/BPI-BOOT

SD FDisk

pi@bpi-iot-ros-ai:~$ 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: 0x3b7f8abe
 
Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1      204800   729087   524288  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      729088 14940159 14211072  6.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): 729088
Last sector, +sectors or +size{K,M,G,T,P} (729088-31116287, default 31116287): 
 
Created a new partition 2 of type 'Linux' and of size 14.5 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@bpi-iot-ros-ai:~$ sudo shutdown -r now

SD 확장

$ sudo 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 3798400 (4k) blocks long.

SD 확장 확인

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            181M     0  181M   0% /dev
tmpfs            50M  2.3M   48M   5% /run
/dev/mmcblk0p2   15G  4.9G  8.9G  36% /
tmpfs           248M  220K  248M   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           248M     0  248M   0% /sys/fs/cgroup
tmpfs            50M   24K   50M   1% /run/user/1000
/dev/mmcblk0p1  256M  9.7M  247M   4% /media/pi/BPI-BOOT

RDP(원격데스크탑) 설치

출처 : How to use RDP - BananaPro/Pi - LeMaker wiki

RDP(원격데스크탑) 설치

$ sudo apt-get install xrdp
$ sudo apt-get install tightvncserver

RDP 서비스로 등록

$ sudo systemctl enable xrdp
xrdp.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable xrdp
insserv: script firstrun.bpi: service firstrun already provided!
insserv: script firstrun.bpi: service firstrun already provided!

재부팅

$ sudo reboot

원격데스크탑 접속

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)

BPI-M2 Berry - RDP 서버 설치

OS/Banana Pi /BPI-Bit 2017.09.15 02:10 Posted by 파란크리스마스

출처 : How to use RDP - BananaPro/Pi - LeMaker wiki

RDP 서버 설치

$ sudo apt-get install xrdp
$ sudo apt-get install tightvncserver

RDP 서버 서비스 등록

$ sudo systemctl enable xrdp
xrdp.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable xrdp

재부팅

$ sudo shutdown -r now