[HOWTO] Install magisk with heimdall

Following the great tutorial on magisk github trying to root a samsung phone, you will face the problem of samsung phones not being detected by fastboot.

Fastboot is the recommended method by magisk developers, but fastboot does not work with samsung devices.
On a standard e/os/ installation interact with the bootloader on samsung phones is only possible using odin or heimdall.

Heimdall is multiplatform and open source so in this Howto i will use it.

  1. Get the boot.img file from the zip file containing the e/os/ build for your phone.
    You can grab the zip file containing the right e/os/ build for your phone from
    https://images.ecloud.global/dev/yourphonename/
    substituting yourphonename with (obviously) the name for your phone you can find on supported devices page. For example my S8+'s name is dream2lte so the builds page is https://images.ecloud.global/dev/dream2lte/

  2. Follow the magisk tutorial “Getting started” section (ignore the specific samsung section, dedicated to samsung original firmware), until you will got a patched boot .img file.

  3. Install heimdall (there are plenty of tutorials on the web, just search the right one for your OS).

  4. Reboot in download mode.

  5. print PIT:
    heimdall print-pit --no-reboot > print-pit.txt

  6. In print-pit.txt file search the right boot partition name, in my case it was like this:
    — Entry #12 —
    Binary Type: 0 (AP)
    Device Type: 8 (Unknown)
    Identifier: 7
    Attributes: 5 (Read/Write)
    Update Attributes: 1 (FOTA)
    Partition Block Size/Offset: 14336
    Partition Block Count: 10240
    File Offset (Obsolete): 0
    File Size (Obsolete): 0
    Partition Name: BOOT
    Flash Filename: boot.img
    FOTA Filename:

  7. As root flash the boot image you previously patched with magisk app:
    sudo heimdall flash --resume --BOOT magisk_patched-25200_XXXXX.img
    Substitute “BOOT” with your boot partition name.
    The --resume option is needed only if you previously used the --no-reboot flag printing PIT.
    Note: on the latest version of heimdall sudo does not work, obtaining a root shell with su is needed.
    Of course, adjust the .img file name.
    I didn’t test flashing under Windows, anyway i suggest to use an elevated privileges command prompt or powershell.

  8. Done, after flashing the system will reboot. Enjoy your rooted device.

4 Likes

I must report a strange behaviour that occurred after the last OS upgrade.
After magisk installation magisk settings page was reporting that zygdisk was not installed, modules and root access options was greyed out.
I went to bed with this problem, and the morning after all was working as expected.
So, if it seems that magisk isn’t working, please wait some time before throwing your phone trough the window :wink:

1 Like