这篇文档主要用于介绍如何在VIM3上面运行Google的新系统Fuchsia。
准备
这里主要是设置编译源码的环境和编译fuchsia的源码
环境准备
检验HOST环境
Google提供了检测HOST环境的脚本
$ curl -sO https://storage.googleapis.com/fuchsia-ffx/ffx-linux-x64 && chmod +x ffx-linux-x64 && ./ffx-linux-x64 platform preflight
没有报错即可正常编译fuchsia的源码。
安装依赖
编译需要依赖curl
. Git
以及unzip
, fastboot
用于烧录
$ sudo apt-get install curl git unzip fastboot
获取源码
$ mkdir workspace && cd workspace
$ curl -s "https://fuchsia.googlesource.com/fuchsia/+/HEAD/scripts/bootstrap?format=TEXT" | base64 --decode | bash
这过程在下载完源码以后还会安装需要的其他依赖,比如烧录的秘钥。
设置环境变量
$ vim ~/.bashrc
并添加以下内容,
export PATH=$PATH:${workspace}/fuchsia/.jiri_root/bin
source ${workspace}/fuchsia/scripts/fx-env.sh
添加完以后重新加载配置文件
$ source ~/.bashrc
检测是否生效
$ cd ${workspace}/fuchsia
fx
命令
$ fx help
usage: fx [--dir BUILD_DIR] [-d DEVICE_NAME] [-i] [-x] COMMAND [...]
Run Fuchsia development commands. Must be run from a directory
that is contained in a Platform Source Tree.
...
online documentation
Fuchsia development: https://fuchsia.dev/fuchsia-src/development
Fuchsia workflows: https://fuchsia.dev/fuchsia-src/development/build/fx
jiri
命令
$ jiri help
Command jiri is a multi-purpose tool for multi-repo development.
Usage:
jiri [flags] <command>
...
-vv=false
Print trace level output.
编译源码
$ cd cd ${workspace}/fuchsia
- 选择平台
$ fx set workstation.vim3 --with //bundles:tools,//bundles:tests
- 编译
$ fx build
烧写U-Boot
烧写U-boot请参考Docs更新U-boot
烧写系统
- 板子进入升级模式
如何进入升级模式请参考–>如何进入升级模式
在串口会看到这些打印信息
USB RESET
SPEED ENUM
USB RESET
SPEED ENUM
此时板子已经可以烧写Fuchsia的系统了。
- 烧录
获取设备serial
$ sudo fastboot devices
c86314704a54 fastboot
通过fastboot
烧录,
$ fx flash --pave -s c86314704a54
看到这些信息就是烧录完成了
INFO: Running fx ffx -t c86314704a54 target flash /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/flash.json fuchsia --ssh-key /home/yan/.ssh/fuchsia_authorized_keys
Preparing to upload /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/firmware.img
Uploading... Done [0.07s]
Partitioning bootloader... Done [0.17s]
Rebooting to bootloader... Done [4.21s]
Preparing to upload /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/fuchsia.zbi
Uploading... large file, please wait... Done [0.92s]
Partitioning zircon_a... large file, please wait... Done [0.91s]
Preparing to upload /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/fuchsia.zbi
Uploading... large file, please wait... Done [1.11s]
Partitioning zircon_b... large file, please wait... Done [0.76s]
Preparing to upload /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/zedboot.zbi
Uploading... large file, please wait... Done [0.86s]
Partitioning zircon_r... large file, please wait... Done [0.79s]
Preparing to upload /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/fuchsia.vbmeta
Uploading... Done [0.00s]
Partitioning vbmeta_a... Done [0.03s]
Preparing to upload /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/fuchsia.vbmeta
Uploading... Done [0.00s]
Partitioning vbmeta_b... Done [0.03s]
Preparing to upload /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/zedboot.vbmeta
Uploading... Done [0.00s]
Partitioning vbmeta_r... Done [0.03s]
Preparing to upload /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/obj/build/images/fvm.fastboot.blk
Uploading... large file, please wait... Done [4.88s]
Partitioning fvm... large file, please wait... Done [8.44s]
Preparing to stage /home/yan/.ssh/fuchsia_authorized_keys
Uploading... Done [0.00s]
Sending command "add-staged-bootloader-file ssh.authorized_keys"
Continuing to boot - this could take awhile
Total Time [25.19s]
+ exec /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/host_x64/bootserver --board_name vim3 --firmware /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/firmware.img
--fvm /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/obj/build/images/fvm.sparse.blk --vbmetaa /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/fuchsia.vbmeta --vbme
tar /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/zedboot.vbmeta --zircona /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/fuchsia.zbi --zirconr /home/yan/data/git
/khadas/fuchsia/fuchsia-source/fuchsia/out/default/zedboot.zbi -1 --authorized-keys /home/yan/.ssh/fuchsia_authorized_keys
2021-06-15 10:50:39 [bootserver] Board name set to [vim3]
2021-06-15 10:50:39 [bootserver] cannot bind to [::]:33331 98: Address already in use
there may be another bootserver running
重启设备就能运行Fuchsia系统了
烧写logo
板子需要进入升级模式,随后从HOST解除设备锁,
$ fastboot flashing unlock
解除设备锁以后,就能烧录logo了。
$ cd ${workspace}/fuchsia
$ fastboot flash logo zircon/kernel/target/arm64/board/vim2/firmware/logo.img -s c86314704a54
target reported max download size of 1524629504 bytes
sending 'logo' (600 KB)...
OKAY [ 0.040s]
writing 'logo'...
FAILED (remote: locked device)
finished. total time: 0.069s
test
关于Fuchsia的测试,包含了系统测试,内核测试等众多测试内容,这里演示如何进行端到端测试
- 启动fx服务
$ fx serve &
- 进行端到端测试
$ fx test --e2e screen_is_not_black_no_basemgr_test
Logging all output to: /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/fxtest-2021-06-16T15:19:06.824215.log
Use the `--logpath` argument to specify a log location or `--no-log` to disable
Found 2668 total tests in //out/default/tests.json
Will run 1 test
> fx build host_x64/screen_is_not_black_no_basemgr_test
ninja: Entering directory `/home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default'
ninja: no work to do.
PASS: 0 FAIL: 0 00:00 🤔 /home/yan/data/git/khadas/fuchsia/fuchsia-source/fuchsia/out/default/host_x64/screen_is_not_black_no_basemgr_test
>> Runtime has exceeded 2 seconds (adjust this value with the -s|--slow flag)
00:00 +0: screen_is_not_black_test the startup screen is not black
[INFO]: SSH key path: /home/yan/.ssh/fuchsia_ed25519, setting owner only
[INFO]: Target device: [fe80::7348:d05e:241e:4779%eno2]
[INFO]: SL4F has started.
[INFO]: Initiating reboot sequence.
[FINE]: Running over ssh: killall sl4f.cmx
[FINE]: Running over ssh: dm reboot
[WARNING]: dm reboot; exit code: 255
[WARNING]:
[WARNING]:
[WARNING]: SL4F isRunning request errored: SocketException: OS Error: Connection refused, errno = 111, address = fe80::7348:d05e:241e:4779%eno2, port = 50946.
[INFO]: Try 0 at starting sl4f.
[FINE]: Running over ssh: run -d fuchsia-pkg://fuchsia.com/sl4f#meta/sl4f.cmx > /dev/null 2> /dev/null
[WARNING]: SL4F isRunning request errored: SocketException: OS Error: Connection refused, errno = 111, address = fe80::7348:d05e:241e:4779%eno2, port = 50956.
[INFO]: SL4F has started.
[INFO]: The test was started with --no-start_basemgr, so the test will not ensure that basemgr.cmx is running; screenshotting should be provided through some other means.
正常测试时,可以看到相关INFO打印出来
其他测试可以参考: