Getting Started with R2 - Banana Pi Wiki

Introduction

  The Banana Pi R2 is a router based development board, which can run on a variety of open source operating systems including OpenWrt, Android, and Bananian. It has 4 Gigabit LAN ports, 1 Gigabit WAN, and 300Mbs wireless N capabilities. 

Read more: Banana Pi BPI-R2

Key Features

  • MediaTek MT7623N, Quad-core ARM Cortex-A7

  • Mali 450 MP4 GPU

  • 2G DDR3 SDRAM

  • 1x Mini PCIE interface

  • 2x SATA interface

  • 4x Gigabit LAN 1x Gigabit WAN

Hardware

BPI-R2 SATA interface

BPI-R2 support 2 sata interface and onboard power port.

you can use sata line connect your hardisk on BPI-R2.

  • Test a SAMSUNG SSD DISK, the Read/Write performance are below:

Read from disk: 230MB/s \(command: dd if=/dev/sda of=/dev/zero bs=1M count=10240\) Write to disk: 192MB/s \(command: dd if=/dev/zero of=/dev/sda bs=1M count=1024 oflag=direct\)

  • Note:

if you use 3.5 big hardisk ,you may need power with outside power. on board power maybe can not support enough current

Development

Let's get start to develop on BPI-R2, see amazing things happen.

Basic Development

Prepare to develop

Load your first image on R2

Update Your Ubuntu On SD Card

Ubuntu On Emmc

OpenWrt On SD & Emmc Steps

Network-Configuration

Advanced Development

GPIO

GPIO Control

  • echo xxx > /sys/class/gpio/export

  • echo in/out > /sys/class/gpio/gpioxxx/direction

  • echo 0/1 > /sys/class/gpio/gpioxxx/value

Check the base gpio, you could see mine is 233

R2 gpio base.png

For example: if you want to change gpio 22 as out highlevel, you need input commands like this:

  • echo 255(22+233) > /sys/class/gpio/export

  • echo out > /sys/class/gpio/gpio255/direction

  • echo 1 > /sys/class/gpio/gpio255/value

PWM Control

  • echo x >/sys/class/pwm/pwmchip0/export

  • echo 200000 >/sys/class/pwm/pwmchip0/pwmx/period

  • echo 100000 >/sys/class/pwm/pwmchip0/pwmx/duty_cycle

  • echo 1 >/sys/class/pwm/pwmchip0/pwmx/enable

More about GPIO : http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:gpio

Install RPi.GPIO

  • after clone the repo, cd RPi.GPIO

  • Execute "sudo apt-get update"

  • Execute "sudo apt-get install python-dev python3-dev"

  • Execute "sudo python setup.py install" or "sudo python3 setup.py install" to install the module

Using RPi.GPIO

  • cd /usr/local/bin

  • Execute "./g40.py" to test RPi.GPIO

Develop 4G module with R2

Gets more info from here:

Using 4G module with BananaPi

WiFi and Ap mode on R2 Ubuntu

STA

  • wmt_loader (ignore errors)

  • stp_uart_launcher -p /etc/firmware &

  • ip link set wlan0 up

  • iw dev wlan0 scan | grep SSID

  • vim /etc/wpasupplicant/wpa_supplicant.conf

  • wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

  • dhclient wlan0

AP mode

  • wmt_loader (ignore errors)

  • stp_uart_launcher -p /etc/firmware &

  • echo A >/dev/wmtWifi

  • create your hostapd.conf: "vim /etc/hostapd/hostapd.conf "

  • According to your network interface(can search internet) to config ap0:

“ifconfig ap0 192.168.30.188 netmask 255.255.255.0”

  • Run hostapd : “hostapd -d /etc/hostapd/hostapd.conf”

  • Config dhcp file : “vim /etc/dhcp/dhcpd.conf”

  • Config dhcp of ap0, then the devices which connect ap0 could get IP: "dhcpd ap0 -pf /var/run/dhcpd.pid "

  • And a bridge

  • brctl addbr br0

  • brctl addif br0 ap0

  • brctl addif br wan

  • Config br0 : “ifconfig br0 192.168.30.180 netmask 255.255.255.0”

  • Add br0 gw as : “route add -net default netmask 255.255.255.0 gw 192.168.30.1 dev br0”

Ap Mode FAQ

If you meet problem like this:

Then, you could solve by following command:

  • nmcli radio wifi off

A64 ap 2.png

  • rfkill unblock 1

  • rfkill unblock 2

  • ifconfig ap0 up

  • hostapd -d hostapd.conf

WiFi and Ap mode on R2 Openwrt

AP mode

1. Make a bash script

  • vim setup.sh

2. Create your hostapd.conf

  • vim hostapd.conf

3. Make it run

  • ./setup.sh

4. Add it to starting progress

  • vim /etc/rc.local

5. If your Ap is not stable, please limit the speed, here I limit download speed as 8Mbit/s, upload as 4Mbit/s

  • tc qdisc add dev ap0 root handle 1: htb default 11

  • tc class add dev ap0 parent 1:1 classid 1:2 htb rate 8Mbit ceil 4Mbit prio 2

Make your own image

  • Prepare a SD card which have installed Ubuntu system

  • Boot your SD card with R2, after R2 finish starting, copy your files and config your Ubuntu, then poweroff R2

  • Plug your SD card in Linux PC, "cd /media", then "ln -s pi"

  • Execute "bpi-migrate -c bpi-r2.conf -c ubuntu-mate-from-sd.conf -d /dev/sdx"

  • Then you could get your own image now

FAQ

  • 1.Banana Pi BPI-R2 Razberry board OpenHab2

https://community.openhab.org/t/banana-pi-bpi-r2-razberry-board-openhab2-help/37222/8

http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:start

http://www.banana-pi.org/r2.html

http://forum.banana-pi.org/

Last updated

Was this helpful?