|
| 1 | +# heimdall-osx-arm64 |
| 2 | + |
| 3 | +[Heimdall](https://www.glassechidna.com.au/heimdall) specifically built for ARM64 macOS. |
| 4 | + |
| 5 | +I made this initially only as a reference for myself in the future |
| 6 | +because I couldn't find any prebuilt binary for ARM64 macOS, |
| 7 | +also I had a hard time building Heimdall on my M1 MacBook Pro. |
| 8 | + |
| 9 | +# Downloads |
| 10 | + |
| 11 | +Download from [Releases section](https://github.com/fathonix/heimdall-osx-arm64/releases/latest). |
| 12 | + |
| 13 | +Even if you download a prebuilt binary, **you still have to install [Homebrew](https://brew.sh) and its dependencies.** |
| 14 | +(except `cmake` which is only required for building). |
| 15 | +More details can be seen below. |
| 16 | + |
| 17 | +# Installing |
| 18 | + |
| 19 | +To install Homebrew, run this command: |
| 20 | + |
| 21 | + bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 22 | + |
| 23 | +Install libusb and Qt5 through Homebrew. |
| 24 | + |
| 25 | + brew install libusb qt@5 |
| 26 | + |
| 27 | +After downloading `heimdall` binary, move it to `/usr/local/bin`. |
| 28 | + |
| 29 | +You can move it by issuing this command: |
| 30 | + |
| 31 | + sudo mv /path/to/heimdall /usr/local/bin/ |
| 32 | + |
| 33 | +Extract `heimdall-frontend-x.x.x.zip` and put `heimdall-frontend.app` in `/Applications`. |
| 34 | + |
| 35 | +Before using `heimdall-frontend`, you have to set user-scope `PATH` to make sure it detects the `heimdall` binary. |
| 36 | +Run the below command to set the `PATH`. |
| 37 | + |
| 38 | + sudo launchctl config user path "/usr/local/bin:$PATH" |
| 39 | + |
| 40 | +# Building |
| 41 | + |
| 42 | +Make sure you already have Homebrew and Xcode Command-Line Tools installed to simplify the process of getting the dependencies and building. |
| 43 | + |
| 44 | +To install Xcode Command-Line Tools, run this command: |
| 45 | + |
| 46 | + xcode-select --install |
| 47 | + |
| 48 | +Install CMake, libusb and Qt5 through Homebrew. |
| 49 | + |
| 50 | + brew install cmake libusb qt@5 |
| 51 | + |
| 52 | +The original Heimdall hasn't been updated since 2017, |
| 53 | +and Samsung has updated Odin protocol on their latest devices, which broke the original Heimdall. |
| 54 | +Moreover, the original Heimdall can't be compiled with Apple Clang anymore. |
| 55 | +After lots of trials and errors in trying different versions and forks, |
| 56 | +I found [Henrik Grimler](https://github.com/Grimler91) fork works best. |
| 57 | +It's also still actively maintained. |
| 58 | + |
| 59 | +Clone the repo to get the source code. |
| 60 | + |
| 61 | + git clone https://git.sr.ht/~grimler/Heimdall |
| 62 | + |
| 63 | +Change to the repo directory. |
| 64 | + |
| 65 | + cd Heimdall |
| 66 | + |
| 67 | +Switch to the latest stable version. |
| 68 | +At the time of writing, the latest stable version is v2.0.1. |
| 69 | +You can check by running `git tag`. |
| 70 | + |
| 71 | + git checkout tags/v2.0.1 |
| 72 | + |
| 73 | +Run `cmake` to configure things. |
| 74 | + |
| 75 | + cmake . \ |
| 76 | + -DCMAKE_BUILD_TYPE=Release \ |
| 77 | + -DCMAKE_INSTALL_PREFIX=/usr/local \ |
| 78 | + -DQt5Widgets_DIR=/opt/homebrew/opt/qt5/lib/cmake/Qt5Widgets |
| 79 | + |
| 80 | +Export `LIBRARY_PATH` environment variable pointing to Homebrew `lib` folder, to avoid linking issues. |
| 81 | + |
| 82 | + export LIBRARY_PATH=/opt/homebrew/lib |
| 83 | + |
| 84 | +Finally, run `make` to build and install. |
| 85 | + |
| 86 | + make |
| 87 | + sudo make install |
| 88 | + |
| 89 | +You'll see that `heimdall` is now installed in `/usr/local/bin` and `heimdall-frontend` in `/Applications`. |
| 90 | + |
| 91 | +To check that everything works, run `heimdall`. |
| 92 | + |
| 93 | + heimdall info |
| 94 | + |
| 95 | +It should output like this: |
| 96 | + |
| 97 | + Heimdall v2.0.1 |
| 98 | + |
| 99 | + Copyright (c) 2010-2017 Benjamin Dobell, Glass Echidna |
| 100 | + https://www.glassechidna.com.au/ |
| 101 | + |
| 102 | + This software is provided free of charge. Copying and redistribution is encouraged. |
| 103 | + |
| 104 | + If you appreciate this software and you would like to support future development please consider donating: |
| 105 | + https://www.glassechidna.com.au/donate/ |
| 106 | + |
| 107 | + Heimdall utilises libusb for all USB communication: |
| 108 | + https://www.libusb.info/ |
| 109 | + |
| 110 | + libusb is licensed under the LGPL-2.1: |
| 111 | + https://www.gnu.org/licenses/licenses.html#LGPL |
| 112 | + |
| 113 | +In the other hand, `heimdall-frontend` should run, but it can't find `heimdall` binary. |
| 114 | +If you click **Detect** in **Utilities** tab, you will see this output. |
| 115 | + |
| 116 | + FRONTEND ERROR: Failed to start Heimdall! |
| 117 | + |
| 118 | +That's because it's located in `/usr/local/bin` which is not in user-scope `PATH`. |
| 119 | + |
| 120 | +Run this command to add the directory to `PATH`. |
| 121 | + |
| 122 | + sudo launchctl config user path "/usr/local/bin:$PATH" |
| 123 | + |
| 124 | +Reboot your Mac. Now you should see the following output once you click Detect. |
| 125 | + |
| 126 | + ERROR: Failed to detect compatible download-mode device. |
| 127 | + |
| 128 | +Or this if you've connected your phone. |
| 129 | + |
| 130 | + Device detected |
| 131 | + |
| 132 | +# Building without Frontend |
| 133 | + |
| 134 | +If you don't want to use `heimdall-frontend`, |
| 135 | +or you want to use another frontend like [JOdin3](https://github.com/GameTheory-/jodin3), |
| 136 | +you can just build the `heimdall` binary. |
| 137 | + |
| 138 | +Do all steps in [Building section](#building), with some changes. |
| 139 | + |
| 140 | +You don't need to install Qt5, as it's only needed by `heimdall-frontend`. |
| 141 | + |
| 142 | + brew install cmake libusb |
| 143 | + |
| 144 | +Remove `Qt5Widgets_DIR` and append `DISABLE_FRONTEND` option in `cmake`. |
| 145 | + |
| 146 | + cmake . \ |
| 147 | + -DCMAKE_BUILD_TYPE=Release \ |
| 148 | + -DCMAKE_INSTALL_PREFIX=/usr/local \ |
| 149 | + -DDISABLE_FRONTEND=ON |
| 150 | + |
| 151 | +Once you've done everything, you'll only get `heimdall` binary located in `/usr/local/bin`. |
| 152 | + |
| 153 | +# Notes |
| 154 | + |
| 155 | +* This binary does not have built-in libraries; instead it relies on libraries provided by Homebrew. Because of that, **you must not uninstall Homebrew, libusb and Qt5.** (if you use `heimdall-frontend`) **Otherwise the binary would crash.** |
| 156 | + |
| 157 | + I'm still thinking about building `heimdall` statically and bundling Qt5 to `heimdall-frontend`, but I haven't found a way to do it. |
| 158 | + |
| 159 | +* Although Heimdall repository provides a "driver" for macOS, I don't think you'll need it. I haven't got any problems so far, apart from some warnings which are fine for now. You can't even use the driver without disabling SIP or [System Integrity Protection](https://support.apple.com/en-us/HT204899) which will [prevent you from running iOS apps until you enable it](https://forums.macrumors.com/threads/if-you-disable-sip-all-you-ios-apps-will-stop-working-on-your-m1.2269661/). |
| 160 | + |
| 161 | +* For those who don't know yet, **you can only do one read-write operation on Heimdall at one session**, unlike Odin. For example, if you've run `heimdall flash --no-reboot` or `heimdall print-pit --no-reboot` once, the second time would fail with errors like `ERROR: Protocol initialisation failed!`. See this [issue](https://github.com/Benjamin-Dobell/Heimdall/issues/413#issuecomment-336619935). |
| 162 | + |
| 163 | + If you want to run another operation, reboot your phone to Download Mode again. |
| 164 | + |
| 165 | +Many thanks to: |
| 166 | + |
| 167 | +* [Glass Echidna](https://www.glassechidna.com.au) for developing Heimdall in the first place |
| 168 | +* [Henrik Grimler](https://github.com/Grimler91) for maintaining Heimdall to support newer devices |
| 169 | +* [Arch Linux heimdall Package Details](https://archlinux.org/packages/community/x86_64/heimdall/) (I found how to build Heimdall from this because instructions from Heimdall itself don't work) |
| 170 | +* [heimdall-nogui-git AUR](https://aur.archlinux.org/packages/heimdall-nogui-git) for commands to build Heimdall without Frontend |
0 commit comments