Skip to content

Instantly share code, notes, and snippets.

@pjobson
Last active September 20, 2021 00:07
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pjobson/1e04674e5b30d664b58bc7ec6130824e to your computer and use it in GitHub Desktop.
Save pjobson/1e04674e5b30d664b58bc7ec6130824e to your computer and use it in GitHub Desktop.
Compile Heimdall in Mojave & Catalina

Compile Heimdall in Mojave & Catalina

I forked BenjaminDobell's Heimdall with some patches to the CmakeList files.

Extrapolated from a combination of:

Install Homebrew

In terminal do your homebrew install and install dependancies.

Full instructions here: https://brew.sh/

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install cmake libusb

Do the Build

### CLONE THE REPO ###
git clone https://gitlab.com/pjobson/Heimdall.git
cd Heimdall

### Disable SIP - Possibly Catalina Only ###
### Reboot to Recovery with COMMAND-R ###
csrutil disable
reboot
### After Reboot ###
sudo mount -uw /
sudo killall Finder

### INSTALL THE KEXT ###
OSX/install-kext.sh
# Maybe Reboot # 

### DO THE BUILD ###
mkdir build
cd build
cmake -DDISABLE_FRONTEND=ON -DCMAKE_BUILD_TYPE=Release ..
LIBRARY_PATH=/usr/local/lib make
make install

### DO STUFF ###
which heimdall
heimdall info
heimdall version
heimdall download-pit --output pit.pit
heimdall flash --RECOVERY recovery.img

# Flashing a Phone Example:

heimdall flash --APNHLOS NON-HLOS.bin     \
               --ABOOT   aboot.mbn        \
               --BOOT    boot.img         \
               --CACHE   cache.img.ext4   \
               --HIDDEN  hidden.img.ext4  \
               --MODEM   modem.bin        \
               --RPM     rpm.mbn          \
               --SBL1    sbl1.mbn         \
               --DBI     sdi.mbn          \
               --SYSTEM  system.img.ext4  \
               --TZ      tz.mbn           \
               --no-reboot

### Re-Enable SIP - Possibly Catalina Only ###
csrutil enable
sudo reboot

That's it. Some guides show to run heimdall as root, I'm not sure if that is necessary.

cmake_minimum_required(VERSION 2.8.4)
project(heimdall-frontend)
set(LIBPIT_INCLUDE_DIRS
../libpit/source)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON) # moc files are generated in build (current) directory
find_package(Qt5Widgets REQUIRED)
find_package(ZLIB REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
if(MINGW)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
endif(MINGW)
include_directories(${LIBPIT_INCLUDE_DIRS})
set(HEIMDALL_FRONTEND_SOURCE_FILES
source/aboutform.cpp
source/Alerts.cpp
source/FirmwareInfo.cpp
source/main.cpp
source/mainwindow.cpp
source/PackageData.cpp
source/Packaging.cpp)
qt5_wrap_ui(HEIMDALL_FRONTEND_FORMS
mainwindow.ui
aboutform.ui)
qt5_add_resources(HEIMDALL_FRONTEND_RESOURCES
mainwindow.qrc)
add_executable(heimdall-frontend WIN32
MACOSX_BUNDLE
${HEIMDALL_FRONTEND_SOURCE_FILES}
${HEIMDALL_FRONTEND_FORMS}
${HEIMDALL_FRONTEND_RESOURCES})
include(LargeFiles)
use_large_files(heimdall-frontend YES)
set_property(TARGET heimdall-frontend
APPEND PROPERTY COMPILE_DEFINITIONS "QT_LARGEFILE_SUPPORT")
target_link_libraries(heimdall-frontend pit)
target_link_libraries(heimdall-frontend Qt5::Widgets)
target_link_libraries(heimdall-frontend z)
install (TARGETS heimdall-frontend
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
cmake_minimum_required(VERSION 2.8.4)
project(heimdall)
if((NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux") AND (NOT DEFINED libusb_USE_STATIC_LIBS))
set(libusb_USE_STATIC_LIBS YES)
endif((NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux") AND (NOT DEFINED libusb_USE_STATIC_LIBS))
find_package(libusb REQUIRED)
set(CMAKE_EXE_LINKER_FLAGS "-lobjc -framework IOKit -framework CoreFoundation")
set(LIBPIT_INCLUDE_DIRS
../libpit/source)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
if(MINGW)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
endif(MINGW)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_definitions(-DOS_LINUX)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
include_directories(SYSTEM ${LIBUSB_INCLUDE_DIRS})
include_directories(${LIBPIT_INCLUDE_DIRS})
set(HEIMDALL_SOURCE_FILES
source/Arguments.cpp
source/BridgeManager.cpp
source/ClosePcScreenAction.cpp
source/DetectAction.cpp
source/DownloadPitAction.cpp
source/FlashAction.cpp
source/HelpAction.cpp
source/InfoAction.cpp
source/Interface.cpp
source/main.cpp
source/PrintPitAction.cpp
source/Utility.cpp
source/VersionAction.cpp)
include(LargeFiles)
use_large_files(heimdall YES)
add_executable(heimdall ${HEIMDALL_SOURCE_FILES})
target_link_libraries(heimdall PRIVATE pit)
target_link_libraries(heimdall PRIVATE ${LIBUSB_LIBRARY})
install (TARGETS heimdall
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
cmake_minimum_required(VERSION 2.8.4)
project(libpit)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dnullptr=NULL")
set(LIBPIT_SOURCE_FILES
source/libpit.cpp)
add_library(pit STATIC ${LIBPIT_SOURCE_FILES})
@swidnow2
Copy link

swidnow2 commented Sep 3, 2020

Your instructions saved me a lot of time! Thanks!

@pjobson
Copy link
Author

pjobson commented Sep 3, 2020

@swidnow2 happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment