Difference between revisions of "快速上手 BPI-W2"

From Banana Pi Wiki
Jump to: navigation, search
(Introduction)
(Development)
Line 10: Line 10:
 
关于更多: [[Banana Pi BPI-W2]]
 
关于更多: [[Banana Pi BPI-W2]]
  
=Development=
+
=开发=
Let's get start to develop on BPI-W2, see amazing things happen.
+
==基础开发==
==Basic Development==
+
===开发前准备===
===Prepare to develop===
+
* 准备一张容量不低于8Gb的TF卡, USB-Serial 串口线, 一台运行Ubuntu系统的PC机
 
+
* 使用你的串口线去连接W2的调试串口
  
 
===Load your first image on W2===
 
===Load your first image on W2===
 +
1.你可以从下面链接下载最近的镜像
 +
* http://forum.banana-pi.org/t/bananapi-w2-ubuntu-18-04-new-image-release-2018-09-17/6790
 +
 +
2.在你的Ubuntu系统电脑上安装bpi-tools, 执行以下命令即可安装:
 +
* apt-get install pv
 +
* curl -sL https://github.com/BPI-SINOVOIP/bpi-tools/raw/master/bpi-tools | sudo -E bash
 +
 +
3.下载完镜像后, 插入TF卡到你的Ubuntu电脑中
 +
* 运行命令 "bpi-copy xxx.img /dev/sdx" 烧录镜像到你的TF卡中.
 +
 +
4.烧录完成后, 把TF卡插到W2中, 按住W2的电源键启动W2.
  
 +
===构建W2镜像===
 +
====在SD卡上制作bootloader====
  
===Build your own image on W2===
+
由SW4控制, W2有两种启动方式
====How to make a SD card with bootloader====
 
 
 
there are two ways to boot w2, controlled by SW4
 
  
 
[[File:Bootsw4.jpg]]
 
[[File:Bootsw4.jpg]]
  
*0 boot from emmc.
+
*0 emmc 启动.
*1 boot from SPI + SD card.
+
*1 SPI + SD 启动.
 
 
After power on, there are 3 steps must be done before loading kernel,(Normally they all are called bootloader):
 
 
 
*step 1: CPU init - the code is inside CPU;
 
*step 2: init the flash device on which we boot from; (normally it’s called preloader)
 
*step 3: u-boot;
 
  
RTD1296 supports booting from eMMC and SPI flash, so if we want to boot W2 from SD card, (that means we put u-boot on the SD card.) the second step code must be written to SPI flash, normally it’s done in factory before the board sending out, and the code is fixed and provided by RTK without source. We need not care about it, it does a simple job.
+
打开W2的电源后, 这里需要三个步骤来加载内核, 通常这三个步骤被称作bootloader
  
In fact, if the board will boot from eMMC, the second code must be written to eMMC first too, remember that we introduced how to do it with u-boot together on other pages. Normally it’s also been done in factory.
+
*第一步 1: CPU 初始化 - 这份代码属于CPU内部;
 +
*第二步 2: 初始化我们要启动的Flash 通常这步被称作preloader
 +
*第三步 3: u-boot;
  
The u-boot for eMMC and SD card are different, normally eMMC u-boot 's name is '''dvrboot.exe.bin''', and u-boot for SD card name is '''u-boot.bin'''.
+
RTD1296 支持从 eMMC 和 SPI flash 启动, 因此如果你想要从sd卡启动W2, (这意味着我们把 u-boot 放进 SD 中.) 第二步的代码必须要写到 SPI flash中, 通常工厂需要把这一步做好.
 +
实际上, 如果W2从eMMC启动, 第二步的代码需要写道eMMC, 请留意这里我们在介绍怎么烧录uboot, 通常这一步也是工厂做好.
 +
在eMMC和SD卡中的uboot是不同的, 通常eMMC的uboot名称为'''dvrboot.exe.bin''', SD卡的uboot名称为'''u-boot.bin'''.
  
Write u-boot to SD card
+
把uboot写入SD卡
  
The u-boot file for booting from SD card is here: https://drive.google.com/drive/folders/17ShSHLOvxeYA6tI9HQXOAb3O7RjqfD_6?usp=sharing
+
SD的uboot相关资料在这里: https://drive.google.com/drive/folders/17ShSHLOvxeYA6tI9HQXOAb3O7RjqfD_6?usp=sharing
  
*step 1: build a SD card system according:
+
*第一步 1: 编译SD卡系统:
 
::2.1.3.2.1 How to make and run the 64-bit ubuntu 16.04 on SD card 2018-4-28
 
::2.1.3.2.1 How to make and run the 64-bit ubuntu 16.04 on SD card 2018-4-28
  
*step 2: boot up the board with eMMC and press ‘Esc’ key to let board stays on u-boot prompt;  
+
*第二步 2: boot up the board with eMMC and press ‘Esc’ key to let board stays on u-boot prompt;  
*step 3: using tftp to get u-boot.bin file from network;
+
*第三步 3: using tftp to get u-boot.bin file from network;
 
       tftp 0x1500000 u-boot.bin
 
       tftp 0x1500000 u-boot.bin
 
*step4: using sd command to write it to SD card:
 
*step4: using sd command to write it to SD card:

Revision as of 20:49, 12 October 2018

介绍

Overview: BPI-W2 Android 6.0

关于更多: Banana Pi BPI-W2

开发

基础开发

开发前准备

  • 准备一张容量不低于8Gb的TF卡, USB-Serial 串口线, 一台运行Ubuntu系统的PC机
  • 使用你的串口线去连接W2的调试串口

Load your first image on W2

1.你可以从下面链接下载最近的镜像
* http://forum.banana-pi.org/t/bananapi-w2-ubuntu-18-04-new-image-release-2018-09-17/6790

2.在你的Ubuntu系统电脑上安装bpi-tools, 执行以下命令即可安装:
* apt-get install pv
* curl -sL https://github.com/BPI-SINOVOIP/bpi-tools/raw/master/bpi-tools | sudo -E bash

3.下载完镜像后, 插入TF卡到你的Ubuntu电脑中
* 运行命令 "bpi-copy xxx.img /dev/sdx" 烧录镜像到你的TF卡中.

4.烧录完成后, 把TF卡插到W2中, 按住W2的电源键启动W2.

构建W2镜像

在SD卡上制作bootloader

由SW4控制, W2有两种启动方式

Bootsw4.jpg

  • 0 从 emmc 启动.
  • 1 从 SPI + SD 启动.

打开W2的电源后, 这里需要三个步骤来加载内核, 通常这三个步骤被称作bootloader

  • 第一步 1: CPU 初始化 - 这份代码属于CPU内部;
  • 第二步 2: 初始化我们要启动的Flash 通常这步被称作preloader
  • 第三步 3: u-boot;

RTD1296 支持从 eMMC 和 SPI flash 启动, 因此如果你想要从sd卡启动W2, (这意味着我们把 u-boot 放进 SD 中.) 第二步的代码必须要写到 SPI flash中, 通常工厂需要把这一步做好. 实际上, 如果W2从eMMC启动, 第二步的代码需要写道eMMC, 请留意这里我们在介绍怎么烧录uboot, 通常这一步也是工厂做好. 在eMMC和SD卡中的uboot是不同的, 通常eMMC的uboot名称为dvrboot.exe.bin, SD卡的uboot名称为u-boot.bin.

把uboot写入SD卡

SD的uboot相关资料在这里: https://drive.google.com/drive/folders/17ShSHLOvxeYA6tI9HQXOAb3O7RjqfD_6?usp=sharing

  • 第一步 1: 编译SD卡系统:
2.1.3.2.1 How to make and run the 64-bit ubuntu 16.04 on SD card 2018-4-28
  • 第二步 2: boot up the board with eMMC and press ‘Esc’ key to let board stays on u-boot prompt;
  • 第三步 3: using tftp to get u-boot.bin file from network;
      tftp 0x1500000 u-boot.bin
  • step4: using sd command to write it to SD card:
      sd write 0x1500000 0x50 0x3f0
  • forum pthread
http://forum.banana-pi.org/t/how-to-make-a-sd-card-with-bootloader/5767

Ubuntu

How to make and run the 64-bit ubuntu 16.04 on SD card 2018-4-28

1.Requirement:

  • 1.A PC with ubuntu as the host;
  • 2.A banana Pi W2 board;
  • 3.A SD card;
  • 4.Downloaded latest ubuntu base tar file (ubuntu-base-16.04.4-base-arm64.tar.gz) from url:
http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ 17
  • 5.Hardware configuration file, u-boot binary file, kernel image file and audio file, which can be downloaded from:
https://drive.google.com/file/d/1LX4FwXcSzkuI4BUPEVxbUyeG_UYwIkwY/view?usp=sharing 17
oRTD1296_hwsetting_BOOT_4DDR4_4Gb_s1866_padding.bin – hardware config
odvrboot.exe.bin – u-boot binary
ouImage – kernel image
obluecore.audio – audio and video firmware for RTK1296

2.Write the bootloader to the Banana Pi W2 flash:

Banana Pi W2 board can boot from EMMC flash or SPI flash on the board, the difference is the location of the bootloader, so if you will not participate in the development of u-boot, this will not matter to you. So here is how to write bootloader to EMMC.

Normally the W2 board you got had been programed in the factory, but if the version of the bootloader isn’t the latest one, I recommend you to program it by yourself again. The latest version of bootloader is available on the Banana Pi website.

Requirement:

  • 1.A windows PC runs serial terminal tool like hypertrm. (I recommend using “hypertrm”, because other tools sometimes fail to transmit data);
  • 2.Latest version u-boot binary file from Banana Pi website (dvrboot.exe.bin);
  • 3.A hardware configuration binary file for W2 (RTD1296_hwsetting_BOOT_4DDR4_4Gb_s1866_padding.bin);

Steps:

  • 1.Connect the serial port between the host and the board correctly, run the terminal software and set up the relevant parameters (115200, 8N1, none);
  • 2.press “ctrl+q” then to power on the board, and when the screen appears’ d/g/r ', it can be released;
  • 3.Input “h” and send hardware configuration binary files (RTD1296_hwsetting_BOOT_4DDR4_4Gb_s1866_padding.bin) in Y-modem mode on the terminal side.
  • 4.Wait for the transfer to complete, then input below in console:
s98007058
01500000
  • 5.Input “d” and send u-boot binary files (dvrboot.exe.bin) in Y-modem mode on the terminal side.
  • 6.Wait for the transmission to complete. Enter “g” then the u-boot will be programed to the EMMC automatically.

3.Make a ubuntu root file system for W2 on a ubuntu PC.

Ubuntu has the version for arm64 architecture, it’s suitable for the Banana Pi W2, most of packages built by ubuntu for arm64 can run on the W2 board.

Requirement:

Steps: (on the host):

  • 1.mkdir rootfs
  • 2.su root
  • 3.tar zxvf ubuntu-base-16.04.4-base-arm64.tar.gz -C rootfs
  • 4.write a shell script file, please copy below contents to the file ch-mount.sh (vi ch-mount.sh and copy):
!/bin/bash
function mnt() {
    echo "MOUNTING"
    sudo mount -t proc /proc ${2}proc
    sudo mount -t sysfs /sys ${2}sys
    sudo mount -o bind /dev ${2}dev
    sudo mount -o bind /dev/pts ${2}dev/pts        
    sudo chroot ${2}
}
function umnt() {
    echo "UNMOUNTING"
    sudo umount ${2}proc
    sudo umount ${2}sys
    sudo umount ${2}dev/pts
    sudo umount ${2}dev
}
if [ "$1" == "-m" ] && [ -n "$2" ] ;
then
    mnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
then
    umnt $1 $2
else
    echo ""
    echo "Either 1'st, 2'nd or both parameters were missing"
    echo ""
    echo "1'st parameter can be one of these: -m(mount) OR -u(umount)"
    echo "2'nd parameter is the full path of rootfs directory(with trailing '/')"
    echo ""
    echo "For example: ch-mount -m /media/sdcard/"
    echo ""
    echo 1st parameter : ${1}
    echo 2nd parameter : ${2}
fi
  • 5.apt-get install qemu-user-static
  • 6.cp /usr/bin/qemu-aarch64-static rootfs/usr/bin
  • 7.cp -b /etc/resolv.conf rootfs/etc/
  • 8../ch-mount.sh -m rootfs/
  • 9.apt-get install iputils-ping
  • 10.apt-get install udev
  • 11.apt-get install net-tools
  • 12.Modify the root password by running: “passwd root”
  • 13.exit
  • 14../ch-mount.sh -u rootfs/

Until now, the ubuntu file system have been built successfully on the host, next we will write it to the SD card.

4.Write the system to the SD card (on the host):

Requirement:

  • 1.A SD card;
  • 2.Device tree binary file downloaded from Banana Pi website: bpi-w2.dtb;
  • 3.Kernel image file downloaded from Banana Pi website: uImage;
  • 4.Video and Audio firmware file downloaded from Banana Pi website: bluecore.audio;

Steps:

  • 1.Using fdisk tool to create two partitions in SD card: format the first partition as FAT32, and the second partition as ext4; It’s recommended that the first partition size should not be less than 100M;
  • 2.Copy the three files: bpi-w2.dtb, uImage, bluecore.audio to the first partition;
  • 3.Copy the all files in root filesystem which just built by us to the second partition using root privilege:
cp -a rootfs/* /media/xxx/sdxx/
sync
  • 4.Eject the SD card and insert it to the W2 board, after power on the board, you can see the ubuntu is running now.
  • 5.Set up network and get packages by using apt-get from ubuntu repository

Steps:

  • 1.Log in with root and the password was set by yourself;
  • 2.Ifconfig eth0 or eth1: ifconfig eth1 192.168.2.231
  • 3.Add default gateway to let the board can reach internet: route add default gw 192.168.2.1
  • 4.Add a DNS: echo ‘nameserver 8.8.8.8’ >> /etc/resolv.conf
  • 5.apt-get update
  • 6.then you can fetch and install any packages from ubuntu by using apt-get.

6.Furthermore:

Some functions are not available on the W2 now, because the kernel is not fully functional, we are working hard to make it more and more complete, please follow our official website update.

PDF format file download

http://forum.banana-pi.org/uploads/default/original/2X/c/c6dc409abc249c57a4cb2b7aedaddec6b80a9026.pdf

Ubuntu 16.04 Install and run Node.js and http-server
  • insltall Node.js
After running Ubuntu 16.04, it's easy to install packages on the W2. Please follow below steps to install node.js:
   1.  apt-get install nodejs
   2.  apt-get install npm
   3.  npm install -g http-server
   4. make a link to nodejs:  cd /usr/bin/; ln -sf nodejs node

then Node.js is ready on your system.

OpenWrt

Burn OpenWRT with Linux kernel 4.4

1.About this release

This release is for banana pi W2 board to run OpenWRT,you will know how to burn and run OpenWRT on W2.

2.Burn OpenWRT on W2 steps:

The Bootloader of OpenWRT is u-boot64, there are two ways to burn it on W2 EMMC.

A. Use RTK MP_Tool burn uboot on W2:

1)You need these files and tool:

  • MP_Tool
  • RTD1296_hwsetting_BOOT_4DDR4_4Gb_s1866.config(hardware configuration file)
  • dvrboot.exe.bin(u-boot binary file)

2)Connect W2 debug console to windows PC,and run MP_Tool:

Burun openwrt.jpg

  • Set your console parameters
  • Choose config file and uboot file
  • Choose "LK option"
  • Click Wirte button and then power on W2, and waiting for response "OK"

B. Use hypertrm burn uboot on W2:

1)You need these files and tool:

  • hypertrm
  • RTD1296_hwsetting_BOOT_4DDR4_4Gb_s1866_padding.bin(hardware configuration binary file)
  • dvrboot.exe.bin(u-boot binary file)

2)Connect W2 debug console to windows PC:

  • Run hypertrm ,config console parameters right
  • Holding on press “ctrl + q” and power on board,after the screen show “d/g/r”,then loose “ctrl + q”
  • Input “h”,use Y-modem way to send “RTD1296_hwsetting_BOOT_4DDR4_4Gb_s1866_padding.bin” to W2 board
  • After finish transferred,input these parameters:
 ::s98007058  
 ::01500000
  • Input “d”,and send u-boot binary file
  • after finish transferred,input “g” to burn u-boot file on W2 EMMC

After succeed to burn u-boot on W2, then install OpenWRT on W2.

1)You need these tools and files:

  • U disk
  • install.img

2)Burn OpenWRT on W2 steps:

  • Format U disk as FAT32 filesystem
  • Copy install.img to U disk root directory
  • Decompress install.img to get four files:
  emmc.uImage
  rescue.root.emmc.cpio.gz_pad.img
  bluecore.audio
  rescue.emmc.dtb
  • Plug U disk to W2 USB3.0 interface,holding press “Esc” button to power on W2 board
  • Then W2 board will go into u-boot console
  • Input these commands step by step:
  setenv bootargs "earlycon=uart8250,mmio32,0x98007800 console=ttyS0,115200 loglevel=7
  
  init=/etc/init root=/dev/mmcblk0p1 rootfstype=squashfs rootwait"
  save
  go ru
  • Waiting for OpenWRT burning,after finished,W2 will reboot and go into OpenWRT system.

Burun openwrt 1.jpg

3.Image & Tools link:

Baidu Drive: https://pan.baidu.com/s/1Rs9F46wNJibORaeCfVh4wg PinCode:1w4w

Google Drive:https://drive.google.com/file/d/10kfP142Jw0sA92uwaIYZt7CeXcDKelO1/view?usp=sharing

4.BPI-W2 run OpenWRT video:

https://youtu.be/eTaRy8Jnfpk

Advanced Development

GPIO

GPIO Control

PWM Control

Develop 4G module with W2

WiFi and Ap mode on W2

WiFi Client

AP mode

Make your own image

FAQ