Skip to content

Instantly share code, notes, and snippets.

@mmtrt
Last active March 4, 2025 01:45
Show Gist options
  • Save mmtrt/5dfbd2559ea988dfbe56277347ac6c96 to your computer and use it in GitHub Desktop.
Save mmtrt/5dfbd2559ea988dfbe56277347ac6c96 to your computer and use it in GitHub Desktop.
[ROOT] [Magisk] [Service.d] [Script] [Fix] DriveDroid on Android 9+
#!/bin/sh
# run while loop for boot_completed status & sleep 10 needed for magisk service.d
while [ "$(getprop sys.boot_completed | tr -d '\r')" != "1" ]; do sleep 1; done
sleep 10
# save currently active function name
echo "$(ls -al /config/usb_gadget/g1/configs/b.1/)" | grep -Eo f1.* | awk '{print $3}' | cut -d/ -f8 > /data/adb/.fixdd
# loop
# run every 0.5 seconds
while true
do
# check the app is active
chkapp="$(pgrep -f drivedroid | wc -l)"
# check currently active function
chkfn=$(echo "$(ls -al /config/usb_gadget/g1/configs/b.1/)" | grep -Eo f1.* | awk '{print $3}' | cut -d/ -f8)
# load previous active function
chkfrstfn="$(cat /data/adb/.fixdd)"
if [ "$chkapp" -eq "1" ] && [ "$chkfn" != "mass_storage.0" ]; then
# add mass_storage.0 config & function and remove currently active function
rm /config/usb_gadget/g1/configs/b.1/f*
mkdir -p /config/usb_gadget/g1/functions/mass_storage.0/lun.0/
ln -s /config/usb_gadget/g1/functions/mass_storage.0 /config/usb_gadget/g1/configs/b.1/f1
elif [ "$chkapp" -eq "0" ] && [ "$chkfn" = "mass_storage.0" ]; then
# remove mass_storage.0 function & restore previous function
rm /config/usb_gadget/g1/configs/b.1/f*
ln -s /config/usb_gadget/g1/functions/"$chkfrstfn" /config/usb_gadget/g1/configs/b.1/f1
if [ "$chkfrstfn" = "ffs.adb" ]; then
setprop sys.usb.config adb
elif [ "$chkfrstfn" = "ffs.mtp" ]; then
setprop sys.usb.config mtp
fi
fi
sleep 0.5
done
@zak-ink-5
Copy link

I have an INFINIX SMART 5
And I have got this
/system/bin/sh: curl: inaccessible or not found
I think bc I need to download something,but IDK how
Can someone please help me

@be4zad
Copy link

be4zad commented Sep 28, 2024

I have an INFINIX SMART 5 And I have got this /system/bin/sh: curl: inaccessible or not found I think bc I need to download something,but IDK how Can someone please help me

You should install busybox I guess

@zak-ink-5
Copy link

I have an INFINIX SMART 5 And I have got this /system/bin/sh: curl: inaccessible or not found I think bc I need to download something,but IDK how Can someone please help me

You should install busybox I guess

Thanks I Will try

@zak-ink-5
Copy link

I have an INFINIX SMART 5 And I have got this /system/bin/sh: curl: inaccessible or not found I think bc I need to download something,but IDK how Can someone please help me

You should install busybox I guess

Does not work :/

@zak-ink-5
Copy link

@mmtrt can you tell me how can I make it work

@mmtrt
Copy link
Author

mmtrt commented Oct 1, 2024

@zak-ink-5 try this also make sure termux packages are updated.

curl -sL https://gist.github.com/mmtrt/5dfbd2559ea988dfbe56277347ac6c96/raw/478204e0d0107f14ec0af3e0d4b4774e6f598838/fixdd > fixdd && chmod +x fixdd

just manually run the script whenever want to use dd run these commands

su

then

./fixdd

@Samsara69
Copy link

Use it

Hello, thanks but this app doesn't work

@MakisEu
Copy link

MakisEu commented Dec 10, 2024

Oh, guys, stop talking this, just see what you have in your phone's dir /config/usb_gadget/g1/functions, if there is mass_storage.0, then use the script above, and if there is mass_storage.usb0 instead, just do this.

Or you have anything else, just edit the droid apk yourself.

Hello, do you have any tips if /config/usb_gadget/g1/functions does not contain usb mass storage?
On Samsung galaxy s9+ exynos, I only have these functions

accessory.0 acm.0 audio_source.0 conn_gadget.0 dm.0 ffs.adb midi.0 mtp.0 ncm.0 ptp.0 rndis.0 

I have tried running both the script and this module but nothing worked https://github.com/overzero-git/DriveDroid-fix-Magisk-module. I also looked into finding a custom kernel to see if that fixes it but I haven't found an updated for my model. Tried with stock rom and LOS with same results. Any help is appreciated

@Samsara69
Copy link

Hello, do you have any tips if /config/usb_gadget/g1/functions does not contain usb mass storage? On Samsung galaxy s9+ exynos, I only have these functions

accessory.0 acm.0 audio_source.0 conn_gadget.0 dm.0 ffs.adb midi.0 mtp.0 ncm.0 ptp.0 rndis.0 

I have tried running both the script and this module but nothing worked https://github.com/overzero-git/DriveDroid-fix-Magisk-module. I also looked into finding a custom kernel to see if that fixes it but I haven't found an updated for my model. Tried with stock rom and LOS with same results. Any help is appreciated

Hello.
Have you tried this kernel ? https://xdaforums.com/t/kernel-8-0-8-1-9-0-endurance-kernel-v2-0-27-v1-2-33-linux-4-9-190-csgd-bsb1.3849434/

@MakisEu
Copy link

MakisEu commented Dec 11, 2024

Hello @Samsara69 and thanks for the response!
I have tried to install the kernel but after flashing my phone was stuck at boot. I think it is because my Android version is too high.
Do you have any other suggestions?
Ideally that can be used with LineageOS.

@Samsara69
Copy link

Samsara69 commented Dec 11, 2024

Hello @Samsara69 and thanks for the response! I have tried to install the kernel but after flashing my phone was stuck at boot. I think it is because my Android version is too high. Do you have any other suggestions? Ideally that can be used with LineageOS.

Sorry dear. You have to find kernel matching to your ROM or ROM matching to this kernel ( the kernel now supports 8.1 and 9.0 AOSP ROM ).
But you're lucky.

I have same problem with my S20+ 5G , and there's no one kernel include Drivedroid.
I tried several solution ,no one working.
Seems to build my own kernel but don't have enough knowledge now.

@freewee
Copy link

freewee commented Feb 25, 2025

Hi
You said to somebody "I've updated instructions should be easy to understand." OK but I don't see any instruction on the page where I am!
If you can tell me more!
Thank you for your job! [edit]Excuses the link was not visible!!

@Lowyk
Copy link

Lowyk commented Mar 4, 2025

Works great on my Pixel 6a!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment