Edited at

[メモ] ASUS TinkerBoard: カーネル・OSイメージのビルド / ベンチマーク

More than 1 year has passed since last update.


概要


  • TinkerBoardで使えるOSイメージをビルド
    (2017-3-21現在)


    • ここでビルドしたものでは、WifiとBluetoothは使えない

    • ASUSが、TinkerOSとか、カーネルのソースコード・ビルド手順を出してないよね?
      => https://github.com/TinkerBoard/debian_kernel ここにある。(2017-09-26更新... ずっと前から、みんな知ってるよな! 記事更新してなかった)



  • 基本的に [TUTORIAL] Build a Tinker Board development image にそってます。

  • Windowsで、VirtualBox上に、Ubuntu16.04の仮想機を作って、そこでビルド。


  • 作成したイメージは、sshが有効になっていて、ユーザ名: linaro / パスワード: linaroで、ログインできる。


  • 3840x2160での表示(を縮小したもの)....
    起動画面jpg



環境


  • ASUS TinkerBoard

  • 仮想機ホスト: Windows 10 64bit


    • Vagrant 1.9.2

    • Virtualbox 5.0.32

    • 仮想マシン: Ubuntu 16.04


      • ベースイメージ ubuntu/xenial64 (20170320.0.0) 使用

      • CPU:2コア / RAM: 4GB (お好みにより変更)

      • ソースコードとか生成物を置く、16GBの外部ディスクイメージを作成(/vagrant/disk-ext4.img, /vagrantは Windowsから提供される共有フォルダ)
        sudo mount -t ext4 -o loop /vagrant/disk-ext4.img /mnt/tinker
        にて、マウント。起動ごとにうまくマウントすること.






手順


Windowsでの作業


  1. インストールして使えるようにしとく::


    • Vagrant

    • Virtualbox

    • git for Windows




  2. C:\Vagrant\TB-Dev フォルダを作成して、Vagrantfileを作る


    Vagrantfile

    # Vagrantfile
    
    # mt08

    VB_NAME="Build-TinkerOS-MoDoKi"
    VM_MEMORY=4096
    VM_CORES=2
    VM_HOSTNAME="TB-MoDoKi.local"

    Vagrant.configure("2") do |config|
    config.vm.box = "ubuntu/xenial64"
    config.ssh.username = 'ubuntu'

    config.vm.provider "virtualbox" do |vb|
    vb.gui = false
    vb.name = VB_NAME
    vb.memory = VM_MEMORY
    vb.cpus = VM_CORES
    end

    config.vm.provision "shell", inline: <<-SHELL
    #echo 'Acquire::http::Proxy "http://apt-cache-server:3142";' | tee /etc/apt/apt.conf.d/02proxy

    apt-get update
    apt-get upgrade -y

    apt-get install -y git build-essential bc libssl-dev
    apt-get install -y gcc-arm-linux-gnueabihf u-boot-tools device-tree-compiler mtools parted binfmt-support
    apt-get install -y qemu-user-static
    apt-get install -y python-dbus python-debian python-parted python-yaml python-apt

    # python-support for Ubuntu 16.04
    wget http://launchpadlibrarian.net/109052632/python-support_1.0.15_all.deb
    dpkg -i ./python-support_1.0.15_all.deb
    rm -fv ./python-support_1.0.15_all.deb
    apt-get install -f
    SHELL
    end





  3. Git Bashをひらいて、


    1. 仮想機起動:
      vagrant up

    2. ... 返って来るまで、待つ ...

    3. 16GBのファイル(disk-ext4.img)を作る
      fsutil file createnew disk-ext4.img 17179869184

    4. sshログイン
      vagrant ssh




Ubuntuでの作業


  1. ファイルの確認:
    ls -l /vagrant/disk-ext4.img

  2. ext4でフォーマット
    mkfs.ext4 /vagrant/disk-ext4.img


  3. マウントして、作業フォルダ作成・移動

    sudo mkdir /mnt/tinker
    
    sudo mount -t ext4 -o loop /vagrant/disk-ext4.img /mnt/tinker/
    ls -l /mnt/tinker #確認
    cd /mnt/tinker #移動
    sudo mkdir tinkeroscustom
    sudo chmod 777 tinkeroscustom
    sudo chown ubuntu.ubuntu tinkeroscustom
    cd tinkeroscustom



  4. ソースコード・スクリプトなど取得


    結構、時間かかるよ

    cd /mnt/tinker/tinkeroscustom
    
    git clone https://github.com/rockchip-linux/kernel.git
    git clone https://github.com/rockchip-linux/u-boot.git
    git clone https://github.com/rockchip-linux/rk-rootfs-build.git
    git clone https://github.com/rockchip-linux/build.git




  5. ビルド



    1. uboot:
      build/mk-uboot.sh miniarm


      参考

      real    0m32.818s
      
      user 0m26.388s
      sys 0m2.136s




    2. rootfsイメージ作成

      cd rk-rootfs-build/
      
      # 必要なパッケージ導入
      sudo dpkg -i ubuntu-build-service/packages/*
      sudo apt-get install -f

      # ビルド
      TARGET=desktop ARCH=armhf ./mk-base-debian.
      #参考time
      #real 25m41.317s
      #user 15m4.508s
      #sys 0m56.804s

      ARCH=armhf ./mk-rootfs.sh
      #参考time
      #real 3m5.331s
      #user 2m23.524s
      #sys 0m9.888s

      ./mk-image.sh
      #参考time
      #real 0m43.335s
      #user 0m0.332s
      #sys 0m2.840s




    3. カーネルビルド

      cd /mnt/tinker/tinkeroscustom
      
      build/mk-kernel.sh miniarm
      #参考time
      #real 8m38.834s
      #user 14m12.372s
      #sys 1m20.440s





  6. 仕上げ



    1. rk3288の編集: vi build/extlinux/rk3288.conf
      root=/dev/mmcblk2p7root=/dev/mmcblk0p7


      こんな感じ/mnt/tinker/tinkeroscustombuild/extlinux/rk3288.conf

      label kernel-4.4
      
      kernel /zImage
      fdt /rk3288-miniarm.dtb
      append earlyprintk console=tty1 console=ttyS2,115200n8 rw root=/dev/mmcblk0p7 rootfstype=ext4 init=/sbin/init




    2. sdイメージ作成

      build/mk-image.sh -c miniarm -t boot
      
      build/mk-image.sh -c miniarm -t system -s 4000 -r rk-rootfs-build/linaro-rootfs.img



    3. out/system.img


      system.imgをSDにやく

      ubuntu@ubuntu-xenial:/mnt/tinker/tinkeroscustom$ ls -l ./out/system.img
      
      -rw-rw-r-- 1 ubuntu ubuntu 1974607872 Mar 21 17:20 ./out/system.img





  7. Windows側へコピー:
    cp out/system.img /vagrant/
    => Windowsから、いつものツールで、SDに焼く



ベンチ


byte-unixbench

```bash:byte-unixbench導入・実行

sudo apt-get install git-core build-essential
git clone https://github.com/kdlucas/byte-unixbench.git
cd byte-unixbench/UnixBench
./Run
```

```shell-session:結果...1時間くらいかかたのか...
linaro@linaro-alip:~/byte-unixbench/UnixBench$ ./Run
gcc -o pgms/arithoh -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME -Darithoh src/arith.c
gcc -o pgms/register -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME -Ddatum='register int' src/arith.c
gcc -o pgms/short -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME -Ddatum=short src/arith.c
gcc -o pgms/int -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME -Ddatum=int src/arith.c
gcc -o pgms/long -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME -Ddatum=long src/arith.c
gcc -o pgms/float -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME -Ddatum=float src/arith.c
gcc -o pgms/double -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME -Ddatum=double src/arith.c
gcc -o pgms/hanoi -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME src/hanoi.c
gcc -o pgms/syscall -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME src/syscall.c
gcc -o pgms/context1 -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME src/context1.c
gcc -o pgms/pipe -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME src/pipe.c
gcc -o pgms/spawn -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME src/spawn.c
gcc -o pgms/execl -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME src/execl.c
gcc -o pgms/dhry2 -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME -DHZ= ./src/dhry_1.c ./src/dhry_2.c
gcc -o pgms/dhry2reg -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME -DHZ= -DREG=register ./src/dhry_1.c ./src/dhry_2.c
gcc -o pgms/looper -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME src/looper.c
gcc -o pgms/fstime -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME src/fstime.c
gcc -o pgms/whetstone-double -Wall -pedantic -O3 -ffast-math -march=native -mtune=native -I ./src -DTIME -DDP -DGTODay -DUNIXBENCH src/whets.c -lm
make all
make[1]: Entering directory '/home/linaro/byte-unixbench/UnixBench'
make distr
make[2]: Entering directory '/home/linaro/byte-unixbench/UnixBench'
Checking distribution of files
./pgms exists
./src exists
./testdir exists
./tmp exists
./results exists
make[2]: Leaving directory '/home/linaro/byte-unixbench/UnixBench'
make programs
make[2]: Entering directory '/home/linaro/byte-unixbench/UnixBench'
make[2]: Nothing to be done for 'programs'.
make[2]: Leaving directory '/home/linaro/byte-unixbench/UnixBench'
make[1]: Leaving directory '/home/linaro/byte-unixbench/UnixBench'
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
sh: 1: 3dinfo: not found

# # # # # # # ##### ###### # # #### # #
# # ## # # # # # # # ## # # # # #
# # # # # # ## ##### ##### # # # # ######
# # # # # # ## # # # # # # # # #
# # # ## # # # # # # # ## # # # #
#### # # # # # ##### ###### # # #### # #

Version 5.1.3 Based on the Byte Magazine Unix Benchmark

Multi-CPU version Version 5 revisions by Ian Smith,
Sunnyvale, CA, USA
January 13, 2011 johantheghost at yahoo period com

Use of uninitialized value in printf at ./Run line 1438.
Use of uninitialized value in printf at ./Run line 1439.
Use of uninitialized value in printf at ./Run line 1438.
Use of uninitialized value in printf at ./Run line 1439.
Use of uninitialized value in printf at ./Run line 1438.
Use of uninitialized value in printf at ./Run line 1439.
Use of uninitialized value in printf at ./Run line 1438.
Use of uninitialized value in printf at ./Run line 1439.
Use of uninitialized value in printf at ./Run line 1648.
Use of uninitialized value in printf at ./Run line 1649.
Use of uninitialized value in printf at ./Run line 1648.
Use of uninitialized value in printf at ./Run line 1649.
Use of uninitialized value in printf at ./Run line 1648.
Use of uninitialized value in printf at ./Run line 1649.
Use of uninitialized value in printf at ./Run line 1648.
Use of uninitialized value in printf at ./Run line 1649.

1 x Dhrystone 2 using register variables 1 2 3 4 5 6 7 8 9 10

1 x Double-Precision Whetstone 1 2 3 4 5 6 7 8 9 10

1 x Execl Throughput 1 2 3

1 x File Copy 1024 bufsize 2000 maxblocks 1 2 3

1 x File Copy 256 bufsize 500 maxblocks 1 2 3

1 x File Copy 4096 bufsize 8000 maxblocks 1 2 3

1 x Pipe Throughput 1 2 3 4 5 6 7 8 9 10

1 x Pipe-based Context Switching 1 2 3 4 5 6 7 8 9 10

1 x Process Creation 1 2 3

1 x System Call Overhead 1 2 3 4 5 6 7 8 9 10

1 x Shell Scripts (1 concurrent) 1 2 3

1 x Shell Scripts (8 concurrent) 1 2 3

4 x Dhrystone 2 using register variables 1 2 3 4 5 6 7 8 9 10

4 x Double-Precision Whetstone 1 2 3 4 5 6 7 8 9 10

4 x Execl Throughput 1 2 3

4 x File Copy 1024 bufsize 2000 maxblocks 1 2 3

4 x File Copy 256 bufsize 500 maxblocks 1 2 3

4 x File Copy 4096 bufsize 8000 maxblocks 1 2 3

4 x Pipe Throughput 1 2 3 4 5 6 7 8 9 10

4 x Pipe-based Context Switching 1 2 3 4 5 6 7 8 9 10

4 x Process Creation 1 2 3

4 x System Call Overhead 1 2 3 4 5 6 7 8 9 10

4 x Shell Scripts (1 concurrent) 1 2 3

4 x Shell Scripts (8 concurrent) 1 2 3

========================================================================
BYTE UNIX Benchmarks (Version 5.1.3)

System: linaro-alip: GNU/Linux
OS: GNU/Linux -- 4.4.52 -- #1 SMP Tue Mar 21 17:17:30 UTC 2017
Machine: armv7l (unknown)
Language: en_US.utf8 (charmap="ANSI_X3.4-1968", collate="ANSI_X3.4-1968")
CPU 0: ARMv7 Processor rev 1 (v7l) (0.0 bogomips)

CPU 1: ARMv7 Processor rev 1 (v7l) (0.0 bogomips)

CPU 2: ARMv7 Processor rev 1 (v7l) (0.0 bogomips)

CPU 3: ARMv7 Processor rev 1 (v7l) (0.0 bogomips)

19:31:01 up 6 min, 3 users, load average: 0.66, 0.34, 0.16; runlevel Mar

------------------------------------------------------------------------
Benchmark Run: Tue Mar 21 2017 19:31:01 - 19:59:16
4 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables 10094986.0 lps (10.0 s, 7 samples)
Double-Precision Whetstone 1494.8 MWIPS (10.1 s, 7 samples)
Execl Throughput 974.9 lps (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 173252.4 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 57547.3 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 421426.1 KBps (30.0 s, 2 samples)
Pipe Throughput 362544.6 lps (10.0 s, 7 samples)
Pipe-based Context Switching 48032.5 lps (10.0 s, 7 samples)
Process Creation 369.6 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 1352.4 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 1020.5 lpm (60.1 s, 2 samples)
System Call Overhead 783442.5 lps (10.0 s, 7 samples)

System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 10094986.0 865.0
Double-Precision Whetstone 55.0 1494.8 271.8
Execl Throughput 43.0 974.9 226.7
File Copy 1024 bufsize 2000 maxblocks 3960.0 173252.4 437.5
File Copy 256 bufsize 500 maxblocks 1655.0 57547.3 347.7
File Copy 4096 bufsize 8000 maxblocks 5800.0 421426.1 726.6
Pipe Throughput 12440.0 362544.6 291.4
Pipe-based Context Switching 4000.0 48032.5 120.1
Process Creation 126.0 369.6 29.3
Shell Scripts (1 concurrent) 42.4 1352.4 319.0
Shell Scripts (8 concurrent) 6.0 1020.5 1700.9
System Call Overhead 15000.0 783442.5 522.3
========
System Benchmarks Index Score 330.7

------------------------------------------------------------------------
Benchmark Run: Tue Mar 21 2017 19:59:16 - 20:27:43
4 CPUs in system; running 4 parallel copies of tests

Dhrystone 2 using register variables 30422699.0 lps (10.0 s, 7 samples)
Double-Precision Whetstone 5071.9 MWIPS (10.1 s, 7 samples)
Execl Throughput 4141.1 lps (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 218831.1 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 62352.0 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 683966.7 KBps (30.0 s, 2 samples)
Pipe Throughput 1253660.1 lps (10.0 s, 7 samples)
Pipe-based Context Switching 148544.1 lps (10.0 s, 7 samples)
Process Creation 8500.8 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 7484.8 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 1025.5 lpm (60.1 s, 2 samples)
System Call Overhead 2394917.0 lps (10.0 s, 7 samples)

System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 30422699.0 2606.9
Double-Precision Whetstone 55.0 5071.9 922.2
Execl Throughput 43.0 4141.1 963.0
File Copy 1024 bufsize 2000 maxblocks 3960.0 218831.1 552.6
File Copy 256 bufsize 500 maxblocks 1655.0 62352.0 376.7
File Copy 4096 bufsize 8000 maxblocks 5800.0 683966.7 1179.3
Pipe Throughput 12440.0 1253660.1 1007.8
Pipe-based Context Switching 4000.0 148544.1 371.4
Process Creation 126.0 8500.8 674.7
Shell Scripts (1 concurrent) 42.4 7484.8 1765.3
Shell Scripts (8 concurrent) 6.0 1025.5 1709.2
System Call Overhead 15000.0 2394917.0 1596.6
========
System Benchmarks Index Score 969.7

linaro@linaro-alip:~/byte-unixbench/UnixBench$
```


その他



  • ビルド後のディスクの使用量はこんな感じ。

    ubuntu@ubuntu-xenial:/mnt/tinker/tinkeroscustom$ pwd
    
    /mnt/tinker/tinkeroscustom
    ubuntu@ubuntu-xenial:/mnt/tinker/tinkeroscustom$ sudo du -sh *
    1.3M build
    4.4G kernel
    1.9G out
    5.5G rk-rootfs-build
    269M u-boot
    ubuntu@ubuntu-xenial:/mnt/tinker/tinkeroscustom$ df -h .
    Filesystem Size Used Avail Use% Mounted on
    /dev/loop0 16G 12G 2.9G 81% /mnt/tinker
    ubuntu@ubuntu-xenial:/mnt/tinker/tinkeroscustom$


  • 起動ごとに、EthernetのMACアドレスが変わる. (ので、DHCPで取得されるIPアドレスも変わるかと..)


  • まだ、シロウトには、使えるものでないな...