heimdall on Centos7

You want to flash a Samsung Galaxy Android device.

You’ll need heimdall.

It’s not available as a package for Centos7, so you’ll need to compile it.

Expanded instructions

It uses cmake, which I’d not tripped over before, and the build process is a good deal messier than I expected. As in literally, it leaves stuff all over the place.

The live git repo is now in GitLab, and the procedure for linux, slightly expanded (with help from some other docs) is:

git checkout https://gitlab.com/BenjaminDobell/Heimdall.git
cd Heimdall
  # now verbatim from the readme
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
  # and now the rest
cd ..
sudo cp bin/heimdall /usr/local/bin/
sudo cp bin/heimdall-frontend /usr/local/bin/
sudo chown root:root /usr/local/bin/heimdall /usr/local/bin/heimdall-frontend

The ‘..’ looks slightly odd, as though the rest of the parameters are missing. What it actually means is .. you created a build sub directory amongst the source code, and that parameter directs cmake to locate the source code.

I did it slightly differently.  I’m doing this all with Puppet, and the installation of dependencies and the cmake/make/cp is done with a script.

cd /usr/local/src
mkdir heimdall
cd heimdall
git checkout https://gitlab.com/BenjaminDobell/Heimdall.git git
mkdir build
chown nobody:nobody ./ build
cd build
sudo -u nobody cmake -DCMAKE_BUILD_TYPE=Release /usr/local/src/heimdall/git
sudo -u nobody make

cmake uses ../ which is why the /usr/local/source/heimdall directory needs to be writable by nobody.

Otherwise:

CMake Error at /usr/share/cmake/Modules/CMakeDetermineSystem.cmake:170 (file):
  file Internal CMake error when trying to open file:
  /usr/local/src/heimdall/CMakeFiles/CMakeOutput.log for writing.
Call Stack (most recent call first):
  CMakeLists.txt:7 (project)
[....]
-- Configuring incomplete, errors occurred!
CMake Error: Cannot open file for write: /usr/local/src/heimdall/CMakeCache.txt.tmp
CMake Error: : System Error: Permission denied
CMake Error: Unable to open cache file for save. /usr/local/src/heimdall/CMakeCache.txt
CMake Error: : System Error: Permission denied

You end up with:

heimdall/git/.git
heimdall/git/<etc>
heimdall/CMakeFiles/            # created by cmake
heimdall/build/bin/             # with the binaries in
heimdall/build/CMakeCache.txt
heimdall/build/CMakeFiles
heimdall/build/cmake_install.cmake 
heimdall/build/heimdall/
heimdall/build/heimdall-frontend/
heimdall/build/libpit/
heimdall/build/Makefile

My reason for separating build working space from the git repo is partly cleanliness, and partly that it makes it easier to clean up bits and get Puppet to redeploy them. If the git repo needs downloading again:

rm -rf git ; puppet agent --test

If the build is misbehaving:

rm -rf build CMakeFiles ; puppet agent --test

Also, the master can be pulled to pick up more recent code without stuff that’s not in .gitignore (CMakeFiles/ – that’s you) causing it to fail.

Dependencies

Because this is what we live for in Linux land.

Some errors first, because let’s face it, thats probably how you got here.

  • install libusbx, libusbx-devel not libusb, libusb-devel, otherwise:
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
  Could NOT find libusb (missing: LIBUSB_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
  cmake/Findlibusb.cmake:30 (find_package_handle_standard_args)
  heimdall/CMakeLists.txt:9 (find_package)
  • install qt5-qtbase-devel, otherwise:
CMake Error at heimdall-frontend/CMakeLists.txt:11 (find_package):
  By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "Qt5Widgets", but CMake did not find one.

  Could not find a package configuration file provided by "Qt5Widgets" with
  any of the following names:

    Qt5WidgetsConfig.cmake
    qt5widgets-config.cmake

  Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set
  "Qt5Widgets_DIR" to a directory containing one of the above files.  If
  "Qt5Widgets" provides a separate development package or SDK, be sure it has
  been installed.

My full set of dependencies is as follows.

Apart from compilers etc, I only specify installing the -devel packages.

  1. The -devel packages bring in the actual library packages (ie non -devel packages) as dependencies, if you don’t have them installed.
  2. My build script uninstalls components required for compiling afterwards; cleanliness reason – I don’t need them once compiling is done. As [1] handles the library packages etc., they’re not listed.
  3. The only package listed here which I wouldn’t expect to remove after compiling is make. My minimal install had it already.
  4. It’s possible all the compilers etc. aren’t needed, but the only instructions I could find were even broader (like: install the development tools group)
  5. I didn’t find these the hard way; they’re mostly what got dragged in by the packages installed for Fedora and / or generic Linux here. Most are probably for the GUI binary which I don’t plan to use anyway!
yum install zlib-devel qt-devel xorg-x11-proto-devel mesa-libGLU-devel \
            mesa-libEGL-devel mesa-libGL-devel mesa-khr-devel libxcb-devel \
            libuuid-devel libpng-devel libglvnd-devel libglvnd-core-devel \
            libdrm-devel libXxf86vm-devel libXv-devel libXt-devel libXrender-devel \
            libXrandr-devel libXinerama-devel libXi-devel libXft-devel \
            libXfixes-devel libXext-devel  libXdamage-devel libXcursor-devel \
            libXau-devel libX11-devel libSM-devel libICE-devel freetype-devel \
            fontconfig-devel expat-devel qt5-qtbase-devel glibc-devel \
            libstdc++-devel libusbx-devel zlib-devel kernel-headers make \
            cmake libtool gcc gcc-c++ cpp glibc-headers automake autoconf

Aside: when you’ve found that at a pwned PHP forum server was able to compile code to exploit a root shell vulnerability in the kernel, it makes you think about why you want to remove compilers once you’re done with them.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s