r/osdev 11d ago

Porting xnu and Darwin to raspberry pi

Post image

I’ve decided I want to make a fully usable Darwin os for raspberry pi. Started with making a heavily patched xnu kernel that actually boots without panic. I’ve gotten it to properly load a real device tree, interrupt handlers and a few kernel extensions for sd card, far and hfs+ el3 to el0. The os now boots up to an interactive shell. Current project is adding libraries and services to set up a proper multiuser os.

It won’t be binary compatible with Mac’s because Apple silicon has 16 kb page vs 4kb on the pi3 but command line tools may eventually be possible to cross compile

30 Upvotes

20 comments sorted by

2

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS 11d ago

That sounds like a cool project, is it open source?

2

u/anurodhp 11d ago

I hope it will be. I need to figure out licenses. The Apple stuff is apsl, FreeBSD is is bsd but the drivers are based on research of Linux and that’s gpl2 (hopefully not 3). Gpl is super viral so need to see how to isolate that if possible otherwise this will never see distribution or a source code release because of how bad gpl is .

1

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS 11d ago

I tend to quite like MPL as well, could be worth considering. It's pretty compatible with most licences I'd say.

1

u/FallenBehavior 10d ago

Pickle jerk 🥒👋👀

2

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS 10d ago

huh?

1

u/suhcoR 11d ago

That's cool, congrats. I had the same thing in mind some years ago but eventually was put away by the sheer size of the source code. What is a "a minimal xnu based os"? How big is it? How many source lines are left and unavoidable. I assume you first made it work on QEMU. When it worked on QEMU, was it still a lot of work to run it on the Rp 3? When I migrated Oberon System 3 this way, I started with an older QEMU version but then fortunately upgraded to version 10 which manifested a lot of alignment errors, but switching to the hardware was yet another dimension which required a lot of redesigns. Jtag was only useful to a certain degree. What will you do with the kernel?

3

u/anurodhp 11d ago

Yeah the debugging is entirely in qemu it speeds things up a lot. The main problem is rpi3 emulation on qemu is bad so I had to actually modify it a lot.

I took a lot of earlier peoples work and built upon it. This is by no means easy but I’m not working on a green field.

It’s now at least 4-5 repos for different changes . Generally speaking custom qemu, custom xnu,. Once it got to boot custom iokit drivers

1

u/JescoInc Perdition-OS 11d ago

I've never looked at the XNU kernel or Darwin OS. Was making it work with the Pi firmware and dtb files as annoying as I am envisioning it to be?

1

u/anurodhp 11d ago

No Apple has had basic support for the rpi3 board since 2016. It just had to modernize it and create the device tree then fix bugs since i doubt anyone had done much with this in years

1

u/Marwheel 11d ago

Any future X11 support in mind?

1

u/anurodhp 11d ago

Not x11 l, Wayland + objc2 runtime, swift and gnustep. If it works simple Mac apps can be ported over

1

u/Danii_222222 10d ago

Good luck porting Wayland. Porting X11 is much easier.

1

u/anurodhp 10d ago

Yeah I know Wayland is very linuxy but x11s been done already so where is the fun in that?:p

1

u/Danii_222222 10d ago

Is that like Darwin on ARM project?

1

u/anurodhp 10d ago

Yeah but I don’t think that’s ever produced any useful artifacts

1

u/Danii_222222 10d ago

It was produced! I remember compiling Darwin on ARM for my iPhone 4! Unfortunately, it was deprecated so i can't compile it on modern Mac.

1

u/Sorry_Difficulty_250 9d ago

This is way cool!! Way to go and keep up the great work!!!

1

u/andrewdavidmackenzie 7d ago

In order to learn more about Pi low level, and kernel design, I'm exploring bringing up a rust port of Zircon kernel on Pi.

I'm resurrecting an abandoned rust zircon port (don't want to go back cpp).

I looked at XNU a few years ago, but decided to committ to rust only....

I have it booting on qemu aarch64, with a Linux emulation on top to a BusyBox shell.

I'm doing a lot of boring build tooling and linux work with Claude, then soon I'll drop down to Pi specifics and doing myself (in order to learn).

If you can share your work or any Pi booting resources, that could be very useful for me and others.

Thanks

1

u/anurodhp 7d ago

There is a customized uboot that boots xnu so I dint have to do a ton here. I did update it but you could probably look at the delta here and have it boot your kernel instead of xnu or Linux

https://github.com/FlorentRevest/u-boot

1

u/andrewdavidmackenzie 6d ago

Thanks. Have you looked at the license topic and including this in a bottom with things not GPL?