[Samsung Galaxy Z Flip 5] kickassdave:
Hi all,

The subject indicates this is for the SM-F731B variant (EU unlocked model I believe?), however, this may work perfectly fine on other models.

I've not had a Samsung for quite some time myself, so the only thing I remembered previously was that Odin was required for flashing the device with factory ROMs. Needless to say, a good number of factory resets later and some nice finds and I finally got root on the device, while still having a working Samsung Health app etc. (I have a Galaxy Watch 4 Classic).

Anyway... on to the steps:

WARNING:: The initial steps required involve wiping your device (you cannot unlock the bootloader without also wiping your device..). And you will need to wipe again in order to apply a modified boot image.. so... BACK YOUR STUFF UP FIRST!

This will also trip your KNOX security to be 0x1 instead of 0x0. This may not matter for those not intending to use the device for work/secure purposes or those not utilising some of the Samsung apps, but for everyone else, just bear in mind you may need to hold off on updating your device occasionally since you will want to ensure the below apps/modules etc. have been updated to support the relevant update.

For those of you (like myself :( ... ) who rooted their device without realising it was going to bork your Samsung Health app etc.... then just download the required apps/modules from below then follow the steps post-unlock.

Also... [insert usual remark around broken devices etc. NOT being my fault - if YOU downloaded the wrong firmware and borked your device, that is on YOU]

REQUIREMENTS:

I recommend downloading these on a computer first, just so you have all of them handy. As we have to wipe the device anyway, you're going to lose them....

Download the latest stock firmware zip for your device and extract the zipped files to a folder

I got mine from samfw.com however this might not be the best source for everyone, so search around for your variant and ensure you download the correct firmware for your country and carrier

For myself, the latest firmware (as of writing - 18th Oct 2023 - was: F731BXXS1AWI6 with country code EUX - I don't have a carrier specific variant)

It will be a zip file containing the following (or similar):

View attachment 6022581

Download the latest version of Odin from the below link and extract to a folder ready to run the exe:

Download Samsung Odin Flash Tool (All Versions) for Windows | 2023

Odin Tool is used to flashing stock firmware file (in .tar or .tar.md5 formats) on Android-based Samsung devices and supports any Windows 10, 8.1, 8, 7

www.getdroidtips.com

Download the latest Magisk apk from here:

Releases · topjohnwu/Magisk

The Magic Mask for Android. Contribute to topjohnwu/Magisk development by creating an account on GitHub.

github.com

Download the Zygisk version of the modded safetynet fix magisk module from here:

NOTE: NOT the 2.0 version, the 1.3 version

Releases · Displax/safetynet-fix

SafetyNet & Play Integrity API workarounds for Magisk - Displax/safetynet-fix

github.com

View attachment 6022584

Download the latest Lsposed module for Magisk/Zygisk from here:

Releases · LSPosed/LSPosed

LSPosed Framework. Contribute to LSPosed/LSPosed development by creating an account on GitHub.

github.com

View attachment 6022585

Download thelatest Lsposed manager from the Play Store (I ended up requiring this because the shortcut Lsposed created wouldn't work and after disabling the notification, there's no other way to access it....):

LSPosed - Apps on Google Play

LSPosed Xposed Framework

play.google.com

Download the latest version of KnoxPatch Enhancer (an Lsposed module) from here (both the zip module and apk):

Releases · salvogiangri/KnoxPatch

LSPosed module to get Samsung apps/features working again in your rooted Galaxy device. - salvogiangri/KnoxPatch

github.com

View attachment 6022586

Lastly, download and install the latest Samsung USB driver from here:

Samsung Android USB Driver | Samsung Developers

You need the driver only if you are developing on Windows and want to connect a Samsung Android device to your development environment over USB.

developer.samsung.com

With the above items downloaded and ready, let's move on to preparing the phone.

UNLOCKING THE BOOTLOADER:

It just so happens, my variant had no restrictions on allowing you to unlock the bootloader. Unfortunately, this may not be the case for all models and other methods from much more clever folk might be needed :)

Enable Developer Options

Enable the "Allow OEM Unlock" option in Developer Options

Unplug any cables and power off your device

To access download mode.... (Note: other methods did not work for me)

Hold VOL- & VOL+ at the same time

While holding them, connect your phone to a PC via USB

After a moment or two, you should see a green themed screen with lots of info about the device

Hold VOL+ to access the bootloader unlock screen

Follow prompt to unlock the bootloader

The device will factory reset at this point

Skip most steps during initial set up and don't add any accounts, as you are going to have to wipe the device again

PATCHING THE FIRMWARE:

Some of you may be used to just extracting the boot.img from the firmware, patching it with Magisk, then using fastboot to flash the patched boot file to the device.... but that's not the Sammy way :D:D

Connect your phone to your PC and enable file transfers

Transfer the extracted "AP...md5" from the previously downloaded firmware file to your phone storage

For me, this file (and yes... again it's humongous compared to just a boot.img...) :

View attachment 6022588

Transfer the Magisk apk file you downloaded to the device and install it

Open Magisk, tap "Install", tap "Select and Patch a File", browse to the above AP_... file and let Magisk do it's... errr... magic

This will create a modified version of this file and place it in the same folder (in my case... Downloads) which should look something like this:

View attachment 6022589

Move this back to the same folder you extracted the firmware files to

Follow previous steps via "UNLOCKING THE BOOTLOADER" again to put the device in to Download mode (see step 4)

Launch Odin

You should see your device in the box below "ID:COM", if you don't, try reinstalling the Samsung USB driver (see "REQUIREMENTS"), assuming you did actually install it :)

The firmware files correspond to the similarly named buttons in Odin, with the exception that we are going to replace the AP_ file, with our modified version

See below guide:

View attachment 6022593

If (like me) you were a bit confused by the inclusion of CSC_ and HOME_CSC_.. see here for more info:

CSC or HOME CSC? Which CSC File to Flash in Odin?

Samsung firmware consists of 5 binaries including 2 CSC files. Here is a guide to help you find the difference between the CSC and Home CSC.

technastic.com

Since we want to wipe and clean flash this, we are going to use CSC_

Hit "Start" to flash the phone with the modified boot image

The phone will automatically boot up once complete

HIDING/FIXING ROOT/KNOX STATUS:

The issue at this point is that your KNOX status is now tripped and certain Samsung apps will refuse to work. In addition, some banking apps etc. also will now fail to work. Historically, you just used "Magisk Hide" within the Magisk app, and this took care of everything so long as you made sure you selected all relevant apps to hide.

Many security updates later though and a lot has changed.

We need to enable certain modules in Magisk first, install the "Xposed" framework API called "Lsposed" and then utilise some additional modules to further hide our changes from your Google and Samsung apps. See below steps.

Complete the sign-in process as normal (we do not need to wipe again)

Ensure all apps, Samsung Galaxy Store + Play Store, are updated before continuing

Also ensure any additional Samsung apps you need are installed as well. In my case, Samsung Health Monitor, as this wasn't installed by default

Transfer the following previously downloaded files to your device (see "REQUIREMENTS" section for links):

Magisk (apk)

Safetynet fix (zip)

Lsposed module (zip)

KnoxPatch Enhancer (both "DynamicInstaller" zip + apk)

Install Magisk

Launch Magisk, hit Settings (cog icon at top right), enable Zygisk

Go back to the main screen and tap on Modules (bottom right) - REPEAT THESE STEPS FOR EACH MODULE

Install the safetynet fix module --> Reboot

Install the Lsposed module --> Reboot

Install the KnoxPatch Enhancer dynamicInstaller module --> Reboot

Now install the KnoxPatch apk

Install Lsposed Manager via Play Store

Open Lsposed app, go to Settings, disable the "Status Notification" to get rid of the annoying permanent notification

Go to the modules tab (2nd from the left at the bottom)

Tap on "KnoxPatch" and enable it

Now tick every app (some may have been ticked automatically) that you want to hide the KNOX status from

In my case, I selected all of the Samsung apps which didn't work before, but you may find others I have missed also don't work without this... so enable whatever you need to here

I'm not sure if required at this point, but once you've enabled the apps you want to hide KNOX status from, reboot

You should be able to use root now and also Gpay/Samsung Pay/Samsung Health etc. without issue.

OTHER NOTES:

You can confirm your security check (CTS profile) passes by downloading an app called YASNAC from the Play Store. Open it and run the check to see if your device passes

If you find the Lsposed app doesn't open again, just uninstall via Play Store and install again (settings will remain)

I would be VERY cautious about updating immediately to new firmware - check forums/Github pages etc. for the various apps and modules used here and just double check if things will work for you before committing to upgrading

If you want to update to newer firmware, be prepared to wipe again :(

However... you might get away with Odin flashing HOME_CSC_ instead of CSC_ during the flashing process. This will keep your files/programs intact. Since I haven't tested this yet, I can't guarantee it will work while retaining your Magisk/module changes etc. - WORTH A GO THOUGH lol.

If you want to back up apps in their entirety, there's a fantastic alternative to the discontinued Titanium Backup on the Play Store called "Swift Backup". I use this to make full app backups and also SMS/Calls etc.

Lastly... as with any process like this, some changes made my Google/Samsung etc. may break things. Sadly, this is obviously out-with my control.

I will do my best to update this occasionally, however I'm a busy guy with ADHD. There's a good chance I just won't have the time and/or patience to do so, but I always appreciate how great this community is in continuing to help others in the comments. I'm also happy for mods to make critical changes (if any needed!) to my post.

Hope this helps others and have a nice day.