FEMU on an M1 Mac

787 views
Skip to first unread message

John K

unread,
Jun 17, 2021, 6:38:42 AM6/17/21
to discuss

Hello,

I downloaded and installed Fuchsia in an arm64 Mac by running an x64 terminal (as suggested in the documentation).

I've built my Fuchsia image like so:

fx set workstation.qemu-x64 --release
fx build

... and now, when I try to run FEMU, I get this output:

frumiousj@dirtycomputer fuchsia % fx vdl start
2021/06/16 20:56:52 [info] FVD Properties:
device_spec:  {
  horizontal_resolution:  1280
  vertical_resolution:  800
  vm_heap:  192
  ram:  8192
  cache:  32
  screen_density:  240
}
fvm_size:  "2G"
gpu:  "host"

2021/06/16 20:56:52 [info] images: using fvm tool from /Users/frumiousj/src/fuchsia/out/default/host_x64/fvm
2021/06/16 20:56:52 [info] images: using zbi tool from /Users/frumiousj/src/fuchsia/out/default/host_x64/zbi
2021/06/16 20:56:52 [info] Resizing /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/launcher500944086/femu_fvm file to 2G
2021/06/16 20:56:52 [info] found fuchsia board architecture: arm64
2021/06/16 20:56:52 [info] running on host architecture: amd64
2021/06/16 20:56:52 [info] device: DISPLAY=:0
2021/06/16 20:56:52 /Users/frumiousj/src/fuchsia/prebuilt/third_party/aemu/mac-x64/emulator -feature VirtioInput,GLDirectMem,Vulkan,RefCountPipe -metrics-collection -avd-arch arm64 -no-hidpi-scaling -gpu host -window-size 1280x800 -no-location-ui -fuchsia -kernel /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/vdl_staging_MmWNWh/femu_kernel -initrd /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/launcher500944086/femu_zircona-ed25519 -m 8192M -vga none -device virtio-keyboard-pci -smp 4,threads=2 -drive file=/var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/launcher500944086/femu_fvm,format=raw,if=none,id=vdisk -device virtio-blk-pci,drive=vdisk -serial stdio -machine q35 -device isa-debug-exit,iobase=0xf4,iosize=0x04 -cpu Haswell,+smap,-check,-fsgsbase -device virtio_input_multi_touch_pci_1 -soundhw hda -netdev type=user,id=net0,restrict=off,hostfwd=tcp::48220-:22,hostfwd=tcp::54264-:22 -device virtio-net-pci,vectors=8,netdev=net0,mac=52:54:00:63:5e:7a -append "verbose kernel.serial=legacy TERM=xterm-256color kernel.entropy-mixin=42ac2452e99c1c979ebfca03bce0cbb14126e4021a6199ccfeca217999c0aaa0 kernel.halt-on-panic=true zircon.nodename=fuchsia-5254-0063-5e7a kernel.lockup-detector.critical-section-fatal-threshold-ms=0"
2021/06/16 20:56:52 Starting emulator
2021/06/16 20:56:52 [info] Failed ssh. Device is probably not up yet: dial tcp [::1]:48220: connect: connection refused
2021/06/16 20:56:52 [info] Waiting for emulator to start...
2021/06/16 20:56:53 [info] Failed ssh. Device is probably not up yet: dial tcp [::1]:48220: connect: connection refused

[... many more of the same messages]

2021/06/16 20:58:51 [info] Waiting for emulator to start...
2021/06/16 20:58:52 [info] Failed ssh. Device is probably not up yet: dial tcp [::1]:48220: connect: connection refused
2021/06/16 20:58:52 [info] Waiting for emulator to start...

2021/06/16 21:02:02 failed to start Fuchsia device: 4:device health check failed. Unable to ssh due to error:

When I run the 'emulator' directly, it says it needs to replace the executable, does that, and _still_ doesn't work:

frumiousj@dirtycomputer fuchsia % ./prebuilt/third_party/aemu/mac-x64/emulator -feature VirtioInput,GLDirectMem,Vulkan,RefCountPipe,HVF -metrics-collection -no-hidpi-scaling -gpu host -window-size 1280x800 -no-location-ui -fuchsia -kernel /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/vdl_staging_Bw2EMG/femu_kernel -initrd /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/launcher610636832/femu_zircona-ed25519 -m 8192M -vga none -device virtio-keyboard-pci -smp 4,threads=2 -drive file=/var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/launcher610636832/femu_fvm,format=raw,if=none,id=vdisk -device virtio-blk-pci,drive=vdisk -serial stdio -machine q35 -device isa-debug-exit,iobase=0xf4,iosize=0x04 -enable-hvf -cpu Haswell -device virtio_input_multi_touch_pci_1 -soundhw hda -netdev type=user,id=net0,restrict=off,hostfwd=tcp::32824-:22,hostfwd=tcp::52103-:22 -device virtio-net-pci,vectors=8,netdev=net0,mac=52:54:00:63:5e:7a -append "verbose kernel.serial=legacy TERM=xterm-256color kernel.entropy-mixin=42ac2452e99c1c979ebfca03bce0cbb14126e4021a6199ccfeca217999c0aaa0 kernel.halt-on-panic=true zircon.nodename=fuchsia-5254-0063-5e7a kernel.lockup-detector.critical-section-fatal-threshold-ms=0 kernel.page-scanner.page-table-eviction-policy=never"

emulator: ERROR: process is translated under Rosetta. Attempting to replace emulator installation.

emulator: Replacing via command: /Users/frumiousj/src/fuchsia/prebuilt/third_party/aemu/mac-x64/darwin-aarch64-replace.sh (downloading ~120 MB)...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   651  100   651    0     0   2120      0 --:--:-- --:--:-- --:--:--  2120
  1 91.8M    1 1618k    0     0   306k      0  0:05:06  0:00:05  0:05:01  342k^Cemulator: Replacement done. Please relaunch the emulator. You will also need to be using an Apple Silicon-compatible system image.

Any clue as to how to get this working?

Cheers,

- johnk

Daniel Obieglo

unread,
Jun 17, 2021, 9:42:25 AM6/17/21
to discuss, John K, yua...@google.com
cc @Yuan Zhi

i think yuan can help you with that.

The first thing i notice is the "--avd-arch arm64"
i think that the device_launcher doesn't distinguish between the x64 shell and the real arch of the Mac (But this is just a guess on my side).

You could try to run the emulator with
$fx emu
This call will only set the avd-arch flag when you call it with "--experiment-arm64 "

But i'm not sure if this will even work at the moment because of the "darwin-aarch64-replace.sh" ^^


Cheers
Daniel

Yuan Zhi

unread,
Jun 17, 2021, 1:03:40 PM6/17/21
to Daniel Obieglo, Lingfeng Yang, discuss, John K
Hi,

I know that there was some exploratory work running AEMU on a Mac with M1 processors, though we've not tested if FEMU works on it. I've added Lingfeng who might know some more on the current state of AEMU support for M1.

The emulator command is correct, however, when using `fvdl` we copy the images into a temp folder, then delete them afterwards, if you want to run it directly, you'll have to replace the bolded file paths with the ones from your /out/default/...

frumiousj@dirtycomputer fuchsia % ./prebuilt/third_party/aemu/mac-x64/emulator -feature VirtioInput,GLDirectMem,Vulkan,RefCountPipe,HVF -metrics-collection -no-hidpi-scaling -gpu host -window-size 1280x800 -no-location-ui -fuchsia -kernel /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/vdl_staging_Bw2EMG/femu_kernel -initrd /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/launcher610636832/femu_zircona-ed25519 -m 8192M -vga none -device virtio-keyboard-pci -smp 4,threads=2 -drive file=/var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/launcher610636832/femu_fvm,format=raw,if=none,id=vdisk -device virtio-blk-pci,drive=vdisk -serial stdio -machine q35 -device isa-debug-exit,iobase=0xf4,iosize=0x04 -enable-hvf -cpu Haswell -device virtio_input_multi_touch_pci_1 -soundhw hda -netdev type=user,id=net0,restrict=off,hostfwd=tcp::32824-:22,hostfwd=tcp::52103-:22 -device virtio-net-pci,vectors=8,netdev=net0,mac=52:54:00:63:5e:7a -append "verbose kernel.serial=legacy TERM=xterm-256color kernel.entropy-mixin=42ac2452e99c1c979ebfca03bce0cbb14126e4021a6199ccfeca217999c0aaa0 kernel.halt-on-panic=true zircon.nodename=fuchsia-5254-0063-5e7a kernel.lockup-detector.critical-section-fatal-threshold-ms=0 kernel.page-scanner.page-table-eviction-policy=never"

Yuan

Frank Yang

unread,
Jun 17, 2021, 1:08:24 PM6/17/21
to Yuan Zhi, Daniel Obieglo, discuss, John K
We've been running the emulator natively for M1 for Android guests for quite a while, it's supported in Android Studio.

Frank Yang

unread,
Jun 17, 2021, 1:09:25 PM6/17/21
to Yuan Zhi, Daniel Obieglo, discuss, John K

John Kemp

unread,
Jun 17, 2021, 4:50:09 PM6/17/21
to Frank Yang, Yuan Zhi, Daniel Obieglo, discuss
That was pretty helpful. I downloaded the zipfile for aarch64_sdk_tools_mac and unzipped it into the aemu mac-x64 prebuilt directory.

I had to use xattr to get past an error about needing to dump the new emulator in the trash:

xattr -cr ./prebuilt/third_party/aemu/mac-x64

Then I tried to run using fx (avoiding the need to change the file paths as Yuan suggested.

I see the emulator flash for a second, but then, a crash...

frumiousj@dirtycomputer fuchsia % cat out/emu_crash.log
cannot add library /Users/frumiousj/src/fuchsia/prebuilt/third_party/aemu/mac-x64/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib: failed
cannot add library /Users/frumiousj/src/fuchsia/prebuilt/third_party/aemu/mac-x64/lib64/vulkan/libvulkan.dylib: failed
cannot add library /Users/frumiousj/src/fuchsia/prebuilt/third_party/aemu/mac-x64/qemu/darwin-aarch64/lib64/vulkan/libMoltenVK.dylib: failed
added library /Users/frumiousj/src/fuchsia/prebuilt/third_party/aemu/mac-x64/lib64/vulkan/libMoltenVK.dylib
createOrGetGlobalVkEmulation: warning: instance doesn't support external memory capabilities, picking first physical device
qemu-system-aarch64: -kernel /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/vdl_staging_IJ68K1/femu_kernel: unsupported machine type
Use -machine help to list supported machines
qemu-system-aarch64: -kernel /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/vdl_staging_IJ68K1/femu_kernel: No machine specified, and there is no default
Use -machine help to list supported machines
emulator: WARNING: IniFile.cpp:228: Write called without a backing file!
handleCpuAccelerationForMinConfig: configure CPU acceleration
handleCpuAccelerationForMinConfig: Checking CPU acceleration capability on host...
handleCpuAccelerationForMinConfig: Host can use CPU acceleration
handleCpuAccelerationForMinConfig: Host CPU acceleration capability status string: [Hypervisor.Framework OS X Version 11.4]
handleCpuAccelerationForMinConfig: Selecting HVF for CPU acceleration
emulator: INFO: QtLogger.cpp:68: Debug: Location UI disabled by command-line option. (/Volumes/Android/buildbot/src/android/emu-master-dev/external/qemu/android/android-emu/android/skin/qt/extended-pages/location-page.cpp:137, LocationPage::LocationPage(QWidget *))

I haven’t checked yet to see what the supported machine types have to do with this, but if anything obvious stands out, please let me know!

Thanks,

- johnk

Frank Yang

unread,
Jun 17, 2021, 5:19:00 PM6/17/21
to John Kemp, Yuan Zhi, Daniel Obieglo, discuss
qemu-system-aarch64: -kernel /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/vdl_staging_IJ68K1/femu_kernel: unsupported machine type
Use -machine help to list supported machines
qemu-system-aarch64: -kernel /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/vdl_staging_IJ68K1/femu_kernel: No machine specified, and there is no default
Use -machine help to list supported machines

Looks like that's the issue. You'll have to build the arm64 version of Fuchsia, most likely

John Kemp

unread,
Jun 17, 2021, 6:40:28 PM6/17/21
to Frank Yang, Yuan Zhi, Daniel Obieglo, discuss
> On Jun 17, 2021, at 5:16 PM, Frank Yang <l...@google.com> wrote:
>
> qemu-system-aarch64: -kernel /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/vdl_staging_IJ68K1/femu_kernel: unsupported machine type
> Use -machine help to list supported machines
> qemu-system-aarch64: -kernel /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/vdl_staging_IJ68K1/femu_kernel: No machine specified, and there is no default
> Use -machine help to list supported machines
>
> Looks like that's the issue. You'll have to build the arm64 version of Fuchsia, most likely

Thanks for the suggestion. I had tried that earlier, but no luck.

And when I look at qemu-system-aarch64:

frumiousj@dirtycomputer fuchsia % ./prebuilt/third_party/aemu/mac-x64/qemu/darwin-aarch64/qemu-system-aarch64 --machine help
dyld: Library not loaded: /Users/lyang/install-qt/lib/libQt5CoreAndroidEmu.5.dylib
Referenced from: /Users/frumiousj/src/fuchsia/./prebuilt/third_party/aemu/mac-x64/qemu/darwin-aarch64/qemu-system-aarch64
Reason: image not found
zsh: abort ./prebuilt/third_party/aemu/mac-x64/qemu/darwin-aarch64/qemu-system-aarch64

FWIW, there is no ‘lyang’ user on my laptop, so of course libQt5CoreAndroidEmu.5.dylib will not load…

Frank Yang

unread,
Jun 18, 2021, 11:36:37 AM6/18/21
to John Kemp, Yuan Zhi, Daniel Obieglo, discuss
You can't run ./prebuilt/third_party/aemu/mac-x64/qemu/darwin-aarch64/qemu-system-aarch64 directly. You need to follow what the fx emu script is doing.

John Kemp

unread,
Jun 22, 2021, 8:44:24 PM6/22/21
to Frank Yang, Yuan Zhi, Daniel Obieglo, discuss
On Jun 18, 2021, at 11:34 AM, Frank Yang <l...@google.com> wrote:

You can't run ./prebuilt/third_party/aemu/mac-x64/qemu/darwin-aarch64/qemu-system-aarch64 directly. You need to follow what the fx emu script is doing.

I haven’t had much luck with that. My emu crash log still has the following errors:

> frumiousj@dirtycomputer fuchsia % cat out/emu_crash.log 
> cannot add library /Users/frumiousj/src/fuchsia/prebuilt/third_party/aemu/mac-x64/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib: failed
> cannot add library /Users/frumiousj/src/fuchsia/prebuilt/third_party/aemu/mac-x64/lib64/vulkan/libvulkan.dylib: failed
> cannot add library /Users/frumiousj/src/fuchsia/prebuilt/third_party/aemu/mac-x64/qemu/darwin-aarch64/lib64/vulkan/libMoltenVK.dylib: failed
> added library /Users/frumiousj/src/fuchsia/prebuilt/third_party/aemu/mac-x64/lib64/vulkan/libMoltenVK.dylib
> createOrGetGlobalVkEmulation: warning: instance doesn't support external memory capabilities, picking first physical device
> qemu-system-aarch64: -kernel /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/vdl_staging_IJ68K1/femu_kernel: unsupported machine type
> Use -machine help to list supported machines
> qemu-system-aarch64: -kernel /var/folders/5l/7f_8r141005d0dp1446cl3t80000gn/T/vdl_staging_IJ68K1/femu_kernel: No machine specified, and there is no default
> Use -machine help to list supported machines

Interestingly, I am able to build qemu using the zircon instructions and then run that for zircon. But that qemu doesn’t work for fuchsia, which seems to require the AOSP qemu. 

All a bit confusing - I have 3 qemus - the open source one, the zircon one, and the fuchsia prebuilt one. All with different behaviour, and everything but the fuchsia one, working.

Abin Vijayasadan

unread,
Oct 15, 2022, 4:34:26 AM10/15/22
to discuss, John K, Yuan Zhi, d.ob...@gmail.com, discuss, Frank Yang

Hi,
I want to try fuchsia emulator images. Is this supported in m1 chip currently?
Reply all
Reply to author
Forward
0 new messages