Root SM-M405F (Galaxy M40)

Search This thread

awsmanks

Senior Member
Feb 4, 2013
106
19
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:

  1. Download the firmware for SM-M405F
  2. Unzip the firmware and copy the AP tar file to your device. It is normally named as AP_[device_model_sw_ver].tar.md5
  3. Install the latest Magisk Manager
  4. In Magisk Manager: Install → Install → Select and Patch a File and select the AP tar file.
  5. Magisk Manager will patch the whole firmware file and store the output to [Internal Storage]/Download/magisk_patched.tar
  6. Copy the tar file to your PC and boot your device to download mode.
  7. 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.
  8. Important: Uncheck “Auto Reboot” in Options!
  9. Magisk is now successfully flashed! But there are still several steps before you can properly use the device.
  10. We now want to boot into the stock recovery to factory reset our device.
  11. Full data wipe is mandatory! Do not skip this step.
  12. 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.
  13. 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.
  14. 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.
  15. The device will automatically reboot for the first time it boots. This is completely normal and done by design.
  16. After the device is booted up, do the usual initial setup. The following steps will need internet connection.
  17. 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.
  18. Magisk Manager will ask to do additional setups. Let it do its job and the app will automatically reboot your device.
  19. Enjoy Root :)
 
Last edited:

Ayan Chakraborty

Senior Member
Jul 26, 2019
74
10
Successfully rooted Galaxy M40

Thanks for the post. I have successfully rooted Galaxy M40 using magisk. Just one thing to add to the above post-- while copying patched ap from phone to pc use adb otherwise the flashing patched AP fails.
 
Last edited:

Theseusperse

Senior Member
Nov 6, 2017
99
55
Gibraltar
Be careful doing this, since the latest Samsung firmware update in August it doesn't work anymore. You can root at first, but then every time you reboot the phone unroots... If you persist and do it again Samsung lock the phone for "security reasons" and you can't even reach the bootloader or recovery screens using the up / down buttons... Meaning you can't go back to stock firmware without taking your phone back to the store or sending for service, but of course you now no longer have warranty.
 
  • Like
Reactions: mueenuli and DeeCr

rajeshca911

Senior Member
Mar 12, 2014
123
32
Vizag
Rooted Successfully.
I had to flash twice since it did not boot into the stock recovery first time and messed with root I presume. second time it went perfectly and manually installed magisk manager. later magisk manager did some setups and rebooted my system.
Thanks Dev.
waiting for TWRP
 

Scorpio02

New member
Aug 10, 2019
3
0
Rooted Successfully.
I had to flash twice since it did not boot into the stock recovery first time and messed with root I presume. second time it went perfectly and manually installed magisk manager. later magisk manager did some setups and rebooted my system.
Thanks Dev.
waiting for TWRP

So this the new update it works?
 

Theseusperse

Senior Member
Nov 6, 2017
99
55
Gibraltar
This method will work for samsung a60 with his own firmware? Its the china better version of m40, i think i'll try this method

The A60 and the M40 are identical, it's not the "china better version" lol, it's just 90 USD more expensive because Chinese people have more money. It's literally identical down to the microchips inside.
 

rajeshca911

Senior Member
Mar 12, 2014
123
32
Vizag
So this the new update it works?
I think that I flashed on latest firmware AP_M405FDDU1ASF2_CL16060793_QB24248847_REV00_user_low_ship_MULTI_CERT_meta_RKEY_OS9.tar
Android Pie
Magisk 19.3
Magisk Manager 7.3.2
everything works perfectly except that annoying message on the boot screen

Here are my screenshots
View attachment 4807915 Screenshot_20190819-234639_Settings.jpgView attachment 4807917
 
  • Like
Reactions: Scorpio02

rajeshca911

Senior Member
Mar 12, 2014
123
32
Vizag
Be careful doing this, since the latest Samsung firmware update in August it doesn't work anymore. You can root at first, but then every time you reboot the phone unroots... If you persist and do it again Samsung lock the phone for "security reasons" and you can't even reach the bootloader or recovery screens using the up / down buttons... Meaning you can't go back to stock firmware without taking your phone back to the store or sending for service, but of course you now no longer have warranty.

I rooted my phone yesterday, today I rebooted my phone. and pfff it is gone.:(
this rooting procedure is not persistent
Waiting for a stable root method:confused:
now I am neither on ofw nor on rooted firmware
 

Theseusperse

Senior Member
Nov 6, 2017
99
55
Gibraltar
I rooted my phone yesterday, today I rebooted my phone. and pfff it is gone.:(
this rooting procedure is not persistent
Waiting for a stable root method:confused:
now I am neither on ofw nor on rooted firmware

Yeah that was the same issue I was having, I'm using the Indian version of the firmware so I wonder if it just affects Indian models.

I did a lot of research and there's actually not just 5 international models but 7, some with a /DS on the end which appear to use different firmwares, and I wonder if that is the cause of the issue.

Anyway I found a temporary fix. Reset everything back to stock firmware, do the rooting as the guide shows on page 1, then ALWAYS reboot using root, either by installing or upgrading a new Magisk module, or updating your AdAway blacklist, or by using ADB Shell #Su... For some reason when you reboot like this it doesn't unroot the phone and everything stays fine. Also make sure you never ever press the "Okay continue" button that appears when the phone first starts and tells you the bootloader is unlocked, just wait a while and allow it to continue automatically.
 

rajeshca911

Senior Member
Mar 12, 2014
123
32
Vizag
Yeah that was the same issue I was having, I'm using the Indian version of the firmware so I wonder if it just affects Indian models.

I did a lot of research and there's actually not just 5 international models but 7, some with a /DS on the end which appear to use different firmwares, and I wonder if that is the cause of the issue.

Anyway I found a temporary fix. Reset everything back to stock firmware, do the rooting as the guide shows on page 1, then ALWAYS reboot using root, either by installing or upgrading a new Magisk module, or updating your AdAway blacklist, or by using ADB Shell #Su... For some reason when you reboot like this it doesn't unroot the phone and everything stays fine. Also make sure you never ever press the "Okay continue" button that appears when the phone first starts and tells you the bootloader is unlocked, just wait a while and allow it to continue automatically.
Thanks Theseusperse, I will follow that. and can u suggest me easy way to port twrp? I tried carlive image kitchen however when i flashed it not only reboots into stock rom but also shrinked my internal space to 16 GB. To Revert this effect I had to flash stock rom again using Odin ( only odin other tools failed) . Please let me know if there is any safe porting Recovery
 

Theseusperse

Senior Member
Nov 6, 2017
99
55
Gibraltar
Thanks Theseusperse, I will follow that. and can u suggest me easy way to port twrp? I tried carlive image kitchen however when i flashed it not only reboots into stock rom but also shrinked my internal space to 16 GB. To Revert this effect I had to flash stock rom again using Odin ( only odin other tools failed) . Please let me know if there is any safe porting Recovery

There won't be any port of TWRP for a long time, Samsung has to release the source code for the phone first. Based on the Galaxy A series that was released in May this year, they just got their source code last week and the TWRP porting community literally kicked off in the past few days, so we'll probably have to wait some months. I'd estimate November sometime.

I'm excited for when it finally does happen though, I absolutely hate the stock Samsung software and want pure Google, even if it means a GSI rom.

Our phone is actually 100% identical to the Samsung Galaxy A60, so it's possible any TWRP ports made for that device would work, but so far the ones I've tried have all failed and resulted in the same effects you experienced.
 

rajeshca911

Senior Member
Mar 12, 2014
123
32
Vizag
SIZE=1]---------- Post added at 04:02 AM ---------- Previous post was at 03:59 AM ----------[/SIZE]

[/COLOR]
There won't be any port of TWRP for a long time, Samsung has to release the source code for the phone first. Based on the Galaxy A series that was released in May this year, they just got their source code last week and the TWRP porting community literally kicked off in the past few days, so we'll probably have to wait some months. I'd estimate November sometime.

I'm excited for when it finally does happen though, I absolutely hate the stock Samsung software and want pure Google, even if it means a GSI rom.

Our phone is actually 100% identical to the Samsung Galaxy A60, so it's possible any TWRP ports made for that device would work, but so far the ones I've tried have all failed and resulted in the same effects you experienced.
Im excited to hear that A60 recovery might work on M40 any ways me either hate to be on stock rom. I got habituated to the root and custom roms. Hope A60 source works for M40 . Please do update me if anything that kind of miracle happens. Thanks in advance Brother
 

rajeshca911

Senior Member
Mar 12, 2014
123
32
Vizag
No, never ever do this, it will shrink your data partition and there's no way to ever fix it, even with a total system restore or using manufacturer tools.
Too late, I already did that and it shrieked my devices storage to 16Gb first time and 32 gb on second flash. But It got fixed with Odin repartition. Dont worry It is fixable

Sent from my SM-M405F using Tapatalk
 

Top Liked Posts

  • There are no posts matching your filters.
  • 3
    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:

    1. Download the firmware for SM-M405F
    2. Unzip the firmware and copy the AP tar file to your device. It is normally named as AP_[device_model_sw_ver].tar.md5
    3. Install the latest Magisk Manager
    4. In Magisk Manager: Install → Install → Select and Patch a File and select the AP tar file.
    5. Magisk Manager will patch the whole firmware file and store the output to [Internal Storage]/Download/magisk_patched.tar
    6. Copy the tar file to your PC and boot your device to download mode.
    7. 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.
    8. Important: Uncheck “Auto Reboot” in Options!
    9. Magisk is now successfully flashed! But there are still several steps before you can properly use the device.
    10. We now want to boot into the stock recovery to factory reset our device.
    11. Full data wipe is mandatory! Do not skip this step.
    12. 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.
    13. 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.
    14. 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.
    15. The device will automatically reboot for the first time it boots. This is completely normal and done by design.
    16. After the device is booted up, do the usual initial setup. The following steps will need internet connection.
    17. 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.
    18. Magisk Manager will ask to do additional setups. Let it do its job and the app will automatically reboot your device.
    19. Enjoy Root :)
    2
    Be careful doing this, since the latest Samsung firmware update in August it doesn't work anymore. You can root at first, but then every time you reboot the phone unroots... If you persist and do it again Samsung lock the phone for "security reasons" and you can't even reach the bootloader or recovery screens using the up / down buttons... Meaning you can't go back to stock firmware without taking your phone back to the store or sending for service, but of course you now no longer have warranty.
    1
    So this the new update it works?
    I think that I flashed on latest firmware AP_M405FDDU1ASF2_CL16060793_QB24248847_REV00_user_low_ship_MULTI_CERT_meta_RKEY_OS9.tar
    Android Pie
    Magisk 19.3
    Magisk Manager 7.3.2
    everything works perfectly except that annoying message on the boot screen

    Here are my screenshots
    View attachment 4807915Screenshot_20190819-234639_Settings.jpgView attachment 4807917
    1
    I've uploaded the latest firmware file to Mega for anyone who doesn't want to wait 10 years for it to download from the snail-speed Samsung Firmware website:

    https://mega.nz/#!T1sBka7B!iP8Ub8xbmO4ppa1CJg5vh4dWk_Vh-KjnPM6M6VjiqCc

    Feel free to check the MD5 hashes, zero changes.
    1
    I've uploaded the latest firmware file to Mega for anyone who doesn't want to wait 10 years for it to download from the snail-speed Samsung Firmware website:

    https://mega.nz/#!T1sBka7B!iP8Ub8xbmO4ppa1CJg5vh4dWk_Vh-KjnPM6M6VjiqCc

    Feel free to check the MD5 hashes, zero changes.

    Thankyou for this. Its a big help