• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[Recovery] TWRP (Unofficial/Experimental) for Samsung M40

Search This thread

rohitrss

Member
Nov 27, 2013
47
5
Moto G
Xiaomi Redmi Note 7
We got our first recovery for Samsung M40 (SM-M405F). This one is ported using Samsung Auto TWRP recovery porter by Team Hovatek
Please try and let everyone know if it works for you or not.
(If you want to do it yourself for any other Android OS version, you can refer to the original Hovatek post.)

You must disable dm_verity before flashing TWRP.

TWRP based on version: 3.5.*

Details of base recovery used for porting:
Source: Extracted from downloaded firmware
Version: Android 11
Build Date: Mon, 12 Apr 2021 07:54:43 +0000
Security Patch Level: 2021-04-01
Product code: INS
PDA: M405FDDU2CUD2
CSC: M405FODM2CUD2

If this works for you, please post here so everyone will know.

If something goes wrong you need and any stock img/file let me know, I will share that too.

Update 1 =>
NOTE: Unfortunately, I can not test this recovery for few more days as this M40 is the only device that I have and it is also source of internet access for me and my laptop. If this mobile is turned off for any reason I wont have internet access so looking for fixes would be difficult.
But I have rooted some devices before and know how things work so I will help in every possible way if someone stuck at any place while trying this recovery.
Also, if someone confirms this recovery does not work, I am planning to port TWRP from scratch.

Update 2 =>
Instructions for NON-Rooted and Bootloader locked device-
Unlocking Bootloader:
  • Allow bootloader unlocking in Developer options → OEM unlocking
  • Reboot to download mode: power off your device and 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.
  • Go through the initial setup. Skip through all the steps since data will be wiped again in later steps. Connect the device to Internet during the setup.
  • Enable developer options, and confirm that the OEM unlocking option exists and is grayed out. This means the VaultKeeper service has unleashed the bootloader.
  • Your bootloader now accepts unofficial images in download mode
Disable DM_Verity (Android Verified Boot):
  • Copy the vbmeta.img (download from attachments) into your adb and fastboot folder
  • You can now flash the vbmeta.img using fastboot to remove dm_verity from your device

    // Enable USB Debugging and enter following commands in CMD/Terminal after connecting device to computer.
    adb devices
    // You should see your device listed

    adb reboot-bootloader
    // Device should reboot to bootloader

    fastboot devices
    // You should see your device listed

    fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img

    // OR if the command above doesn't work, try below
    fastboot flash vbmeta vbmeta.img
    // DONE
////////////////////////////////++++++++++++++++++++++++++////////////////////////////////
Note: For Magisk Rooted devices above steps are not required, as Magisk already patches vbmeta.img and disabled dm_verity (Android Verified Boot)

Flash TWRP with/without Root using Odin
1. Download and install Odin on your PC
2. Download the attached recovery.img, convert it into .tar
3. Reboot to download mode: power off your device and press Volume Up + Volume Down and plug in your device to a PC to boot into download mode.
4. Select recovery.tar under AP_ and Uncheck “Auto Reboot” in Options!
5. Flash the device
6. Now do not power on to System, enter into Recovery/TWRP mode using key combination.
Once TWRP is booted, TWRP will patch the stock ROM to prevent the stock ROM from replacing TWRP. If you don't follow this step, you will have to repeat the install.
*DONE*


Enjoy TWRP!
 

Attachments

  • TWRP for Samsung M40 (SM-M405F).zip
    27.6 MB · Views: 32
  • patched vbmeta img.zip
    3.7 KB · Views: 1
Last edited:
  • Like
Reactions: deadinside322

rohitrss

Member
Nov 27, 2013
47
5
Moto G
Xiaomi Redmi Note 7
did you already tested it on your device??
Unfortunately no, I can not do any testing for few more days as this M40 is the only device that I have and it is also source of internet access for me and my laptop. If this mobile is turned off for any reason I wont have internet access so looking for fixes would be difficult.
But I have rooted some devices before and know how things work so I will help in every possible way if someone stuck at any place while trying this recovery.
Also, if someone confirms this recovery does not work, I am planning to port TWRP from scratch.
 

rohitrss

Member
Nov 27, 2013
47
5
Moto G
Xiaomi Redmi Note 7
My Product code : SM-M405FZBDINS
My device is rooted using magisk patch.
I flashed twrp before root using odin.
I didn't disable dm_verity.
How can I disable dm_verity?
As you have flashed TWRP before root, it failed at verification stage. You need to disable dm_verity, please follow https://forum.hovatek.com/thread-32719.html based on your OS version.
Otherwise, you can flash TWRP after rooting as Magics already disables dm_verity.
 
  • Like
Reactions: deadinside322

Shashvatsawar

Member
Oct 23, 2017
7
2
20
Jaipur
Samsung Galaxy M40
  • Like
Reactions: deadinside322

Akhil137

Senior Member
Jun 12, 2012
145
12
Mumbai
I unlocked the bootloader, then booted my device to download mode.. change .img file extension to .tar then tried to flashing it using oden and selected recovery.tar in AP slot.. but it's stuck on file analysis.

Any help? Any step I did wrong? Let me know
 

rohitrss

Member
Nov 27, 2013
47
5
Moto G
Xiaomi Redmi Note 7
I unlocked the bootloader, then booted my device to download mode.. change .img file extension to .tar then tried to flashing it using oden and selected recovery.tar in AP slot.. but it's stuck on file analysis.

Any help? Any step I did wrong? Let me know
As you have flashed TWRP before root, it failed at verification stage. You need to disable dm_verity, please follow https://forum.hovatek.com/thread-32719.html based on your OS version.
Otherwise, you can flash TWRP after rooting as Magics already disables dm_verity.
 

Shashvatsawar

Member
Oct 23, 2017
7
2
20
Jaipur
Samsung Galaxy M40
Did you try key combination or adb command?
Also, could you please share what all have you tried/done so far so I will have better idea?
I followed this thread to root my device

https://forum.xda-developers.com/t/root-sm-m405f-galaxy-m40.3951491/

There was no option of dm verity while patching stock rom using magisk.
Though My phone was successfully rooted.

I can't use fastboot as it's not showing my device in devices list ( tried a lot).

Finally I flashed your recovery using odin but after going to recovery mode it rebooted only. For recovery mode I tried key combination first and then a root app after device booted.
 
  • Like
Reactions: deadinside322

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Did you try key combination or adb command?
    Also, could you please share what all have you tried/done so far so I will have better idea?
    I followed this thread to root my device

    https://forum.xda-developers.com/t/root-sm-m405f-galaxy-m40.3951491/

    There was no option of dm verity while patching stock rom using magisk.
    Though My phone was successfully rooted.

    I can't use fastboot as it's not showing my device in devices list ( tried a lot).

    Finally I flashed your recovery using odin but after going to recovery mode it rebooted only. For recovery mode I tried key combination first and then a root app after device booted.
  • 1
    We got our first recovery for Samsung M40 (SM-M405F). This one is ported using Samsung Auto TWRP recovery porter by Team Hovatek
    Please try and let everyone know if it works for you or not.
    (If you want to do it yourself for any other Android OS version, you can refer to the original Hovatek post.)

    You must disable dm_verity before flashing TWRP.

    TWRP based on version: 3.5.*

    Details of base recovery used for porting:
    Source: Extracted from downloaded firmware
    Version: Android 11
    Build Date: Mon, 12 Apr 2021 07:54:43 +0000
    Security Patch Level: 2021-04-01
    Product code: INS
    PDA: M405FDDU2CUD2
    CSC: M405FODM2CUD2

    If this works for you, please post here so everyone will know.

    If something goes wrong you need and any stock img/file let me know, I will share that too.

    Update 1 =>
    NOTE: Unfortunately, I can not test this recovery for few more days as this M40 is the only device that I have and it is also source of internet access for me and my laptop. If this mobile is turned off for any reason I wont have internet access so looking for fixes would be difficult.
    But I have rooted some devices before and know how things work so I will help in every possible way if someone stuck at any place while trying this recovery.
    Also, if someone confirms this recovery does not work, I am planning to port TWRP from scratch.

    Update 2 =>
    Instructions for NON-Rooted and Bootloader locked device-
    Unlocking Bootloader:
    • Allow bootloader unlocking in Developer options → OEM unlocking
    • Reboot to download mode: power off your device and 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.
    • Go through the initial setup. Skip through all the steps since data will be wiped again in later steps. Connect the device to Internet during the setup.
    • Enable developer options, and confirm that the OEM unlocking option exists and is grayed out. This means the VaultKeeper service has unleashed the bootloader.
    • Your bootloader now accepts unofficial images in download mode
    Disable DM_Verity (Android Verified Boot):
    • Copy the vbmeta.img (download from attachments) into your adb and fastboot folder
    • You can now flash the vbmeta.img using fastboot to remove dm_verity from your device

      // Enable USB Debugging and enter following commands in CMD/Terminal after connecting device to computer.
      adb devices
      // You should see your device listed

      adb reboot-bootloader
      // Device should reboot to bootloader

      fastboot devices
      // You should see your device listed

      fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img

      // OR if the command above doesn't work, try below
      fastboot flash vbmeta vbmeta.img
      // DONE
    ////////////////////////////////++++++++++++++++++++++++++////////////////////////////////
    Note: For Magisk Rooted devices above steps are not required, as Magisk already patches vbmeta.img and disabled dm_verity (Android Verified Boot)

    Flash TWRP with/without Root using Odin
    1. Download and install Odin on your PC
    2. Download the attached recovery.img, convert it into .tar
    3. Reboot to download mode: power off your device and press Volume Up + Volume Down and plug in your device to a PC to boot into download mode.
    4. Select recovery.tar under AP_ and Uncheck “Auto Reboot” in Options!
    5. Flash the device
    6. Now do not power on to System, enter into Recovery/TWRP mode using key combination.
    Once TWRP is booted, TWRP will patch the stock ROM to prevent the stock ROM from replacing TWRP. If you don't follow this step, you will have to repeat the install.
    *DONE*


    Enjoy TWRP!
    1
    My Product code : SM-M405FZBDINS
    My device is rooted using magisk patch.
    I flashed twrp before root using odin.
    I didn't disable dm_verity.
    How can I disable dm_verity?
    As you have flashed TWRP before root, it failed at verification stage. You need to disable dm_verity, please follow https://forum.hovatek.com/thread-32719.html based on your OS version.
    Otherwise, you can flash TWRP after rooting as Magics already disables dm_verity.
    1
    As you have flashed TWRP before root, it failed at verification stage. You need to disable dm_verity, please follow https://forum.hovatek.com/thread-32719.html based on your OS version.
    Otherwise, you can flash TWRP after rooting as Magics already disables dm_verity.
    I tried it But I am not able to boot into recovery then.
    It just reboots.
    1
    I tried it But I am not able to boot into recovery then.
    It just reboots.
    Did you try key combination or adb command?
    Also, could you please share what all have you tried/done so far so I will have better idea?
    1
    Did you try key combination or adb command?
    Also, could you please share what all have you tried/done so far so I will have better idea?
    I followed this thread to root my device

    https://forum.xda-developers.com/t/root-sm-m405f-galaxy-m40.3951491/

    There was no option of dm verity while patching stock rom using magisk.
    Though My phone was successfully rooted.

    I can't use fastboot as it's not showing my device in devices list ( tried a lot).

    Finally I flashed your recovery using odin but after going to recovery mode it rebooted only. For recovery mode I tried key combination first and then a root app after device booted.