JohnBel / EfsTools

Command line tools for Qualcomm EFS file system
MIT License
84 stars 34 forks source link

Critical error. Error 2 (Linux, Fedora 33) #5

Open mikelpr opened 3 years ago

mikelpr commented 3 years ago

previously built serialportstream at $HOME/Apps/serialportstream following https://github.com/jcurl/SerialPortStream

trying to execute: LD_LIBRARY_PATH=$HOME/Apps/serialportstream/dll/serialunix/bin/usr/local/lib64:$LD_LIBRARY_PATH dotnet ./EfsTools.dll targetInfo

simply returns Critical error. Error 2

mikelpr commented 3 years ago

modified a bit the code to not just show the message

   at RJCP.IO.Ports.Native.UnixNativeSerial.ThrowException()
   at RJCP.IO.Ports.Native.UnixNativeSerial.Open()
   at RJCP.IO.Ports.SerialPortStream.Open(Boolean setCommState)
   at RJCP.IO.Ports.SerialPortStream.Open()
   at EfsTools.Qualcomm.HdlcSerial.Open() in /home/mikel/Apps/EfsTools/EfsTools/Qualcomm/HdlcSerial.cs:line 37
   at EfsTools.Qualcomm.QcdmManager.Open() in /home/mikel/Apps/EfsTools/EfsTools/Qualcomm/QcdmManager.cs:line 200
   at EfsTools.EfsTools.OpenQcdmManager() in /home/mikel/Apps/EfsTools/EfsTools/EfsTools.cs:line 443
   at EfsTools.EfsTools.GetTargetInfo() in /home/mikel/Apps/EfsTools/EfsTools/EfsTools.cs:line 43
   at EfsTools.Program.<>c__DisplayClass0_0.<Main>b__2(GetTargetInfoOptions opts) in /home/mikel/Apps/EfsTools/EfsTools/Program.cs:line 49
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at EfsTools.Program.Main(String[] args) in /home/mikel/Apps/EfsTools/EfsTools/Program.cs:line 49
Aborted (core dumped)
dimitriusx commented 3 years ago

I have the same error. My system is Arch

xabolcs commented 1 year ago

strace-ing the run reveals the following:

$ strace dotnet EfsTools.dll getModemConfig -p out.json
execve("/usr/bin/dotnet", ["dotnet", "EfsTools.dll", "getModemConfig", "-p", "out.json"], 0x7ffe515454e0 /* 64 vars */) = 0
brk(NULL)                               = 0x55921d28f000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffdfb1fe5f0) = -1 EINVAL (Invalid argument)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
...
read(69, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\3408\0\0\0\0\0\0"..., 832) = 832
fstat(69, {st_mode=S_IFREG|0644, st_size=119736, ...}) = 0
mmap(NULL, 50392, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 69, 0) = 0x7fb85d8e8000
mmap(0x7fb85d8eb000, 24576, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 69, 0x3000) = 0x7fb85d8eb000
mmap(0x7fb85d8f1000, 8192, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 69, 0x9000) = 0x7fb85d8f1000
mmap(0x7fb85d8f3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 69, 0xa000) = 0x7fb85d8f3000
close(69)                               = 0
mprotect(0x7fb85d8f3000, 4096, PROT_READ) = 0
futex(0x7fb85d8f44cc, FUTEX_WAKE_PRIVATE, 2147483647) = 0
mprotect(0x7fb7eb199000, 4096, PROT_READ|PROT_WRITE) = 0
madvise(0x7fb7eb199000, 4096, MADV_DODUMP) = 0
mprotect(0x7fb7eae67000, 4096, PROT_READ|PROT_WRITE) = 0
madvise(0x7fb7eae67000, 4096, MADV_DODUMP) = 0
mprotect(0x7fb7eae67000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mprotect(0x7fb7eb1ab000, 4096, PROT_READ|PROT_WRITE) = 0
madvise(0x7fb7eb1ab000, 4096, MADV_DODUMP) = 0
mprotect(0x7fb7eb19a000, 4096, PROT_READ|PROT_WRITE) = 0
madvise(0x7fb7eb19a000, 4096, MADV_DODUMP) = 0
mprotect(0x7fb7eae68000, 4096, PROT_READ|PROT_WRITE) = 0
madvise(0x7fb7eae68000, 4096, MADV_DODUMP) = 0
mprotect(0x7fb7eae68000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mprotect(0x7fb7e8577000, 4096, PROT_READ|PROT_WRITE) = 0
madvise(0x7fb7e8577000, 4096, MADV_DODUMP) = 0
mprotect(0x7fb7e8577000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
openat(AT_FDCWD, "/dev/ttyUSB0", O_RDWR|O_NOCTTY|O_NONBLOCK) = -1 ENOENT (No such file or directory)
mprotect(0x7fb7eb1ac000, 4096, PROT_READ|PROT_WRITE) = 0
madvise(0x7fb7eb1ac000, 4096, MADV_DODUMP) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb863078000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb86302a000
pipe([69, 70])                          = 0
fcntl(69, F_GETFD)                      = 0
fcntl(69, F_GETFL)                      = 0 (flags O_RDONLY)
fcntl(69, F_SETFD, FD_CLOEXEC)          = 0
fcntl(69, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
fcntl(70, F_GETFD)                      = 0
fcntl(70, F_GETFL)                      = 0x1 (flags O_WRONLY)
fcntl(70, F_SETFD, FD_CLOEXEC)          = 0
fcntl(70, F_SETFL, O_WRONLY|O_NONBLOCK) = 0
futex(0x7fb862ccd1e0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
write(1, "\33[39;49m", 8)               = 8
mprotect(0x7fb7eae69000, 4096, PROT_READ|PROT_WRITE) = 0
madvise(0x7fb7eae69000, 4096, MADV_DODUMP) = 0
mprotect(0x7fb7eae69000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mprotect(0x7fb7eb19b000, 4096, PROT_READ|PROT_WRITE) = 0
madvise(0x7fb7eb19b000, 4096, MADV_DODUMP) = 0
mprotect(0x7fb7eb19c000, 4096, PROT_READ|PROT_WRITE) = 0
madvise(0x7fb7eb19c000, 4096, MADV_DODUMP) = 0
write(1, "\33[91m", 5)                  = 5
write(57, "Critical error. Error 2\n", 24Critical error. Error 2
) = 24
write(1, "\33[39;49m", 8)               = 8
unlink("/tmp/dotnet-diagnostic-1109453-3725029-socket") = 0
futex(0x563f0ebfe650, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x563f0ebfe600, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x563f0eb5cb90, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x563f0eb5cb40, FUTEX_WAKE_PRIVATE, 1) = 0
unlink("/tmp/clr-debug-pipe-1109453-3725029-in") = 0
unlink("/tmp/clr-debug-pipe-1109453-3725029-out") = 0
write(4, "\3", 1)                       = 1
munmap(0x7fb862a54000, 422536)          = 0
rt_sigaction(SIGTTOU, {sa_handler=0x7fb85db4fad0, sa_mask=[], sa_flags=SA_RESTORER|SA_RESETHAND, sa_restorer=0x7fb863019420}, NULL, 8) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, SNDCTL_TMR_START or TCSETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
rt_sigaction(SIGTTOU, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fb863019420}, NULL, 8) = 0
exit_group(0)                           = ?
+++ exited with 0 +++

The <efstools port="xxxx" ...> in the EfsTools.dll.config file should point to an existing serial device. In my example above, it's /dev/ttyUSB0 but still doesn't work. It doesn't work with auto or Auto. See related commit c81a15d51b63c796467c8d041219ae0dfd129981 !

Sadly I don't have any clue how to define a serial port to an Android device which is in adb DIAG mode already. :shrug:

xabolcs commented 1 year ago

Sadly I don't have any clue how to define a serial port to an Android device which is in adb DIAG mode already. :shrug:

lsusb output:

Bus 005 Device 039: ID 05c6:9091 Qualcomm, Inc. 

Echoing 05c6 9091 into /sys/bus/usb-serial/drivers/qcserial/new_id did a little trick:

[51418.168657] qcserial 5-1.4:1.1: Qualcomm USB modem converter detected
[51418.168802] usb 5-1.4: Qualcomm USB modem converter now attached to ttyUSB0
[51418.172262] qcserial 5-1.4:1.2: Qualcomm USB modem converter detected
[51418.172364] usb 5-1.4: Qualcomm USB modem converter now attached to ttyUSB1

After setting the connection params (port="/dev/ttyUSB0" baudrate="115200") in EfsTools.dll.config it didn't really helped:

$ dotnet EfsTools.dll targetInfo
Critical error. Error 5
shvchk commented 11 months ago

Can confirm. Steps to reproduce:

  1. Build https://github.com/jcurl/RJCP.DLL.SerialPortStream, export:

    export LD_LIBRARY_PATH="/path/to/serialportstream/lib:$LD_LIBRARY_PATH"
  2. Load qcserial module:

    sudo modprobe qcserial
  3. Find out Qualcomm device ID with lsusb (e.g. 05c6:9091)

  4. Trigger new qcserial device with this ID:

    echo '05c6 9091' | sudo tee /sys/bus/usb-serial/drivers/qcserial/new_id
  5. Find out which ttyUSB device is used:

    journalctl --since '1 h ago' | grep ttyUSB
  6. Change port to that device (e.g. /dev/ttyUSB0) in EfsTools.dll.config

  7. Run efstools:

    dotnet --roll-forward LatestMajor EfsTools.dll targetInfo
    Critical error. Error 5

OS: Ubuntu 23.10

> dotnet --info                                                                                                                                                                                     05:44:48

Host:
  Version:      7.0.13
  Architecture: x64
  Commit:       3f73a2f186

.NET SDKs installed:
  No SDKs were found.

.NET runtimes installed:
  Microsoft.NETCore.App 7.0.13 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found
lameventanas commented 10 hours ago

Anyone ever got this to work in Linux?