[Samsung Galaxy M40 Guides, News, & Discussion] awsmanks:
Read all the Instructions very carefully, as missing even a single steps cause bootloop.

1. Unlocking Bootloader

Allow bootloader unlocking in Developer options → OEM unlocking

Power off your device. Press Volume Up + Volume Down and plug in your device to a PC to boot into download mode

Long press volume up to unlock the bootloader. This will wipe your data and automatically reboot.

Just when you think the bootloader is unlocked, surprise surprise, it is actually not! Samsung introduced VaultKeeper in the system, meaning the bootloader will reject any unofficial partitions before VaultKeeper explicitly allows it.

Go through the initial setup. Skip through all the steps since data will be wiped again later when we are installing Magisk. Connect the device to internet in the setup!

Enable developer options, and confirm that the OEM unlocking option exists and grayed out!

2. Before Installing Magisk

Installing Magisk WILL trip KNOX

Installing Magisk for the first time REQUIRES a full data wipe, backup before continue

You have to have your bootloader unlocked before following the instructions

After installing Magisk, you can directly upgrade Magisk within Magisk Manager without an issue.

3. Flashing Magisk:

Download the firmware for SM-M405F

Unzip the firmware and copy the

AP tar

file to your device. It is normally named as AP_[device_model_sw_ver].tar.md5

Install the latest Magisk Manager

In Magisk Manager: Install → Install → Select and Patch a File and select the AP tar file.

Magisk Manager will patch the whole firmware file and store the output to [Internal Storage]/Download/magisk_patched.tar

Copy the tar file to your PC and boot your device to download mode.

Flash magisk_patched.tar as AP in ODIN, together with the BL, CP and

HOME_CSC

files. Never flash only an AP file, as Odin can shrink your /data file-system if you do.

Important: Uncheck “Auto Reboot” in Options!

Magisk is now successfully flashed! But there are still several steps before you can properly use the device.

We now want to boot into the stock recovery to factory reset our device.

Full data wipe is mandatory! Do not skip this step.

Press Power + Volume Down to exit download mode. As soon as the screen turns off, immediately press Power + Volume Up to boot to recovery partition. Just as mentioned in the previous section, since we want to boot into stock recovery, continue pressing the volume up button until you see the stock recovery screen.

In the stock recovery menu, use volume buttons to navigate through menus, and the power button to select the option. Select Wipe data/factory reset to wipe the data of the device.

This time, we can finally boot to the system with Magisk.

Select Reboot system now, and immediately press Power + Volume Up

. After seeing the bootloader warning screen, release all buttons so it can boot to the system.

The device will automatically reboot for the first time it boots. This is completely normal and done by design.

After the device is booted up, do the usual initial setup. The following steps will need internet connection.

You shall see Magisk Manager in your app drawer; if not, manually install the APK you downloaded and continue to the next step. The app would be a stub and it shall automatically upgrade to the full Magisk Manager when you open it.

Magisk Manager will ask to do additional setups. Let it do its job and the app will automatically reboot your device.

Enjoy Root :)