天天看點

fuchsia學習_下載下傳編譯遇到問題和demo運作

下載下傳編譯,官網 https://fuchsia.dev

$ curl -s "https://fuchsia.googlesource.com/fuchsia/+/master/scripts/bootstrap?format=TEXT" | base64 --decode | bash

$ export PATH="/home/fuchsia/.jiri_root/bin:$PATH"

$ fx set core.x64 --with //bundles:kitchen_sink

$ fx build

$ fx emu -N

// 模拟器運作起來後,可執行指令:

$ printf "1234"  $ pwd  $ ps  $ date  $ ls  $ uname  $ uname -srm  $ locate

https://fuchsia.dev/fuchsia-src/getting_started

$ fx get-device-addr

====

遇到問題五(shasum指令問題):

$ fx qemu -N

"$errmsg" is not exported by the Digest::SHA module

Can't continue after import errors at /usr/local/bin/shasum line 21.

方案參考  https://command-not-found.com/shasum

$ sudo apt-get install libdigest-sha-perl

驗證指令方式  $ shasum --help

====

遇到問題四(ubuntu18的KVM權限問題):

$ fx qemu -N

qemu-system-x86_64: failed to initialize KVM: Permission denied

方案參考  https://stackoverflow.com/questions/59131434/unable-to-start-fuchsia-on-emulator

$ sudo chmod 777 /dev/kvm

====

遇到問題三(運作虛拟機):

$ fx qemu

ERROR: Could not extend fvm, unable to stat fvm image

問題解決(原因是非英文系統會遇到):

方案參考 https://github.com/assusdan/fuchsia-patches 或 https://forum.fuchsia-china.com/t/fuchsia/754

用文本編輯器打開~/fuchsia/tools/devshell/lib/fvm.sh,将

stat_output=$(stat "${stat_flags[@]}" "${fvmraw}") 改為

stat_output=$(LC_ALL=C stat "${stat_flags[@]}" "${fvmraw}")

這是似乎是因為系統語言導緻的相關問題。在

size="${BASH_REMATCH[1]}" 的後面下一行

echo $size

====

遇到問題二(權限問題):

ERROR: 'git clone --no-checkout https://chromium.googlesource.com/catapult /home/fuchsia/third_party/catapult' failed:

stdout:

stderr:

正克隆到 '/home/fuchsia/third_party/catapult'...

fatal: 遠端錯誤:

Invalid authentication credentials.

Please generate a new identifier:

  https://chromium.googlesource.com/new-password

問題分解:單獨執行git clone指令仍同樣提示。

問題解決:注冊一下,并把對應的結果在shell中執行一下;

====

遇到問題一(git工具版本号問題):

$ curl -s "https://fuchsia.googlesource.com/fuchsia/+/master/scripts/bootstrap?format=TEXT" | base64 --decode | bash

cipd bootstrapped to path:"/home/fuchsia/.jiri_root/bin/cipd"

Please add /home/fuchsia/.jiri_root/bin to your PATH

[17:50:40.128] WARN: Please opt in or out of analytics collection. You will receive this warning until an option is selected.

To check what data we collect run: jiri init -show-analytics-data

To opt-in run: jiri init -analytics-opt=true "/home/fuchsia"

To opt-out run: jiri init -analytics-opt=false "/home/fuchsia"

[17:50:40.130] WARN: Please opt in or out of analytics collection. You will receive this warning until an option is selected.

To check what data we collect run: jiri init -show-analytics-data

To opt-in run: jiri init -analytics-opt=true "/home/fuchsia"

To opt-out run: jiri init -analytics-opt=false "/home/fuchsia"

[17:50:40.495] Updating all projects

ERROR: failed to set remote back to https://fuchsia.googlesource.com/fuchsia for project {Name:fuchsia Path:/home/fuchsia Remote:https://fuchsia.googlesource.com/fuchsia RemoteBranch:master Revision:6d824f73f110fbcab88958409457c691316bddab HistoryDepth:0 GerritHost:https://fuchsia-review.googlesource.com GitHooks: Attributes: GitAttributes:integration_a2f241a9a570dfae,stem Flag: XMLName:{} ComputedKey: LocalConfig:{Ignore:false NoUpdate:false NoRebase:false XMLName:{}} ComputedAttributes: ManifestPath:/tmp/jiri-load322640697/integration_a2f241a9a570dfae/stem}

[17:50:58.414] Jiri packages are not fetched due to fatal errors when updating projects.

[17:50:58.414] Jiri hooks are not run due to fatal errors when updating projects or packages

[17:51:04.407] Jiri packages are not fetched due to fatal errors when updating projects.

[17:51:04.407] Jiri hooks are not run due to fatal errors when updating projects or packages

ERROR: Creating project "fuchsia": 'git remote set-url origin https://fuchsia.googlesource.com/fuchsia' failed:

stdout:

stderr:

fatal: Expected git repo version <= 0, found 1

command fail error: exit status 128, Creating project "fuchsia": 'git init /home/fuchsia' failed:

stdout:

stderr:

fatal: Expected git repo version <= 0, found 1

command fail error: exit status 128

問題分解:

單獨執行依然報錯 $git init /home/fuchsia

解決方案(git版本号問題),參考連結 https://unix.stackexchange.com/questions/33617/how-can-i-update-to-a-newer-version-of-git-using-apt-get

sudo apt-get install python-software-properties

sudo apt-get install software-properties-common

sudo add-apt-repository ppa:git-core/ppa -y

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install git -y

git --version

===========================

總結:garnet層fidl通訊demo,分别使用了go語言,rust語言,cpp語言,c語言,llcpp語言;  topaz層fidl通訊demo,使用的dart語言;

運作demo程式

// 需要啟動服務,前提是需要配置網絡否則會無法連結;

$ fx serve

// 新添加app;   參考 https://zhuanlan.zhihu.com/p/74431726   添加後目錄在out/default/args.gn

//garnet層,完成fidl通訊,分别使用了go語言,rust語言,cpp語言,c語言,llcpp語言;

// 把所有garnet下的examples都添加到系統 $ fx set core.x64 --with //garnet/examples:examples ;  fx list-packages

$ fx set terminal.x64 --with //garnet/examples/fidl/echo_client_go ; fx build-push echo_client_go

$ fx set terminal.x64 --with //garnet/examples/fidl/echo_server_go ; fx build-push echo_server_go

在fx shell内部或者虛拟器指令行中執行成功 $ run 'fuchsia-pkg://fuchsia.com/echo_client_go#meta/echo_client_go'

$ fx set terminal.x64 --with //garnet/examples/fidl/echo_server_rust ; fx build-push echo_server_rust

$ fx set terminal.x64 --with //garnet/examples/fidl/echo_client_rust ; fx build-push echo_client_rust

在fx shell内部或者虛拟器指令行中執行成功 $ run fuchsia-pkg://fuchsia.com/echo_client_rust#meta/echo_client_rust.cmx

$ fx set terminal.x64 --with //garnet/examples/fidl/echo_client_cpp ; fx build-push echo_client_cpp

$ fx set terminal.x64 --with //garnet/examples/fidl/echo_server_cpp ; fx build-push echo_server_cpp

在fx shell内部或者虛拟器指令行中執行成功 $ run 'fuchsia-pkg://fuchsia.com/echo_client_cpp#meta/echo_client_cpp.cmx'

$ fx set terminal.x64 --with //garnet/examples/fidl/echo_client_rust_synchronous ; fx build-push echo_client_rust_synchronous

在fx shell内部或者虛拟器指令行中執行成功 $ run 'fuchsia-pkg://fuchsia.com/echo_client_rust_synchronous#meta/echo_client_rust_synchronous.cmx'

$ fx set terminal.x64 --with //garnet/examples/fidl/echo_client_cpp_synchronous ; fx build-push echo_client_cpp_synchronous

在fx shell内部或者虛拟器指令行中執行成功 $ run 'fuchsia-pkg://fuchsia.com/echo_client_cpp_synchronous#meta/echo_client_cpp_synchronous.cmx'

$ fx set terminal.x64 --with //garnet/examples/components ; fx build-push component_hello_world

在fx shell内部或者虛拟器指令行中執行成功 $ run fuchsia-pkg://fuchsia.com/component_hello_world#meta/hello_world.cmx

在fx shell内部或者虛拟器指令行中執行成功 $ run fuchsia-pkg://fuchsia.com/component_hello_world#meta/hello_world2.cmx

$ fx set terminal.x64 --with //garnet/examples/benchmark ; fx build-push benchmark

在fx shell内部或者虛拟器指令行中執行成功 $ run fuchsia-pkg://fuchsia.com/benchmark#meta/benchmark.cmx

// 修改run指令(src/sys/tools/run/main.cc)或time指令(garnet/bin/time/time.c)或uname指令(garnet/bin/uname/uname.c)的日志,直接build-push運作即可;

$ fx build-push run

$ fx build-push time

在fx shell内部或者虛拟器指令行中執行成功 $ run  或者  $ time

$ fx set terminal.x64 --with //topaz/examples/fidl/echo_server_async_dart ; fx build-push echo_server_async_dart

$ fx set terminal.x64 --with //topaz/examples/fidl/echo_client_async_dart ; fx build-push echo_client_async_dart

在fx shell内部或者虛拟器指令行中執行成功 $ run 'fuchsia-pkg://fuchsia.com/echo_client_async_dart#meta/echo_client_async_dart.cmx'

$ fx set terminal.x64 --with //examples/cowsay ; fx build-push cowsay

在fx shell内部或者虛拟器指令行中執行成功 $ cowsay "123456"

$ fx set terminal.x64 --with //examples/fortune ; fx build-push fortune

在fx shell内部或者虛拟器指令行中執行成功 $ fortune

$ fx set terminal.x64 --with //examples/hello_world/rust ; fx build-push hello_world_rust

在fx shell内部或者虛拟器指令行中執行成功 $ run 'fuchsia-pkg://fuchsia.com/hello_world_rust#meta/hello_world_rust.cm'

$ fx set terminal.x64 --with //examples/hello_world/cpp ; fx build-push hello_world_cpp

在fx shell内部或者虛拟器指令行中執行成功 $ run fuchsia-pkg://fuchsia.com/hello_world_cpp#meta/hello_world_cpp.cmx

$ fx set terminal.x64 --with //examples/rolldice ; fx build-push rolldice

在fx shell内部或者虛拟器指令行中執行成功 $ rolldice  $ run rolldice   $ run 'fuchsia-pkg://fuchsia.com/rolldice#meta/rolldice.cmx'

$ fx set terminal.x64 --with //examples/dotmatrix_display ; fx build-push dotmatrix_display

在fx shell内部或者虛拟器指令行中執行成功 $ dotmatrix_display $ run fuchsia-pkg://fuchsia.com/dotmatrix_display#meta/dotmatrix_display.cmx

繼續閱讀