学习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

发布了8 篇原创文章 · 获赞 7 · 访问量 12万+

猜你喜欢

转载自blog.csdn.net/liu31187/article/details/105226595
今日推荐