Difference between revisions of "Getting Started with R64"

From Banana Pi Wiki
Jump to: navigation, search
(Sata)
(MT7622 Reference Manual for Develope Board(BPi))
(46 intermediate revisions by 2 users not shown)
Line 49: Line 49:
  
 
     bpi-copy  <XXX.img.zip>
 
     bpi-copy  <XXX.img.zip>
 +
 +
    [[Image:R64_Emmc_image.jpg]]
  
 
   * After this, reboot R64.
 
   * After this, reboot R64.
Line 58: Line 60:
 
==Advanced Development==
 
==Advanced Development==
 
===GPIO===
 
===GPIO===
 +
====40 Pins Definition====
 +
 +
[[Image:R64_gpio_40.jpg]]
 +
 
====GPIO Control====
 
====GPIO Control====
 
* echo xxx > /sys/class/gpio/export
 
* echo xxx > /sys/class/gpio/export
Line 63: Line 69:
 
* echo 0/1 > /sys/class/gpio/gpioxxx/value
 
* echo 0/1 > /sys/class/gpio/gpioxxx/value
  
Check the base gpio, you could see mine is 233
+
Check the base gpio, you could see mine is 409
  
[[Image:R2_gpio_base.png]]
+
[[Image:R64_gpio_base.jpg]]
  
 
For example: if you want to change gpio 22 as out highlevel, you need input commands like this:
 
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 431(22+409) > /sys/class/gpio/export
* echo out > /sys/class/gpio/gpio255/direction
+
* echo out > /sys/class/gpio/gpio431/direction
* echo 1 > /sys/class/gpio/gpio255/value
+
* echo 1 > /sys/class/gpio/gpio431/value
  
 
====PWM Control====
 
====PWM Control====
Line 80: Line 86:
  
 
===Sata===
 
===Sata===
 +
* '''If you want to use Sata interface on R64, you need to give GPIO90 low level'''
 +
** echo 499 > /sys/class/gpio/export
 +
** echo out > /sys/class/gpio/gpio499/direction
 +
** echo 0 > /sys/class/gpio/gpio499/value
 +
 +
*Test a TOSHIBA HDD DISK, the Read/Write performance are below:
 +
 +
::Read from disk: 50MB/s command: dd if=/dev/sda of=/dev/null bs=1M count=1024
 +
 +
::Write to disk: 38MB/s  command: dd if=/dev/zero of=/dev/sda bs=1M count=1024
 +
[[Image:R64_hdd_sata_test.jpg]]
 +
 
*Test a SAMSUNG SSD DISK, the Read/Write performance are below:
 
*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\)
+
::Read from disk: 360MB/s command: dd if=/dev/sda of=/dev/null bs=1M count=1024
  
::Write to disk: 192MB/s \(command: dd if=/dev/zero of=/dev/sda bs=1M count=1024 oflag=direct\)
+
::Write to disk: 200MB/s command: dd if=/dev/zero of=/dev/sda bs=1M count=1024
[[Image:R64_sata_test.jpg]]
+
[[Image:R64_ssd_sata_test.jpg]]
 +
 
 +
===PCIe===
 +
* '''If you want to use PCIe interface on R64, you need to give GPIO90 high level'''
 +
** echo 499 > /sys/class/gpio/export
 +
** echo out > /sys/class/gpio/gpio499/direction
 +
** echo 1 > /sys/class/gpio/gpio499/value
 +
 
 +
* PCIe supports EC-25 4G module.
 +
[[Image:R64_pcie_test_1.jpg]]
 +
 
 +
[[Image:R64_pcie_test_2.jpg]]
  
 
===GMAC===
 
===GMAC===
Line 98: Line 127:
 
[[Image:R64_Gmac_test.jpg]]
 
[[Image:R64_Gmac_test.jpg]]
  
===GMAC===
+
===BT & BLE on R64===
Use iperf3 to test gmac
+
'''R64 BT Architectural'''
 +
 
 +
[[Image:R64_BT_Arch.jpg]]
 +
 
 +
* BLE on R64
 +
* Input Command "btmw-test", you will enter to "btmw_test_cli" command line
  
1. On PC Terminal:
+
[[Image:R64_BT_cli.jpg]]
* Execute "iperf3 -s"
 
  
2. On R64 console:
+
* Here are some example commands:
* TCP test: "iperf3 -c serverIP"
+
** MW_GAP name 7622_BT /*rename bt device*/
* UDP test: "iperf3 -u -c serverIP"
+
** MW_GAP info        /*check local BT device info*/
[[Image:R64_Gmac_test.png]]
+
** MW_GATTC scan      /* start ble scan*/
 +
** MW_GATTC stop_scan  /* stop ble scan*/
  
===Develop 4G module with R2===
+
===R64 LAN Function===
Gets more info from here:  
+
* LAN eth interface is eth2, use "ifconfig eth2 up" to enable it.
 +
* Config the ip, "ifconfig eth2 192.168.1.1".
 +
  [[Image:R64_Lan_test_1.jpg]]
  
[[Using 4G module with BananaPi]]
+
* Config your dhcp server, "vim /etc/dhcp/dhcpd.conf", add these configurations.
 +
  [[Image:R64_Lan_test_2.jpg]]
  
===WiFi and Ap mode on R2 Ubuntu===
+
* Start dhcp server, "dhcpd eth2".
====WiFi Client====
+
   [[Image:R64_Lan_test_3.jpg]]
* 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====
+
* then config iptables and set package forward.
* wmt_loader (ignore errors)
+
** Add "net.ipv4.ip_forward=1" to "/etc/sysctl.conf"
* stp_uart_launcher -p /etc/firmware &
+
** "/sbin/sysctl -p" to make forward work
* echo A >/dev/wmtWifi
+
** "iptables -t nat -A POSTROUTING -s 192.168.1.1/24 -o eth3 -j MASQUERADE"
* create your hostapd.conf: "vim /etc/hostapd/hostapd.conf "
 
  
  interface=ap0
+
===Ap mode on R64===
  bridge=br0
+
* Find "mt_wifi.ko" and insmod it.
  ssid=test_r2
+
** insmod ./lib/modules/4.4.92-BPI-R64-Kernel/extra/mt_wifi.ko
  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:
+
* Then you will see ra0 and rai0.
   my network interface which can search internet is wan, and ip is 192.168.30.102, so I config ap0 as follows:
+
   [[Image:R64_wifi_test_1.jpg]]
  
“ifconfig ap0 192.168.30.188 netmask 255.255.255.0”
+
* ra0 is MT7622 2.4G wifi
 +
* rai0 is MT7615 5G wifi
  
* Run hostapd : “hostapd -d /etc/hostapd/hostapd.conf”
+
====2.4G WiFi====
* Config dhcp file : “vim /etc/dhcp/dhcpd.conf”
+
* Use "ifconfig ra0 up" to enable it.
 +
* Config the ip, "ifconfig ra0 192.168.1.1".
  
  subnet 192.168.30.0 netmask 255.255.255.0 {
+
* Config your dhcp server, "vim /etc/dhcp/dhcpd.conf", add these configurations.
  range 192.168.30.2 192.168.30.250;
+
   [[Image:R64_Lan_test_2.jpg]]
  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 "
+
* Start dhcp server, "dhcpd ra0".
* 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”
 
  
===WiFi and Ap mode on R2 Openwrt===
+
* then config iptables and set package forward.
====AP mode====
+
** Add "net.ipv4.ip_forward=1" to "/etc/sysctl.conf"
1. Make a bash script
+
** "/sbin/sysctl -p" to make forward work
* vim setup.sh
+
** "iptables -t nat -A POSTROUTING -s 192.168.1.1/24 -o eth3 -j MASQUERADE"
  #!/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
+
====5G WiFi====
* ./setup.sh
+
* Use "ifconfig rai0 up" to enable it.
 +
* Config the ip, "ifconfig rai0 192.168.1.1".
  
4. Add it to starting progress
+
* Config your dhcp server, "vim /etc/dhcp/dhcpd.conf", add these configurations.
* vim /etc/rc.local
+
   [[Image:R64_Lan_test_2.jpg]]
  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
+
* Start dhcp server, "dhcpd rai0".
* 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===
+
* then config iptables and set package forward.
* Prepare a SD card which have installed Ubuntu system
+
** Add "net.ipv4.ip_forward=1" to "/etc/sysctl.conf"  
* Boot your SD card with R2, after R2 finish starting, copy your files and config your Ubuntu, then poweroff R2
+
** "/sbin/sysctl -p" to make forward work
* Plug your SD card in Linux PC, "cd /media", then "ln -s <your account> pi"
+
** "iptables -t nat -A POSTROUTING -s 192.168.1.1/24 -o eth3 -j MASQUERADE"
* 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==
 
==FAQ==
*1.Banana Pi BPI-R2 Razberry board OpenHab2
+
*MT7622 Reference Manual for Develope Board(BPi)
::https://community.openhab.org/t/banana-pi-bpi-r2-razberry-board-openhab2-help/37222/8
+
::Google Drive:https://drive.google.com/open?id=1UhaIM9ork1O9cNO-t6ENMVVamB75AThV
 +
::BaiDu  Drive:https://pan.baidu.com/s/1KduFT2MUvMs2FhOF4A8kQQ
  
 
='''Reference Link'''=
 
='''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/
 
http://forum.banana-pi.org/

Revision as of 19:29, 24 December 2018

Introduction

  The Banana Pi R64 is a router based development board, which can run on a variety of open source operating systems including OpenWrt,Linux. It has 4 Gigabit LAN ports, 1 Gigabit WAN, and AC wifi AP function. use 64 bit chip design.

Read more: Banana Pi BPI-R64

Key Features

  • MediaTek MT7622,1.35GHZ 64 bit dual-core ARM Cortex-A53
  • 1G DDR3 SDRAM
  • Mini PCIE interface support 4G module
  • Built-in 4x4n 802.11n/Bluetooth 5.0 system-on-chip
  • MTK7615 4x4ac wifi on board
  • Support 1 SATA interface
  • MicroSD slot supports up to 256GB expansion
  • 8G eMMC flash (option 16/32/64G)
  • 5 port 10/100/1000 Mb Ethernet port
  • 1 Port USB 3.0
  • Slow I/O:ADC, Audio Amplifier, GPIO, I2C, I2S, IR, PMIC I/F, PWM, RTC, SPI, UART
  • POE function support

Development

Basic Development

Prepare to develop

 * Prepare 8G/above TF card, USB-Serial interface, Ubuntu System
 * Using your USB-Serial Connect debug console on R64
 R64 debug console.jpg

Load your first image on R64

 1.You could download latest image from our forum
 * Here is the example image link: 
 
 2.Install bpi-tools on your Ubuntu
 * 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 R64, and press power button to setup R64

Ubuntu On Emmc

 1. If you want to install image 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>
   R64 Emmc image.jpg
 * After this, reboot R64.
 * Remove SD & power on.

Network-Configuration

Advanced Development

GPIO

40 Pins Definition

R64 gpio 40.jpg

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 409

R64 gpio base.jpg

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

  • echo 431(22+409) > /sys/class/gpio/export
  • echo out > /sys/class/gpio/gpio431/direction
  • echo 1 > /sys/class/gpio/gpio431/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

Sata

  • If you want to use Sata interface on R64, you need to give GPIO90 low level
    • echo 499 > /sys/class/gpio/export
    • echo out > /sys/class/gpio/gpio499/direction
    • echo 0 > /sys/class/gpio/gpio499/value
  • Test a TOSHIBA HDD DISK, the Read/Write performance are below:
Read from disk: 50MB/s command: dd if=/dev/sda of=/dev/null bs=1M count=1024
Write to disk: 38MB/s command: dd if=/dev/zero of=/dev/sda bs=1M count=1024

R64 hdd sata test.jpg

  • Test a SAMSUNG SSD DISK, the Read/Write performance are below:
Read from disk: 360MB/s command: dd if=/dev/sda of=/dev/null bs=1M count=1024
Write to disk: 200MB/s command: dd if=/dev/zero of=/dev/sda bs=1M count=1024

R64 ssd sata test.jpg

PCIe

  • If you want to use PCIe interface on R64, you need to give GPIO90 high level
    • echo 499 > /sys/class/gpio/export
    • echo out > /sys/class/gpio/gpio499/direction
    • echo 1 > /sys/class/gpio/gpio499/value
  • PCIe supports EC-25 4G module.

R64 pcie test 1.jpg

R64 pcie test 2.jpg

GMAC

Use iperf3 to test gmac

1. On PC Terminal:

  • Execute "iperf3 -s"

2. On R64 console:

  • TCP test: "iperf3 -c serverIP"
  • UDP test: "iperf3 -u -c serverIP"

R64 Gmac test.jpg

BT & BLE on R64

R64 BT Architectural

R64 BT Arch.jpg

  • BLE on R64
  • Input Command "btmw-test", you will enter to "btmw_test_cli" command line

R64 BT cli.jpg

  • Here are some example commands:
    • MW_GAP name 7622_BT /*rename bt device*/
    • MW_GAP info /*check local BT device info*/
    • MW_GATTC scan /* start ble scan*/
    • MW_GATTC stop_scan /* stop ble scan*/

R64 LAN Function

  • LAN eth interface is eth2, use "ifconfig eth2 up" to enable it.
  • Config the ip, "ifconfig eth2 192.168.1.1".
 R64 Lan test 1.jpg
  • Config your dhcp server, "vim /etc/dhcp/dhcpd.conf", add these configurations.
 R64 Lan test 2.jpg
  • Start dhcp server, "dhcpd eth2".
 R64 Lan test 3.jpg
  • then config iptables and set package forward.
    • Add "net.ipv4.ip_forward=1" to "/etc/sysctl.conf"
    • "/sbin/sysctl -p" to make forward work
    • "iptables -t nat -A POSTROUTING -s 192.168.1.1/24 -o eth3 -j MASQUERADE"

Ap mode on R64

  • Find "mt_wifi.ko" and insmod it.
    • insmod ./lib/modules/4.4.92-BPI-R64-Kernel/extra/mt_wifi.ko
  • Then you will see ra0 and rai0.
 R64 wifi test 1.jpg
  • ra0 is MT7622 2.4G wifi
  • rai0 is MT7615 5G wifi

2.4G WiFi

  • Use "ifconfig ra0 up" to enable it.
  • Config the ip, "ifconfig ra0 192.168.1.1".
  • Config your dhcp server, "vim /etc/dhcp/dhcpd.conf", add these configurations.
 R64 Lan test 2.jpg
  • Start dhcp server, "dhcpd ra0".
  • then config iptables and set package forward.
    • Add "net.ipv4.ip_forward=1" to "/etc/sysctl.conf"
    • "/sbin/sysctl -p" to make forward work
    • "iptables -t nat -A POSTROUTING -s 192.168.1.1/24 -o eth3 -j MASQUERADE"

5G WiFi

  • Use "ifconfig rai0 up" to enable it.
  • Config the ip, "ifconfig rai0 192.168.1.1".
  • Config your dhcp server, "vim /etc/dhcp/dhcpd.conf", add these configurations.
 R64 Lan test 2.jpg
  • Start dhcp server, "dhcpd rai0".
  • then config iptables and set package forward.
    • Add "net.ipv4.ip_forward=1" to "/etc/sysctl.conf"
    • "/sbin/sysctl -p" to make forward work
    • "iptables -t nat -A POSTROUTING -s 192.168.1.1/24 -o eth3 -j MASQUERADE"

FAQ

  • MT7622 Reference Manual for Develope Board(BPi)
Google Drive:https://drive.google.com/open?id=1UhaIM9ork1O9cNO-t6ENMVVamB75AThV
BaiDu Drive:https://pan.baidu.com/s/1KduFT2MUvMs2FhOF4A8kQQ

Reference Link

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