Qualcomm Diag Mode without USB connection to PC - Galaxy S 4 Developer Discussion [Developers-Only]

Hello guys,
I am curious, what the /dev/diag device can be used for. Does anyone know its purpose? Regarding the Kconfig of /drivers/char/diag, this virtual device is an interface for exchanging diag data. However, performing a cat on that device file, resulted in an error:
Code:
cat: /dev/diag: Bad address
Echo-ing the 4-byte-version-query into the diag-device did not result in an error. But nothing else happened, either.
I would like to be able to access the baseband's diag data without having a computer attached to the phone's USB port - and, if even possible, without even modifying the kernel.
Regards

Related

usb serial in diagnostic

Hi I have just noticed in the nokia diagnostic tool in the bottom right the three dots when pressed gives you settings option and within that option it says usb mode Zune or usb serial with an option to choose which one ... What's this serial in this case ?? Will this allow direct access to hdd and find a way to use as mass storage ? or can we use this to access the cpu or other parts of the phone ?? im not sure were the serial point to yet ...
Probably that would be the way to flash rom.
It seems to be used for reparing the device or OS level software debugging - it won't give you USB Mass storage device....Or it maybe if you found the right driver...from Nokia Engineer. On HTC phones, this can be used for tethering with the right driver.
Serial Ports are the port that were used for Modem and Mouse before USB was invented (COM ports) It is the very basic form of communication port that most device implements - which the chipset on Lumia also emulate Serial Port over USB cable. (http://en.wikipedia.org/wiki/Serial_port)
Ahhhh ok thanks very much guys
Didn‘t notice that before, I'll poke at it using a serial debugger once I get home, could be some interesting/fun stuff that can be done
In winxp you can load a driver for a system device. maybe at driver level the connection data can be verified. How:
connect in serial mode. it will at first time detect a nokia rm801 or whatever device and ask for a driver. it finds 4 devices.
for the first, the xp system will itself suggest
1) USB Composite Device
2) will not find anything, and show the dialog to go onto internet, search etc.
Don't search and choose the driver to install yourself, with the downmost radiobutton and click next, in the categories go to System Devices, the driver assist will suggest a Compaq Deskpro Thermal Sensor, install this. Will install without error
3) see 2.
4) see 2.
Because it installs a temperature sensor driver, it must be possible to monitor or probe somehow. help?
My guess that will only gain you access to temprature data from the phone.
Have you tried putty and a baudrate of 9600? this is the most common used baudrate, tho It is quite possible they use 16000 instead if the serial connection is ment to handle data transfer.
I've been looking at the schematics for the phone and I can not seem to find out which chip they have used for GPIO. We would probably need to get hold of service level 3 or 4 manuals for Nokia Care (unless someone wants to dissasemble their phone and have a look at the mainboard)
Edit:
After a bit more digging I think I've traced serial to be managed directly by the CPU.
This suggests that it's a purely SW serial console.
I haven't been able to find any details on WP7/7.1/7.5 SW serial.
Worth looking into but I guess would require disassembly of the software?
what is the protocol for example when doing a software update through Zune? It gets into some kind of bootloader mode then too.
can imagine the serial connection is hosted as sw in the phones sw environment when running the mango os. But is the serial mode still fully sw if you boot it? Don't know if you could find anything in the 15 sec of booting to mango
I think the easiest way of figuring out how this is done is to disassemble the .net library that is used in the WP7 update tool.
I will have access to the required tools when I get home. The tool is this one if you want to get cracking on it:
http://xboxmod.sylvester20007.com/TOOLS/WP7_update_tool.rar

[Serial Port API] - Connection can not be opened

Hello,
I am writing here to see if somebody faced this problem before. I am trying to control a very specific Hardware from an Android device using the android-serialport-api lib: code.google.com/archive/p/android-serialport-api/
My hardware uses a RS232 connector and I connect it to Android with a USB to RS232 adapter, just as it shows on the "solution 2" of this image: code.google.com/archive/p/android-serialport-api/wikis/android_to_rs232_guideline.wiki (Solution 4 seems to be the ideal one, but I do not understand it, I will appreciate any indication here as well)
When I try to open a connection to the port, I always get an error indicating the the connection can not be open. The problem with this approach is, as the wiki mentions, you "may need to root your device in order to change /dev/ttyUSB0 file permission, and to load a kernel module.".
Does anybody had to root their device in order to be able to open tty connections? The tablet I am using is a HANNSpree HSG1351 (which I could not find any rooting guide).
Thanks
I will answer myself here just in case it can be useful for someone else in the future:
I ended up using this serial controller for Android, which makes read / write operations easy: github.com/felHR85/UsbSerial
Before being able to open a serial connection with the device, you should give permissions to the USB as it is explained here: developer.android.com/guide/topics/connectivity/usb/accessory.html#permission-a
Just to clarify, this is generic for any device, doesn't matter if it is rooted or not.

mtp/data transfer disabled in android Pie. Charging still works

So i thought my usb port was damaged, replaced it, still no data connection. charging just fine. all usb settings are greyed out.
I thought it may have been rom related, flashed a new rom, it replaced my recovery as well unfortunately, on first boot it installed an OTA to the 2nd slot, which also replaced my recovery, I cannot access ADB except over wifi which is pretty helpful but cant sideload over wifi, cannot access fastboot to flash any of the good stuff. I can use root but only through adb shell on computer which is a godsend.
I managed to manually install busybox, so i have that. cant figure out how to flash firmware without usb access. cant figure out how to pull patch and push my boot image with magisk without fastboot.
checked my init script as well as the init.usb scripts and compared them with a generic one online, they seem ok as far as i can tell. getprop shows usb is ok. But:
jasmine_sprout:/ # echo 1 > sys/devices/virtual/android_usb/android0/enable
/system/bin/sh: can't create sys/devices/virtual/android_usb/android0/enable: Permission denied
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2|jasmine_sprout:/sys/devices/virtual/android_usb/android1 # cat state
DISCONNECTED
jasmine_sprout:/sys/devices/virtual/android_usb/android1 # cd ..
jasmine_sprout:/sys/devices/virtual/android_usb # cd android0
jasmine_sprout:/sys/devices/virtual/android_usb/android0 # ls
f_audio_source f_midi power state subsystem uevent
jasmine_sprout:/sys/devices/virtual/android_usb/android0 # cat state
DISCONNECTED
I dont understand why it is attemtpting to create that instead of changing the value in it. and the second figure shows usb is disconnected but it is not
I am getting much better at linux but still have alot to learn, so i can understand most instruction just need a point in the proper direction.
Xiaomi Mi A2 type C
I will attach my init scripts i dunno how helpful that is. also trying to record a trace while connecting and enabling USB features. All USB options are greyed out
https://drive.google.com/drive/folders/18gKDQBjQ6wORyHncdcBBfHvOAZZkh44L?usp=sharing
google drive folder with all init files inside. im going to make them txt files and attach to xda actually
I attached all init files to original post.. I am growing desperate for regular functionality of my phone. I shouldve submitted a warranty claim instead of changing the USB of the device
Bump

Talking to the MediaTek preloader

I have been doing some work, trying to figure out how to talk to the MediaTek preloader on a couple of different devices. I believe it has more functionality than what is available to us through SP-Flashtool. I came across an interesting article here. The preloader seems to accept some combination of commands via raw serial bytes and AT commands to do its work. In an attempt to reverse engineer the protocol, I have attempted to set up Wireshark to capture the usb traffic between my system and the preloader while using SP-flashtool, but I have been unsuccessful. I'm able to capture all sort of adb traffic, so I think my usb sniffing setup is working, but it's as if Wireshark just doesn't see the connection to the preloader or any of the SP-flashtool traffic.
With some python script, I have been able to at least attempt to send commands to the preloader, but I just keep getting a response along the lines of "device reports it is ready to read but sent no reply."
From the article I linked: The USB port will assume that the tool is connected if it receives a “set line coding” (configures baudrate etc.) CDC message. It then sends the string READY to the tool and waits for the reception of a token of eight bytes.
Has anyone ever been able to work out how to send this "set line coding" message? Or does anyone out there have any insight about how to configure Wireshark to capture this communication with the preloader so this protocol might be reverse engineered?
threadreaper said:
I have been doing some work, trying to figure out how to talk to the MediaTek preloader on a couple of different devices. I believe it has more functionality than what is available to us through SP-Flashtool. I came across an interesting article here. The preloader seems to accept some combination of commands via raw serial bytes and AT commands to do its work. In an attempt to reverse engineer the protocol, I have attempted to set up Wireshark to capture the usb traffic between my system and the preloader while using SP-flashtool, but I have been unsuccessful. I'm able to capture all sort of adb traffic, so I think my usb sniffing setup is working, but it's as if Wireshark just doesn't see the connection to the preloader or any of the SP-flashtool traffic.
With some python script, I have been able to at least attempt to send commands to the preloader, but I just keep getting a response along the lines of "device reports it is ready to read but sent no reply."
From the article I linked: The USB port will assume that the tool is connected if it receives a “set line coding” (configures baudrate etc.) CDC message. It then sends the string READY to the tool and waits for the reception of a token of eight bytes.
Has anyone ever been able to work out how to send this "set line coding" message? Or does anyone out there have any insight about how to configure Wireshark to capture this communication with the preloader so this protocol might be reverse engineered?
Click to expand...
Click to collapse
Hello ive been trying to learn this im using libusdotnet for talking with the device

Question Wrong vendor:product IDs presented to USB host

Hi All,
I need to set up a reliable way to access this phone remotely via USB. Looks like whenever the phone is connected to a USB host (a server in my case) via USB it presents itself with wrong vendor/product IDs as follows from the lsusb output on the host:
Bus 002 Device 006: ID 18d1:4ee8 Google Inc. Nexus/Pixel Device (MIDI)
, which only changes to the right ones when I select "Transfer Files" (MTP) mode in the pop-up menu on the phone:
Bus 002 Device 007: ID 22d9:2765 OPPO Electronics Corp. Oppo N1
Is there a way to memorize my "Transfer Files" (MTP) mode selection for this particular host, so there's no need to select it every time? (it has Default USB Mode set to MTP in Dev Options, which it seems to be ignoring) The problem is that the phone isn't accessible remotely at that early stage yet, probably because of those wrong vendor/product IDs, hence catch 22. IIRC when connecting some other phone (probably a Samsung one) to my Windows laptop in the past I'd normally make my mode selection for it once and was never prompted to select it again and again for that phone, so if it's actually the Windows that remembered my selection back then how do I achieve the same with Linux on my current host? (CentOS 7).
Many thanks in anticipation!
The selection of which interfaces to present (ADB, MTP, Midi...) and which VID/PID to use is decided on the Android, the host plays no role.
There is a lot of OEM customization and stupidity on USB mode selection.
You can try:
Code:
$ setprop persist.sys.usb.config mtp,adb
It may say that you can't.
Me? I just set it to ADB and do everything through that.
@Renate: thanks for your reply.
> $ setprop persist.sys.usb.config mtp,adb
I suppose it requires rooting the phone first, right?
Code:
127|OP5552L1:/ $ setprop persist.sys.usb.config mtp,adb
Failed to set property 'persist.sys.usb.config' to 'mtp,adb'.
See dmesg for error reason.
1|OP5552L1:/ $
1|OP5552L1:/ $ dmesg
dmesg: klogctl: Permission denied
1|OP5552L1:/ $
Yeah, you need root for that on yours.
You can set it Settings to "No transfer" and leave the ADB on.
That will probably stick.
Copy individual files with adb push.
I use my adbsync.exe to keep all my devices synced with content and the photos pulled to desktop.
Renate said:
Yeah, you need root for that on yours.
You can set it Settings to "No transfer" and leave the ADB on.
That will probably stick.
Click to expand...
Click to collapse
Just tested it and still getting that mode selection prompt on it upon plugging USB cable into it, and the wrong vendor/product IDs presented again... Unsure I'll be allowed to root this phone because of the warranty but I'll ask.
It's not really "wrong" VID/PID.
There are the stock Android VID/PID that are 18d1/4ee?
Then there are the Oppo ones like 22d9/2765
It's the stupid UsbManager that's doing that popup silliness.
In point of fact, when it's plugged in it's already in some mode.
Renate said:
It's not really "wrong" VID/PID.
There are the stock Android VID/PID that are 18d1/4ee?
Click to expand...
Click to collapse
I understand they're some vendor-independent Google/Android ones at that early stage: looks like it's not the only phone behaving this way.
Renate said:
It's the stupid UsbManager that's doing that popup silliness.
In point of fact, when it's plugged in it's already in some mode.
Click to expand...
Click to collapse
Yeah, just not in the right one for my remote mgmt application Unfortunately there doesn't seem to be a way to force desired VID/PID onto it in all its modes from the USB host side... unless the phone can be instructed to always use them somehow (like using that CLI you advised).
It would certainly annoy me if every time I plugged in an Android it asked me what to do!
If you were rooted you could easily patch something in services.jar to get around this.
Renate said:
It would certainly annoy me if every time I plugged in an Android it asked me what to do!
If you were rooted you could easily patch something in services.jar to get around this.
Click to expand...
Click to collapse
Yeah, fortunately it's my customer's phone and not mine I'll inquire about the possibility of rooting it then, as it seems to be the last hopeful thing left by now.

Categories

Resources