I recently added support for building a Mach-O binary directly within the ReactOS unofficial fork. Follow the instructions below for building freeldr.sys
to build it; you will get a file called mach_kernel
which you can copy to a USB directly as described below.
THIS PROJECT IS NOT FINISHED OR PRODUCTION READY. DO NOT ATTEMPT TO USE THIS TO INSTALL WINDOWS ON YOUR APPLE TV. IT WILL NOT WORK.
Wrapper and first stage bootloader for the unofficial original Apple TV port of FreeLoader, allowing ReactOS and Windows to run on the Apple TV (1st Generation). See below for information on project status and instructions.
Project status as of 12/26/2023: 80% complete. ReactOS will successfully boot to the desktop on both VirtualBox and real hardware, but PCI does not work correctly, leading to most hardware not working. This issue is an upstream UEFI issue with ReactOS/FreeLoader.
Portion | Status | Location | Notes |
---|---|---|---|
First stage boot loader | 100% | This repository | Complete |
FreeLoader | 98% | ReactOS unofficial fork | PCI stuff needs to be fixed |
ReactOS booting | 60% | ReactOS unofficial fork | USB not working (caused by PCI breakage) |
Windows XP/2003 boot support | 30% | Microsoft, I guess | - UEFI video driver not yet working - ACPI 1.x tables not passed in yet |
Available when PCI is fixed
The first (here) and second (ReactOS) stages of this bootloader have entirely different build systems. This guide will go over both.
Note: Building on Linux is recommended no matter what, as it will simplify the process later on.
- Install the ReactOS build environment (Linux users: ignore the PPA, use the link above it for download)
- Clone/download the unofficial ReactOS:
git clone https://github.com/DistroHopper39B/reactos && cd reactos
- Run
./configure.sh -DSARCH=appletv
(Linux, macOS) orconfigure.cmd -DSARCH=appletv
(Windows) from within the ReactOS Build Environment - cd to the output directory (called
output-MinGW-i386
in most cases) - Run
ninja freeldr
FreeLoader will be located at <output dir>/boot/freeldr/freeldr/freeldr.sys
.
This is the easiest way to build freeldr-wrapper-appletv
and will work on macOS 10.8 and above.
- Install the Xcode Command Line Tools if you haven't already by typing
xcode-select --install
into Terminal - Build FreeLoader (see above)
- Clone/download this repository:
git clone https://github.com/DistroHopper39B/freeldr-wrapper-appletv && cd freeldr-wrapper-appletv
- Run
make FREELDR_SYS=/path/to/freeldr.sys
, replacing/path/to/freeldr.sys
with your actual path.
You will now have a mach_kernel
file.
On Linux, we have to cross-compile to generate the correct executable format. These steps should work on any modern Linux distribution.
- Build FreeLoader (see above)
- Install prerequisites:
clang llvm libstdc++6 libdispatch autoconf automake
(libstdc++6
is part ofgcc-libs
on Arch) - Clone/download
cctools-port
:git clone https://github.com/tpoechtrager/cctools-port.git
. This is needed to link for macOS. - cd into the correct directory:
cd cctools-port/cctools
- Build:
./configure --prefix=/opt/cross --target=i386-apple-darwin8 && make -j$(nproc) && sudo make install
- Clone/download this repository:
git clone https://github.com/DistroHopper39B/freeldr-wrapper-appletv && cd freeldr-wrapper-appletv
- Run
make
You will now have a mach_kernel
file.
Follow the Linux steps in WSL.
The following files must be placed on a specially formatted (we'll get to this later) USB stick:
boot.efi
: Apple-official file designed to load a Mac OS X kernel. Instructions for acquiring are below.mach_kernel
: The actual bootloader that we compiled/downloaded earlier. Acts like a Mac OS X kernel to allowboot.efi
to load it.com.apple.Boot.plist
: A configuration file for the Appleboot.efi
. Located inUSBData
./System/Library/Extensions/KernelMemoryAccess.kext
: A "dummy kext" that is only used to makeboot.efi
happy.BootLogo.png
: The graphic seen at the top of this page. If this is not included, a white Apple screen will appear instead.
The Apple TV will only boot using the Apple original boot.efi
shipped with the device. Since this file cannot
be redistributed, we must download it directly from Apple.
The software update can be found at https://mesu.apple.com/data/OS/061-7495.20100210.TAVfr/2Z694-6013-013.dmg.
It is roughly 235MB in size and has a SHA-1 checksum of 97623d8d21bb59b0f4dc9d1b1c037f25c9fe09c3
. On Windows or Linux,
we can use 7-zip or p7zip
to extract the boot.efi from this file. A one-liner to extract the file
would be:
7z e 2Z694-6013-013.dmg OSBoot/System/Library/CoreServices/boot.efi
On macOS, you can mount the image directly within Finder. boot.efi
is stored at /OSBoot/System/Library/CoreServices/boot.efi
.
For now, these instructions will only work on Linux. It is possible to do this process on both Windows and macOS, but for now, these instructions will only apply to Linux.
First, you will need a USB flash drive. The capacity doesn't matter, but you shouldn't be using it for anything else, because we will be storing the bootloader on this drive permanently (loading only from the hard drive is possible but complex).
To set up the USB drive, follow these steps:
- Install and open GParted.
- Select your USB drive.
- Go to
Device -> Create Partition Table
. If necessary, unmount partitions usingPartition -> Unmount
. - Set the partition table type to
gpt
and click Apply. WARNING: THIS WILL DELETE ALL DATA ON YOUR USB FLASH DRIVE!! - Go to
Partition -> New
. Set the filesystem tofat32
and the label toboot
. - Apply the changes.
- Select your new partition and go to
Partition -> Flags
, then check theatvrecv
box. - Close GParted. The disk should show up in your file manager's device list. If it doesn't, disconnect and reconnect it.
- Copy
boot.efi
.mach_kernel
,com.apple.Boot.plist
,BootLogo.png
, and theSystem
folder to the root of the USB drive. - Eject the USB drive.
See CONFIGURATION.md.
More detailed instructions to follow. Basically, you have to remove the hard drive from the Apple TV, install Windows or ReactOS on it through any one of a variety of methods, and reinstall it. As of 1/2/2024, the expected behavior is getting to the desktop, but since PCI is broken, it's impossible to actually control the system.
- The_DarkFire_ for helping me with this process and answering my stupid questions
- The developers of atv-bootloader and its predecessors
- The OSDev wiki for helping with my PCI IDE hack
- The ReactOS developers for creating FreeLoader
The majority of this project is licensed under the MIT license. However, since some files are sourced from atv-bootloader and the Linux kernel, both GPL-2.0-only projects, the project is distributed under the GPLv2. The FreeLoader boot info header is distributed under the GPL-2.0-or-later license for its inclusion in FreeLoader.
TODO: Use/create MIT-able vsprintf
so that base functionality does not require GPL to be used.