Samsung-Loki / Thor

An alternative to Heimdall
Mozilla Public License 2.0
203 stars 22 forks source link

flashTar directory doesn't detect img #8

Open lmateovf opened 1 year ago

lmateovf commented 1 year ago

Description

Whenever I try to "flashTar" a dir, it only displays three dots ... no img selection...

Reproduction

1) Enter command flashTar "dir" 2) Attempt to flash BL_A325FXXU5DWE3_A325FXXU5DWE3_MQB65744574_REV00_user_low_ship_MULTI_CERT.tar that contains img.lz4 files. 3) I get the error:

Photo of the device

Captura desde 2023-07-15 13-15-05

Full logs of the tool, in debug mode

To enable debug mode, enter debug on before doing connect for collecting as much info as possible. \ To get the "full logs", scroll up to the first message in Thor, select it's start, and drag to the end of the last message and copy it here:

lmateovf@popos-mateo:~/Descargas/linux$ sudo ./TheAirBlow.Thor.Shell 
Welcome to Thor Shell v1.0.4!
Successfully loaded "usb.ids" from cache.
Type "help" for list of commands.
To start off, type "connect" to initiate a connection.
~~~~~~~~ Platform specific notes ~~~~~~~~
You have to run Thor as root or edit udev rules as follows:
1) create and open /etc/udev/rules.d/51-android.rules in an editor
2) enter SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="YourUserGroupHere"
Additionally, you may have to disable the cdc_acm kernel module:
1) To temporarily unload, run "sudo modprobe -r cdc_acm"
2) To disable it, run "echo 'blacklist cdc_acm' | sudo tee -a /etc/modprobe.d/cdc_acm-blacklist.conf"
shell> debug on
Enabled debug logging
shell> connect
[13:24:17 DBG] Number of configurations: 1
[13:24:17 DBG] Number of interfaces: 2
[13:24:17 DBG] ~~~~ Interface index 0 ~~~~
[13:24:17 DBG] Number of endpoints: 1
[13:24:17 DBG] Interface class: 0x02
[13:24:17 DBG] $$ Endpoint index 0 $$
[13:24:17 DBG] !! Class-dependant descriptor, skipping (len = 5 - 2)
[13:24:17 DBG] !! Class-dependant descriptor, skipping (len = 5 - 2)
[13:24:17 DBG] !! Class-dependant descriptor, skipping (len = 4 - 2)
[13:24:17 DBG] !! Class-dependant descriptor, skipping (len = 5 - 2)
[13:24:17 DBG] Endpoint address: 0x82
[13:24:17 DBG] !! USB_ENDPOINT_XFER_BULK fail (value = 03)
[13:24:17 DBG] !! Interface is invalid, continuing
[13:24:17 DBG] ~~~~ Interface index 1 ~~~~
[13:24:17 DBG] Number of endpoints: 2
[13:24:17 DBG] Interface class: 0x0A
[13:24:17 DBG] $$ Endpoint index 0 $$
[13:24:17 DBG] Endpoint address: 0x81
[13:24:17 DBG] $$ Endpoint index 1 $$
[13:24:17 DBG] Endpoint address: 0x01
[13:24:17 DBG] > Interface is valid, exiting
[13:24:17 DBG] Interface: 0x01, Alternate: 0x00, Read Endpoint: 0x81, Write Endpoint: 0x01
Successfully connected to the device!
Now run "begin" with the protocol you need.
shell> begin odinç
~~~~~~~~~~~~~^
Invalid option choice, should be [odin]
shell> begin odin
[13:24:26 DBG] Bootloader version integer 0x00020000
[13:24:26 DBG] Unknown1: 0, Unknown2: 0, Version: 2
[13:24:26 DBG] Sending file part size of 1048576
Successfully began an Odin session!
shell> flashTar /home/lmateovf/Descargas/intento/Descomprimidos/Def
[13:24:48 DBG] PIT size is 4000 (16384), 33 total blocks
[13:24:56 DBG] Full exception: System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
   at System.IO.Stream.ReadAtLeastCore(Span`1 buffer, Int32 minimumBytes, Boolean throwOnEndOfStream)
   at System.IO.Stream.ReadExactly(Span`1 buffer)
   at System.Formats.Tar.TarHeader.TryGetNextHeader(Stream archiveStream, Boolean copyData, TarEntryFormat initialFormat, Boolean processDataBlock)
   at System.Formats.Tar.TarReader.TryGetNextEntryHeader(Boolean copyData)
   at System.Formats.Tar.TarReader.GetNextEntry(Boolean copyData)
   at ThorRewrite.Shell.Commands.ProtoOdin.FlashTar.RunCommand(State state, List`1 args) in /home/theairblow/RiderProjects/Thor/TheAirBlow.Thor.Shell/Commands/ProtoOdin/FlashTar.cs:line 30
~~~~~~~^
Unable to read beyond the end of the stream.
shell> flashTar /home/lmateovf/Descargas/intento/Descomprimidos/Def
[13:25:03 DBG] PIT size is 4000 (16384), 33 total blocks
Choose what partitions to flash from BL_A325FXXU5DWE3_A325FXXU5DWE3_MQB65744574_REV00_user_low_ship_MULTI_CERT.tar:
…                                                                                                                  

(Press <space> to select, <enter> to accept)                                                                       [13:25:03 DBG] Full exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at Spectre.Console.MultiSelectionPrompt`1.Spectre.Console.IListPromptStrategy<T>.HandleInput(ConsoleKeyInfo key, ListPromptState`1 state) in /_/src/Spectre.Console/Prompts/MultiSelectionPrompt.cs:line 165
   at Spectre.Console.ListPrompt`1.Show(ListPromptTree`1 tree, CancellationToken cancellationToken, Int32 requestedPageSize, Boolean wrapAround) in /_/src/Spectre.Console/Prompts/List/ListPrompt.cs:line 58
   at Spectre.Console.MultiSelectionPrompt`1.ShowAsync(IAnsiConsole console, CancellationToken cancellationToken) in /_/src/Spectre.Console/Prompts/MultiSelectionPrompt.cs:line 97
   at Spectre.Console.MultiSelectionPrompt`1.Show(IAnsiConsole console) in /_/src/Spectre.Console/Prompts/MultiSelectionPrompt.cs:line 89
   at Spectre.Console.AnsiConsole.Prompt[T](IPrompt`1 prompt) in /_/src/Spectre.Console/AnsiConsole.Prompt.cs:line 21
   at ThorRewrite.Shell.Commands.ProtoOdin.FlashTar.RunCommand(State state, List`1 args) in /home/theairblow/RiderProjects/Thor/TheAirBlow.Thor.Shell/Commands/ProtoOdin/FlashTar.cs:line 42
~~~~~~~^
Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
shell>

Hardware and software

Additional context

I want to root this A32 for root access.

lmateovf commented 1 year ago

Maybe is because of the img.lz4 files?

lmateovf commented 1 year ago

imagen

This is the magisk .tar, extracted...

lmateovf commented 1 year ago

Please, help me...

TheAirBlow commented 1 year ago

From the looks of it, my program fails to properly get the tar file entries. Not sure why it would happen - but I think it's fault of the tar lib I'm using, as I didn't have any issues. Just to make sure - are the following files at the root of the tar archive (not in a directory in the archive)?

a7md8762 commented 1 year ago

imagen

This is the magisk .tar, extracted...

Extract them again, To be like name.img, Then compress it to .tar I had the same issue, I just extracted the archive.img.lz4, Then took the archive.img and compressed it to .tar archive and it worked.

lmateovf commented 1 year ago

From the looks of it, my program fails to properly get the tar file entries. Not sure why it would happen - but I think it's fault of the tar lib I'm using, as I didn't have any issues. Just to make sure - are the following files at the root of the tar archive (not in a directory in the archive)?

I don’t have the computer with me right now… but I obtained the tar files with this tool: https://github.com/SlackingVeteran/frija/releases/tag/v1.4.4

I don’t know if you can try this and tell for yourself if the tar files are ok for your program or not while I’m at work…

Anyway, again thank you for the help

lmateovf commented 1 year ago

while I don’t have my phone or Linux here, I have a doubt: is it ok if I flash a SM-A325F img (Galaxy A32) on a SM-A325F/DS (same but dual-sim, my actual model)?

lmateovf commented 1 year ago

imagen This is the magisk .tar, extracted...

Extract them again, To be like name.img, Then compress it to .tar I had the same issue, I just extracted the archive.img.lz4, Then took the archive.img and compressed it to .tar archive and it worked.

About this… this program is able to decompress img.lz4 for itself, but anyway I will give it a try later too… thank you

lmateovf commented 1 year ago

So there was two issues:

Thank you for your help, if I close this ticket is because I have achieve the root flashing... Hope I don't have to bother you again hehehe

lmateovf commented 1 year ago

Ok so it detects the magisk AP TAR but not the others: Captura desde 2023-07-18 20-28-05 Captura desde 2023-07-18 20-28-16

I'm going to try what @a7md8762 told me, and I will report... because it does not detect the lz4 files only the ones that are already .img...

lmateovf commented 1 year ago

shell> debug on
Enabled debug logging
shell> connect
[22:11:38 DBG] Number of configurations: 1
[22:11:38 DBG] Number of interfaces: 2
[22:11:38 DBG] ~~~~ Interface index 0 ~~~~
[22:11:38 DBG] Number of endpoints: 1
[22:11:38 DBG] Interface class: 0x02
[22:11:38 DBG] $$ Endpoint index 0 $$
[22:11:38 DBG] !! Class-dependant descriptor, skipping (len = 5 - 2)
[22:11:38 DBG] !! Class-dependant descriptor, skipping (len = 5 - 2)
[22:11:38 DBG] !! Class-dependant descriptor, skipping (len = 4 - 2)
[22:11:38 DBG] !! Class-dependant descriptor, skipping (len = 5 - 2)
[22:11:38 DBG] Endpoint address: 0x82
[22:11:38 DBG] !! USB_ENDPOINT_XFER_BULK fail (value = 03)
[22:11:38 DBG] !! Interface is invalid, continuing
[22:11:38 DBG] ~~~~ Interface index 1 ~~~~
[22:11:38 DBG] Number of endpoints: 2
[22:11:38 DBG] Interface class: 0x0A
[22:11:38 DBG] $$ Endpoint index 0 $$
[22:11:38 DBG] Endpoint address: 0x81
[22:11:38 DBG] $$ Endpoint index 1 $$
[22:11:38 DBG] Endpoint address: 0x01
[22:11:38 DBG] > Interface is valid, exiting
[22:11:38 DBG] Interface: 0x01, Alternate: 0x00, Read Endpoint: 0x81, Write Endpoint: 0x01
Successfully connected to the device!
Now run "begin" with the protocol you need.
shell> begin odin
[22:11:46 DBG] Full exception: System.ApplicationException: Failed to bulk read: Connection timed out (110)
   at TheAirBlow.Thor.Library.Platform.Linux.Interop.HandleError(String message) in /home/theairblow/RiderProjects/Thor/TheAirBlow.Thor.Library/Platform/Linux.cs:line 366
   at TheAirBlow.Thor.Library.Platform.Linux.BulkRead(Int32 amount, Int32& read, Int32 timeout) in /home/theairblow/RiderProjects/Thor/TheAirBlow.Thor.Library/Platform/Linux.cs:line 228
   at TheAirBlow.Thor.Library.Protocols.Odin.Handshake() in /home/theairblow/RiderProjects/Thor/TheAirBlow.Thor.Library/Protocols/Odin.cs:line 30
   at ThorRewrite.Shell.Commands.Begin.RunCommand(State state, List`1 args) in /home/theairblow/RiderProjects/Thor/TheAirBlow.Thor.Shell/Commands/Begin.cs:line 21
~~~~~~~^
Failed to bulk read: Connection timed out (110)
shell> disconnecrt
~~~~~~~^
This command does not exist
shell> disconnect
Successfully disconnected the device!
shell> connecrt
~~~~~~~^
This command does not exist
shell> connect 
[22:12:06 DBG] Number of configurations: 1
[22:12:06 DBG] Number of interfaces: 2
[22:12:06 DBG] ~~~~ Interface index 0 ~~~~
[22:12:06 DBG] Number of endpoints: 1
[22:12:06 DBG] Interface class: 0x02
[22:12:06 DBG] $$ Endpoint index 0 $$
[22:12:06 DBG] !! Class-dependant descriptor, skipping (len = 5 - 2)
[22:12:06 DBG] !! Class-dependant descriptor, skipping (len = 5 - 2)
[22:12:06 DBG] !! Class-dependant descriptor, skipping (len = 4 - 2)
[22:12:06 DBG] !! Class-dependant descriptor, skipping (len = 5 - 2)
[22:12:06 DBG] Endpoint address: 0x82
[22:12:06 DBG] !! USB_ENDPOINT_XFER_BULK fail (value = 03)
[22:12:06 DBG] !! Interface is invalid, continuing
[22:12:06 DBG] ~~~~ Interface index 1 ~~~~
[22:12:06 DBG] Number of endpoints: 2
[22:12:06 DBG] Interface class: 0x0A
[22:12:06 DBG] $$ Endpoint index 0 $$
[22:12:06 DBG] Endpoint address: 0x81
[22:12:06 DBG] $$ Endpoint index 1 $$
[22:12:06 DBG] Endpoint address: 0x01
[22:12:06 DBG] > Interface is valid, exiting
[22:12:06 DBG] Interface: 0x01, Alternate: 0x00, Read Endpoint: 0x81, Write Endpoint: 0x01
Successfully connected to the device!
Now run "begin" with the protocol you need.
shell> begin odin
[22:12:08 DBG] Bootloader version integer 0x00020000
[22:12:08 DBG] Unknown1: 0, Unknown2: 0, Version: 2
[22:12:08 DBG] Sending file part size of 1048576
Successfully began an Odin session!
shell> flashTar /home/lmateovf/Descargas/Frenadol/DEFINITIVOS
[22:12:23 DBG] PIT size is 4000 (16384), 33 total blocks
You chose to flash 15 partitions in total:
boot.img from AP.tar on partition boot
dtbo.img from AP.tar on partition dtbo
gz-verified.img from AP.tar on partition gz1
md_udc.img from AP.tar on partition md_udc
misc.bin from AP.tar on partition misc
recovery.img from AP.tar on partition recovery
scp-verified.img from AP.tar on partition scp1
spmfw-verified.img from AP.tar on partition spmfw
sspm-verified.img from AP.tar on partition sspm_1
super.img from AP.tar on partition super
tee-verified.img from AP.tar on partition tee1
tzar.img from AP.tar on partition tzar
userdata.img from AP.tar on partition userdata
vbmeta.img from AP.tar on partition vbmeta
vbmeta_system.img from AP.tar on partition vbmeta_system
Are you absolutely sure you want to flash those? [y/n] (n): y

     Flashing sequence 2 / 2 onto boot ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 33.2 MB/s 32.0 MB    00:00:00          
     Flashing sequence 1 / 1 onto dtbo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 9.2 MB/s  250.5 KB   00:00:00          
      Flashing sequence 1 / 1 onto gz1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 3.1 MB/s  2.6 MB     00:00:00          
   Flashing sequence 1 / 1 onto md_udc ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 1.9 MB/s  52.1 KB    00:00:00          
     Flashing sequence 1 / 1 onto misc ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 16.6 MB/s 508.5 KB   00:00:00          
 Flashing sequence 2 / 2 onto recovery ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 34.0 MB/s 32.0 MB    00:00:00          
     Flashing sequence 1 / 1 onto scp1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 8.6 MB/s  240.0 KB   00:00:00          
    Flashing sequence 1 / 1 onto spmfw ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 45.9 KB/s 48.6 KB    00:00:00          
   Flashing sequence 1 / 1 onto sspm_1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 17.9 MB/s 494.5 KB   00:00:00          
Flashing sequence 226 / 226 onto super ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% 28.6 MB/s 6.6 GB     00:00:00          
     Flashing sequence 1 / 1 onto tee1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 2.5 MB/s  2.0 MB     00:00:00          
     Flashing sequence 1 / 1 onto tzar ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 8.4 MB/s  2.9 MB     00:00:00          
         Sending flash sequence 3 / 48 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   4% 36.4 MB/s 0.1/1.4 GB 00:00:37          

[22:16:45 DBG] Full exception: System.ApplicationException: Failed to bulk write: Connection timed out (110)
   at TheAirBlow.Thor.Library.Platform.Linux.Interop.HandleError(String message) in /home/theairblow/RiderProjects/Thor/TheAirBlow.Thor.Library/Platform/Linux.cs:line 366
   at TheAirBlow.Thor.Library.Platform.Linux.BulkWrite(Byte[] buf, Int32 timeout, Boolean zlp) in /home/theairblow/RiderProjects/Thor/TheAirBlow.Thor.Library/Platform/Linux.cs:line 200
   at TheAirBlow.Thor.Library.Protocols.Odin.FlashPartition(Stream stream, PitEntry entry, Action`1 progress, Int64 length) in /home/theairblow/RiderProjects/Thor/TheAirBlow.Thor.Library/Protocols/Odin.cs:line 355
   at ThorRewrite.Shell.Commands.ProtoOdin.FlashTar.<>c__DisplayClass0_0.<RunCommand>b__0(ProgressContext ctx) in /home/theairblow/RiderProjects/Thor/TheAirBlow.Thor.Shell/Commands/ProtoOdin/FlashTar.cs:line 84
   at Spectre.Console.Progress.<>c__DisplayClass25_0.<Start>b__0(ProgressContext ctx) in /_/src/Spectre.Console/Live/Progress/Progress.cs:line 65
   at Spectre.Console.Progress.<>c__DisplayClass27_0.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Live/Progress/Progress.cs:line 98
--- End of stack trace from previous location ---
   at Spectre.Console.Progress.<>c__DisplayClass28_0`1.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Live/Progress/Progress.cs:line 133
--- End of stack trace from previous location ---
   at Spectre.Console.Internal.DefaultExclusivityMode.RunAsync[T](Func`1 func) in /_/src/Spectre.Console/Internal/DefaultExclusivityMode.cs:line 40
   at Spectre.Console.Progress.StartAsync[T](Func`2 action) in /_/src/Spectre.Console/Live/Progress/Progress.cs:line 116
   at Spectre.Console.Progress.StartAsync(Func`2 action) in /_/src/Spectre.Console/Live/Progress/Progress.cs:line 96
   at Spectre.Console.Progress.Start(Action`1 action) in /_/src/Spectre.Console/Live/Progress/Progress.cs:line 69
   at ThorRewrite.Shell.Commands.ProtoOdin.FlashTar.RunCommand(State state, List`1 args) in /home/theairblow/RiderProjects/Thor/TheAirBlow.Thor.Shell/Commands/ProtoOdin/FlashTar.cs:line 66
~~~~~~~^
Failed to bulk write: Connection timed out (110)
shell>

It's getting stuck on some img, I don't know why. I have, in every each attempt, reset to factory the userdata... and nothing, still same error, tried with only one tar file at a time, nothing... I'm tired now, will continue tomorrow

lmateovf commented 1 year ago

In the end i successfully rooted muy device with Odín... Thabks again for your help and i hope your app will be great. ❤️

a7md8762 commented 1 year ago

In the end i successfully rooted muy device with Odín... Thabks again for your help and i hope your app will be great. heart

Nice! That's great to hear!

ethical-haquer commented 1 year ago

I have the same issue. Basically, Thor is unable to detect, or at least present to the user, the .lz4 compressed files. So it simply displays "...". Opening the .tar AP file, extracting the .lz4 files, and then re-tarring it worked as a workaround, as suggested by @a7md8762. @TheAirBlow, do you think this issue could be fixed in a later release?

TheAirBlow commented 1 year ago

I have the same issue. Basically, Thor is unable to detect, or at least present to the user, the .lz4 compressed files. So it simply displays "...". Opening the .tar AP file, extracting the .lz4 files, and then re-tarring it worked as a workaround, as suggested by @a7md8762. @TheAirBlow, do you think this issue could be fixed in a later release?

I have no clue as to why it would happen, as I did include LZ4 support... Maybe an accidentally messed up if check?

However, I do not have the time to work on Thor as I switched my interest to a different project of mine, so do not expect me to continue for a while.

TheAirBlow commented 8 months ago

I've been working on a proper library for doing GUIs with ImGUI in C#, so who knows, maybe I'll make a GUI for Thor sometime soon xD