You've loaded an old revision of the document! If you save it, you will create a new version with this data. Media Files====== The Dreaded ACPI Timeout Bug ====== Some models can experience really, really long boot times with OpenBSD. This bug has been known for a while and seems to have appeared around OpenBSD 7.6. It has [[https://bsd.network/@brynet/114322673716285788|featured]] [[https://old.reddit.com/r/openbsd/comments/1ixz0bn/macbook_2015/|in]] [[https://marc.info/?l=openbsd-bugs&m=173855804823166&w=2|a lot of]] [[https://marc.info/?l=openbsd-misc&m=174438934730598&w=2|discussions]], and resolving it caused so much unbridled joy that it prompted the creation of this entire wiki. ===== The Symptoms ===== Booting the stock installer or kernel will cause the boot procedure to hang quite early on, usually after identifying the hard disks: {{ :misc:acpi-bug-macbook-12-1.jpg?direct&640 |}} As @brynet@bsd.network pointed out, it is caused by "some kind of regression that triggers a weird ACPI firmware bug on this machine." The machine **will** boot, eventually, if you leave it long enough, usually 2+ hours. However, without applying a simple patch to the kernel, it will do the same thing every single time you boot the machine. ===== Affected Models ===== * [[:A1502]] Early 2015 Macbook Pro * Maybe others? ==== Patch to fix the ACPI bug ==== <code> Index: sys/dev/acpi/acpi.c =================================================================== RCS file: /cvs/src/sys/dev/acpi/acpi.c,v diff -u -p -u -r1.444 acpi.c --- sys/dev/acpi/acpi.c 24 Mar 2025 09:53:20 -0000 1.444 +++ sys/dev/acpi/acpi.c 20 Apr 2025 19:45:13 -0000 @@ -823,8 +823,8 @@ acpi_pci_set_powerstate(pci_chipset_tag_ } #endif /* NACPIPWRRES > 0 */ - if (state == ACPI_STATE_D0 && pre) - aml_evalname(sc, pdev->node, "_PS0", 0, NULL, NULL); +// if (state == ACPI_STATE_D0 && pre) +// aml_evalname(sc, pdev->node, "_PS0", 0, NULL, NULL); } int </code> ==== How to patch ==== You have two options: build a custom installer and install your system with a patched kernel, or going the "slow way" and wait out the long boot time on booting the installer; installing the system; waiting out the first boot; then patching the kernel for the machine you are on. Before you start, give the following manual pages a good read, you will have a much clearer understanding of what's going on: * [[https://www.openbsd.org/anoncvs.html|Getting sources from the OpenBSD CVS]] * [[https://man.openbsd.org/release|RELEASE(8) Manual Page]] * [[https://www.openbsd.org/faq/faq5.html|OpenBSD FAQ - Building the System from Source]] * If going the "Custom installer" route, [[https://www.openbsd.org/faq/faq4.html#MkInsMedia|OpenBSD FAQ - Creating Install Media ]] === I. The Slow Boot Way === Waiting out the slow boot times is probably a little bit easier, and it doesn't require you to have another working OpenBSD install that you can use to compile a custom kernel and create a custom installer image. So after you have downloaded the latest ''installXX.img'', flashed it to a USB drive or whatever, plugged it in, booted up the Mac by holding down Option until you see the bootloader screen, selected the USB drive ("EFI BOOT" usually), started the installer, waited / slept / went for a walk until it got over the ACPI nonsense, installed, rebooted, waited / slept / went for a walk until it got over the ACPI nonsense again, and logged in... == 0. Setting some ENV variables == It makes your life easier if you set the $CVSROOT env variable in your ''%%~/.profile%%'' or ''%%~/.kshrc%%'' or preferred place that will get sourced on login. First, pick a server close to you from the list at the bottom of the [[https://www.openbsd.org/anoncvs.html|OpenBSD Anonymous CVS]] page Then add to your dotfile of choice the below: <code> export CVSROOT=anoncvs@url-to-your-cvs-server-of-cho.ice:/cvs </code> And source it: <code> $ . ~/.my-favourite-dotfile </code> == 1. Add your user to the source groups == You need to be a member of ''wsrc'' and ''wobj'' groups. As root, therefore, run: <code> # usermod -G wsrc,wobj $YOURUSERNAME </code> == 2. CVS Checkout the Tree of the Sauce == It is important that you get the sources for the branch you follow. Check the instructions under **"Getting an Initial Tree"** on the [[https://www.openbsd.org/anoncvs.html|OpenBSD Anonymous CVS]] page. If you are on ''-current'', it's advised you make sure you are on the latest snapshot before downloading the source tree, by running ''%%# sysupgrade -s%%'' first. First checkout takes a while, but once done, you should have the source tree in ''/usr/src''. == 3. Patch / Edit the appropriate files == Paste the contents of the Patch above into a new file (let's call it <del>best-patch-ever.diff</del> ''mac_acpi_patch.diff'' for our purposes), and then run: <code> $ patch < mac_acpi_patch.diff </code> You can of course simply comment out the two (!) affected lines manually; [[https://old.reddit.com/r/openbsd/comments/1ixz0bn/macbook_2015/|you need to delete / comment out two lines]] in ''/usr/src/sys/dev/acpi/acpi.c''. (In OpenBSD 7.7 they start at :823). == 4. Compiling == Follow the ''release(8)'' man page closely here. As root, first, change directories to the appropriate directory in ''/sys''. Make sure you are in the right folder because ''/usr/src/sys'' follows the same directory structure, but if you compile from there, you won't get the right results. This was a lesson learned //The Hard Way//™. So to be on the safe side do exactly as the manpage says, and run: <code> $ doas -s # cd /sys/arch/amd64/compile/GENERIC.MP </code> Then proceed as the manual suggests, with root privileges - otherwise "make install" will fail. This is another lesson learned //The Hard Way//™. <code> # make obj # make config # make && make install </code> After you reboot, the new kernel should be the one in use. It will be easy to tell whether the patch worked, because if your system boots "normally", it worked, if you are back at waiting for 2+ hours at "sd0", it failed and you need to check over whether you did everything correctly. ---- === II. The Custom Installer Way === Creating a custom installer requires you to have another amd64 machine running OpenBSD. You will be able to build the kernel at the version your OpenBSD machine is already on. You need to make sure you are fetching the appropriate version of the sources, like above. The procedure, in short, involves building the custom GENERIC.MP image as well as a custom RAMDISK, but WITHOUT running ''make install'' at the end. Then you create a ''vnode'' device out of the downloaded ''installXX.img'', mount it, then overwrite the installer's {bsd,bsd.mp,bsd.rd} files with the ones you created. == 0. Preliminaries == You will also need a copy of ''installXX.img'' and a flash drive. (Some Macs cannot boot off an SD card so best to stick with USB flash drives). If you are on ''-current'' then you need to make sure that the installer you download corresponds to the snapshot you are on. To see what version exactly you are on, run: <code> $ sysctl kern.version kern.version=OpenBSD 7.7-current (GENERIC.MP) #0: Wed Apr 23 20:21:10 BST 2025 [..snip..] </code> Note the date; in the above example, it's **"Apr 23 2025"**, so you need the installXX.img from that same snapshot - as it's on **7.7-current** it will be ''install77.img''. A good place to get previous snapshots is on ''ftp://ftp.hostserver.de/archive/'', choosing the ''YYYY-MM-DD-HHSS'' format directory that corresponds to the date of your ''kern.version'' date; so in this example, the file needed would be at: ''%%https://ftp.hostserver.de/archive/%%**2025-04-23-0105**/snapshots/amd64/**install77.img**'' ==== Upgrading your system after patching ==== Should a new release come out, unless there's a rewrite of ''acpi.c'', you will need to re-patch your kernel upon upgrade. On your working, normally booting system, you need to patch in place like with "The Slow Boot Way" above. First, you need to follow the "anoncvs" tutorial on the OpenBSD website and upgrade the source tree. When updating it will skip "acpi.c" because you have manually changed the file locally. Overwrite the local changes by running: <code> # cd /usr/src/dev/acpi/ # cvs update -C acpi.c </code> This will then move your own version of ''acpi.c'' to a hidden backup file, something like ''.#acpi.c.1.444'' or similar, keep a note of the command output. Run a diff on the freshly fetched acpi.c and the one you had: <code> # diff acpi.c .#acpi.c.1.444 </code> If the only two lines that differ are the ones you commented out with the above patch, just ''mv'' back ''.#acpi.c*'' to ''acpi.c'' because there were no changes. If the output of ''diff'' is more substantial, you might need to edit out the two lines by hand again; if they still exist, and give us a shout so we can also update this tutorial. You now need to build the kernel as above, but **without** running ''make install''. You then need to fetch the release you are upgrading to, but without rebooting. On ''-current'' this will be: <code> # sysupgrade -ns </code> On ''-stable'' this will be: <code> # sysupgrade -n </code> Then sysupgrade will download the new files for the download, you will find then under ''/home/_sysupgrade''. You will then need to swap out the ''bsd.mp'' file in ''/home/_sysupgrade'' with what you just compiled. <code> # install -bp /usr/obj/sys/arch/amd64/compile/GENERIC.MP/bsd /home/_sysupgrade/bsd.mp </code> Reboot... Done!SavePreviewCancel Edit summary Note: By editing this page you agree to license your content under the following license: CC Attribution-Share Alike 4.0 International