Google Fuchsia OS on VIM3

This document is mainly used to introduce how to run Google’s new system Fuchsia on VIM3

Preparation

Here is mainly to set up the environment for compiling the source code and the source code for compiling fuchsia

Environmental preparation

Test the HOST environment

Google provides a script to detect the HOST environment

$ curl -sO https://storage.googleapis.com/fuchsia-ffx/ffx-linux-x64 && chmod +x ffx-linux-x64 && ./ffx-linux-x64 platform preflight 

The source code of fuchsia can be compiled normally without error

Install dependencies

Compilation dependencies curl. Git and unzip, fastboot is used for burning

$ sudo apt-get install curl git unzip  fastboot

Get source code

$ mkdir workspace && cd workspace
$ curl -s "https://fuchsia.googlesource.com/fuchsia/+/HEAD/scripts/bootstrap?format=TEXT" | base64 --decode | bash

This process will install other dependencies required after downloading the source code, such as the burning key.

Set environment variables

$ vim ~/.bashrc

And add the following,

export PATH=$PATH:${workspace}/fuchsia/.jiri_root/bin
source ${workspace}/fuchsia/scripts/fx-env.sh

Reload the configuration file after adding

$ source ~/.bashrc

Whether the test is effective,

$ cd ${workspace}/fuchsia

fx command

$ 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 command

$ jiri help
Command jiri is a multi-purpose tool for multi-repo development.

Usage:
   jiri [flags] <command>
...
 -vv=false
   Print trace level output.

Compile Source Code

$ cd cd ${workspace}/fuchsia
  1. Choose a platform
$ fx set workstation.vim3 --with //bundles:tools,//bundles:tests
  1. Compile
$ fx build

Burn U-Boot

To flash U-boot, please refer to DocsUpdate U-boot

Burn System

  1. The board enters the upgrade mode

How to enter the upgrade mode please refer to → How to enter the upgrade mode

You will see these print information on the serial port

USB RESET
SPEED ENUM

USB RESET
SPEED ENUM

At this point, the board is ready to burn Fuchsia.

  1. Burn

Get device serial

$ sudo  fastboot devices
c86314704a54    fastboot

Burn system via fastboot

$ fx flash --pave -s c86314704a54

When you see this information, the burning is complete

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

Restart the device to run the Fuchsia system

Burn Logo

The board needs to enter the upgrade mode, and then unlock the device from the HOST

$ fastboot flashing unlock

After unlocking the device, you can burn the 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

About Fuchsia test, it includes system test, kernel test and many other test contents, here is how to perform end-to-end test

  1. Start fx Serve
$ fx serve &
  1. Test End to End
$ 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.

During normal testing, you can see the relevant INFO printed out

Other tests can refer to:

https://fuchsia.dev/fuchsia-src/development/testing/testing

6 Likes

The link in Burn U-Boot section is broken.

For VIM3 it should be:

Does it support flash u-boot with USB Disks?

Looks like it’s supported Boot From SPI Flash | Khadas Documentation

But I have no luck with it. An error happens all the time

=> fatload usb 0 12000000 u-boot.bin
Failed to load ‘u-boot.bin’

I think google is working on USB currently along wit other things, for right now i think you need to use a serial connection via gpio pins

Thanks @zonggestsu

I guess I’m already using serial connection under upgrade mode(“Hit SPACE in 2 seconds to stop autoboot”).

I want to load u-boot.bin located in usb-disks, “fatload usb 0 12000000 u-boot.bin”
But just like above, always turns failed

It seems that the prebuild u-boot timeout is set to 0, so you can not enter the u-boot command line. If you want to do this you have to modify the u-boot source code and rebuild the u-boot.

1 Like

I followed these, @Daeseung’s, and the main fuchsia site instructions to eventually get the fuchsia working on vim3. There was a hiccup using the latest prebuilt u-boot binary (instance id: T4sB7NoVqAxIOdCHfMBnHIJR9xN7xtP2Bl9tqwceutsC). It appears not to have fastboot compiled into it. After switching to 2EuVZARuOjI_Z5HMNFrDv7V86Aqq0iZH7DesElTIqbYC, fuchsia paved successfully.

I’m now starting to dive into fuchsia on vim3 and I’m wondering if there are any groups focused on this setup. Would be useful to exchange best practices and lessons learned. For instance, what is the best way to stop the cooling fan from continuously running regardless of temperature?

Any insight appreciated.