Skip to content

Instantly share code, notes, and snippets.

@TomK
Forked from pjobson/compile_heimdall_mojave.md
Created April 15, 2020 11:20
Show Gist options
  • Save TomK/05735d4a0af5154cd40d87596ab9b4f3 to your computer and use it in GitHub Desktop.
Save TomK/05735d4a0af5154cd40d87596ab9b4f3 to your computer and use it in GitHub Desktop.
Compile Heimdall in Mojave

Compile Heimdall in Mojave

Extrapolated from a combination of:

Open Terminal

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

### PATCH THE CMakeLists.txt ###
curl https://gist.githubusercontent.com/pjobson/1e04674e5b30d664b58bc7ec6130824e/raw/f1bc6d3959593c528c209275cd81abda3be2ff59/heimdall-frontend.CMakeLists.txt -o heimdall-frontend/CMakeLists.txt
curl https://gist.githubusercontent.com/pjobson/1e04674e5b30d664b58bc7ec6130824e/raw/f1bc6d3959593c528c209275cd81abda3be2ff59/heimdall.CMakeLists.txt -o heimdall/CMakeLists.txt
curl https://gist.githubusercontent.com/pjobson/1e04674e5b30d664b58bc7ec6130824e/raw/f1bc6d3959593c528c209275cd81abda3be2ff59/libpit.CMakeLists.txt -o libpit/CMakeLists.txt

### 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

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})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment