[RECOVERY][Testing][amami] TWRP 3.2.1

Search This thread

115ek

Senior Member
Jan 30, 2017
614
702
This one is deprecated! Please use this one instead.

Some words about...
This recovery is for amami - Sony Z1 compact.
I'm opening this thread because I was looking for an up-to-date version of TWRP recovery. After a long search i found this one: https://forum.xda-developers.com/sony-xperia-z1-compact/orig-development/lineageos-12-1-z1c-current-sec-patches-t3614936.
Why am I opening this thread then?
Well,
  • I want to built TWRP from newest android sources (not like cm12.1 that is used in the link above )
  • and I want to get a deeper understanding of sony's partition layout (especially concerning recovery).

I just read a comment about the possibilities to store a recovery on our device, but unfortunately I couldn't find it again. It was something like that:
  1. fastboot flash boot boot.img (recovery uses same kernel but different ramdisk, common sony approach, after kernel boot-up hardware keys decide which ramdisk to load)
  2. fastboot flash FOTAKernel recovery.img (recovery is stored on extra partition with own kernel and own ramdisk)
  3. fastboot flash recovery recovery.img (recovery is stored on extra partition with own kernel and own ramdisk)

So I stumbled over https://forum.xda-developers.com/showpost.php?p=73575131&postcount=130 and followed the instruction. But an inspection of the partitions leads me to the following assumption: either the thing doesn't worked - or fastboot flash FOTAKernel recovery.img and fastboot flash recovery recovery.img are doing the same thing.

The partitions afterwards:

Code:
major minor  #blocks  name              #label

 254        0     524288 zram0
 179        0   15267840 mmcblk0
 179        1       2048 mmcblk0p1      TA
 179        2        512 mmcblk0p2      sbl1    
 179        3        256 mmcblk0p3      s1sbl
 179        4         64 mmcblk0p4      dbi
 179        5        512 mmcblk0p5      aboot
 179        6        512 mmcblk0p6      rpm
 179        7        512 mmcblk0p7      tz
 179        8        512 mmcblk0p8      alt_sbl1
 179        9        256 mmcblk0p9      alt_s1sbl
 179       10         64 mmcblk0p10     alt_dbi
 179       11        512 mmcblk0p11     alt_aboot
 179       12        512 mmcblk0p12     alt_rpm
 179       13        512 mmcblk0p13     alt_tz
 179       14      20480 mmcblk0p14     boot
 179       15      10240 mmcblk0p15     ramdump
 179       16      16384 mmcblk0p16     FOTAKernel
 179       17         32 mmcblk0p17     DDR
 179       18      16384 mmcblk0p18     lta-label
 179       19       1536 mmcblk0p19     modemst1
 179       20       1536 mmcblk0p20     modemst2
 179       21       1536 mmcblk0p21     fsg
 179       22       8192 mmcblk0p22     apps_log
 179       23    2379776 mmcblk0p23     system
 179       24     204800 mmcblk0p24     cache
 179       25   12589039 mmcblk0p25     userdata
 179       32       4096 mmcblk0rpmb

1 block == 1 kByte == 1024 Bytes

--> get actual size in Byte: #blocks*1024 Bytes


How to install
  • unlock bootloader
  • fastboot flash FOTAKernel recovery.img (this should work in any case)
    OR
    fastboot flash recovery recovery.img (if my findings are correct, this should only work with new bootloader from here: https://forum.xda-developers.com/showpost.php?p=73575131&postcount=130 )
  • remove USB cable
  • press and hold Vol. down and power, if device vibrates release power and keep Vol. down holding. That's it.

Feel free to test and give comments on my thougts. :silly:

Credits:
  • SpritCroc (and AICP team)
  • munjeni (new bootloader)
  • Micha-Btz
  • charles1018

Sources:
my manifest: https://github.com/115ek/manifest
forked device tree: https://github.com/115ek/device_sony_amami
original device tree and kernel sources: https://github.com/aicp
TWRP: https://github.com/omnirom/android_bootable_recovery
 

Attachments

  • recovery.zip
    11.8 MB · Views: 7,731
Last edited:

115ek

Senior Member
Jan 30, 2017
614
702
One thing I forgot:
The recovery.img is packed into a .zip file. Please unpack first - it's not flashable via recovery.
I saw threads with a download section. Is this only possible with devDB threads? :confused:
 
  • Like
Reactions: DahakePL

pain87

Member
Feb 25, 2018
26
2
22
Well, for me it worked without problems.
What isn't working in detail? What filesystem does your OTG device uses? What exactly did you do to mount and check for the files on the USB drive? :cool:

My Pendrive is formatted as NTFS. A click on Select Storage and USB OTG "says" 0MB. The Pendrive is works fine in TWRP 3.1.1.
 

115ek

Senior Member
Jan 30, 2017
614
702
My Pendrive is formatted as NTFS. A click on Select Storage and USB OTG "says" 0MB. The Pendrive is works fine in TWRP 3.1.1.
Hmm. Okay. I think I didn't include ntfs support. I'll have a look on this next build.
But did you set the check mark at USB OTG under mount menu point?
Do you also have an USB drive with fat format to test?
Thanks for the info ;)
 
Last edited:

pain87

Member
Feb 25, 2018
26
2
22
Hmm. Okay. I think I didn't include ntfs support. I'll have a look on this next build.
But did you set the check mark at USB OTG under mount menu point?
Do you also have an USB drive with fat format to test?
Thanks for the info ;)

Yes, I do. Formatted as FAT32 but still not working. :(

Edit: Clicked on the Circle, but nothing happened.
 
Last edited:

pipyakas

Senior Member
Apr 22, 2013
1,150
281
I can only boot into TWRP by shutting down the phone and use vol- and power on at the same time, using the reboot to recovery option and adb reboot recovery command doesnt work. Is there any workaround for this? Previously I recall booting into 2 different twrp version by hardware buttons/software command that way
 

jho55

Senior Member
Sep 8, 2015
238
65
Munich
I can only boot into TWRP by shutting down the phone and use vol- and power on at the same time, using the reboot to recovery option and adb reboot recovery command doesnt work. Is there any workaround for this? Previously I recall booting into 2 different twrp version by hardware buttons/software command that way

you can always upgrade to a new TWRP inside TWRP itself! You can flash a new img file within twrp. You need to change the filter from zip to img though.
 
  • Like
Reactions: lm089

pipyakas

Senior Member
Apr 22, 2013
1,150
281
you can always upgrade to a new TWRP inside TWRP itself! You can flash a new img file within twrp. You need to change the filter from zip to img though.

I'm already on the latest version of TWRP given in this post - although it was through flashing in TWRP 2.8.7.0 included in a pre-rooted stock rom. I'm just not being able to boot into twrp from the rom itself - only via hardware buttons
 

115ek

Senior Member
Jan 30, 2017
614
702
I can only boot into TWRP by shutting down the phone and use vol- and power on at the same time, using the reboot to recovery option and adb reboot recovery command doesnt work. Is there any workaround for this? Previously I recall booting into 2 different twrp version by hardware buttons/software command that way
The recovery you enter while holding Vol- and power is the one stored on FOTAKernel partition (that is the "real" one, it has got own kernel and ramdisk).
The recovery you enter with power and then Vol+ when LED lights up is the combined one. It is stored inside the boot partition.
The normal case is: kernel stored in boot.img starts and checks for user input. If you do so, a special recovery ramdisk gets loaded. Otherwise the "normal" ramdisk is loaded up.

Entering the recovery from inside the android system is a problem of your ROM. The system has to set a flag that survives reboot. Then the bootloader examines this flag and does the according operation.
 

pipyakas

Senior Member
Apr 22, 2013
1,150
281
The recovery you enter while holding Vol- and power is the one stored on FOTAKernel partition (that is the "real" one, it has got own kernel and ramdisk).
The recovery you enter with power and then Vol+ when LED lights up is the combined one. It is stored inside the boot partition.
The normal case is: kernel stored in boot.img starts and checks for user input. If you do so, a special recovery ramdisk gets loaded. Otherwise the "normal" ramdisk is loaded up.

Entering the recovery from inside the android system is a problem of your ROM. The system has to set a flag that survives reboot. Then the bootloader examines this flag and does the according operation.
Well then that "flag" surely can trigger something, because I do remember booting into a different twrp version from within the rom than the "real" one. Also, the one booted from the rom always seem to have much worse brightness, if that's saying something. I cant exactly repeat the process to get that recovery either
 

pain87

Member
Feb 25, 2018
26
2
22
Cool :cool:
Can you test with ntfs, too? Only if that doesn't create circumstances ;)

No problem with FAT32! Works fine. ;)

Edit: Sorry I tested with TWRP 3.1.0 :C I need to flash TWRP 3.2.1

Edit 2 Flashed TWRP 3.2.1, clicked on Mount, Enable MTP, then clicked on USB OTG but nothing happened. Still not works with FAT32. :rolleyes:
 
Last edited:

115ek

Senior Member
Jan 30, 2017
614
702
Well then that "flag" surely can trigger something, because I do remember booting into a different twrp version from within the rom than the "real" one. Also, the one booted from the rom always seem to have much worse brightness, if that's saying something. I cant exactly repeat the process to get that recovery either
Yes, that sounds like your reboot-to-recovery option boots to the recovery included in boot.img, which came along with the installation of your ROM.
At the end a system call passes a "recovery" argument to the kernel restart function. This restart function then sets the kernel start parameters to the recovery-ramdisk and restarts the kernel (warm reboot).
If you want to enter the "real" recovery you have to explain the bootloader that he should load the kernel from FOTAKernel partition instead of boot partition.
You can google for more details, but there's not so much info unfortunately :(
https://stackoverflow.com/questions/5472761/how-does-the-bootloader-pick-up-the-command-after-a-restarting-system-with-comm
Nevertheless I'll look into it - it's really interesting. Another thing that's on my list is decryption support for TWRP...
 

Top Liked Posts

  • There are no posts matching your filters.
  • 8
    This one is deprecated! Please use this one instead.

    Some words about...
    This recovery is for amami - Sony Z1 compact.
    I'm opening this thread because I was looking for an up-to-date version of TWRP recovery. After a long search i found this one: https://forum.xda-developers.com/sony-xperia-z1-compact/orig-development/lineageos-12-1-z1c-current-sec-patches-t3614936.
    Why am I opening this thread then?
    Well,
    • I want to built TWRP from newest android sources (not like cm12.1 that is used in the link above )
    • and I want to get a deeper understanding of sony's partition layout (especially concerning recovery).

    I just read a comment about the possibilities to store a recovery on our device, but unfortunately I couldn't find it again. It was something like that:
    1. fastboot flash boot boot.img (recovery uses same kernel but different ramdisk, common sony approach, after kernel boot-up hardware keys decide which ramdisk to load)
    2. fastboot flash FOTAKernel recovery.img (recovery is stored on extra partition with own kernel and own ramdisk)
    3. fastboot flash recovery recovery.img (recovery is stored on extra partition with own kernel and own ramdisk)

    So I stumbled over https://forum.xda-developers.com/showpost.php?p=73575131&postcount=130 and followed the instruction. But an inspection of the partitions leads me to the following assumption: either the thing doesn't worked - or fastboot flash FOTAKernel recovery.img and fastboot flash recovery recovery.img are doing the same thing.

    The partitions afterwards:

    Code:
    major minor  #blocks  name              #label
    
     254        0     524288 zram0
     179        0   15267840 mmcblk0
     179        1       2048 mmcblk0p1      TA
     179        2        512 mmcblk0p2      sbl1    
     179        3        256 mmcblk0p3      s1sbl
     179        4         64 mmcblk0p4      dbi
     179        5        512 mmcblk0p5      aboot
     179        6        512 mmcblk0p6      rpm
     179        7        512 mmcblk0p7      tz
     179        8        512 mmcblk0p8      alt_sbl1
     179        9        256 mmcblk0p9      alt_s1sbl
     179       10         64 mmcblk0p10     alt_dbi
     179       11        512 mmcblk0p11     alt_aboot
     179       12        512 mmcblk0p12     alt_rpm
     179       13        512 mmcblk0p13     alt_tz
     179       14      20480 mmcblk0p14     boot
     179       15      10240 mmcblk0p15     ramdump
     179       16      16384 mmcblk0p16     FOTAKernel
     179       17         32 mmcblk0p17     DDR
     179       18      16384 mmcblk0p18     lta-label
     179       19       1536 mmcblk0p19     modemst1
     179       20       1536 mmcblk0p20     modemst2
     179       21       1536 mmcblk0p21     fsg
     179       22       8192 mmcblk0p22     apps_log
     179       23    2379776 mmcblk0p23     system
     179       24     204800 mmcblk0p24     cache
     179       25   12589039 mmcblk0p25     userdata
     179       32       4096 mmcblk0rpmb
    
    1 block == 1 kByte == 1024 Bytes
    
    --> get actual size in Byte: #blocks*1024 Bytes


    How to install
    • unlock bootloader
    • fastboot flash FOTAKernel recovery.img (this should work in any case)
      OR
      fastboot flash recovery recovery.img (if my findings are correct, this should only work with new bootloader from here: https://forum.xda-developers.com/showpost.php?p=73575131&postcount=130 )
    • remove USB cable
    • press and hold Vol. down and power, if device vibrates release power and keep Vol. down holding. That's it.

    Feel free to test and give comments on my thougts. :silly:

    Credits:
    • SpritCroc (and AICP team)
    • munjeni (new bootloader)
    • Micha-Btz
    • charles1018

    Sources:
    my manifest: https://github.com/115ek/manifest
    forked device tree: https://github.com/115ek/device_sony_amami
    original device tree and kernel sources: https://github.com/aicp
    TWRP: https://github.com/omnirom/android_bootable_recovery
    2
    I just did the hard way...
    Backing up my System wiping everything and flashing the ROM provided by EMMA (the same from your screenshot).
    Turned the phone on by holding Vol- and... it showed the Sony screen!
    Flashed munjenis FTF to support real recovery.
    Flashed your recovery image AND!!!
    Booted up fine :)!
    Right now I'm restoring my backup. So my assumption was correct and now I have real recovery, too!
    1
    One thing I forgot:
    The recovery.img is packed into a .zip file. Please unpack first - it's not flashable via recovery.
    I saw threads with a download section. Is this only possible with devDB threads? :confused:
    1
    I can only boot into TWRP by shutting down the phone and use vol- and power on at the same time, using the reboot to recovery option and adb reboot recovery command doesnt work. Is there any workaround for this? Previously I recall booting into 2 different twrp version by hardware buttons/software command that way

    you can always upgrade to a new TWRP inside TWRP itself! You can flash a new img file within twrp. You need to change the filter from zip to img though.
    1
    Sorry for the semi-necroing this thread but what would happen if you flash the ta backup in twrp with the bootloader unlocked and a custom rom installed?:). Will dm-verity stop the phone from booting somehow?

    "Can I restore my TA while running a ROM with a non-stock kernel?
    A: Yes, but it will soft-brick your device and you need Sony PC Companion or Flashtool to fix it by flashing stock firmware. Best is to first return to a complete stock ROM or at least flash a stock kernel (do not confuse with stock based kernel!) before restoring the TA, this prevents the soft-brick."

    thats what I found here https://forum.xda-developers.com/showthread.php?t=2292598