Difference between revisions of "Getting Started with R64"

From Banana Pi Wiki
Jump to: navigation, search
(BPI-R2 SATA interface)
(Prepare to develop)
 
(90 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
[[zh:快速上手 香蕉派 BPI-R64]]
 
[[zh:快速上手 香蕉派 BPI-R64]]
='''Introduction'''=
+
=Introduction=
 
+
[[File:Banana_Pi_BPI-R64_1.jpg|thumb|Overview:[[Banana Pi BPI-R64]]]]
 +
[[File:BPI-R64_case_1.jpg|thumb|[[Banana Pi BPI-R64]] Metal Jacket]]
 +
[[File:BPI-R64_PoE.JPG|thumb|BPI-R64 with BPI-7402 POE function support]]
 +
[[File:BPI-7402_IEEE_802.3at_PoE_module_1.jpg|thumb|[[BPI-7402 IEEE 802.3at PoE module]]]]
 +
[[File:5G_gateway_2.jpg|thumb|BPI:4.0 [[Successful case]] 5G Converged communication gateway]]
 +
[[File:Banana_pi_BPI-R1_1.JPG|thumb|[[Banana Pi BPI-R1]] Allwinner A20]]
 +
[[File:BPI-R2_3.JPG|thumb|[[Banana Pi BPI-R2]] with MTK MT7623N chip design]]
 +
[[File:Banana_Pi_BPI-R2_Pro_1_750.jpg|thumb|[[Banana Pi BPI-R2 Pro]] Rockchip RK3568 design]]
 +
[[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 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.
 
   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]]
 
Read more: [[Banana Pi BPI-R64]]
  
Line 21: Line 30:
 
* POE function support
 
* POE function support
  
==Hardware==
+
=Development=
='''Development'''=
 
Let's get start to develop on BPI-R2, see amazing things happen.
 
 
==Basic Development==
 
==Basic Development==
 
===Prepare to develop===
 
===Prepare to develop===
   * Prepare 16G/above TF card, USB-Serial interface, Ubuntu System
+
   * Prepare 8G/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 R64
 
+
  * Default IP address for LAN port: '''192.168.1.1'''
   [[Image:R2_debug_console.png|240px]]
+
   * User name/password: '''pi/bananapi''' ,'''root/bananapi'''.
 +
  Or the user is '''root without a password'''.
 +
  * WIFI: '''Operwrt'''
  
   * BananaPi R2 - Debug-UART :http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:debug-uart
+
   [[Image:R64_debug_console.jpg|320px]]
  
===Load your first image on R2===
+
===How to burn image to SD card===
 
   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:  
 
    
 
    
   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
Line 44: Line 53:
 
   * 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 R64, and press power button to setup R64
  
====Ubuntu On SD Card====
+
====How to burn image to onboard eMMC====
   1. Clone Bsp project from Github
+
   Before burning image to eMMC, please prepare a SD card with flashed bootable image and a USB disk. Let's take OpenWrt image (mtk-bpi-r64-preloader-emmc.bin,2020-04-09-OpenWRT-mtk-bpi-r64-EMMC.img) for example, the steps are below:
   * Execute "git clone git@github.com:BPI-SINOVOIP/BPI-R2-bsp.git"
+
   Note: You can download the .bin file from github: https://github.com/BPI-SINOVOIP/BPI-R64-openwrt/tree/master/staging_dir/target-aarch64_cortex-a53_musl/image
 
+
 
   2. Execute "./build.sh", to build your own uboot and kernel.
+
   1. Insert the flashed SD card and power on to start the board.(the image on the SD card can be OpenWrt or other linux OS like ubuntu...)
[[Image:R2_build_sh.png]]
+
 
 
+
   2. Copy eMMC bootable OpenWrt image(mtk-bpi-r64-preloader-emmc.bin,2020-04-09-OpenWRT-mtk-bpi-r64-EMMC.img) to USB disk, if the image is compressed please uncompress it before copying to USB disk.
  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:
 
 
 
    bpi-copy  <XXX.img.zip> /dev/mmcblk1
 
  
   * XXX.img.zip is ubuntu image we can get it from http://www.banana-pi.org/r2-download.html
+
   3. Plug in USB disk to the board, and mount the USB to /mnt or other directory as follows: (you can skip mounting if it is mounted automatically)
  * power off
+
    * mount -t vfat /dev/sda1 /mnt
  * remove SD & power on
+
    * change your directory to the mounting point, here is : cd /mnt
  
====OpenWrt On SD & Emmc Steps====
+
   4. Execute following command to enable and copy image to eMMC:
   1. Clone OpenWrt project from Github.
+
    * echo 0 > /sys/block/mmcblk0boot0/force_ro
  * Execute "git clone https://github.com/garywangcn/bpi-r2_lede.git"
+
    * dd if=2020-04-09-OpenWRT-mtk-bpi-r64-EMMC.img of=/dev/mmcblk0
 
+
    * dd if=mtk-bpi-r64-preloader-emmc.bin of=/dev/mmcblk0boot0
  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.
+
    * mmc bootpart enable 1 1   /dev/mmcblk0
 
 
  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.
 
  
* 1,Banana Pi R2 install openWRT: https://www.cnblogs.com/topbin/p/8794152.html
+
  5. Shutdown, remove SD card and USB disk, and restart the board from eMMC.
* 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 108: Line 80:
 
==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 113: Line 89:
 
* 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 129: Line 105:
 
* echo 1 >/sys/class/pwm/pwmchip0/pwmx/enable
 
* echo 1 >/sys/class/pwm/pwmchip0/pwmx/enable
  
More about GPIO : http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:gpio
+
====SPI touch panel====
 +
SPI Panel module:
 +
 
 +
2.4" Touch Screen TFT LCD with SPI Interface, 240x320 (ILI9341 + ADS7843/XPT2046/HR2046)
 +
 
 +
SPI Panel <–> BPIR64
 +
 
 +
T_DO, T_DIN, T_CLK <–> SPIC_0: MOSI / MISO / CLK
 +
T_CS <–> SPI-CE0
 +
T_IRQ <–> IO-37
 +
SDO, SCK, SDI <–> SPIC_1: MOSI / MISO / CLK
 +
LED <–> PIN-31
 +
DC <–> PIN-11
 +
RESET <–> PIN-13
 +
CS <–> SPI-CE1
 +
GND <–> GND-9
 +
VCC <–> 3.3V-1
 +
 
 +
DTS Modification:
 +
 
 +
/ {
 +
        backlight: backlight {
 +
                compatible = "gpio-backlight";
 +
                gpios = <&pio 82 GPIO_ACTIVE_HIGH>;        //PIN31 IO-31 : GPIO82
 +
                default-on;
 +
        };
 +
};
  
===Develop 4G module with R2===
+
&pio {
Gets more info from here:
+
        spic0_pins: spic0-pins {
 +
                mux {
 +
                        function = "spi";
 +
                        groups = "spic0_0";
 +
                };
 +
        };
 +
 +
        spic1_pins: spic1-pins {
 +
                mux {
 +
                        function = "spi";
 +
                        groups = "spic1_0";
 +
                };
 +
        };
 +
}
  
[[Using 4G module with BananaPi]]
+
&spi0 {
 +
        pinctrl-names = "default";
 +
        pinctrl-0 = <&spic0_pins>;
 +
        status = "okay";
 +
        touch@0 {
 +
                reg = <0>;                                //CE0
 +
                compatible = "ti,ads7843";
 +
                interrupt-parent = <&pio>;
 +
                interrupts = <86 0>;                      //PIN37: IO-37 == GPIO86
 +
                pendown-gpio = <&pio 86 0>;
 +
                spi-max-frequency = <1000000>;
 +
                vcc-supply = <&reg_3p3v>;
 +
                wakeup-source;
 +
        };
 +
};
  
===WiFi and Ap mode on R2 Ubuntu===
+
&spi1 {
====WiFi Client====
+
        pinctrl-names = "default";
* wmt_loader (ignore errors)
+
        pinctrl-0 = <&spic1_pins>;
* stp_uart_launcher -p /etc/firmware &
+
        status = "okay";
* ip link set wlan0 up
+
        display@0{
* iw dev wlan0 scan | grep SSID
+
                compatible = "ilitek,ili9341";
* vim /etc/wpasupplicant/wpa_supplicant.conf
+
                reg = <0>;                                //CE0
  network={  
+
                spi-max-frequency = <32000000>;
  ssid="ssid"  
+
                dc-gpios = <&pio 51 GPIO_ACTIVE_HIGH>;    //PIN11 UART1-TXD : GPIO51
  psk="password"   
+
                reset-gpios = <&pio 52 GPIO_ACTIVE_HIGH>;  //PIN13 UART1-RXD : GPIO52
  priority=1
+
                backlight = <&backlight>;
  }
+
        };
* wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
+
};
* dhclient wlan0
 
  
====AP mode====
+
Kernel config:
* 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
+
+CONFIG_FB_TFT_ILI9341
  bridge=br0
+
+CONFIG_FB_TFT
  ssid=test_r2
+
+CONFIG_FB
  driver=nl80211
+
+CONFIG_BACKLIGHT_LCD_SUPPORT
  country_code=US
+
+CONFIG_BACKLIGHT_CLASS_DEVICE
  hw_mode=b
+
+CONFIG_BACKLIGHT_GPIO
  channel=1
+
+CONFIG_INPUT
  max_num_sta=5
+
+CONFIG_INPUT_TOUCHSCREEN
  wpa=2     
+
+CONFIG_TOUCHSCREEN_ADS7846
  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:
+
Application:
  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”
+
{| class="wikitable"
 +
|-
 +
| Package  ||+ Description  || Source 
 +
|-
 +
|  fbv ||  framebuffer image viewer  ||  https://github.com/godspeed1989/fbv
 +
|-
 +
| input-event-daemon  ||  input-event-daemon with touchTEST event ||  https://github.com/SAM33/input-event-daemon
 +
|-
 +
|}
  
* Run hostapd : “hostapd -d /etc/hostapd/hostapd.conf”
+
input-event-daemon config that show image by touch area:
* Config dhcp file : “vim /etc/dhcp/dhcpd.conf”
+
(I don't know why are the coordinates so strange, but the result of my actual touch and
 +
print out that it is like this)
  
  subnet 192.168.30.0 netmask 255.255.255.0 {
+
[Global]
  range 192.168.30.2 192.168.30.250;
+
listen = /dev/input/event0
  option domain-name-servers 8.8.8.8;
+
listen = /dev/input/event1
  option routers 192.168.30.1; }
+
[TouchTEST]
 +
340,400,3440,1860 = cat /dev/zero > /dev/fb0; fbv -f /root/bpi_608x429.jpg -s 1
 +
340,2260,3440,1860 = cat /dev/zero > /dev/fb0; fbv -f /root/openwrt_449x449.png -s 1
  
* Config dhcp of ap0, then the devices which connect ap0 could get IP: "dhcpd ap0 -pf /var/run/dhcpd.pid "
+
Banana Pi BPI-R64 SPI touch panel test: https://www.youtube.com/watch?v=ikag-D_TI0g&feature=youtu.be
* 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===
+
===Sata===
====AP mode====
+
* '''If you want to use Sata interface on R64, you need to give GPIO90 low level'''
1. Make a bash script
+
** echo 499 > /sys/class/gpio/export
* vim setup.sh
+
** echo out > /sys/class/gpio/gpio499/direction
  #!/bin/ash
+
** echo 0 > /sys/class/gpio/gpio499/value
  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
+
*Test a TOSHIBA HDD DISK, the Read/Write performance are below:
* ./setup.sh
 
  
4. Add it to starting progress
+
::Read from disk: 50MB/s command: dd if=/dev/sda of=/dev/null bs=1M count=1024
* 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
+
::Write to disk: 38MB/s command: dd if=/dev/zero of=/dev/sda bs=1M count=1024
* tc qdisc add dev ap0 root handle 1: htb default 11
+
[[Image:R64_hdd_sata_test.jpg]]
* tc class add dev ap0 parent 1:1 classid 1:2 htb rate 8Mbit ceil 4Mbit prio 2
 
  
===Make your own image===
+
*Test a SAMSUNG SSD DISK, the Read/Write performance are below:
* 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
+
::Read from disk: 360MB/s command: dd if=/dev/sda of=/dev/null bs=1M count=1024
* 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"
+
::Write to disk:  200MB/s command: dd if=/dev/zero of=/dev/sda bs=1M count=1024
* Then you could get your own image now
+
[[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===
 +
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"
 +
[[Image:R64_Gmac_test.jpg]]
 +
 
 +
===BT & BLE on R64===
 +
'''R64 BT Architectural'''
 +
 
 +
[[Image:R64_BT_Arch.jpg]]
 +
 
 +
* BLE on R64
 +
* Input Command "btmw-test", you will enter to "btmw_test_cli" command line
 +
 
 +
[[Image: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".
 +
  [[Image:R64_Lan_test_1.jpg]]
 +
 
 +
* Config your dhcp server, "vim /etc/dhcp/dhcpd.conf", add these configurations.
 +
  [[Image:R64_Lan_test_2.jpg]]
 +
 
 +
* Start dhcp server, "dhcpd eth2".
 +
  [[Image: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.
 +
  [[Image: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.
 +
  [[Image: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.
 +
  [[Image: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==
 
==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/

Latest revision as of 23:21, 3 January 2024

Introduction

Banana Pi BPI-R64 Metal Jacket
BPI-R64 with BPI-7402 POE function support
BPI:4.0 Successful case 5G Converged communication gateway
Banana Pi BPI-R1 Allwinner A20
Banana Pi BPI-R2 with MTK MT7623N chip design
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 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(3.3V,Baud: 115200) Connect debug console on R64
 * 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.
 * WIFI: Operwrt
 R64 debug console.jpg

How to burn image to SD card

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

How to burn image to onboard eMMC

 Before burning image to eMMC, please prepare a SD card with flashed bootable image and a USB disk. Let's take OpenWrt image (mtk-bpi-r64-preloader-emmc.bin,2020-04-09-OpenWRT-mtk-bpi-r64-EMMC.img) for example, the steps are below:
 Note: You can download the .bin file from github: https://github.com/BPI-SINOVOIP/BPI-R64-openwrt/tree/master/staging_dir/target-aarch64_cortex-a53_musl/image
 1. Insert the flashed SD card and power on to start the board.(the image on the SD card can be OpenWrt or other linux OS like ubuntu...)
 2. Copy eMMC bootable OpenWrt image(mtk-bpi-r64-preloader-emmc.bin,2020-04-09-OpenWRT-mtk-bpi-r64-EMMC.img) to USB disk, if the image is compressed please uncompress it before copying to USB disk.
 3. Plug in USB disk to the board, and mount the USB to /mnt or other directory as follows: (you can skip mounting if it is mounted automatically)
    * mount -t vfat /dev/sda1 /mnt 
    * change your directory to the mounting point, here is : cd /mnt
 4. Execute following command to enable and copy image to eMMC:
    * echo 0 > /sys/block/mmcblk0boot0/force_ro
    * dd if=2020-04-09-OpenWRT-mtk-bpi-r64-EMMC.img of=/dev/mmcblk0
    * dd if=mtk-bpi-r64-preloader-emmc.bin of=/dev/mmcblk0boot0
    * mmc bootpart enable 1 1   /dev/mmcblk0
 5. Shutdown, remove SD card and USB disk, and restart the board from eMMC.

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

SPI touch panel

SPI Panel module:

2.4" Touch Screen TFT LCD with SPI Interface, 240x320 (ILI9341 + ADS7843/XPT2046/HR2046)

SPI Panel <–> BPIR64

T_DO, T_DIN, T_CLK <–> SPIC_0: MOSI / MISO / CLK
T_CS <–> SPI-CE0
T_IRQ <–> IO-37
SDO, SCK, SDI <–> SPIC_1: MOSI / MISO / CLK
LED <–> PIN-31
DC <–> PIN-11
RESET <–> PIN-13
CS <–> SPI-CE1
GND <–> GND-9
VCC <–> 3.3V-1

DTS Modification:

/ {
       backlight: backlight {
               compatible = "gpio-backlight";
               gpios = <&pio 82 GPIO_ACTIVE_HIGH>;        //PIN31 IO-31 : GPIO82
               default-on;
       };
};
&pio {
       spic0_pins: spic0-pins {
               mux {
                       function = "spi";
                       groups = "spic0_0";
               };
       };

       spic1_pins: spic1-pins {
               mux {
                       function = "spi";
                       groups = "spic1_0";
               };
       };
}
&spi0 {
       pinctrl-names = "default";
       pinctrl-0 = <&spic0_pins>;
       status = "okay";
       touch@0 {
               reg = <0>;                                 //CE0
               compatible = "ti,ads7843";
               interrupt-parent = <&pio>;
               interrupts = <86 0>;                       //PIN37: IO-37 == GPIO86
               pendown-gpio = <&pio 86 0>;
               spi-max-frequency = <1000000>;
               vcc-supply = <&reg_3p3v>;
               wakeup-source;
       };
};
&spi1 {
       pinctrl-names = "default";
       pinctrl-0 = <&spic1_pins>;
       status = "okay";
       display@0{
               compatible = "ilitek,ili9341";
               reg = <0>;                                 //CE0
               spi-max-frequency = <32000000>;
               dc-gpios = <&pio 51 GPIO_ACTIVE_HIGH>;     //PIN11 UART1-TXD : GPIO51
               reset-gpios = <&pio 52 GPIO_ACTIVE_HIGH>;  //PIN13 UART1-RXD : GPIO52
               backlight = <&backlight>;
       };
};

Kernel config:

+CONFIG_FB_TFT_ILI9341
+CONFIG_FB_TFT
+CONFIG_FB
+CONFIG_BACKLIGHT_LCD_SUPPORT
+CONFIG_BACKLIGHT_CLASS_DEVICE
+CONFIG_BACKLIGHT_GPIO
+CONFIG_INPUT
+CONFIG_INPUT_TOUCHSCREEN
+CONFIG_TOUCHSCREEN_ADS7846

Application:

Package + Description Source
fbv framebuffer image viewer https://github.com/godspeed1989/fbv
input-event-daemon input-event-daemon with touchTEST event https://github.com/SAM33/input-event-daemon

input-event-daemon config that show image by touch area: (I don't know why are the coordinates so strange, but the result of my actual touch and print out that it is like this)

[Global]
listen = /dev/input/event0
listen = /dev/input/event1
[TouchTEST]
340,400,3440,1860 = cat /dev/zero > /dev/fb0; fbv -f /root/bpi_608x429.jpg -s 1
340,2260,3440,1860 = cat /dev/zero > /dev/fb0; fbv -f /root/openwrt_449x449.png -s 1

Banana Pi BPI-R64 SPI touch panel test: https://www.youtube.com/watch?v=ikag-D_TI0g&feature=youtu.be

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/