### Install LogoutHook Source: https://github.com/acidanthera/opencorepkg/blob/master/Utilities/LogoutHook/README.md Install the LogoutHook service using the provided command. ```bash ./Launchd.command install ``` -------------------------------- ### Prepare QEMU Launch Directory Structure Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md Example directory structure for launching QEMU with OpenCore. Ensure your EFI boot files are placed correctly within the ESP. ```text . └── ESP └── EFI ├── BOOT │   └── BOOTx64.efi └── OC ├── OpenCore.efi └── config.plist ``` -------------------------------- ### Run QEMU with Basic Configuration Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md Starts QEMU with the OVMF firmware and a raw FAT filesystem for the EFI System Partition. This command uses the combined OVMF.fd file. ```bash ./build.sh -a X64 qemu -drive format=raw,file=fat:rw:ESP ``` -------------------------------- ### Install EnableGop Driver using DXEInject Source: https://github.com/acidanthera/opencorepkg/blob/master/Staging/EnableGop/README.md Use DXEInject to automatically add the EnableGop.ffs driver to your firmware ROM. The modified ROM is then ready for burning. ```bash DXEInject {original}.rom {modified}.rom EnableGop.ffs ``` -------------------------------- ### Run DNSMASQ for Testing Source: https://github.com/acidanthera/opencorepkg/blob/master/Platform/OpenNetworkBoot/README.md Command to start dnsmasq in the foreground for testing purposes with a specified configuration file and verbose logging. ```bash sudo dnsmasq --no-daemon -C dnsmasq.conf --log-dhcp --log-debug ``` -------------------------------- ### Run QEMU with SMM Support and Debugger Port Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md Starts QEMU with SMM enabled, separate OVMF code and variables, and specifies the GDB port for debugger connection. Secure boot is enabled. ```bash qemu-system-x86_64 -L . -global driver=cfi.pflash01,property=secure,value=on \ -drive if=pflash,format=raw,unit=0,file="$OVMF_BUILD"/OVMF_CODE.fd,readonly=on \ -drive if=pflash,format=raw,unit=1,file="$OVMF_BUILD"/OVMF_VARS.fd \ -drive format=raw,file=fat:rw:ESP \ -global ICH9-LPC.disable_s3=1 -machine q35,smm=on,accel=tcg -m 2048 -cpu Penryn \ -smp 4,cores=2 -usb -device usb-mouse -gdb tcp::8864 ``` -------------------------------- ### Install Shim EFI Files Source: https://github.com/acidanthera/opencorepkg/blob/master/Utilities/ShimUtils/README.md Copy the built Shim EFI files to the EFI System Partition (ESP). Use the appropriate command for macOS or Linux. ```shell ./shim-make.tool install /Volumes/EFI ``` ```shell sudo ./shim-make.tool install /boot/efi ``` -------------------------------- ### Build 32-bit Windows Utility with MinGW Source: https://github.com/acidanthera/opencorepkg/blob/master/User/README.md Command to build a 32-bit Windows utility using MinGW. This example specifies the architecture, C compiler, stripping tool, and target distribution. ```sh UDK_ARCH=Ia32 CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip DIST=Windows make ``` -------------------------------- ### Check LogoutHook Status Source: https://github.com/acidanthera/opencorepkg/blob/master/Utilities/LogoutHook/README.md Verify the installation status of the LogoutHook daemon. Shows non-empty daemon pid only if installed with default settings. ```bash ./Launchd.command status ``` -------------------------------- ### Install PyYAML on macOS Source: https://github.com/acidanthera/opencorepkg/blob/master/AppleModels/README.md Use this command to install the PyYAML package, which is required for updating the database. ```bash sudo -H python3 -m pip install pyyaml ``` -------------------------------- ### Setting Pool Allocation Limit in Userspace UEFI Source: https://github.com/acidanthera/opencorepkg/blob/master/User/README.md Example demonstrating how to set a custom memory pool allocation limit using `SetPoolAllocationSizeLimit`. This is crucial when your code might allocate more than the default 512MB limit. ```c #include int main(int argc, char *argv[]) { SetPoolAllocationSizeLimit (SINGLE_ALLOCATION_MEMORY_LIMIT); /* your code goes here */ return 0; } ``` -------------------------------- ### Run QEMU with Realistic Machine Architecture Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md Launches QEMU with a Q35 machine architecture, 2048MB RAM, Penryn CPU, and 4 cores. Debugging is enabled via GDB on TCP port 8864. The -L . flag sets the current directory as the library path. ```bash qemu-system-x86_64 -L . -bios "$OVMF_BUILD/OVMF.fd" -drive format=raw,file=fat:rw:ESP \ -machine q35 -m 2048 -cpu Penryn -smp 4,cores=2 -usb -device usb-mouse -gdb tcp::8864 ``` -------------------------------- ### GDB Commands for UEFI Debugging Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md Reference commands for debugging UEFI applications with GDB. Ensure GDB Multiarch is installed and the Python script is available. ```shell $ ggdb /opt/UDK/Build/OpenCorePkg/NOOPT_XCODE5/X64/OpenCorePkg/Debug/GdbSyms/GdbSyms/DEBUG/GdbSyms.dll.dSYM/Contents/Resources/DWARF/GdbSyms.dll target remote localhost:8864 source /opt/UDK/OpenCorePkg/Debug/Scripts/gdb_uefi.py set pagination off reload-uefi b DebugBreak ``` -------------------------------- ### Manually Insert EnableGop Driver using UEFITool Source: https://github.com/acidanthera/opencorepkg/blob/master/Staging/EnableGop/README.md Instructions for manually inserting the EnableGop.ffs driver into the firmware using UEFITool 0.25.1. This method requires specific steps for searching and inserting the file. ```text Perform a header-only GUID search for BAE7599F-3C6B-43B7-BDF0-9CE07AA91AA6 Double-click on the search result Right-click on the DXE driver with that GUID which should then appear Choose "Insert after..." and select EnableGop.ffs Save the modified firmware ``` -------------------------------- ### Build Debug Binaries with EDK II Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md Use the 'NOOPT' build option to create unoptimized binaries suitable for debugging. Be aware that this significantly increases binary size. ```shell build -a X64 -t XCODE5 -b NOOPT -p OpenCorePkg/OpenCorePkg.dsc # for macOS ``` ```shell build -a X64 -t CLANGPDB -b NOOPT -p OpenCorePkg/OpenCorePkg.dsc # for other systems ``` -------------------------------- ### Product Model Lookup URI Source: https://github.com/acidanthera/opencorepkg/blob/master/Utilities/macserial/FORMAT.md Construct a URI to look up hardware specifications using the product code. Replace PPPP with the actual product code. ```text http://support-sp.apple.com/sp/index?page=cpuspec&cc=PPPP ``` -------------------------------- ### Get Mac Serial Information Source: https://github.com/acidanthera/opencorepkg/blob/master/Utilities/macserial/FORMAT.md Run this command to retrieve information about the current Mac's serial number. Use the -i flag with a specific serial number to check others. ```bash ./macserial ``` ```bash ./macserial -i SERIALNUMBER ``` -------------------------------- ### Build Shim with Vendor Signatures Source: https://github.com/acidanthera/opencorepkg/blob/master/Utilities/ShimUtils/README.md Use shim-make.tool to build Shim with custom vendor signature lists. Ensure paths are accessible by the build environment. ```shell ./shim-make.tool make VENDOR_DB_FILE={full-path-to}/vendor.db VENDOR_DBX_FILE={full-path-to}/vendor.dbx ``` -------------------------------- ### Basic dnsmasq PXE Boot Configuration Source: https://github.com/acidanthera/opencorepkg/blob/master/Platform/OpenNetworkBoot/README.md A minimal `dnsmasq` configuration for PXE booting. It disables the DNS server, acts as a DHCP proxy, matches client architectures, specifies boot options, and enables TFTP with a specified root directory. ```ini # Disable DNS Server port=0 # Run as network boot DHCP proxy dhcp-range=192.168.10.0,proxy # Identify requested arch # REF: https://wiki.archlinux.org/title/dnsmasq#PXE_server dhcp-match=set:arch_x64,option:client-arch,7 dhcp-match=set:arch_x64,option:client-arch,9 dhcp-match=set:arch_ia32,option:client-arch,6 # Specify one or more boot options per architecture pxe-service=tag:arch_x64,x86-64_EFI,"Open Shell",OpenShell.efi pxe-service=tag:arch_x64,x86-64_EFI,"Boot Helper",BootHelper.efi # Enable TFTP support enable-tftp tftp-root=/home/mjsbeaton/tftp ``` -------------------------------- ### Dump UEFI Handles to File Source: https://github.com/acidanthera/opencorepkg/blob/master/Platform/OpenNetworkBoot/README.md Pipe the output of the `dh` command to a file for later examination. This is useful on systems with slow console output. The example shows changing to a filesystem and redirecting output. ```shell > fs0: > dh > dh_dump ``` -------------------------------- ### Manually Detect GOP Offset in GPU Firmware Source: https://github.com/acidanthera/opencorepkg/blob/master/Staging/EnableGop/README.md If automatic GOP offset detection fails, use a hex editor to search for the byte sequence 'F1 0E 00 00' followed closely by '55 AA'. The starting address of '55 AA' is the required GOP offset. ```plaintext F1 0E 00 00 55 AA ``` -------------------------------- ### Write PBR using PowerShell Source: https://github.com/acidanthera/opencorepkg/blob/master/Utilities/LegacyBoot/README.md Writes the updated PBR from `pbr.bin` back to the specified volume (e.g., X:). This step finalizes the bootloader configuration. ```powershell $disk = [System.IO.File]::Open("\\.\X:", [System.IO.FileMode]::Open) $buffer = [System.IO.File]::ReadAllBytes("pbr.bin") $disk.Write($buffer, 0, $buffer.Length) $disk.Close() ``` -------------------------------- ### VS Code launch.json for LLDB Debugging (x86) Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md Configure this for LLDB debugging of 32-bit (Ia32) targets. Verify paths to the DLL and Python scripts. ```json { "name": "OC lldb (32/32)", "type": "cppdbg", "request": "launch", "targetArchitecture": "x86", "program": "${workspaceFolder}/Debug/GdbSyms/Bin/Ia32_XCODE5/GdbSyms.dll", "cwd": "${workspaceFolder}/Debug", "MIMode": "lldb", "customLaunchSetupCommands": [ {"text": "gdb-remote localhost:8832"}, {"text": "target create GdbSyms/Bin/Ia32_XCODE5/GdbSyms.dll", "ignoreFailures": true}, {"text": "command script import Scripts/lldb_uefi.py"}, {"text": "command script add -c lldb_uefi.ReloadUefi reload-uefi"}, {"text": "reload-uefi"} ], "launchCompleteCommand": "exec-continue", "logging": { "engineLogging": false, "trace": true, "traceResponse": true } } ``` -------------------------------- ### VS Code launch.json for LLDB Debugging (x64) Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md Use this configuration for LLDB debugging of 64-bit targets. Ensure the Python scripts and DLLs are correctly placed. ```json { "name": "OC lldb", "type": "cppdbg", "request": "launch", "targetArchitecture": "x64", "program": "${workspaceFolder}/Debug/GdbSyms/Bin/X64_XCODE5/GdbSyms.dll", "cwd": "${workspaceFolder}/Debug", "MIMode": "lldb", "setupCommands": [ {"text": "settings set plugin.process.gdb-remote.target-definition-file Scripts/x86_64_target_definition.py"} ], "customLaunchSetupCommands": [ {"text": "gdb-remote localhost:8864"}, {"text": "target create GdbSyms/Bin/X64_XCODE5/GdbSyms.dll", "ignoreFailures": true}, {"text": "command script import Scripts/lldb_uefi.py"}, {"text": "command script add -c lldb_uefi.ReloadUefi reload-uefi"}, {"text": "reload-uefi"} ], "launchCompleteCommand": "exec-continue", "logging": { "engineLogging": false, "trace": true, "traceResponse": true } } ``` -------------------------------- ### Makefile for Userspace UEFI Projects Source: https://github.com/acidanthera/opencorepkg/blob/master/User/README.md A basic Makefile structure for userspace UEFI projects. Ensure to adapt VPATH and include paths according to your project's library structure. ```makefile PROJECT = ProjectName PRODUCT = $(PROJECT)$(SUFFIX) OBJS = $(PROJECT).o ExtraObject.o VPATH = ../../Library/MyExtraLib:$ include ../../User/Makefile CFLAGS += -I../../Library/MyExtraLib ``` -------------------------------- ### Configure VMware Fusion Boot Delay Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md Add this line to the .vmx file to introduce a delay during POST, allowing easier entry into UEFI firmware settings. ```ini bios.bootDelay = "3000" ``` -------------------------------- ### QEMU Flags for Keyboard and Mouse Support Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md Options for enabling keyboard and mouse support in QEMU. Choose between using UEFI drivers or passing specific QEMU arguments and drivers. ```text For keyboard support either, a) use `KeySupport=true`, or b) use `KeySupport=false`, in which case pass `-usb -device usb-kbd` to QEMU, and use `OpenUsbKbDxe.efi` driver. For mouse support either, a) use `Ps2MouseDxe.efi` driver, or b) pass `-usb -device usb-mouse` to QEMU and use `UsbMouseDxe.efi` driver. ``` -------------------------------- ### HTTP Boot Drivers Source: https://github.com/acidanthera/opencorepkg/blob/master/Platform/OpenNetworkBoot/README.md Drivers necessary for HTTP booting functionality. ```shell DnsDxe HttpDxe HttpUtilitiesDxe HttpBootDxe ``` -------------------------------- ### OVMF PXE Boot with QEMU User Mode Network Source: https://github.com/acidanthera/opencorepkg/blob/master/Platform/OpenNetworkBoot/README.md Configure OVMF for PXE boot testing using QEMU's built-in TFTP/PXE server. Specify the TFTP directory and boot file. ```bash -netdev user,id=net0,tftp=$HOME/tftp,bootfile=/OpenShell.efi \ -device virtio-net-pci,netdev=net0,id=nic0 ``` -------------------------------- ### PXE Boot Drivers Source: https://github.com/acidanthera/opencorepkg/blob/master/Platform/OpenNetworkBoot/README.md Drivers for PXE booting, with separate options for IPv4 and IPv6. ```shell UefiPxeBcDxe Mtftp4Dxe (IPv4 only) Mtftp6Dxe (IPv6 only) ``` -------------------------------- ### Build with LLVM Sanitizers and Debugging Source: https://github.com/acidanthera/opencorepkg/blob/master/User/README.md Command to build a utility with LLVM sanitizers and debugging information enabled. This is useful for identifying runtime errors and memory issues. ```sh DEBUG=1 SANITIZE=1 make ``` -------------------------------- ### HTTPS Support Driver Source: https://github.com/acidanthera/opencorepkg/blob/master/Platform/OpenNetworkBoot/README.md Driver for enabling TLS support for HTTP Boot. ```shell TlsDxe ``` -------------------------------- ### Download Default and Latest macOS Versions Source: https://github.com/acidanthera/opencorepkg/blob/master/Utilities/macrecovery/recovery_urls.txt Specify '-os default' to download the oldest available version or '-os latest' for the most recent version. Replace '' with the actual Machine-Readable Licensee Board ID. ```shell ./macrecovery.py -b Mac-7BA5B2D9E42DDD94 -m 00000000000JG3600 download ``` ```shell ./macrecovery.py -b Mac-7BA5B2D9E42DDD94 -m -os default download ``` ```shell ./macrecovery.py -b Mac-CFF7D910A743CAAF -m 00000000000000000 -os latest download ``` ```shell ./macrecovery.py -b Mac-CFF7D910A743CAAF -m -os latest ``` -------------------------------- ### Compile OpenDuetPkg with INTREE=1 Source: https://github.com/acidanthera/opencorepkg/blob/master/Legacy/README.md Use this command to perform in-tree compilation of OpenDuetPkg. Ensure TARGETARCH and TARGET are set appropriately. ```shell TARGETARCH=X64 TARGET=RELEASE INTREE=1 DuetPkg/macbuild.tool ``` -------------------------------- ### Insert EnableGop Driver into GPU Firmware Source: https://github.com/acidanthera/opencorepkg/blob/master/Staging/EnableGop/README.md Use this script to insert the EnableGop EFI driver into a GPU firmware dump. Ensure you have the correct version of nvflash (Nvidia) or amdvbflash (AMD) to read and write the firmware. The script supports both AMD and Nvidia cards. ```bash ./vBiosInsert.sh [-a|-n] {original}.rom EnableGop.efi {modified}.rom ``` -------------------------------- ### OVMF Bridged Network Support Source: https://github.com/acidanthera/opencorepkg/blob/master/Platform/OpenNetworkBoot/README.md Use this QEMU option for macOS-specific bridged network support in OVMF. Requires sudo. ```bash -netdev vmnet-bridged,id=net0,ifname=en0 \ -device virtio-net-pci,netdev=net0,id=nic0 ``` -------------------------------- ### VS Code launch.json for GDB Debugging (x86) Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md Use this for GDB debugging of 32-bit (Ia32) targets. Confirm the symbol file and script paths are correct. ```json { "name": "OC gdb (32/32)", "type": "cppdbg", "request": "launch", "targetArchitecture": "x86", "program": "${workspaceFolder}/Debug/GdbSyms/Bin/Ia32_GCC5/GdbSyms.debug", "cwd": "${workspaceFolder}/Debug", "MIMode": "gdb", "stopAtEntry": true, "setupCommands": [ {"text": "set arch i386"}, {"text": "symbol-file ${workspaceFolder}/Debug/GdbSyms/Bin/Ia32_GCC5/GdbSyms.debug"}, {"text": "target remote localhost:8832"}, {"text": "source ${workspaceFolder}/Debug/Scripts/gdb_uefi.py"}, {"text": "reload-uefi"} ], "launchCompleteCommand": "exec-continue", "logging": { "engineLogging": false, "trace": true, "traceResponse": true } } ``` -------------------------------- ### VS Code launch.json for GDB Debugging (x64) Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md This configuration is for GDB debugging of 64-bit targets. Ensure the GDB symbol file and Python script are accessible. ```json { "name": "OC gdb", "type": "cppdbg", "request": "launch", "targetArchitecture": "x64", "program": "${workspaceFolder}/Debug/GdbSyms/Bin/X64_GCC5/GdbSyms.debug", "cwd": "${workspaceFolder}/Debug", "MIMode": "gdb", "stopAtEntry": true, "setupCommands": [ {"text": "set arch i386:x86-64:intel"}, {"text": "symbol-file ${workspaceFolder}/Debug/GdbSyms/Bin/X64_GCC5/GdbSyms.debug"}, {"text": "target remote localhost:8864"}, {"text": "source ${workspaceFolder}/Debug/Scripts/gdb_uefi.py"}, {"text": "reload-uefi"} ], "launchCompleteCommand": "exec-continue", "logging": { "engineLogging": false, "trace": true, "traceResponse": true } } ``` -------------------------------- ### Build OVMF Firmware for Debugging Source: https://github.com/acidanthera/opencorepkg/blob/master/Debug/README.md Builds the OVMF firmware in NOOPT mode for debugging. Use the macOS specific XCODE5 toolchain or CLANGPDB for other systems. Add -D SMM_REQUIRE=1 for SMM support or -D DEBUG_ON_SERIAL_PORT=1 for serial debugging. ```bash git submodule init git submodule update # to clone OpenSSL build -a X64 -t XCODE5 -b NOOPT -p OvmfPkg/OvmfPkgX64.dsc # for macOS build -a X64 -t CLANGPDB -b NOOPT -p OvmfPkg/OvmfPkgX64.dsc # for other systems ``` -------------------------------- ### Run LogoutHook Script Source: https://github.com/acidanthera/opencorepkg/blob/master/Utilities/LogoutHook/README.md Execute the main LogoutHook script for its default usage. ```bash ./Launchd.command ``` -------------------------------- ### Load RamDiskDxe Driver Source: https://github.com/acidanthera/opencorepkg/blob/master/Platform/OpenNetworkBoot/README.md Load the RamDiskDxe driver if it is required for loading .iso or .img files with HTTP Boot and not present in firmware. ```shell RamDiskDxe ``` -------------------------------- ### Add boot0 to MBR using dd Source: https://github.com/acidanthera/opencorepkg/blob/master/Utilities/LegacyBoot/README.md Appends the boot0 bootloader to the MBR. This command uses `dd` from WSL to overwrite the initial part of the MBR file with boot0, ensuring the system boots correctly. The `conv=notrunc` option prevents truncation of the file. ```sh cp old_mbr.bin mbr.bin dd if=boot0 of=mbr.bin bs=1 count=446 conv=notrunc ``` -------------------------------- ### Load HiiDatabase Driver Source: https://github.com/acidanthera/opencorepkg/blob/master/Platform/OpenNetworkBoot/README.md Load the HiiDatabase driver if it is not present in the firmware. ```shell HiiDatabase ```