一 、下载源码:
$ git clone https://github.com/fuchsia-mirror/zircon.git
or $ git clone https://fuchsia.googlesource.com/zircon
二、安装编译工具链:
进入源码目录执行(需要科学上网)
$ cd zircon
$ ./scripts/download-toolchain
三、编译Zircon:
$ make -j32 arm64
四、下载QEMU:
$ cd ..
$ git clone https://fuchsia.googlesource.com/buildtools
$ cd buildtools
$ vim fuchsia.ensure
$ ./update.sh
注意:需要下载Google定制的QEMU,亲测QEMU官网或者Ubuntu仓库的QEMU无法正常运行Zircon,会报qemu-system-aarch64: Property '.virtualization' not found错误。
注意:可以节省下载时间,建议删除fuchsia.ensure中的其他内容,我们只需要下载qemu即可。
fuchsia.ensure最终的内容如下:
# Copyright 2017 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
$VerifiedPlatform linux-amd64
$VerifiedPlatform mac-amd64
@Subdir qemu
fuchsia/qemu/mac-amd64 git_revision:0f0027d617976b4cbb7b937d5836f8ef0ac25ba1
五、使用QEMU模拟运行Zircon:
$ cd ../zircon
$ ./scripts/run-zircon-arm64
运行结果见附录。
在终端中可以执行cd、ls、ps、top等命令,其他的需要进一步研究。
注意:./scripts/run-zircon-arm64会自动识别到magenta/scripts/../../buildtools/linux-x64/qemu/bin/qemu-system-aarch64
或者可以qemu-system-aarch64所在目录添加到环境变量中。
附录:
./scripts/run-zircon-arm64
+ echo CMDLINE: TERM=xterm-256color kernel.entropy-mixin=93aaa284aa63dab82825c15798a4d2c0cb84e21f05f1be6ba614beb9ae393c81 kernel.halt-on-panic=true
CMDLINE: TERM=xterm-256color kernel.entropy-mixin=93aaa284aa63dab82825c15798a4d2c0cb84e21f05f1be6ba614beb9ae393c81 kernel.halt-on-panic=true
+ exec qemu-system-aarch64 -m 2048 -nographic -net none -smp 4 -kernel /Users/xichangbao/Gitbox/magenta/build-arm64/zircon.bin -machine virtualization=true -cpu cortex-a53 -machine virt -initrd build-arm64/qemu-bootdata.bin -append 'TERM=xterm-256color kernel.entropy-mixin=93aaa284aa63dab82825c15798a4d2c0cb84e21f05f1be6ba614beb9ae393c81 kernel.halt-on-panic=true '
[00000.000] 00000.00000> PMM: boot reserve add [0x40080000, 0x40202fff]
[00000.000] 00000.00000> FDT: device tree located at [0x48800000, 0x4880ffff]
[00000.000] 00000.00000> PMM: boot reserve add [0x48800000, 0x4880ffff]
[00000.000] 00000.00000> kernel command line: TERM=xterm-256color kernel.entropy-mixin=93aaa284aa63dab82825c15798a4d2c0cb84e21f05f1be6ba614beb9ae393c81
[00000.000] 00000.00000> kernel.halt-on-panic=true
[00000.000] 00000.00000> detected GICv2
[00000.000] 00000.00000> arm generic timer freq 62500000 Hz
[00000.011] 00000.00000> cntpct_per_ns: 00000000.1000000000000000
[00000.011] 00000.00000> ns_per_cntpct: 00000010.0000000000000000
[00000.011] 00000.00000> test_time_conversion_check_result:270: FAIL, off by 72057594037927936
[00000.011] 00000.00000> mem bank 0: base 0x40000000 length 0x8000000
[00000.011] 00000.00000> periph mem bank 0: phys base 0 virt base 0xffffffffc0000000 length 0x40000000
[00000.012] 00000.00000> reserving ramdisk phys range [0x48000000, 0x4872efff]
[00000.012] 00000.00000> PMM: boot reserve add [0x48000000, 0x4872efff]
[00000.012] 00000.00000> boot structure at 0x48800000 seems to point to a FDT
[00000.012] 00000.00000> overriding mem arena 0 size from FDT: 0x80000000
[00000.012] 00000.00000> PMM: add arena 'sdram' [0x40000000, 0xbfffffff]
[00000.060] 00000.00000> PMM: boot reserve marking WIRED [0x40080000, 0x40202fff]
[00000.060] 00000.00000> PMM: boot reserve marking WIRED [0x48000000, 0x4872efff]
[00000.061] 00000.00000> PMM: boot reserve marking WIRED [0x48800000, 0x4880ffff]
[00000.061] 00000.00000>
[00000.061] 00000.00000> welcome to Zircon
[00000.061] 00000.00000>
[00000.061] 00000.00000> INIT: cpu 0, calling hook 0xffffffff0007e2c8 (global_prng_seed) at level 0x30000, flags 0x1
[00000.095] 00000.00000> initializing vm pre-heap
[00000.096] 00000.00000> VM: marking boot alloc used range [0x40203000, 0x40207058)
[00000.097] 00000.00000> INIT: cpu 0, calling hook 0xffffffff0002afe8 (elf_build_id) at level 0x4fffe, flags 0x1
[00000.097] 00000.00000> INIT: cpu 0, calling hook 0xffffffff0002b1a8 (version) at level 0x4ffff, flags 0x1
[00000.097] 00000.00000> version:
[00000.097] 00000.00000> arch: arm64
[00000.097] 00000.00000> platform: generic-arm
[00000.097] 00000.00000> target: arm64
[00000.097] 00000.00000> project: arm64
[00000.097] 00000.00000> buildid: git-d28afb161bdf88f710b9d99869664307b8807415-dirty
[00000.097] 00000.00000> ELF build ID: 283c3d34c1b08640056c7bba1fe5b0af48d90cf1
[00000.097] 00000.00000> initializing heap
[00000.098] 00000.00000> INIT: cpu 0, calling hook 0xffffffff0007cf80 (console) at level 0x50000, flags 0x1
[00000.098] 00000.00000> initializing vm
[00000.098] 00000.00000> VM: reserving kernel region [0xffffffff00000000, 0xffffffff000cc000) flags 0x28 name 'kernel_code'
[00000.112] 00000.00000> VM: reserving kernel region [0xffffffff000cc000, 0xffffffff00103000) flags 0x8 name 'kernel_rodata'
[00000.115] 00000.00000> VM: reserving kernel region [0xffffffff00103000, 0xffffffff00105000) flags 0x18 name 'kernel_data'
[00000.115] 00000.00000> VM: reserving kernel region [0xffffffff00110000, 0xffffffff00183000) flags 0x18 name 'kernel_bss'
[00000.122] 00000.00000> INIT: cpu 0, calling hook 0xffffffff000011c8 (platform_postvm) at level 0x60000, flags 0x1
[00000.122] 00000.00000> CreateSubVmarInternal:121: warning: mapping periph has conflicting cache policies: vmo 00 arch_mmu_flags 02.
[00000.122] 00000.00000> initializing kernel
[00000.122] 00000.00000> initializing mp
[00000.122] 00000.00000> initializing threads
[00000.122] 00000.00000> initializing timers
[00000.122] 00000.00000> INIT: cpu 0, calling hook 0xffffffff00025d70 (debuglog) at level 0x7ffff, flags 0x1
[00000.123] 00000.00000> INIT: cpu 0, calling hook 0xffffffff0006eca8 (thread_set_priority_experiment) at level 0x7ffff, flags 0x1
[00000.123] 00000.00000> thread set priority experiment is : ENABLED
[00000.123] 00000.00000> INIT: cpu 0, calling hook 0xffffffff0007e518 (global_prng_thread_safe) at level 0x7ffff, flags 0x1
[00000.123] 00000.00000> creating bootstrap completion thread
[00000.141] 00000.00000> top of bootstrap2()
[00000.142] 00000.00000> INIT: cpu 0, calling hook 0xffffffff0001ce60 (dpc) at level 0x80000, flags 0x1
[00000.144] 00000.00000> INIT: cpu 0, calling hook 0xffffffff00038600 (libobject) at level 0x80000, flags 0x1
[00000.149] 00000.00000> OOM: started thread
[00000.150] 00000.00000> ARM boot EL2
[00000.150] 00000.00000> ARM cpu 0: midr 0x410fd034 'ARM Cortex-a53 r0p4' mpidr 0x80000000 aff 0:0:0:0
[00000.150] 00000.00000> ARM Features: fp asimd aes pmull sha1 sha2 crc32
[00000.150] 00000.00000> ARM cache line sizes: icache 64 dcache 64 zva 64
[00000.150] 00000.00000> ==== ARM64 CACHE INFO CORE 0 ====
[00000.150] 00000.00000> Inner Boundary = L0
[00000.150] 00000.00000> Level of Unification Uniprocessor = L1
[00000.150] 00000.00000> Level of Coherence = L2
[00000.150] 00000.00000> Level of Unification Inner Shareable = L1
[00000.150] 00000.00000> L1 Details: Data Cache, sets=128, associativity=4, line size=64 bytes
[00000.150] 00000.00000> Instruction Cache, sets=256, associativity=2, line size=64 bytes
[00000.150] 00000.00000> L2 Details: Unified Cache, sets=1024, associativity=16, line size=64 bytes
[00000.151] 00000.00000> L3 Details: Not Implemented
[00000.151] 00000.00000> L4 Details: Not Implemented
[00000.151] 00000.00000> L5 Details: Not Implemented
[00000.151] 00000.00000> L6 Details: Not Implemented
[00000.151] 00000.00000> L7 Details: Not Implemented
[00000.151] 00000.00000> initializing platform
[00000.152] 00000.00000> Trying to start cpu 0:1 returned: 0
[00000.152] 00000.00000> Trying to start cpu 0:2 returned: 0
[00000.152] 00000.00000> Trying to start cpu 0:3 returned: 0
[00000.152] 00000.00000> initializing target
[00000.152] 00000.00000> INIT: cpu 0, calling hook 0xffffffff0001a628 (platform_dev_init) at level 0xa0000, flags 0x1
[00000.154] 00000.00000> INIT: cpu 3, calling hook 0xffffffff0001aca8 (arm_generic_timer_init_secondary_cpu) at level 0x7ffff, flags 0x2
[00000.154] 00000.00000> INIT: cpu 1, calling hook 0xffffffff0001aca8 (arm_generic_timer_init_secondary_cpu) at level 0x7ffff, flags 0x2
[00000.154] 00000.00000> INIT: cpu 2, calling hook 0xffffffff0001aca8 (arm_generic_timer_init_secondary_cpu) at level 0x7ffff, flags 0x2
[00000.155] 00000.00000> ARM cpu 1: midr 0x410fd034 'ARM Cortex-a53 r0p4' mpidr 0x80000001 aff 0:0:0:1
[00000.155] 00000.00000> ARM cpu 2: midr 0x410fd034 'ARM Cortex-a53 r0p4' mpidr 0x80000002 aff 0:0:0:2
[00000.155] 00000.00000> ARM cpu 3: midr 0x410fd034 'ARM Cortex-a53 r0p4' mpidr 0x80000003 aff 0:0:0:3
[00000.155] 00000.00000> entering scheduler on cpu 3
[00000.155] 00000.00000> entering scheduler on cpu 1
[00000.155] 00000.00000> entering scheduler on cpu 2
[00000.164] 00000.00000> UART: started IRQ driven TX
[00000.165] 00000.00000> GICv2 MSI init
[00000.166] 00000.00000> moving to last init level
[00000.167] 00000.00000> INIT: cpu 0, calling hook 0xffffffff00026b88 (ktrace) at level 0xc0000, flags 0x1
[00000.261] 00000.00000> ktrace: buffer at 0xffff0089456c3000 (33554432 bytes)
[00000.262] 00000.00000> INIT: cpu 0, calling hook 0xffffffff0002afe0 (userboot) at level 0xc0000, flags 0x1
[00000.262] 00000.00000> userboot: ramdisk 0x72f000 @ 0xffff000048000000
[00000.283] 00000.00000> userboot: userboot rodata 0 @ [0x14ae3d94c000,0x14ae3d94f000)
[00000.283] 00000.00000> userboot: userboot code 0x3000 @ [0x14ae3d94f000,0x14ae3d959000)
[00000.284] 00000.00000> userboot: vdso/full rodata 0 @ [0x14ae3d959000,0x14ae3d95f000)
[00000.284] 00000.00000> userboot: vdso/full code 0x6000 @ [0x14ae3d95f000,0x14ae3d960000)
[00000.287] 00000.00000> userboot: entry point @ 0x14ae3d94fb98
[00000.288] 00000.00000> INIT: cpu 0, calling hook 0xffffffff0007da08 (kernel_shell) at level 0xc0000, flags 0x1
[00000.296] 01030.01037> userboot: option "TERM=xterm-256color"
[00000.297] 01030.01037> userboot: option "kernel.entropy-mixin.redacted=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[00000.297] 01030.01037> userboot: option "kernel.halt-on-panic=true"
[00000.762] 01030.01037> userboot: searching bootfs for 'bin/devmgr'
[00000.765] 01030.01037> userboot: 'bin/devmgr' has PT_INTERP "lib/ld.so.1"
[00000.765] 01030.01037> userboot: searching bootfs for 'lib/ld.so.1'
[00000.767] 01030.01037> userboot: userboot: loaded lib/ld.so.1 at 0x8dbc9c124000, entry point 0x8dbc9c1a6960
[00000.770] 01030.01037> userboot: userboot: loaded vDSO at 0xb48842475000, entry point 0x0
[00000.773] 01030.01037> userboot: process bin/devmgr started.
[00000.773] 01030.01037> userboot: waiting for loader-service requests...
[00000.787] 01030.01037> userboot: searching bootfs for 'lib/libasync-default.so'
[00000.790] 01030.01037> userboot: searching bootfs for 'lib/liblaunchpad.so'
[00000.793] 01030.01037> userboot: searching bootfs for 'lib/libfdio.so'
[00000.800] 01044.01047> dso: id=57d4a25026cfb0c2ef7961bcfc75d52593084840 base=0x0000824349e18000 name=
[00000.800] 01044.01047> dso: id=82458326f4456da8ea0807b48286ac82119f9876 base=0x0000a54b8bbff000 name=libasync-default.so
[00000.800] 01044.01047> dso: id=33dc72aa652dacdceaf8f1703fd028b4347c722d base=0x000069ce42784000 name=liblaunchpad.so
[00000.800] 01044.01047> dso: id=3d9f6e3fbfb4ee854cc350b13f948c22cb28a78a base=0x00002a323c462000 name=libfdio.so
[00000.801] 01044.01047> dso: id=43af4c7d09a885c24f63a1ee888b719df30f5a0d base=0x0000b48842475000 name=
[00000.801] 01044.01047> dso: id=6ea753c0719d6ef733c49c9bbd0193fa76031478 base=0x00008dbc9c124000 name=libc.so
[00000.819] 01030.01037> userboot: loader-service channel peer closed
[00000.820] 01030.01037> userboot: finished!
[00000.827] 01044.01047> devmgr: main()
[00000.828] 01044.01047> devmgr: init
[00000.831] 01044.01047> coordinator_init()
[00000.845] 01044.01047> devmgr: vfs init
[00000.896] 01044.01047> devmgr: launch /boot/bin/fshost (fshost) OK
[00000.936] 01104.01121> fshost: started.
[00000.980] 01044.01047> cmdline: TERM=xterm-256color
[00000.980] 01044.01047> cmdline: kernel.entropy-mixin.redacted=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[00000.981] 01044.01047> cmdline: kernel.halt-on-panic=true
[00000.990] 01044.01189> devmgr: shell startup
[00000.993] 01044.01047> devmgr: coordinator()
[00001.046] 01044.01194> devmgr: launch /boot/bin/crashlogger (crashlogger) OK
[00001.072] 01044.01194> devmgr: launch /boot/bin/netsvc (netsvc) OK
[00001.110] 01044.01194> devmgr: launch /boot/bin/virtual-console (virtual-console) OK
[00001.281] 01198.01262> crashlogger service ready
[00001.293] 01044.01047> devcoord: launch devhost 'devhost:sys': pid=1643
[00001.314] 01044.01047> devcoord: launch devhost 'devhost:root': pid=1679
[00001.339] 01044.01047> devcoord: launch devhost 'devhost:misc': pid=1713
[00001.613] 01044.01047> devcoord: launch devhost 'devhost:pdev:pci': pid=1951
[00001.635] 01044.01047> devcoord: launch devhost 'devhost:pdev:00:00:6': pid=2001
[00001.700] 01713.01743> usb_virtual_bus_bind
[00001.725] 01044.01189> devmgr: launch /boot/bin/sh (sh:console) OK
$
ls执行结果
$ ls
d 1 0 .
d 2 0 tmp
d 2 0 pkgfs
d 2 0 blob
d 2 0 volume
d 2 0 install
d 2 0 system
d 2 0 data
d 8 0 boot
d 1 0 dev
ps的执行结果
$ ps
TASK PSS PRIVATE SHARED NAME
j:1029 12.8M 3916k root
p:1044 519.9k 512k 40k bin/devmgr
j:1078 1185.3k 1176k zircon-drivers
p:1643 213.9k 212k 28k devhost:sys
p:1679 185.9k 184k 28k devhost:root
p:1713 373.9k 372k 28k devhost:misc
p:1951 209.9k 208k 28k devhost:pdev:pci
p:2001 201.9k 200k 28k devhost:pdev:00:00:6
j:1082 11.1M 2228k zircon-services
p:1104 9557.9k 432k 17.9M fshost
p:1198 393.9k 392k 28k crashlogger
p:1273 213.9k 212k 28k netsvc
p:1347 253.9k 252k 28k virtual-console
p:2050 233.9k 232k 28k sh:console
p:2157 185.9k 184k 28k vc:sh
p:2258 181.9k 180k 28k vc:sh
p:2319 181.9k 180k 28k vc:sh
j:3582 165.9k 164k
p:3583 165.9k 164k 28k /boot/bin/ps
j:1083 0B 0B fuchsia
TASK PSS PRIVATE SHARED NAME
$