# Will the work Asahi Linux is doing to bring Linux to Apple Silicon be able to benefit FreeBSD in the future?



## puppyboy (Dec 29, 2022)

I did a bit of Google searching and didn't see anything talking about this, surprisingly. As you are probably aware, Asahi Linux is a project to bring a fully functioning Linux desktop experience to Apple Silicon-based computers. It's still in the early stages but it is expected that their efforts will be brought over to all the major Linux distributions at some point in the future, once it gets further along.

What I'm wondering is, how much can FreeBSD benefit from what they're doing? License-wise, according to their website most of their code is MIT-licensed or similar, which (I think?) is compatible with BSD. But as far as the code itself, is that something that can eventually be brought into the FreeBSD codebase without too much effort, allowing us to eventually run FreeBSD on our Mac hardware? Or is there so much difference that someone would essentially have to start a comparable FreeBSD-based project from scratch?

I'm not a kernel developer by any means so a lot of the nuts and bolts there go way over my head, so I don't know what all this would really entail. Do you foresee a future with FreeBSD running on Apple Silicon thanks to the work Asahi is doing? Or is it just unfeasible to port over?


----------



## rootbert (Dec 29, 2022)

short- and medium-term: no, long-term maybe. Since we even do not have a modern wireless stack I guess this is just too much work for the few hard-working FreeBSD devs. But then I am no fortune-teller.


----------



## kpedersen (Dec 29, 2022)

OpenBSD has early support for Apple's proprietary aarch64 so it is likely that FreeBSD will follow suite and at least borrow some code. Some of this work was done along with the Asahi Linux developers.

https://www.openbsd.org/72.html

I find FreeBSD has better support for "Broadcom Silicon" in the Raspberry Pi than OpenBSD (especially when it comes to power management) and this is closely related but I think for Apple, much of the efforts are in their GPU that lacks standards like OpenGL and Vulkan. That we do share with Linux.


----------



## rootbert (Dec 29, 2022)

wow, that sounds cool and promising! So in the end not all hope is gone I will buy Apple hardware in the future - I have only dealt with the xserve servers on Linux and FreeBSD and my personal ipod shuffle ;-)


----------



## Beastie7 (Dec 29, 2022)

puppyboy said:


> Do you foresee a future with FreeBSD running on Apple Silicon thanks to the work Asahi is doing?



FreeBSD doesn't even have proper 802.11ac support yet. We probably won't see a working port for the next decade or so.


----------



## ralphbsz (Dec 30, 2022)

Let's do a checklist:

Code generation for the CPU.
Basic CPU/memory initialization support.
Disk interface.
Booting and hardware initialization.
USB interface driver.
Keyboard, mouse (trackpad), and video driver in VGA text mode.
At this point, you have a working computer that one can log into and do useful work. It can use USB-connected network interfaces. I suspect we're pretty close to this.

The next logical step would be to run FreeBSD in a virtual machine inside MacOS. It would have the advantage that it could use the host OS for networking, and for some limited graphical work. I know there are several hosted hypervisors in the works or already existing (VMware, Parallels), those might be useful.

The final step would be to run FreeBSD natively with graphics and wireless support. That seems inordinately difficult.


----------



## yuripv79 (Dec 30, 2022)

There is apparently some work in progress for Apple Silicon:

```
commit 753a23ac152c5024de34f9eb02a2fdccf2881085
Author: Kyle Evans <kevans@FreeBSD.org>
Date:   Fri Nov 11 13:50:29 2022 -0600

    arm64: add a spin-table implementation for Apple Silicon

    The M1 has no EL3, so we're limited to a spin-table implementation if we
    want to eventually use bhyve on it.  Implement spin-table now, but note
    that we still prefer PSCI where possible.

    Reviewed by:    mmel
    Differential Revision:  https://reviews.freebsd.org/D34661
```

Not sure if there's more to that.


----------



## hardworkingnewbie (Dec 30, 2022)

puppyboy said:


> What I'm wondering is, how much can FreeBSD benefit from what they're doing?


The FreeBSD developers can see how stuff is done with Apple Silicon. And then they can rewrite that from scratch. That's basically how they can benefit from it, they can skip the reverse engineering phase done by the Asahi Linux guys if they want to. 

Aside that it is probably better to still understand what's going on with Apple Silicon, because e.g. the loudspeaker coils are sensible to too much volume, which means too much temperature. So MacOS enforces volume limits based on temperature if it gets too high, Linux so far has no such thing in place.









						Speaker protection research · Issue #53 · AsahiLinux/linux
					

Opening this to track the ongoing research into the safety envelope of the speakers (focusing mostly on testing; we can open other threads to discuss potential solutions once we have more data on w...




					github.com


----------



## msplsh (Dec 30, 2022)

hardworkingnewbie said:


> Aside that it is probably better to still understand what's going on with Apple Silicon, because e.g. the loudspeaker coils are sensible to too much volume, which means too much temperature. So MacOS enforces volume limits based on temperature if it gets too high, Linux so far has no such thing in place.


Short answer is yes there's a benefit, because of stuff like this.  Asahi is finding all the undocumented stuff that is really hard to figure out.  If anybody wants to put FreeBSD on Apple Silicon, their job will be easier because Hector & friends found all the quirks, magic numbers, and whatnot.  They're also doing a great job with the video drivers.

The question of "how much" depends on the effort FreeBSD developers put into it.  If there was one developer as dedicated as Hector, I would say it would be a tremendous help.  If it's just "hey we'll get around to it" then maybe only a minimal amount of help, as most of the effort would be actually _doing_ the work.

Since Asahi is GPL like Linux, the code itself isn't useful directly by FreeBSD .  Video driver might be, depending.

Easier to walk the trail than blaze it, but FreeBSD would still have to walk it.


----------



## ralphbsz (Dec 30, 2022)

Let me ask a question: How much value is there in putting effort into this? How many people really run FreeBSD with a GUI? How many of those would run it on a modern Mac?

I know a small number of FreeBSD and OpenBSD developers. I have yet to find one whose "daily driver" laptop is a FreeBSD machine; instead I see Macs running MacOS, Lenovo running Linux, Chromebooks, and in one particularly memorable case a large desktop running Windows (yes, that person is a *BSD kernel developer). Maybe I know all the wrong people.


----------



## cracauer@ (Dec 30, 2022)

ralphbsz said:


> Let me ask a question: How much value is there in putting effort into this? How many people really run FreeBSD with a GUI? How many of those would run it on a modern Mac?
> 
> I know a small number of FreeBSD and OpenBSD developers. I have yet to find one whose "daily driver" laptop is a FreeBSD machine; instead I see Macs running MacOS, Lenovo running Linux, Chromebooks, and in one particularly memorable case a large desktop running Windows (yes, that person is a *BSD kernel developer). Maybe I know all the wrong people.



You seem to imply that running on a Mac would be done with a GUI.

Using a M1 or M2 Mac as a ssh-only machine that does `make world` in a reasonable time with very low power usage seems a good goal.


----------



## ralphbsz (Dec 30, 2022)

Ah, that is a very sensible argument. While the ARMs CPUs that Apple sells end up being pretty expensive (because you have to buy a whole MacBook or iMac to get one), they are also pretty fast and very power efficient. My guess would be: If someone wants this, they would probably be best served by running FreeBSD in a VM under a MacOS hypervisor. Matter-of-fact, I would like to have that myself; my daily driver is a big Mac, and sometimes I need to work disconnected (for example, I spent all day in a car yesterday, going down half the west coast), and having a FreeBSD CLI machine available could be handy.


----------



## msplsh (Dec 30, 2022)

When Apple decides to stop supporting the M1 macs, for the foreseeable future, the only updated OS that will run on it will be Asahi.

Or it could be FreeBSD as well.  That's the value.


----------



## cracauer@ (Dec 30, 2022)

ralphbsz said:


> Ah, that is a very sensible argument. While the ARMs CPUs that Apple sells end up being pretty expensive (because you have to buy a whole MacBook or iMac to get one),



The Mac mini is the most interesting option for a power-saving FreeBSD dev machine. But they don't have M2 chips yet.


----------



## ralphbsz (Dec 30, 2022)

msplsh said:


> When Apple decides to stop supporting the M1 macs, ...
> Or it could be FreeBSD as well.  That's the value.


FreeBSD doesn't even support the i386 as a Tier 1 platform any longer. And there are zillions of those around, compared to relatively few M1 Macs. But the question of where to invest resources is not for me to decide.

Traditionally, support for outdated hardware is NetBSD's realm. Matter-of-fact, supposedly you can run the most current NetBSD 10.0 on a VAX 11/780.

P.S. The Mac Mini idea is good. Matter-of-fact, you can rent Minis in the cloud (at least Amazon AWS provides them, perhaps other vendors too).


----------

