Edge Developer Board

Last updated 2 months ago

Introduction

Product Overview

The Bitmain SophonTM Edge Developer Board(EDB) is designed for bringing powerful Deep Learning capability to various type of applications through its quick prototype development. Sophon Edge Developer Board is powered by BM1880, which equips tailored TPU supporting DNN/CNN/RNN/LSTM operations and models. The edge developer board is compatible with Linaro 96boards while supporting modules for Arduino and Raspberry Pi. Developers can leverage off-the-shelf modules and develop cutting edge DL/ML applications, like facial detection and recognition, facial expression analysis, object detection and recognition, vehicle license plate recognition, voiceprint recognition, etc.

Product Features

  • Supports DNN/CNN/RNN/LSTM models profiling, compiling and tuning

  • Real-time inference in edge device

  • Quickly deploy existing DNN/CNN/RNN/LSTM models or uniquely trained networks

  • Features Bitmain SophonTM BM1880 with energy efficient DNN/CNN/RNN/LSTM processing

  • Compatible to 96Boards Consumer Edition Spec.

  • Support Caffe, ONNX, Pytorch, Tensorflow framework

  • Support ResNet50, Yolo V2, GoogleNet V1, MobileNet v1/v2, SSD300, Alexnet, VGG16… etc

Developer Board Specification

Processor

Sophon BM1880

System Memory

LPDDR4 1GB

Flash Memory

8GB eMMC + micro SD card slot

Connectivity

Gigabit Ethernet(RJ-45), Wi-Fi, Bluetooth

USB

USB 3.0 x 3 (support camera, U-disk..etc)

I/O Expansion

40-pin 96Boards low-speed expansion header

Audio

I2S x 2 (included in 40-pin header)

H.264 decoder, MJPEG encoder/decoder

1x 1080p @60fps or 2x 1080p @30fps H.264 decoder, 75fps for FHD images

Toolkit

  • BMNet: Bitmain Compiler which can convert supported AI models to internal format accelerated by Sophon TPU.

  • ONNX: Compiler which can convert ONNX format to internal format accelerated by Sophon TPU.

  • Quantization Tool: Convert FP32 to INT8 and support calibration function

Get Started

Edge Developer Board(EDB) is designed to work in two mode, we called it USB mode and SoC mode.

Setup the Edge Developer Board(EDB) by following the steps provided below.

USB Mode

Step 1: Prepare Your Equipment

In USB mode, Edge Developer Board(EDB) as a USB device role, BMNNSDK is installed on the X86 host, and calling EDB’s computing for deep learning, the environment requirement are as follows.

  • Hardware environment: X86_64 host with usb port

  • Bitmain SophonTM Edge Developer Board(EDB)

  • Operating system: Ubuntu* 16.04 operating system, or Ubuntu VMware instance

  • Package: libgoogle-glog-dev、libboost-all-dev、libprotobuf-dev, libusb-1.0-0-dev

  • Bitmain Sophon Neural Network Software Development Kit (SDK), such as bmtap2-bm1880-usb-x.y.z.tar.gz or bmtap2-bm1880-usb_x.y.z.run, you can download the compression package from https://www.sophon.cn/drive/36.html

  • Set the DIP switch to bit[1:8]=11000001 to config the usb port work in device mode.

Step 2:Install the BMNNSDK

You can execute below commands to install package

$ sudo apt-get install libgoogle-glog-dev libboost-all-dev libprotobuf-dev libusb-1.0-0-dev

There are two ways to install BMNSDK, you can have a choice you like

Compression package installation

Compression package include installation script, please copy the compression package to x86, unzip and execute the script install.sh.

$ tar zxvf bmtap2-bm1880-usb-x.y.z.tar.gz
$ cd bmtap2-bm1880-usb-x.y.z
$ sudo ./install.sh

The script will install the BMNNSDK to default directory: /opt/bmtap2, and Symbolic Link will be created in the system content:

// you will see the installation folder in the/opt/bmtap2 after successful installation
$ ls /opt/bmtap2
// symbolic link will be found in /usr/bin、/usr/lib、/usr/include
$ ls -alh /usr/bin/bm*
$ ls –alh /usr/lib/bm*
$ ls –alh /usr/include/bmtap2
// if the host has BM1880 NNS,you will find device fold in the directory/dev
$ ls /dev/ttyACM*
/dev/ttyACM0

To uninstall the BMNNSDK ,simply execute the uninstall script in the installation directory.

$ sudo /opt/bmtap2/bm1880-usb-x.y.z/uninstall.sh

Package Installation

Installation package is a self-extracting file that can be run directly. Please copy the installation package to x86 host and run it.

$ chmod +x bmtap2-bm1880-usb_x.y.z.run
$ sudo ./bmtap2-bm1880-usb -x.y.z.run

The installation package will install the BMNNSDK to default directory: /opt/bmtap2, and Symbolic Link will be created in the system content, it also will automatically compile and load the BM1880’s USB device by DKMS, which will drive the bmdnn.ko:

// you will see the installation folder in the directory /opt/bmtap2 after successful installation
$ ls /opt/bmtap2
// symbolic link will be found in /usr/bin、/usr/lib、/usr/include
$ ls -alh /usr/bin/bm*
$ ls –alh /usr/lib/bm*
$ ls –alh /usr/include/bmtap2
// if the host has BM1880 NNS, you will find the device file in the /dev directory
$ ls /dev/ttyACM*
/dev/ttyACM0

To uninstall the BMNNSDK ,simply execute the uninstall script in the installation directory.

$ sudo /opt/bmtap2/bm1880-usb-x.y.z/uninstall.sh

Step 3: Basic function testing

The Basic function testing use the network model and data include in the installation package for Neural Network inference, the test results will be output to the out subdirectory of the current directory, please make sure that the user has the write rights to the current directory.

$ source /opt/bmtap2/bm1880-<Mode>-x.y.z /test/test_bmnet.sh
$ mkdir out
$ run_test_bmnet_bm1880

The test results are as follow:

# run_test_bmnet_bm1880
begin to test net: mtcnn det1 <1,3,12,12>
<CMD> test_bmnet_bmodel /opt/bmtap2/bm1880-usb_1.0.1/test/../models/mtcnn/det1_input_1_3_12_12.bin /opt/bmtap2/bm1880-usb_1.0.1/test/../models/mtcnn/det1_1_3_12_12.bmodel out//det1_output.bin 1 3 12 12
input size: 432
WARNING: Logging before InitGoogleLogging() is written to STDERR
I1026 19:41:03.865362 2635 bm_firmware.cpp:76] check firmware status ...
I1026 19:41:03.865628 2635 bm_firmware.cpp:82] firmware loading ...
I1026 19:41:03.929674 2635 bm_firmware.cpp:47] firmware load success
I1026 19:41:08.937716 2635 bm_firmware.cpp:98] firmware is running
I1026 19:41:08.937757 2635 bm_device.cpp:104] device[0] opened,gmem_size : 0x40000000
output size:6
outputs[0]: [1,4,1,1], "conv4-2"
outputs[1]: [1,2,1,1], "conv4-1"
test_bmnet_bmodel: load 107 us, run 106 us, read 76 us
('/opt/bmtap2/bm1880-usb_1.0.1/test/../models/mtcnn/det1_output_1_3_12_12_ref.bin', ' vs. ', 'out//det1_output.bin')
Result matched @ epsilon = 0.000000
det1<1,3,12,12> passed
begin to test net: mobilenet mobilenet <1,3,224,224>
<CMD> test_bmnet_bmodel /opt/bmtap2/bm1880-usb_1.0.1/test/../models/mobilenet/mobilenet_input_1_3_224_224.bin /opt/bmtap2/bm1880-usb_1.0.1/test/../models/mobilenet/mobilenet_1_3_224_224.bmodel out//mobilenet_output.bin 1 3 224 224
input size: 150528
WARNING: Logging before InitGoogleLogging() is written to STDERR
I1026 19:41:09.092887 2662 bm_firmware.cpp:76] check firmware status ...
I1026 19:41:09.093133 2662 bm_firmware.cpp:85] firmware is running
I1026 19:41:09.093152 2662 bm_device.cpp:104] device[0] opened,gmem_size : 0x40000000
output size:1000
outputs[0]: [1,1000,1,1], "fc7"
test_bmnet_bmodel: load 3773 us, run 2820 us, read 222 us
('/opt/bmtap2/bm1880-usb_1.0.1/test/../models/mobilenet/mobilenet_output_1_3_224_224_ref.bin', ' vs. ', 'out//mobilenet_output.bin')
Result matched @ epsilon = 0.000000
mobilenet<1,3,224,224> passed
test_bmnet_bm1880 success

SoC Mode

Step 1: Prepare Your Equipment

In SoC mode, EDB works as a host role, BMNNSDK is installed on the BM1880 Edge Developer Board(EDB), use the computing resources on the BM1880 SoC board to accelerate the deep learning calculation.

Step 2:Install the BMNNSDK

The environment requirements are as follows.

  • Hardware environment:

    • BM1880 Edge Developer Board(EDB)

    • 5V@2A or 12V@2A power adapter

  • Operating system:BM1880 Linux Release(You can download from:https://www.sophon.cn/drive/36.html or use the git clone command below)

  • Set the DIP switch to bit[1:8]=10100010 to config the usb OTG port work in host mode.(SD boot mode)

https://github.com/BM1880-BIRD/bm1880-system-sdk.git

and now, BMNNSDK soc mode had included in bm1880-system-sdk, while you setup the linux environment finished, the BMNNSDK soc mode installed also.

Step 3: Basic function testing

The Basic function testing use the network model and data include in the installation package for Neural Network inference, the test results will be output to the out subdirectory of the current directory, please make sure that the user has the write rights to the current directory.

git clone https://github.com/BM1880-BIRD/bm1880-ai-demo-program.git

copy bmtap2-bm1880-soc_basic_test folder to rootfs of bm1880 edge development board, and then

ldconfig
cd /system/data
./load_driver.sh
cd bmtap2-bm1880-soc_basic_test/test
./test_bmnet.sh

The test results are as follow:

./test_bmnet.sh
BMNET_OUT_PATH = out/
begin to test net: mtcnn det1 <1,3,12,12>
<CMD> ../bin/test_bmnet_bmodel /workspace/bmtap2-bm1880-soc_1.0.3.1/test/../models/mtcnn/det1_input_1_3_
Runtime Version : [1.0.3]
input size: 432
output size:6
outputs[0]: [1,4,1,1], "conv4-2"
outputs[1]: [1,2,1,1], "conv4-1"
test_bmnet_bmodel: load 5 us, run 85 us, read 9 us
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0101 09:18:24.895155 360 bm_device_soc.cpp:216] device[0] closed
*** Similarity: 1.0 (6/6)
det1<1,3,12,12> passed
begin to test net: mobilenet mobilenet <1,3,224,224>
<CMD> ../bin/test_bmnet_bmodel /workspace/bmtap2-bm1880-soc_1.0.3.1/test/../models/mobilenet/mobilenet_i
Runtime Version : [1.0.3]
input size: 150528
output size:1000
outputs[0]: [1,1000,1,1], "fc7"
test_bmnet_bmodel: load 114 us, run 2566 us, read 11 us
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0101 09:18:24.947519 362 bm_device_soc.cpp:216] device[0] closed
*** Similarity: 1.0 (1000/1000)
mobilenet<1,3,224,224> passed
test_bmnet_bm1880 success

Setup EDB's Linux ENV

Our EDB can support three boot mode you can select it by setting the switch on board

Download boot

To download the latest version of the release package , please visit the website https://github.com/BM1880-BIRD/ .

https://github.com/BM1880-BIRD/bm1880-system-sdk.git

Released package includes:

  • fip.bin : bootloader and uboot package

  • sdboot.itb : Linux kernel image (SD boot mode)

  • rootfs : rootfs for sd boot (on TF-card)

  • bm_update.img (eMMC boot mod)

Boot Modes

EDB supports SD boot, eMMC boot, Boot modes can be selected by the switch SW1

  • BOOT_SEL[2:0] = 3’b101: loading linux kernel from SD card.

  • BOOT_SEL[2:0] = 3’b100: loading linux kernel from eMMC.

SD Boot

(1) Download SD boot files form github (https://github.com/BM1880-BIRD/bm1880-system-sdk/tree/master/install/soc_bm1880_asic_edb) .

(2) Mount TF card to ubuntu system,format TF card and make two partitions: IMAGES partition(FAT file system, 128MB), rootfs partition (EXT4 file system, 3GB or more). You can refer the file "sd_create_rootfs.sh" (https://github.com/BM1880-BIRD/bm1880-system-sdk/tree/master/build/sd_tools).

~$sudo apt install expect
~$sudo sd_create_rootfs_sd.sh /dev/sdb
~$ sudo fdisk -l /dev/sdb
/dev/sdb1 on /media/bitmain/IMAGES type vfat
/dev/sdb2 on /media/bitmain/rootfs type ext4

(3) Copy the files to the sd partitions.

~$cd edb_sd_boot
~$cp fip.bin sdboot.itb /media/bitmain/IMAGES ; sync
~$sudo cp -fr rootfs/* /media/bitmain/rootfs; sync

(4) Select boot mode as SD boot, insert TF card to start Linux system.

eMMC Boot

Get eMMC programmer tool.

The toolkit you downloaded included files as below:

bm_programmer
├── bm1880_usb_dl.py
├── bm_dl_magic.bin
├── bm_update.img
├── prg.bin
└── u-boot.bin

Download pre-build image bm_update.img to eMMC on EDB, the steps as below:

  1. Set the DIP switch to 11000001.

  2. Connect the OTG port to your ubuntu PC with male to male USB cable.

  3. Connect uart port on EDB to you ubuntu PC with micro USB cable.

  4. Power onthe EDB board

you can see the boot log:

NOTICE: Booting Trusted Firmware
NOTICE: BL1: v1.4(debug):bm1880 ROM v1
NOTICE: BL1: Built : 20:13:19, Jul 5 2018
Hit any key to stop autoboot: 0
NOTICE: BL1: fip_src 6
NOTICE: bm_usb_boot_config 30b10
NOTICE: bm_usb_vid 30b1
NOTICE: bm_usb_hw_init done
NOTICE: by pass USB phy detection
NOTICE: fip_src 6

Now you can start the eMMC programmer on ubuntu x86 host, it will spend about 2-3 minutes:

$cd bm_programmer
$sudo python bm1880_usb_dl.py vvid=0x30b1 vpid=0x1000 timeout=100
emmc timeout = 100 s
bm_dl_magic.bin is 128 bytes \
Send to address 0x4003000
--- 0.0 Seconds ---
--- 0.000830173492432 Seconds ---
prg.bin is 81784 bytes
Send to address 0x4003000
--- 0.14 Seconds ---
--- 0.117983102798 Seconds ---
u-boot.bin is 385143 bytest: \
Send to address 0x108000000
--- 0.01 Seconds ---
--- 0.000161170959473 Seconds ---
bm_update.img is 580616192 bytes
Send to address 0x110000000
--- 13.12 Seconds ---
--- 0.0596687793732 Seconds ---
veirfy id = VID:PID=30b1:1000
Download complete0 USB port: ---
--- Reconnect 94.1 Seconds ---
--- 133.34 Seconds ---

Set the DIP switch to eMMC boot mode,DIP[1:8]=10000010, and then re-power on the edge development board.

Make sure that no SD card on edge development board

and you can see the tail part of the boot log show as below,

...
init.sh
mount: mounting /dev/mmcblk0p7 on /data failed: No such file or directory
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.
Warning! Main and backup partition tables differ! Use the 'c' and 'e' options
on the recovery & transformation menu to examine the two tables.
Warning! One or more CRCs don't match. You should repair the disk!
****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************
[ 5.915132] mmcblk0: p1 p2 p3 p4 p5 p6
The operation has completed successfully.
[ 5.924189] mmcblk0: p1 p2 p3 p4 p5 p6
[ 5.964275] random: parted: uninitialized urandom read (16 bytes read)
[ 5.973375] random: parted: uninitialized urandom read (16 bytes read)
[ 5.982944] random: parted: uninitialized urandom read (16 bytes read)
[ 5.992675] random: parted: uninitialized urandom read (16 bytes read)
[ 6.002246] random: parted: uninitialized urandom read (16 bytes read)
[ 6.011735] random: parted: uninitialized urandom read (16 bytes read)
[ 6.019682] random: parted: uninitialized urandom read (16 bytes read)
sh: udevadm: not found
sh: udevadm: not found
Information: You may need to update /etc/fstab.
[ 6.057227] mmcblk0: p1 p2 p3 p4 p5 p6
resize2fs 1.44.2 (14-May-2018)
Resizing the filesystem on /dev/mmcblk0p6 to 482299 (4k) blocks.
The filesystem on /dev/mmcblk0p6 is now 482299 (4k) blocks long.
Starting network: ifup: can't open '/etc/network/interfaces': No such file or directory
FAI[ 6.202411] random: sshd: uninitialized urandom read (32 bytes read)
L
Starting sshd: OK

The log means the it works in recovery mode,re-power on the edge development board again:

...
init.sh
[ 4.029053] EXT4-fs (mmcblk0p3): re-mounted. Opts: data=ordered
[ 4.168992] random: fast init done
[ 4.203548] bm-dwmac 58008000.ethernet eth0: device MAC address e0:a5:09:81:c7:55
[ 4.280022] Broadcom BCM50612E stmmac-0:01: attached PHY driver [Broadcom BCM50612E] (mii_bus:phy_addr=stmmac-0:01, irq=-1)
[ 4.295969] dwmac4: Master AXI performs any burst length
[ 4.301340] bm-dwmac 58008000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
[ 4.309633] bm-dwmac 58008000.ethernet eth0: registered PTP clock
[ 4.315869] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 8.416023] bm-dwmac 58008000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[ 8.424226] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
/ # [ 13.355306] usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
[ 13.380296] hub 2-1:1.0: USB hub found
[ 13.384144] hub 2-1:1.0: 4 ports detected
[ 13.499267] usb 1-1: new high-speed USB device number 2 using xhci-hcd
[ 13.644269] hub 1-1:1.0: USB hub found
[ 13.648114] hub 1-1:1.0: 4 ports detected
[ 13.939272] usb 1-1.4: new high-speed USB device number 3 using xhci-hcd
[ 14.177974] Bluetooth: hci0: rtl: examining hci_ver=08 hci_rev=000c lmp_ver=08 lmp_subver=8821
[ 14.186594] Bluetooth: hci0: rtl: loading rtl_bt/rtl8821a_config.bin
[ 14.194536] Bluetooth: hci0: rtl: loading rtl_bt/rtl8821a_fw.bin
[ 14.201977] Bluetooth: hci0: rom_version status=0 version=1
[ 14.207600] Bluetooth: cfg_sz 10, total size 21678

It means now the EDB works in normal mode.

If you want to build from source, you can get the bm1880 system sdk:

git clone https://github.com/BM1880-BIRD/bm1880-system-sdk.git

Follow the readme file to build, it will generate the bm_update.img for eMMC boot.