昉・星光2 VisionFive2
「麦わら帽子はもう消えた」(「夏休み」吉田拓郎1971/1/1)。というわけで、夏休みの自由研究として「昉・星光2」VisionFive2。
0.ざっくりスペック
- CPU:StarFive JH7110 (U74 4 Core 1.5GHz) RV64GC
- LPDDR4 SDRAM 2GiB/4GiB/8GiB 2800Mbps
- QSPI Flash(Boot Loader)
- microSD Card Slot(TF Card Slot)
- eMMC Socket
- M.2 M-key NVMe Connector(2280)
- 1000BASE-T × 2
- USB 3.0 × 4
- USB-C(Power Supply)
- MIPI CSI/DSI
- GPIO Headers
- Video Processing Unit/GPU
- HDMI
1.ブートローダ更新
SPL(Secondary Program Loader)と U-Boot が古く、最新の Debian を起動できない。書き込みツールと最新版の SPL(Secondary Program Loader)と U-Boot をダウンロードする。
VisionFive2 Software v3.4.5
- sdcard.img 書き込みツール(Minimum LINUX)
- u-boot-spl.bin.normal.out SPL
- visionfive2_fw_payload.img U-Boot
microSDカードを挿入、電源ON。
Advanced Port Scanner(ネットワークスキャナ)で IPアドレスを特定。
Tera Termで ssh接続。(root/starfive)
u-boot-spl.bin.normal.out と visionfive2_fw_payload.img を Tera Term にドラッグ&ドロップ(scp によるファイル転送)。
# flashcp -v u-boot-spl.bin.normal.out /dev/mtd0 # flashcp -v visionfive2_fw_payload.img /dev/mtd1以上でブートローダの更新完了。
reboot して正常に起動することを確認。
2.Debian のディスクイメージの microSDカードを作成する
今回は最新版にしておこう。VisionFive2 Debian starfive-jh7110-202306-SD-minimal-desktop.img.bz2 をダウンロード。
WSL で解凍。
nitobe@X280-i5:~$ bzip2 -d starfive-jh7110-202306-SD-minimal-desktop.img.bz2解凍された starfive-jh7110-202306-SD-minimal-desktop.img を ETCHER で microSDカードに書き込む。
以上でディスクイメージの作成完了。
3.Debian 起動
microSD カードを取り換えて、起動。Tera Term でログイン。(user/starfive)
user@starfive:~$ uname -a Linux starfive 5.15.0-starfive #1 SMP Sun Jun 11 07:48:39 UTC 2023 riscv64 GNU/Linux user@starfive:~$ cat /etc/os-release PRETTY_NAME="Debian GNU/Linux bookworm/sid" # おっ!debian12の sid だね。 NAME="Debian GNU/Linux" VERSION_CODENAME=bookworm ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" user@starfive:~$ cat /etc/debian_version bookworm/sid user@starfive:~$ su - Password: root@starfive:~# passwd root # root パスワード変更。 New password: Retype new password: passwd: password updated successfully root@starfive:~# adduser nitobe # ユーザ追加。 Adding user `nitobe' ... Adding new group `nitobe' (1001) ... Adding new user `nitobe' (1001) with group `nitobe (1001)' ... Creating home directory `/home/nitobe' ... Copying files from `/etc/skel' ... New password: Retype new password: passwd: password updated successfully Changing the user information for nitobe Enter the new value, or press ENTER for the default Full Name []: Hiroaki Nitobe Room Number []: 204 Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] y Adding new user `nitobe' to supplemental / extra groups `users' ... Adding user `nitobe' to group `users' ... root@starfive:~# apt install vim # vim インストール。 :
4.パーティション拡張
パーティション /dev/mmcblkp4 が 2.5GByte しかないのでmicroSD最大(60GByte)まで拡張。root@starfive:~# df Filesystem 1K-blocks Used Available Use% Mounted on udev 4036000 0 4036000 0% /dev tmpfs 809964 3212 806752 1% /run /dev/mmcblk1p4 2538164 2280560 241220 91% / tmpfs 4049816 0 4049816 0% /dev/shm tmpfs 5120 12 5108 1% /run/lock tmpfs 809960 40 809920 1% /run/user/110 tmpfs 809960 24 809936 1% /run/user/1000 root@starfive:~# fdisk /dev/mmcblk1 Welcome to fdisk (util-linux 2.38.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. GPT PMBR size mismatch (5529599 != 123596799) will be corrected by write. This disk is currently in use - repartitioning is probably a bad idea. It's recommended to umount all file systems, and swapoff all swap partitions on this disk. Command (m for help): p # 現在の状況 Disk /dev/mmcblk1: 58.94 GiB, 63281561600 bytes, 123596800 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: E05DB137-41F7-47A6-B1C1-E9BE91A4BC0E Device Start End Sectors Size Type /dev/mmcblk1p1 4096 8191 4096 2M HiFive BBL /dev/mmcblk1p2 8192 16383 8192 4M HiFive FSBL /dev/mmcblk1p3 16384 221183 204800 100M EFI System /dev/mmcblk1p4 221184 5527518 5306335 2.5G Linux filesystem # 2.5GByte Command (m for help): d # 一旦消去 Partition number (1-4, default 4): 4 Partition 4 has been deleted. Command (m for help): n # 新規作成 Partition number (4-128, default 4): 4 First sector (34-123596766, default 221184): 221184 # Firstはデフォルト 221184 Last sector, +/-sectors or +/-size{K,M,G,T,P} (221184-123596766, default 123594751): # Lastはデフォルト 123594751 Created a new partition 4 of type 'Linux filesystem' and of size 58.8 GiB. Partition #4 contains a ext4 signature. Do you want to remove the signature? [Y]es/[N]o: n Command (m for help): w # 書き込み The partition table has been altered. Syncing disks. root@starfive:~# resize2fs /dev/mmcblk1p4 # リサイズ resize2fs 1.46.6-rc1 (12-Sep-2022) Filesystem at /dev/mmcblk1p4 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 8 The filesystem on /dev/mmcblk1p4 is now 15421696 (4k) blocks long. root@starfive:~# df Filesystem 1K-blocks Used Available Use% Mounted on udev 4036000 0 4036000 0% /dev tmpfs 809964 3212 806752 1% /run /dev/mmcblk1p4 60686316 2296992 58372940 4% / # 58.8 GiBに増えた! tmpfs 4049816 0 4049816 0% /dev/shm tmpfs 5120 12 5108 1% /run/lock tmpfs 809960 40 809920 1% /run/user/110 tmpfs 809960 24 809936 1% /run/user/1000 root@starfive:~#reboot して正常に起動することを確認。
5.リポジトリの設定
deb https://snapshot.debian.org/archive/debian-ports/20221225T084846Z unstable main を最新のsidに変更する。root@starfive:~# mv /etc/apt/sources.list{,.d/snapshot.conf.disabled} root@starfive:~# echo "deb http://deb.debian.org/debian-ports unstable main" | sudo tee /etc/apt/sources.list root@starfive:~# wget https://deb.debian.org/debian-ports/pool/main/d/debian-ports-archive-keyring/debian-ports-archive-keyring_2023.02.01_all.deb root@starfive:~# apt install ./debian-ports-archive-keyring_2023.02.01_all.deb root@starfive:~# apt update root@starfive:~# apt full-upgrade : # 800近くの更新がある かなりの時間がかかる root@starfive:~# uname -a Linux starfive 5.15.0-starfive #1 SMP Sun Jun 11 07:48:39 UTC 2023 riscv64 GNU/Linux root@starfive:~# cat /etc/os-release PRETTY_NAME="Debian GNU/Linux trixie/sid" # なんと!debian13の sid だ! NAME="Debian GNU/Linux" VERSION_CODENAME=trixie ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" root@starfive:~# cat /etc/debian_version trixie/sid root@starfive:~# apt install mtd-utils # flashcp インストール : root@starfive:~# flashcp --version flashcp (mtd-utils) 2.1.5 root@starfive:~# apt install pciutils # lspci インストール : root@starfive:~# lspci 00:00.0 PCI bridge: PLDA XpressRich-AXI Ref Design (rev 02) 01:00.0 USB controller: VIA Technologies, Inc. VL805/806 xHCI USB 3.0 Controller (rev 01)
6.開発環境インストール
開発環境をインストールする。root@starfive:~# apt install build-essential m4 # 開発環境をインストール : root@starfive:~# cc --version cc (Debian 13.1.0-9) 13.1.0 # なんと!Version13! Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.FizzBuzzでテストしてみる。
nitobe@starfive:~$ mkdir FizzBuzz nitobe@starfive:~$ cd FizzBuzz nitobe@starfive:~/FizzBuzz$ vi FizzBuzzVF2.s#includenitobe@starfive:~/FizzBuzz$ cc -S FizzBuzzVF2.cint main(void) { int i = 0; while (i++ ^ 100) { printf(i%3? "": "Fizz") | printf(i%5? "": "Buzz") || printf("%d", i); printf(" "); } printf("\n"); return 0; }
nitobe@starfive:~/FizzBuzz$ vi FizzBuzzVF2.c
.file "FizzBuzzVF2.c" .option pic .attribute arch, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0" .attribute unaligned_access, 0 .attribute stack_align, 16 .text .section .rodata .align 3 .LC0: .string "" .align 3 .LC1: .string "Fizz" .align 3 .LC2: .string "Buzz" .align 3 .LC3: .string "%d" .text .align 1 .globl main .type main, @function main: .LFB0: .cfi_startproc addi sp,sp,-48 .cfi_def_cfa_offset 48 sd ra,40(sp) sd s0,32(sp) sd s1,24(sp) .cfi_offset 1, -8 .cfi_offset 8, -16 .cfi_offset 9, -24 addi s0,sp,48 .cfi_def_cfa 8, 0 sw zero,-36(s0) j .L2 .L10: lw a5,-36(s0) mv a4,a5 li a5,3 remw a5,a4,a5 sext.w a5,a5 beq a5,zero,.L3 lla a5,.LC0 j .L4 .L3: lla a5,.LC1 .L4: mv a0,a5 call printf@plt mv a5,a0 mv s1,a5 lw a5,-36(s0) mv a4,a5 li a5,5 remw a5,a4,a5 sext.w a5,a5 beq a5,zero,.L5 lla a5,.LC0 j .L6 .L5: lla a5,.LC2 .L6: mv a0,a5 call printf@plt mv a5,a0 or a5,s1,a5 sext.w a5,a5 bne a5,zero,.L12 lw a5,-36(s0) mv a1,a5 lla a0,.LC3 call printf@plt .L12: nop li a0,32 call putchar@plt .L2: lw a5,-36(s0) addiw a4,a5,1 sw a4,-36(s0) mv a4,a5 li a5,100 bne a4,a5,.L10 li a0,10 call putchar@plt li a5,0 mv a0,a5 ld ra,40(sp) .cfi_restore 1 ld s0,32(sp) .cfi_restore 8 .cfi_def_cfa 2, 48 ld s1,24(sp) .cfi_restore 9 addi sp,sp,48 .cfi_def_cfa_offset 0 jr ra .cfi_endproc .LFE0: .size main, .-main .ident "GCC: (Debian 13.1.0-9) 13.1.0" .section .note.GNU-stack,"",@progbitsnitobe@starfive:~/FizzBuzz$ cc -o FizzBuzzVF2 FizzBuzzVF2.c
nitobe@starfive:~/FizzBuzz$ ./FizzBuzzVF2
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz Fiz
z 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz 31 32 Fizz 34 Buzz Fizz 37 38 Fizz Buzz
41 Fizz 43 44 FizzBuzz 46 47 Fizz 49 Buzz Fizz 52 53 Fizz Buzz 56 Fizz 58 59 Fi
zzBuzz 61 62 Fizz 64 Buzz Fizz 67 68 Fizz Buzz 71 Fizz 73 74 FizzBuzz 76 77 Fizz
79 Buzz Fizz 82 83 Fizz Buzz 86 Fizz 88 89 FizzBuzz 91 92 Fizz 94 Buzz Fizz 97
98 Fizz Buzz
7.GMP(The GNU Multiple Precision Arithmetic Library)ビルド
しばらく目を離していたらGMPが6.3.0になっていた。ビルドしよう。root@starfive:~# wget https://gmplib.org/download/gmp/gmp-6.3.0.tar.lz : root@starfive:~# apt install lzip : root@starfive:~# tar xvf gmp-6.3.0.tar.lz : root@starfive:~# cd gmp-6.3.0 root@starfive:~gmp-6.3.0# mkdir build root@starfive:~gmp-6.3.0# cd build root@starfive:~gmp-6.3.0/build# ../configure -prefix=/usr/local/gmp-6.3.0 : root@starfive:~gmp-6.3.0/build# make -j 4 : root@starfive:~gmp-6.3.0/build# make check : root@starfive:~gmp-6.3.0/build# make install : root@starfive:~gmp-6.3.0/build# make clean : root@starfive:~gmp-6.3.0/build#^dいつもの円周率百万桁の計算をしてみよう。
nitobe@starfive:~$ rsync -av 192.168.1.xx:/home/nitobe/suzuki/ suzuki/ nitobe@starfive:~$ cd suzuki nitobe@starfive:~/suzuki$ cc -Wall -static -O2 -I/usr/local/gmp-6.3.0/include pi.c -o pi-6.3.0 /usr/local/gmp-6.3.0/lib/libgmp.a nitobe@starfive:~/suzuki$ time ./pi-6.3.0 >/dev/null with gcc-13.1.0, gmp-6.3.0 real 0m8.896s user 0m8.708s sys 0m0.180s nitobe@starfive:~/suzuki$すずきひろのぶ氏の円周率100万桁ソースコードを用いて各世代RaspberryPiの速度比較を行う
Raspberry Pi 4 より遅く、Raspberry Pi 3 より速い。
Hardware | Central Processing Unit |
Operating System |
gcc | gmp | time |
---|---|---|---|---|---|
Raspberry Pi 4 Model B Rev 1.2 (2019) |
ARM Cortex-A72 1.5GHz |
RaspberryPiOS (Debian 11 (bullseye)) |
10.2.1 | 6.2.1 | 4.875s |
VisionFive2 (2022) |
StarFive JH7110 (U74 4 Core 1.5GHz) RV64GC |
Debian GNU/Linux trixie/sid | 13.1.0 | 6.3.0 | 8.896s |
Raspberry Pi 3 Model B Rev 1.2 (2016) |
ARM Cortex-A53 1.2GHz |
RaspberryPiOS (Debian 11 (bullseye)) |
10.2.1 | 6.2.1 | 13.826s |
T: Y: ALL: Online:
ThemeSwitch
- Basic
Created in 0.0215 sec.
Comments