yashsingh1/xdaforums huggingface dataset:
[Defy General] Guitwo2:
Many thanks to my friend rootdefyxt320 who told me:

Well, ADB insecure is not really needed. If you have init.d support (if not, see http://www.xda-developers.com/android/init-d-support-for-any-rooted-phone/) you just have to :

I ARE DOING THIS AT YOUR OWN RISKS. I AM NOT RESPONSIBLE FOR ANY DAMAGE YOU MAY CAUSE TO YOUR PHONE (but I can help you repair it :p)

MAKE A FULL BACKUP BEFORE GOING ANY FURTHER

Your phone has to be rooted.

I made a flashable zip

It comes with init.d support.

This one come with this http://xdaforums.com/showthread.php?t=2190758 2ndInit.

For now 2ndInit is for dev only. Don't try anything foolish.

0 - download the attached zip

1 - push the XT320_bootmenu.zip on your sdcard

> adb push XT320_bootmenu.zip /sdcard/XT320_bootmenu.zip

2 - Reboot with a CWM... (recovery.img attached)

>adb reboot bootloader
> fastboot boot recovery.img

3 - Flash XT320_bootmenu.zip thorough CWM

4 - Reboot and enjoy !

What I did (if you are interested):

In /system/bootmenu/script/pre_bootmenu.sh, I replace (line 9)

PART_CACHE=/dev/block/mtdblock10 by PART_CACHE=/dev/block/mtdblock9

and (line 64)

button-backlight by keyboard-backlight (this is not a major issue, I think but it is still raising errors)

same in stock.sh (line 24)

button-backlight by keyboard-backlight

and finally in _config.sh (line 6-7-8)

PART_SYSTEM=/dev/block/mtdblock8

PART_CACHE=/dev/block/mtdblock10

PART_DATA=/dev/block/mtdblock11

by

PART_SYSTEM=/dev/block/mtdblock11

PART_CACHE=/dev/block/mtdblock9

PART_DATA=/dev/block/mtdblock12

So what you have to do if it is not working, is to check which block correspond to which partition and then adapt the values.

In shell:

$mount

Check if init.d support is working:

In shell:[/COLOR][/B]

$cat /data/Test.log

You should be careful before trying 2ndInit and 2ndBoot functionality of bootmenu. They are NOT viable.

Thanks to aweosomeabhijeet

CHANGELOG
V2:
If booting on stock, the amber led is lightening up
If booting on 2ndInit, the red led is lightening up
I repack a more recent version of CWM Recovery (V6.0.9)
Clean the /system/bootmenu folder before install
[Defy General] rootdefyxt320:
Hey has anyone tried cwm from fire xt? It might work on our phone

http://xdaforums.com/showthread.php?t=1997638
[Defy General] rootdefyxt320:
This one doesn't use logwrapper, it uses 97bootmenu to hijack the boot process. The Moto Fire XT 530 has a MSM7227T-1 chipset.
[Defy General] Guitwo2:
Then I am interested ! I will have a closer look. You tried it already ?

---------- Post added at 10:08 AM ---------- Previous post was at 09:29 AM ----------

I just get the apk. Installation seems successful. However, no led is going blue on boot to let me enter bootmenu (V2.3)

I tried V1.4.2, but it was more like if I reset my phone. Still no bootmenu. [EDIT] : I think it just cleared my /etc partition (at least), that's why it messed up. [EDIT2] Or maybe it was working ? I am not sure about how to check if it was.

If the trick were explained somewhere, I could have a closer look...

[EDIT3]

Well I tried http://xdaforums.com/showthread.php?t=1026853 which shall be the same thing as the apk, but no success.

It seems that this method replaces /system/bin/mount_ext3.sh by an other one. But this file does not exist in the in the stock version of my ROM. So I guess the trick cannot work. Or I don't understood how it works.
[Defy General] rootdefyxt320:
Use adbd insecure.

http://xdaforums.com/showthread.php?t=1687590

Patch adbd to run as root.

Then use the Batch installer. The last time I did it, it installed, but it was about to boot into bootmenu, then it exited. Make use the Fire XT 2nd-Init. Not the Defy One.
[Defy General] Guitwo2:
I'll try that !
[Defy General] rootdefyxt320:
Guitwo2 confirmed that bootmenu worked. Go to the link to see it.

http://xdaforums.com/showthread.php?t=1997638
[Defy General] Guitwo2:
Moved to http://xdaforums.com/showpost.php?p=39961127&postcount=1
[Defy General] rootdefyxt320:
Here is 2nd-boot for fire xt:

http://xdaforums.com/showthread.php?t=2190758

You must have 2ndinit CWM for it to work.

If FireXT CWM works on our phone then 2nd-Init/2nd-boot should work on our phone.

The one you download doesn't include 2nd-boot
[Defy General] Guitwo2:
I tried the 2nd init that were here originally, and it seems tp work. But I donot really know what I should expect.
[Defy General] rootdefyxt320:
The bootmenu doesn't seem to work for me. I check the mtdblocks and it matches yours. I have busybox installed, init.d support. The blue led loads up after the bootloader, but when it tries to boot into bootmenu, it exits.
[Defy General] Guitwo2:
Try to run in shell

$su
#sh /etc/init.d/97bootmenu

and see what you get.
[Defy General] krule031:
Im a noob. Can someone tell me what is bootmenu? :D

Sent from my XT320
[Defy General] rootdefyxt320:
It's a way to run CWM on locked bootloaders, it is 2nd-Init basically.

---------- Post added at 06:39 PM ---------- Previous post was at 06:35 PM ----------

It still doesn't boot into bootmenu :(
[Defy General] Guitwo2:
Nothing prompting ?

Try then (in shell with root) :

exec /system/bootmenu/binary/bootmenu
[Defy General] Tubii:
How can i change the Permissions o.O ?
[Defy General] Guitwo2:
chmod XXX /filepath/filename

http://en.wikipedia.org/wiki/Chmod
[Defy General] Tubii:
What am I doing wrong?

http://www7.pic-upload.de/09.04.13/ogq36obcugkw.jpg

Defy is Rootet.

USB Debugging is enable.
[Defy General] Guitwo2:
You forgot to "su" before "exec"

If you are not root when executing 97bootmenu, it will not work.
[Defy General] Tubii:
Ok then my screen darker

http://www7.pic-upload.de/09.04.13/ta1rsvpkl1sk.jpg
[Defy General] Guitwo2:
adb reboot

Then try to enter bootmenu by repetitively pressing on the volume down key.

When entered, don't do anything foolish, just choose reboot or shutdown.
[Defy General] Tubii:
Its boots normal :s

http://www7.pic-upload.de/09.04.13/odn6imcuc44.jpg

I didnt change the permissions is this that the error?

I have no idea how I can change the permissions

Is there cmd codes how to change them?

i change with Root explorer in my phone the Permissions, Is that ok ?
[Defy General] Guitwo2:
You have no cp in /system/bin/cp

Try

which cp

and

su
cp /system/xbin/cp /system/bin/cp

If not working try :

> adb push bootmenu_v2.0.2\CWM\cp /sdcard/cp

Then in shell

> adb shell
$su
#mount -o remount,rw -t yaffs2 /dev/block/mtdblock11 /system
# cp /sdcard/cp /system/bin/cp
# chmod 755 /system/bin/cp

If you followed my previous post and followed the instructions:

$su
#chmod 755 /system/bootmenu/binary/*
#chmod 755 /system/bootmenu/script/*
#chmod 755 /system/etc/init.d/97bootmenu

the permissions should be good. To make sure everything's fine, you should check owner & group or just :

$su
#chown 0.0 /system/bootmenu/binary/*
#chown 0.0 /system/bootmenu/script/*
#chown 0.0 /system/etc/init.d/97bootmenu

To check if it is all good, just

$su
#ls -l /system/bootmenu/binary/ (or /system/bootmenu/script/ or /system/etc/init.d/)

---------- Post added at 02:03 PM ---------- Previous post was at 01:38 PM ----------

Maybe if an admin could move all the stuff about bootmenu to a new topic, it could be appropriate.
[Defy General] Guitwo2:
I tried this one. But I am not sure what I am supposed to get but black screen...

When choosing Boot/2nd-Init what is supposed to happen ?

maybe you have not a cp command available. Put one in /system/bin/
[Defy General] Tubii:
the last is right or ?

http://www7.pic-upload.de/09.04.13/ymnfw22fri8j.jpg
[Defy General] Tubii:
This is the end result :
[Defy General] Tubii:
the CP is in system/bin and the permission is to set to 755.

i make #sh /etc/init.d/97bootmenu my Phone makes a fastreboot but no Blue LED :s

is it normal the cmd stopes on "I:exec /system/bootmenu/script/stock.sh" ?
[Defy General] Guitwo2:
Yes it's normal.

Now, when you do a reboot, no blue led ? (during 1 sec).

You are sure you have init.d support ?
[Defy General] Tubii:
i search and The normal Defy Mini has no init.d support, What can i do ?

i search and found this : http://xdaforums.com/showthread.php?t=1933849

I install the apk and when i press Verify then comes Succesfully ...

Now i have make it new but no LED :s
[Defy General] Guitwo2:
Check if there is test.log in /data
[Defy General] Tubii:
the app says succes but no Test.log :s
[Defy General] jkkk88:
Enlarge value of /sys/class/leds/green/brightness in 97bootmenu from 1 to 255 and you will see it:)

I wanted also try it so first impression:

took photo and after choosing reboot phone rebooted but stuck im red M logo. Needed to take battery off,

boot into custom recovery and move 97bootmenu outside of /etc/init.d directory via adb.

I think it is very good begin :)

Thanks guys.
[Defy General] Tubii:
This is now in ur Defy Mini ? O.O

I have no init.d support , i checket this but i dont become the Test.log :( No way for the normal defy mini :( ?
[Defy General] Guitwo2:
I made a flashable zip

0 - push the XT320_bootmenu.zip on your sdcard

1 - Make sure you have busybox installed

2 - Reboot with a CWM... (recovery.img attached)

>adb reboot bootloader
> fastboot boot recovery.img

3 - Flash XT320_bootmenu.zip thorough CWM

4 - Enjoy !

It comes with init.d support.

This one come this http://xdaforums.com/showthread.php?t=2190758 2ndInit.

For now 2ndInit is for dev only. Don't try anything foolish.

[EDIT]

I increased lcd brightness, to make it more readable.
[Defy General] Tubii:
I install with CWM the bootmenu, it comes success.

Reboot.

NO Blue LED.

When i run 2ndInit installer comes all chmod: system/bootmenu/script/2nd-boot.sh: Operation not permitted x.X

and this on the others to.
[Defy General] Guitwo2:
No /data/Test.log ?
[Defy General] Tubii:
No Test.log

only :

link2sd-boot-receiver.log

link2sd-debuggerd.log ,

link2sd-install-recovery.log

this are only the log files in /data
[Defy General] Guitwo2:
Try this :

$su
#sh /etc/install-recovery.sh
[Defy General] jkkk88:
Tubii, if not resolved between time show us pls install-recovery.sh

adb shell cat /system/etc/install-recovery.sh
[Defy General] Tubii:
CMD say : run-parts: not found.

Its bad or ?! x.X
[Defy General] Guitwo2:
Gimme

$which busybox
$cat /etc/install-recovery.sh
[Defy General] Tubii:
This ?
[Defy General] jkkk88:
c:\>adb shell ls -l $(which run-parts) --color=never
lrwxrwxrwx 1 0 10073 19 Mar 10 13:14 /system/bin/run-parts -> /system/bin/busybox

You have broken busybox, install/update from here

https://play.google.com/store/apps/details?id=stericson.busybox

then run it and choose smart install, reboot
[Defy General] Tubii:
It is so ok ?
[Defy General] Guitwo2:
No. You should add busybox before run-parts in the /etc/install-recovery.sh file
[Defy General] Tubii:
i installed busybox from the PlayStore and smart install.
[Defy General] Guitwo2:
It should work now.
[Defy General] Tubii:
Finished ?

No Blue LED ...
[Defy General] Guitwo2:
Man you are killing me...

su
sh /etc/install-recovery.sh
[Defy General] Tubii:
Ok, i check it :D Sorry :S

I press it, BLUE LED turn it on, I press Vol Down but only Handy reboot X.x
[Defy General] Guitwo2:
You can enter bootmenu only when booting.

Try reboot your phone. The led should come up this time.
[Defy General] Tubii:
When i reboot no LED turn it on only by adb shell -> su -> sh /etc/install-recovery.sh
[Defy General] Guitwo2:
Form the XT320_bootmenu archive, get the installbootmenu.sh file and

$su
#sh installbootmenu.sh
[Defy General] Tubii:
omg only problems ....

sh: Can't open installbootmenu.sh WHY O.O ?
[Defy General] Guitwo2:
Try reinstall XT320_bootmenu.zip via CWM.

That the best I can tell you to do as I don't understand a thing of what you are doing.
[Defy General] Tubii:
I make this only what u write and this instruction from Page 117 First but the normal defy Mini has no init.d

I dont know what is the Problem
[Defy General] Guitwo2:
The only thing that can be wrong is your /system/bin/sysint file.

You told me that

$su
#sh /etc/install-recovery.sh

works without raising error and contains only

#!/system/bin/sh
#init.d support
busybox run-parts system/etc/init.d

Gimme

$su
#cat /system/bin/sysint
#ls -l /system/bin/logwrapper
#/system/bin/sysint
[Defy General] eagleeyetom:
I moved a discussion here. Hopefully it will be more clear now
[Defy General] Guitwo2:
Anyone can come with a brilliant idea to test if the 2nd-Init binary is working ?

I mean bootmenu can select between normal and 2nd-Init (easy to test) but, I have no idea what should happen after that command :

/system/bootmenu/binary/2nd-init

shall the boot continue ?

It seems to me that the only thing I get is bootloop...
[Defy General] jkkk88:
Some ideas are here in this forum :--)

for ex. http://xdaforums.com/showthread.php?t=2099238

I will also try logcat and other stuff... There is also need for replacement of original ramdisk content.

---------- Post added at 09:57 PM ---------- Previous post was at 09:47 PM ----------

A little OT. I saw discussion about adbd insecure. Did you tried droidsshd with putty or ssh on another end? And on this forum you can also find midnight commander working in such session :)
[Defy General] Guitwo2:
Never used ssh, only adb.

Mine might be bootlooping in 2ndInit because of wrong *.rc files. I'll try stock *.rc files for 2ndInit first. Then, I'll look into the recovery.img of my phone. But editing the ramdisk is not doable, the locked bootloader will not be ok with a modified ramdisk (signatures won't match and you'll brick) .

We just need to come up with the right set of init files to make 2ndInit work. Then we will be able to go furher :cool:
[Defy General] Guitwo2:
After testing, stock *.rc files didn't worked in 2ndInit. We may have to port it. I'll look into it.
[Defy General] Tubii:
I've looked and no Blue LED , **** off

Installed XT320 Bootmenu with CWM , No LED ....

Does not matter now
[Defy General] Guitwo2:
Man it is sad, I tried my best to help you here, but it seems that everything is correct.

If I could just have a look at your phone, I probably could solve this
[Defy General] Guitwo2:
To help the one who like to dev with me.

I tried several 2nd-Init binaries, same result each time, the phone bootloop and ends booting on stock recovery (don't ask me why).

I lauch /system/bootmenu/script/2nd-Init via adb shell from bootmenu. It seems to work (at least no major errors are shown, unless some /unmount error device busy).

I logcat a little, I'll try to understand what is happening when continuing boot after 2ndInit.

Log attached. If anyone can help me read through the lines...
[Defy General] jkkk88:
OK, I have put startup script into /system/etc/init.d once more and this time I was able to find out reason why my system on next reboot hangs.

After fixing wrong permission on /system/bootmenu/script with chmod 755 it began to work (I have only extracted files from zip

without further checking permission).

What I like is possibility to set default boot mode (for ex. direct into boot menu) and possibility what to boot on the next start - you don't need to play with volume down button anymore. As first alternative system to boot tested custom cwm/openrecovery 5.0.38.for defy.

I'm currently not able to launch adb under root and also not flash zip file (I've noticed via adb there is missing /tmp directory which probably causes it).
[Defy General] Guitwo2:
I updated the bootmenu.

If booting on stock, the amber led is lightening up

If booting on 2ndInit, the red led is lightening up

I repack a more recent version of CWM Recovery.
[Defy General] Tubii:
Jes i know and this very good from you.

I have now a Test.log in /data and deleted bootmenu from system and have make it new but mhm only by cmd comands blue LED ... this very hard, I delete it now and install ur CWM and look now.

P.S From Page 1 :

U write :

adb push bootmenu_v2.0.2\CMW\bootmenu /sdcard/bootmenu

But it is CWM not CMW , It comes a error :s for ur help
[Defy General] jkkk88:
Guitwo2, can you put bootmenu package to the first message in this thread and if newer version then replace it?

Thanks
[Defy General] Guitwo2:
I am not sure I understood everything.

In Test.log file, there should be a date and time. That is a first way to check.

On boot you should have blue LED on for 1s then press (several time) on volume down. You should enter bootmenu.

If you do not enter bootmenu, it resume booting and amber LED is on for 1s if stock boot and red for 1s if 2ndInit boot (but 2ndInit is not working for now).
[Defy General] Tubii:
I Open the Test.log file and :

so it works in cmd fine but not in reboot

http://www10.pic-upload.de/11.04.13/1c9sgx6qzjzo.jpg
[Defy General] Guitwo2:
Well so init.d is working. Still, no blue led on boot ? Gimme

su
ls -l /etc/init.d/
rm /data/Test.log

Then reboot and check if Test.log is there.
[Defy General] Guitwo2:
Done.
[Defy General] Tubii:
i dont found now Test.log o.O
[Defy General] Guitwo2:
You have serious pb with making init.d support work.

Download this http://www.androidfilehost.com/?fid=9390169635556426791

and execute it

su
sh term-init.sh

Gimme the result. If everything is ok, you just should have to reboot one or two times.
[Defy General] Tubii:
The result is : can't open term-init.sh

Download is complete ...

F*** Phone.

i can send u my phone and u look self :DDDD *Joke*

cmd : (term-init.sh is in c:root)

cd c:\root
adb shell
su
sh term-init.sh
sh : Can't open term-init.sh
[Defy General] Guitwo2:
maybe you should push the file on your phone first ? :silly:

cd c:\root
adb push term-init.sh /sdcard/term-init.sh
adb shell
su
sh term-init.sh
[Defy General] Guitwo2:
I reupload the .zip

I made an error when repacking so that you won't see the difference between V1 and V2 recovery...

And I add a cleaning of the /system/bootmenu directory to make sure everything is gone before unpacking.
[Defy General] Tubii:
I've make it but the self, i check my SD card & term-init is on the SD , the file can't intecoruppted ....
[Defy General] Guitwo2:
because it is

sh /sdcard/term-init.sh
[Defy General] Tubii:
here u have it :)

http://www7.pic-upload.de/11.04.13/tt1xodk89kj.jpg

I Found a Test.log in /data
[Defy General] Guitwo2:
When rebooting ?

I think your init.d support is working, now can you send me this ugly /etc/init.d/11ink2sd of yours ?

I'm pretty sure that this file, in a way, raise an error that stops run-parts before it can execute 97bootmenu.

Or to make it simpler... rename 97bootmenu to 10bootmenu for instance :angel:
[Defy General] Tubii:
I've rename the 97bootmenu to 10bootmenu but with reboot only nothing ... Sry i kill u really ... :s
[Defy General] Guitwo2:
adb shell
su
chmod 755 /etc/init.d/*
chown 0.0 /etc/init.d/*

Reboot at least 2 times. Say 3 to make sure.

Check for /data/Test.log file with a recent time in it (not 2 hours ago)

If it is not ok, then :

adb pull /etc/init.d/11link2sd 11link2sd.txt

and send me 11link2sd.txt

adb pull /etc/install-recovery.sh install-recovery.sh

and send me install-recovery.sh as well
[Defy General] Guitwo2:
Yeah you are really killing me men,driving me nuts, plus I have the felling that we are walking round and round
[Defy General] Tubii:
it works fine thanks *-*

But the with that i cant install the CWM or ?
[Defy General] Guitwo2:
GOOD :good:

What do you mean ?

The only thing that is working with this is the recovery mode.

Do not do anything foolish.
[Defy General] Tubii:
i mean this : http://www.gigasize.com/get/nlo540w6gzd

or this : http://www.gigasize.com/get/g3kc53g7o7d
[Defy General] Guitwo2:
No. Not now.
[Defy General] Tubii:
Okej, Thanks really for help this 8 sites :)
[Defy General] Guitwo2:
Don't hesistate to hit the thanks button ;)

This is off thread but if you want some esthetical custom go there http://uot.dakra.lt
[Defy General] jkkk88:
Well see http://cvpcs.org/blog/2011-06-14/2nd-init._what_it_is_and_how_it_works :)

When you look into bm/script directory, you see what is going on by selecting each option.

I have made general cleanup and some fixes. I think it is almost prepared for production.

Review it and add to your rc version.

For demo purposes I moved recovery stuff to 2ndinit stuff so don't worry that selection [Custom recovery] doesn't work.

It works by selection [2ndinit]. After test move it back to bm/recovery.

What can be fixed but it is acceptable to live without it:

- adb root support

- how to port:

echo charge_only > /dev/usb_device_mode

echo msc_adb > /dev/usb_device_mode

- rethink if not to move from /system/bootmedia to /flex which has more free space after removing vendor crap
[Defy General] Guitwo2:
Well thank you for that.

It pretty clear to me how it works.

It blinds ID1, kill everything, replace environment and force ID1 to continue with that.

Not working for me. Both are freezing. My phone.

To enter recovery somewhere there should be /sbin/recovery unless nothing will happend, the phone is just waiting (and with no adb support)

[/QUOTE]

I'm searching for a way to enable adb root support.

There is a lot of crap to remove from /system as well. But first things first.
[Defy General] Guitwo2:
Ok to check if adb is enable you have this :

/sys/class/usb_composite/adb/enable

So I guess we just could

echo 0 > /sys/class/usb_composite/adb/enable for porting echo charge_only > /dev/usb_device_mode

and

echo 1 > /sys/class/usb_composite/adb/enable for porting echo msc_adb > /dev/usb_device_mode
[Defy General] Guitwo2:
Yeah !

I modified echo msc_adb > /dev/usb_device_mode in adbd.sh scripte and I got adb support in bootmenu ! (but not adb root support)
[Defy General] jkkk88:
Did you extracted package directly in phone?

tar xvf <path>/bootmenu-curr.tar -C /system

If not, check if you have same permissions as in package (it is important). This is reason for using better tar instead zip format.
[Defy General] Guitwo2:
I'll just get your scripts.

I change the 2nd-Init script to load from recovery and not from 2ndInit folder, so that I do not have to much thinks to move.

I used a new init.rc file, I'll check if it is working :)

What about echo acm > /dev/usb_device_mode

What is it for ?
[Defy General] jkkk88:
Qustion for some kernel hacker.

I've now cwm on custom recovery and twrp on 2ndinit, probably time to look how to boot some linux distro :)
[Defy General] Guitwo2:
ACM (Abstract Control Model) to emulate serial ports over USB http://www.atmel.com/Images/doc4322.pdf (found on wikipedia)

For now my 2ndInit freezes... but can be adb rebooted (no adb shell / no adb logcat)

I just changed in your 2nd-init.sh

cp -f -r -p /system/bootmenu/2nd-init/* /

for

cp -f -r -p /system/bootmenu/recovery/* /

cp -f -r -p /system/bootmenu/2nd-init/init /init

In my res recovery, I have this init.rc

import /init.recovery.${ro.hardware}.rc

on early-init
start ueventd

on init
export PATH /sbin
export ANDROID_ROOT /system
export ANDROID_DATA /data
export EXTERNAL_STORAGE /sdcard

symlink /system/etc /etc

mkdir /boot
mkdir /recovery
mkdir /sdcard
mkdir /internal_sd
mkdir /external_sd
mkdir /sd-ext
mkdir /datadata
mkdir /emmc
mkdir /system
mkdir /data
mkdir /cache
mount /tmp /tmp tmpfs

chown root shell /tmp
chmod 0775 /tmp

write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18D1
write /sys/class/android_usb/android0/idProduct D001
write /sys/class/android_usb/android0/functions adb
write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
write /sys/class/android_usb/android0/iProduct ${ro.product.model}
write /sys/class/android_usb/android0/iSerial ${ro.serialno}

on boot

ifup lo
hostname localhost
domainname localdomain

class_start default

service ueventd /sbin/ueventd
critical

service recovery /sbin/recovery

service adbd /sbin/adbd recovery
disabled

# Recovery will start adb once it has checked the keys

# Restart adbd so it can run as root
on property:service.adb.root=1
write /sys/class/usb_composite/adb/enable 0
restart adbd
write /sys/class/usb_composite/adb/enable 1

Anyway, where did you get twrp ?