Difference between revisions of "Getting Started with R2"

From Banana Pi Wiki
Jump to: navigation, search
(Prepare to develop)
(Prepare to develop)
 
(46 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 +
[[zh:快速上手 香蕉派 BPI-R2]]
 +
 
='''Introduction'''=
 
='''Introduction'''=
 +
[[File:BPI-R2_3.JPG|thumb|Overview [[Banana Pi BPI-R2]]]]
 +
[[File:Banana_pi_BPI-R1_1.JPG|thumb|[[Banana Pi BPI-R1]] Allwinner A20]]
  
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.  
+
[[File:Banana_Pi_BPI-R2_Pro_1_750.jpg|thumb|[[Banana Pi BPI-R2 Pro]] Rockchip RK3568 design]]
 +
[[File:BPI-R64_3.JPG|thumb|[[Banana Pi BPI-R64]] MTK MT7622]]
 +
[[File:O2A0500.jpg|thumb|[[Banana Pi BPI-W2]] with Realtek RTD1296 chip design]]
 +
[[File:Banana_Pi_BPI-R3_Router_2.jpg|thumb|[[Banana Pi BPI-R3]] with MediaTek MT7986(Filogic 830)]]
 +
[[File:Banana_Pi_BPI-M2S_1.jpg|thumb|[[Banana Pi BPI-M2S]] Amlogic A311D chip]]
 +
 
 +
  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]]
 
Read more: [[Banana Pi BPI-R2]]
Line 37: Line 47:
 
===Prepare to develop===
 
===Prepare to develop===
 
   * Prepare 16G/above TF card, USB-Serial interface, Ubuntu System
 
   * Prepare 16G/above TF card, USB-Serial interface, Ubuntu System
   * Using your USB-Serial Connect debug console on R2
+
   * Using your USB-Serial ('''3.3V''','''Baud: 115200''')  Connect debug console on R2
 +
  * Default IP address for LAN port: '''192.168.1.1'''
 +
  * User name/password: '''pi/bananapi''' ,'''root/bananapi'''.
 +
    Or the user is '''root without a password'''.
 +
 
  
 
   [[Image:R2_debug_console.png|240px]]
 
   [[Image:R2_debug_console.png|240px]]
Line 46: Line 60:
 
   1.You could download latest image from our forum
 
   1.You could download latest image from our forum
 
   * Here is the example image link: http://forum.banana-pi.org/t/bpi-r2-new-image-release-ubuntu-16-04-v1-3-2018-3-30/5293
 
   * Here is the example image link: http://forum.banana-pi.org/t/bpi-r2-new-image-release-ubuntu-16-04-v1-3-2018-3-30/5293
 
+
 
   2.Install bpi-tools on your Ubuntu
+
   2.Install bpi-tools on your Ubuntu. If you can't access this URL or any other problems, please go to [https://github.com/BPI-SINOVOIP/bpi-tools bpi-tools repo] and install this tools manually.
 
   * apt-get install pv
 
   * apt-get install pv
 
   * curl -sL https://github.com/BPI-SINOVOIP/bpi-tools/raw/master/bpi-tools | sudo -E bash
 
   * curl -sL https://github.com/BPI-SINOVOIP/bpi-tools/raw/master/bpi-tools | sudo -E bash
 
    
 
    
 
 
   3.After you download the image, insert your TF card into your Ubuntu
 
   3.After you download the image, insert your TF card into your Ubuntu
   * Execute "bpi-copy xxx.img /dev/sdx" to install image on your TF card.
+
   * Execute "bpi-copy xxx.img /dev/sdx" to install image on your TF card
 +
 
 +
  4.After step 3, then you can insert your TF card into R2, and press power button for around 10s to setup R2
  
  4.After step 3, then you can insert your TF card into R2, and press power button for around 10s to setup R2.
+
====Update Your Ubuntu On SD Card====
 
 
===Build your own image on R2===
 
====Ubuntu====
 
 
   1. Clone Bsp project from Github
 
   1. Clone Bsp project from Github
 
   * Execute "git clone [email protected]:BPI-SINOVOIP/BPI-R2-bsp.git"  
 
   * Execute "git clone [email protected]:BPI-SINOVOIP/BPI-R2-bsp.git"  
 
+
 
 
   2. Execute "./build.sh", to build your own uboot and kernel.
 
   2. Execute "./build.sh", to build your own uboot and kernel.
 
  [[Image:R2_build_sh.png]]
 
  [[Image:R2_build_sh.png]]
 
+
 
 
   3. After finish built, Execute "cd SD", plug your Ubuntu TFcard in PC.  
 
   3. After finish built, Execute "cd SD", plug your Ubuntu TFcard in PC.  
 +
 
 +
  4. Execute "bpi-update -c bpi-r2.conf -d /dev/sdX", to update the compiled kernel to your TFcard.
  
   4. Execute "bpi-update -c bpi-r2.conf -d /dev/sdX", to update the compiled kernel to your TFcard.
+
====Ubuntu On Emmc====
 +
   1. If you want to install Ubuntu on EMMC, follow these steps:
 +
  * Burn an image to sd card, and set up R64 with sd card.
 +
  * Copy the image which name contains "xxx-emmc-xxx" to U disk.
 +
  * mount U disk to R64, then use bpi-copy to burn image to Emmc.
  
  5. If you want to install Ubuntu on EMMC, follow these steps:
+
     bpi-copy  <XXX.img.zip>
  * Program ubuntu image to SD card
 
  * Install this SD to R2 board and boot from SD
 
  * Enter the Uboot prompt, and run command emmc pconf 48 to change Partition config of EMMC
 
  * And then run command reset, let it boot to OS
 
  * Enter the system with username pi or root
 
  * Run command
 
     echo 0 > /sys/block/mmcblk1boot0/force_ro  to enable /dev/mmcblk1boot0 write mode`
 
  * To write preloader to EMMC by running command:
 
    "bpi-bootsel BPI-R2-EMMC-boot0-DDR1600-0k-0905.img.gz /dev/mmcblk1boot0" where BPI-R2-EMMC-boot0-DDR1600-0k-0905.img.gz is the preloader for emmc, please download it from link:https://github.com/BPI-SINOVOIP/BPI-files/blob/master/SD/100MB/BPI-R2-EMMC-boot0-DDR1600-0k-0905.img.gz
 
  
   * To copy ubuntu image to EMMC:
+
   * XXX.img.zip is ubuntu image we can get it from http://www.banana-pi.org/r2-download.html  
    unzip -p <XXX.img.zip> | pv | dd of=<device> bs=10M status=noxfer
 
    or
 
    bpi-copy  <XXX.img.zip> <device> where the XXX.img.zip is ubuntu image we can get it from http://www.banana-pi.org/r2-download.html 40, and where should be /dev/mmcblk1.
 
 
   * power off
 
   * power off
 
   * remove SD & power on
 
   * remove SD & power on
  
====OpenWrt====
+
====OpenWrt On SD & Emmc Steps====
 
   1. Clone OpenWrt project from Github.
 
   1. Clone OpenWrt project from Github.
 
   * Execute "git clone https://github.com/garywangcn/bpi-r2_lede.git"
 
   * Execute "git clone https://github.com/garywangcn/bpi-r2_lede.git"
 
+
 
 
   2. You need to have installed gcc, binutils, bzip2, flex, python, perl, make, find, grep, diff, unzip, gawk, getopt, subversion, libz-dev and libc headers.
 
   2. You need to have installed gcc, binutils, bzip2, flex, python, perl, make, find, grep, diff, unzip, gawk, getopt, subversion, libz-dev and libc headers.
 
+
 
 
   3. Run "./scripts/feeds update -a" to get all the latest package definitions defined in feeds.conf / feeds.conf.default respectively and "./scripts/feeds install -a" to install symlinks of all of them into package/feeds/.
 
   3. Run "./scripts/feeds update -a" to get all the latest package definitions defined in feeds.conf / feeds.conf.default respectively and "./scripts/feeds install -a" to install symlinks of all of them into package/feeds/.
 
+
 
 
   4. Use "make menuconfig" to configure your image.
 
   4. Use "make menuconfig" to configure your image.
 
   * Choose "Target System" to config as "MediaTek Ralink ARM"
 
   * Choose "Target System" to config as "MediaTek Ralink ARM"
 
   * Choose "Boot Loaders" to config as "u-boot-bpi_r2"
 
   * Choose "Boot Loaders" to config as "u-boot-bpi_r2"
 
+
 
 
   5. Execute "make -j1 V=s" to build your own OpenWrt image.
 
   5. Execute "make -j1 V=s" to build your own OpenWrt image.
 
+
 
 
   6. After built, we have two ways to install image.
 
   6. After built, we have two ways to install image.
 
   (1) Plug your TFcard in Ubuntu PC, and enter to "build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-mediatek_32/",  
 
   (1) Plug your TFcard in Ubuntu PC, and enter to "build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-mediatek_32/",  
Line 107: Line 113:
 
       * mtk-bpi-r2-SD.img
 
       * mtk-bpi-r2-SD.img
 
   (2) Write image to TF card, execute "dd if=mtk-bpi-r2-SD.img of=/dev/sdX"
 
   (2) Write image to TF card, execute "dd if=mtk-bpi-r2-SD.img of=/dev/sdX"
 
+
 
 
   (3) If you want to install image to EMMC, We need another system which is running on SD card to program EMMC image to EMMC, please follow below steps to do:
 
   (3) If you want to install image to EMMC, We need another system which is running on SD card to program EMMC image to EMMC, please follow below steps to do:
 
       * Copy EMMC image to a running system which is from SD card
 
       * Copy EMMC image to a running system which is from SD card
Line 115: Line 121:
 
       * Change the Partition configurion of EMMC is 48h: reboot the system which is running SD, and enter the U-boot command line, run command emmc pconf 48 (for this steps, we can change partition configuration in userspace by using mmc-utils,see more information in BPI-R2 OpenWrt(LEDE) Souce code : 2018-04-11)
 
       * Change the Partition configurion of EMMC is 48h: reboot the system which is running SD, and enter the U-boot command line, run command emmc pconf 48 (for this steps, we can change partition configuration in userspace by using mmc-utils,see more information in BPI-R2 OpenWrt(LEDE) Souce code : 2018-04-11)
 
       * Power off, remove SD card, and then power on R2 board
 
       * Power off, remove SD card, and then power on R2 board
 
+
 
 
   7. This step is for upgrade, if you don't want to install image after you built, you could use runtime upgrade.
 
   7. This step is for upgrade, if you don't want to install image after you built, you could use runtime upgrade.
 
   * Copy "bin/targets/mediatek/32/lede-mediatek-32-bananapi,bpi-r2-sysupgrade.tar" to R2 board which is running OpenWrt system(no matter where(SD or EMMC) it boots from), and then run command "sysupgrade lede-mediatek-32-bananapi,bpi-r2-sysupgrade.tar" to update both kernel and rootfs.
 
   * Copy "bin/targets/mediatek/32/lede-mediatek-32-bananapi,bpi-r2-sysupgrade.tar" to R2 board which is running OpenWrt system(no matter where(SD or EMMC) it boots from), and then run command "sysupgrade lede-mediatek-32-bananapi,bpi-r2-sysupgrade.tar" to update both kernel and rootfs.
 +
 +
* 1,Banana Pi R2 install openWRT: https://www.cnblogs.com/topbin/p/8794152.html
 +
* 2,Banana Pi R2 Openwrt Network port configuration analysis : https://www.cnblogs.com/topbin/p/9518279.html
 +
* 3,Banana Pi R2 developing a simple router based on Openwrt : https://www.cnblogs.com/topbin/p/9519881.html
 +
* 4,Banana Pi R2 Openwrt Luci : https://www.cnblogs.com/topbin/p/9519875.html
  
 
=== Network-Configuration===
 
=== Network-Configuration===
Line 146: Line 157:
  
 
More about GPIO : http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:gpio
 
More about GPIO : http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:gpio
 +
 +
====Install RPi.GPIO====
 +
* Execute "git clone https://github.com/BPI-SINOVOIP/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===
 
===Develop 4G module with R2===
Line 152: Line 174:
 
[[Using 4G module with BananaPi]]
 
[[Using 4G module with BananaPi]]
  
===WiFi and Ap mode on R2===
+
===WiFi and Ap mode on R2 Ubuntu===
====WiFi Client====
+
====STA====
 
* wmt_loader (ignore errors)
 
* wmt_loader (ignore errors)
 
* stp_uart_launcher -p /etc/firmware &
 
* stp_uart_launcher -p /etc/firmware &
Line 159: Line 181:
 
* iw dev wlan0 scan | grep SSID
 
* iw dev wlan0 scan | grep SSID
 
* vim /etc/wpasupplicant/wpa_supplicant.conf
 
* vim /etc/wpasupplicant/wpa_supplicant.conf
* network={ ssid=“ssid” psk=“password” priority=1}
+
network={  
 +
ssid="ssid"   
 +
psk="password"   
 +
priority=1  
 +
}
 
* wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
 
* wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
 
* dhclient wlan0
 
* dhclient wlan0
 +
 
====AP mode====
 
====AP mode====
 
* wmt_loader (ignore errors)
 
* wmt_loader (ignore errors)
Line 168: Line 195:
 
* create your hostapd.conf: "vim /etc/hostapd/hostapd.conf "
 
* create your hostapd.conf: "vim /etc/hostapd/hostapd.conf "
  
  interface=ap0
+
interface=ap0
  bridge=br0
+
bridge=br0
  ssid=test_r2
+
ssid=test_r2
  driver=nl80211
+
driver=nl80211
  country_code=US
+
country_code=US
  hw_mode=b
+
hw_mode=b
  channel=1
+
channel=1
  max_num_sta=5
+
max_num_sta=5
  wpa=2       
+
wpa=2       
  auth_algs=1  
+
auth_algs=1  
  rsn_pairwise=CCMP
+
rsn_pairwise=CCMP
  wpa_key_mgmt=WPA-PSK
+
wpa_key_mgmt=WPA-PSK
  wpa_passphrase=ledetest
+
wpa_passphrase=ledetest
  logger_stdout=-1
+
logger_stdout=-1
  logger_stdout_level=2
+
logger_stdout_level=2
  
 
* According to your network interface(can search internet) to config ap0:
 
* According to your network interface(can search internet) to config ap0:
Line 192: Line 219:
 
* Config dhcp file : “vim /etc/dhcp/dhcpd.conf”
 
* Config dhcp file : “vim /etc/dhcp/dhcpd.conf”
  
  subnet 192.168.30.0 netmask 255.255.255.0 {
+
subnet 192.168.30.0 netmask 255.255.255.0 {
  range 192.168.30.2 192.168.30.250;
+
range 192.168.30.2 192.168.30.250;
  option domain-name-servers 8.8.8.8;
+
option domain-name-servers 8.8.8.8;
  option routers 192.168.30.1; }
+
option routers 192.168.30.1; }
  
 
* Config dhcp of ap0, then the devices which connect ap0 could get IP: "dhcpd ap0 -pf /var/run/dhcpd.pid "
 
* Config dhcp of ap0, then the devices which connect ap0 could get IP: "dhcpd ap0 -pf /var/run/dhcpd.pid "
Line 204: Line 231:
 
* Config br0 : “ifconfig br0 192.168.30.180 netmask 255.255.255.0”
 
* 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”
 
* 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:
 +
 +
[[Image:A64_ap_1.png]]
 +
 +
Then, you could solve by following command:
 +
* nmcli radio wifi off
 +
[[Image:A64_ap_2.png]]
 +
* rfkill unblock 1
 +
* rfkill unblock 2
 +
* ifconfig ap0 up
 +
* hostapd -d  hostapd.conf
 +
[[Image:A64_ap_3.png]]
 +
 +
===WiFi and Ap mode on R2 Openwrt===
 +
====AP mode====
 +
1. Make a bash script
 +
* vim setup.sh
 +
#!/bin/ash
 +
wmt_loader &
 +
sheep 3
 +
stp_uart_launcher -p /etc/firmware &
 +
sleep 5
 +
echo A > /dev/wmtWifi &
 +
sleep 5
 +
hostapd -d hostapd.conf
 +
2. Create your hostapd.conf
 +
* vim hostapd.conf
 +
interface=ap0
 +
bridge=br-lan
 +
ssid=BPI_R2
 +
driver=nl80211
 +
country_code=CN
 +
hw_mode=g
 +
channel=1
 +
max_num_sta=5
 +
wpa=2
 +
auth_algs=1
 +
rsn_pairwise=CCMP
 +
wpa_key_mgmt=WPA-PSK
 +
wpa_passphrase=ledetest
 +
logger_stdout=-1
 +
logger_stdout_level=2
 +
 +
3. Make it run
 +
* ./setup.sh
 +
 +
4. Add it to starting progress
 +
* vim /etc/rc.local
 +
  cd /root/
 +
  sleep 6
 +
  ./setup.sh &
 +
 +
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===
 
===Make your own image===
* Prepare a SD card which have installed Ubuntu system.
+
* 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.
+
* 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 <your account> pi".
+
* Plug your SD card in Linux PC, "cd /media", then "ln -s <your account> pi"
* Execute "bpi-migrate -c bpi-r2.conf -c ubuntu-mate-from-sd.conf -d /dev/sdb".
+
* Execute "bpi-migrate -c bpi-r2.conf -c ubuntu-mate-from-sd.conf -d /dev/sdx"
* Then you could get your own image now.
+
* Then you could get your own image now
 
 
===Install image on EMMC===
 
  
 
==FAQ==
 
==FAQ==
 
*1.Banana Pi BPI-R2 Razberry board OpenHab2  
 
*1.Banana Pi BPI-R2 Razberry board OpenHab2  
 
::https://community.openhab.org/t/banana-pi-bpi-r2-razberry-board-openhab2-help/37222/8
 
::https://community.openhab.org/t/banana-pi-bpi-r2-razberry-board-openhab2-help/37222/8
 +
 +
===TTL Voltage===
 +
:: The debug-uart TTL is tolerant to 3.3V.
  
 
='''Reference Link'''=
 
='''Reference Link'''=

Latest revision as of 01:43, 4 January 2024


Introduction

Banana Pi BPI-R1 Allwinner A20
Banana Pi BPI-R2 Pro Rockchip RK3568 design
Banana Pi BPI-W2 with Realtek RTD1296 chip design
Banana Pi BPI-R3 with MediaTek MT7986(Filogic 830)
Banana Pi BPI-M2S Amlogic A311D chip
  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.

BPI-R2 SATA.jpg

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

 * Prepare 16G/above TF card, USB-Serial interface, Ubuntu System
 * Using your USB-Serial (3.3V,Baud: 115200)  Connect debug console on R2
 * Default IP address for LAN port: 192.168.1.1
 * User name/password: pi/bananapi ,root/bananapi.
   Or the user is root without a password.


 R2 debug console.png
 * BananaPi R2 - Debug-UART :http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:debug-uart

Load your first image on R2

 1.You could download latest image from our forum
 * Here is the example image link: http://forum.banana-pi.org/t/bpi-r2-new-image-release-ubuntu-16-04-v1-3-2018-3-30/5293
 
 2.Install bpi-tools on your Ubuntu. If you can't access this URL or any other problems, please go to bpi-tools repo and install this tools manually.
 * apt-get install pv
 * curl -sL https://github.com/BPI-SINOVOIP/bpi-tools/raw/master/bpi-tools | sudo -E bash
 
 3.After you download the image, insert your TF card into your Ubuntu
 * Execute "bpi-copy xxx.img /dev/sdx" to install image on your TF card
 
 4.After step 3, then you can insert your TF card into R2, and press power button for around 10s to setup R2

Update Your Ubuntu On SD Card

 1. Clone Bsp project from Github
 * Execute "git clone [email protected]:BPI-SINOVOIP/BPI-R2-bsp.git" 
 
 2. Execute "./build.sh", to build your own uboot and kernel.
R2 build sh.png
 
 3. After finish built, Execute "cd SD", plug your Ubuntu TFcard in PC. 
 
 4. Execute "bpi-update -c bpi-r2.conf -d /dev/sdX", to update the compiled kernel to your TFcard.

Ubuntu On Emmc

 1. If you want to install Ubuntu on EMMC, follow these steps:
 * Burn an image to sd card, and set up R64 with sd card.
 * Copy the image which name contains "xxx-emmc-xxx" to U disk.
 * mount U disk to R64, then use bpi-copy to burn image to Emmc.  
   bpi-copy  <XXX.img.zip> 
 * XXX.img.zip is ubuntu image we can get it from http://www.banana-pi.org/r2-download.html 
 * power off
 * remove SD & power on

OpenWrt On SD & Emmc Steps

 1. Clone OpenWrt project from Github.
 * Execute "git clone https://github.com/garywangcn/bpi-r2_lede.git"
 
 2. You need to have installed gcc, binutils, bzip2, flex, python, perl, make, find, grep, diff, unzip, gawk, getopt, subversion, libz-dev and libc headers.
 
 3. Run "./scripts/feeds update -a" to get all the latest package definitions defined in feeds.conf / feeds.conf.default respectively and "./scripts/feeds install -a" to install symlinks of all of them into package/feeds/.
 
 4. Use "make menuconfig" to configure your image.
 * Choose "Target System" to config as "MediaTek Ralink ARM"
 * Choose "Boot Loaders" to config as "u-boot-bpi_r2"
 
 5. Execute "make -j1 V=s" to build your own OpenWrt image.
 
 6. After built, we have two ways to install image.
 (1) Plug your TFcard in Ubuntu PC, and enter to "build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-mediatek_32/", 
     you will find two images:
     * mtk-bpi-r2-EMMC.img
     * mtk-bpi-r2-SD.img
 (2) Write image to TF card, execute "dd if=mtk-bpi-r2-SD.img of=/dev/sdX"
 
 (3) If you want to install image to EMMC, We need another system which is running on SD card to program EMMC image to EMMC, please follow below steps to do:
     * Copy EMMC image to a running system which is from SD card
     * Program EMMC image to User Data Area of EMMC: dd if=mtk-bpi-r2-EMMC.img of=/dev/mmcblk0 (assume /dev/mmcblk0 is for EMMC)
     * Unlock EMMC boot0 block: echo 0 > /sys/block/mmcblk0boot0/force_ro
     * Program preloader to EMMC boot0 block: dd if=mtk-bpi-r2-EMMC.img of=/dev/mmcblk0boot0 bs=1M count=1
     * Change the Partition configurion of EMMC is 48h: reboot the system which is running SD, and enter the U-boot command line, run command emmc pconf 48 (for this steps, we can change partition configuration in userspace by using mmc-utils,see more information in BPI-R2 OpenWrt(LEDE) Souce code : 2018-04-11)
     * Power off, remove SD card, and then power on R2 board
 
 7. This step is for upgrade, if you don't want to install image after you built, you could use runtime upgrade.
 * Copy "bin/targets/mediatek/32/lede-mediatek-32-bananapi,bpi-r2-sysupgrade.tar" to R2 board which is running OpenWrt system(no matter where(SD or EMMC) it boots from), and then run command "sysupgrade lede-mediatek-32-bananapi,bpi-r2-sysupgrade.tar" to update both kernel and rootfs.

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

  • Execute "git clone https://github.com/BPI-SINOVOIP/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
network={    
ssid="ssid"    
psk="password"    
priority=1 
}
  • 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 "
interface=ap0
bridge=br0
ssid=test_r2
driver=nl80211
country_code=US
hw_mode=b
channel=1
max_num_sta=5
wpa=2       
auth_algs=1 
rsn_pairwise=CCMP
wpa_key_mgmt=WPA-PSK
wpa_passphrase=ledetest
logger_stdout=-1
logger_stdout_level=2
  • According to your network interface(can search internet) to config ap0:
 my network interface which can search internet is wan, and ip is 192.168.30.102, so I config ap0 as follows:

“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”
subnet 192.168.30.0 netmask 255.255.255.0 {
range 192.168.30.2 192.168.30.250;
option domain-name-servers 8.8.8.8;
option routers 192.168.30.1; }
  • 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:

A64 ap 1.png

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

A64 ap 3.png

WiFi and Ap mode on R2 Openwrt

AP mode

1. Make a bash script

  • vim setup.sh
#!/bin/ash
wmt_loader &
sheep 3
stp_uart_launcher -p /etc/firmware &
sleep 5
echo A > /dev/wmtWifi &
sleep 5
hostapd -d hostapd.conf

2. Create your hostapd.conf

  • vim hostapd.conf
interface=ap0
bridge=br-lan
ssid=BPI_R2
driver=nl80211
country_code=CN
hw_mode=g
channel=1
max_num_sta=5
wpa=2
auth_algs=1
rsn_pairwise=CCMP
wpa_key_mgmt=WPA-PSK
wpa_passphrase=ledetest
logger_stdout=-1
logger_stdout_level=2

3. Make it run

  • ./setup.sh

4. Add it to starting progress

  • vim /etc/rc.local
 cd /root/
 sleep 6
 ./setup.sh &

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 <your account> 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

TTL Voltage

The debug-uart TTL is tolerant to 3.3V.

Reference Link

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/