• XDA Forums have been migrated to XenForo. We are aware of several issues including missing threads, logins not working, and more. To discuss, use this thread.
  • If you are experiencing issues logging in, we moved to a new and more secure software and older account passwords were not able to be migrated. We recommend trying to reset your password, then contacting us if there are issues.

[DEV] Enable diagnostic mode?

VictorML

New member
Oct 2, 2010
38
1
0
Hey there.

I'd love to enable the diagnostic mode in my Nexus 5 so that I can trace the radio interface with software such as QXDM, X-CAL, etc... but I've had no luck so far.

basically I'm trying to change the variable sys.usb.config to [diag,adb] as shown in this post for the Nexus 4. I'm doing:

> su -c 'setprop sys.usb.config diag,adb'

(if you run getprop you see that the correct order is sys.usb, not usb.sys as shown in that post)

However, when I enter this command the phone automatically reboots... and the value is reverted back to [mtp,adb].

Any ideas? Do you know of any 'friendlier' way to enable diag mode on the Nexus 5? For example, in the Galaxy S4 you can just dial *#0808# to get into the USB config menu, which easily allows you choose the DM mode... but I can't find a similar menu on the Nexus 5.

Seems a bit absurd to me that a developer-oriented phone is the hardest one to put in diag mode... :/

Note: I'm rooted.
 
Last edited:

satadru

New member
Oct 31, 2008
102
11
0
my phone is the same situation
I'm seeing the same thing.

Code:
[email protected]:/ $ su -c 'setprop sys.usb.config diag,adb'
[email protected]:/ $ getprop sys.usb.config                                
mtp,adb
Was this a change in AOSP? Might have to dig through the sources to see what changed.

---------- Post added at 04:56 PM ---------- Previous post was at 04:52 PM ----------

For what it's worth I can get that to change in recovery, but it doesn't enable anything else.

Code:
 setprop sys.usb.config diag,adb
~ # getprop sys.usb.config  
diag,adb
 

prometheusZ

New member
Nov 12, 2013
14
2
0
I'm seeing the same thing.

Code:
[email protected]:/ $ su -c 'setprop sys.usb.config diag,adb'
[email protected]:/ $ getprop sys.usb.config                                
mtp,adb
Was this a change in AOSP? Might have to dig through the sources to see what changed.

---------- Post added at 04:56 PM ---------- Previous post was at 04:52 PM ----------

For what it's worth I can get that to change in recovery, but it doesn't enable anything else.

Code:
 setprop sys.usb.config diag,adb
~ # getprop sys.usb.config  
diag,adb
i have done this with cm11, but the result was the same
 

satadru

New member
Oct 31, 2008
102
11
0
The problem is that this needs to be run as root, with SELinux disabled.

You can set SELinux to permissive with this tool: https://play.google.com/store/apps/details?id=com.mrbimc.selinux

As per here:http://forum.xda-developers.com/showpost.php?p=39686712&postcount=3 the usb init script for hammerhead should tell us the steps for diag mode.


That hammerhead init script is here: https://android.googlesource.com/device/lge/hammerhead/+/kitkat-release/init.hammerhead.usb.rc

Here's the essence, if you want to run it from your own script:

Code:
stop adbd
echo 0 > /sys/class/android_usb/android0/enable
echo 1004 > /sys/class/android_usb/android0/idVendor
echo 61F1 > /sys/class/android_usb/android0/idProduct
echo 239 > /sys/class/android_usb/android0/bDeviceClass
echo 2 > /sys/class/android_usb/android0/bDeviceSubClass
echo 1 > /sys/class/android_usb/android0/bDeviceProtocol
echo smd > /sys/class/android_usb/android0/f_acm/acm_transports
echo diag > /sys/class/android_usb/android0/f_diag/clients
echo acm,diag,mtp,adb > /sys/class/android_usb/android0/functions
echo 1 > /sys/class/android_usb/android0/enable
start adbd
setprop sys.usb.state diag,adb
Here's what you need to do from a shell, either via adb shell or a shell from a console app:
Code:
su
setprop sys.usb.config diag,adb
The device immediately disconnects you.

When I do a
Code:
getprop sys.usb.config
from a console on the device it does show diag,adb mode but I'm not seeing a device showing up when I connect the adb cable.


dmesg on the device (needs to be run as su) shows this error:

Code:
adb release
dwc3 f920000.dw3: request ed50b780 was not queued to ep0out
mtp_release
adb_open
android_usb_gadget: unable to get diag usb channel
diag: Cannot open channel 'diag'
android_bind_enabled_functions: diag failed
andoird_enable:usb_add_config failed: err: -19
adb_open
mtp_release
 
Last edited:

prometheusZ

New member
Nov 12, 2013
14
2
0
The problem is that this needs to be run as root, with SELinux disabled.

You can set SELinux to permissive with this tool: https://play.google.com/store/apps/details?id=com.mrbimc.selinux

As per here:http://forum.xda-developers.com/showpost.php?p=39686712&postcount=3 the usb init script for hammerhead should tell us the steps for diag mode.


That hammerhead init script is here: https://android.googlesource.com/device/lge/hammerhead/+/kitkat-release/init.hammerhead.usb.rc

Here's the essence, if you want to run it from your own script:

Code:
stop adbd
echo 0 > /sys/class/android_usb/android0/enable
echo 1004 > /sys/class/android_usb/android0/idVendor
echo 61F1 > /sys/class/android_usb/android0/idProduct
echo 239 > /sys/class/android_usb/android0/bDeviceClass
echo 2 > /sys/class/android_usb/android0/bDeviceSubClass
echo 1 > /sys/class/android_usb/android0/bDeviceProtocol
echo smd > /sys/class/android_usb/android0/f_acm/acm_transports
echo diag > /sys/class/android_usb/android0/f_diag/clients
echo acm,diag,mtp,adb > /sys/class/android_usb/android0/functions
echo 1 > /sys/class/android_usb/android0/enable
start adbd
setprop sys.usb.state diag,adb
Here's what you need to do from a shell, either via adb shell or a shell from a console app:
Code:
su
setprop sys.usb.config diag,adb
The device immediately disconnects you.

When I do a
Code:
getprop sys.usb.config
from a console on the device it does show diag,adb mode but I'm not seeing a device showing up when I connect the adb cable.


dmesg on the device (needs to be run as su) shows this error:

Code:
adb release
dwc3 f920000.dw3: request ed50b780 was not queued to ep0out
mtp_release
adb_open
android_usb_gadget: unable to get diag usb channel
diag: Cannot open channel 'diag'
android_bind_enabled_functions: diag failed
andoird_enable:usb_add_config failed: err: -19
adb_open
mtp_release
yes i got these messages too. does they mean google disable the diag channel on hardware level?
 

satadru

New member
Oct 31, 2008
102
11
0
I suspect a software and not a hardware issue. Maybe compare kernel sources with that on the LG G2 and also that for the Nexus 4...

Sent from my SCH-I535 using XDA Premium 4 mobile app

---------- Post added at 10:23 AM ---------- Previous post was at 10:23 AM ----------

Or maybe a kernel module in the source just isn't getting built.

Sent from my SCH-I535 using XDA Premium 4 mobile app
 

prometheusZ

New member
Nov 12, 2013
14
2
0
I suspect a software and not a hardware issue. Maybe compare kernel sources with that on the LG G2 and also that for the Nexus 4...

Sent from my SCH-I535 using XDA Premium 4 mobile app

---------- Post added at 10:23 AM ---------- Previous post was at 10:23 AM ----------

Or maybe a kernel module in the source just isn't getting built.

Sent from my SCH-I535 using XDA Premium 4 mobile app
"unable to get diag usb channel" maybe is the key of this problem, i guess
 

satadru

New member
Oct 31, 2008
102
11
0
I think so. But it seems silly to disable a diag channel in hardware in case there's a problem...

Sent from my SCH-I535 using XDA Premium 4 mobile app

---------- Post added at 10:38 AM ---------- Previous post was at 10:35 AM ----------

We might also be able to check the diag functionality by looking at other devices that also have a Qualcomm MDM9x25 chipset, which is only in newer devices...

Sent from my SCH-I535 using XDA Premium 4 mobile app
 

prometheusZ

New member
Nov 12, 2013
14
2
0
I think so. But it seems silly to disable a diag channel in hardware in case there's a problem...

Sent from my SCH-I535 using XDA Premium 4 mobile app

---------- Post added at 10:38 AM ---------- Previous post was at 10:35 AM ----------

We might also be able to check the diag functionality by looking at other devices that also have a Qualcomm MDM9x25 chipset, which is only in newer devices...

Sent from my SCH-I535 using XDA Premium 4 mobile app
found this err in /kernel/msm / android-msm-flo-3.4-kitkat-mr0 / drivers / usb / gadget / f_diag.c

int diag_function_add(struct usb_configuration *c, const char *name,
int (*update_pid)(uint32_t, const char *))
{
struct diag_context *dev;
struct usb_diag_ch *_ch;
int found = 0, ret;

DBG(c->cdev, "diag_function_add\n");

list_for_each_entry(_ch, &usb_diag_ch_list, list) {
if (!strcmp(name, _ch->name)) {
found = 1;
break;
}
}
if (!found) {
ERROR(c->cdev, "unable to get diag usb channel\n");
return -ENODEV;
}
......
......
}
 

satadru

New member
Oct 31, 2008
102
11
0
found this err in /kernel/msm / android-msm-flo-3.4-kitkat-mr0 / drivers / usb / gadget / f_diag.c
Does the Galaxy S4 also use the same chipset? The kitkat kernel sources for that (at least the google edition model) just got released too.

We might be able to do a diff on the usb trees inside the kernel source and see if there's a difference. Probably also makes sense to compare the the source out there for the LG G2 model too, since that's going to be very close to our model.

Also have you seen the work they're trying to do with the LG G2 with qpst here: http://forum.xda-developers.com/showthread.php?t=2493659?

We might want to combine our efforts.
 

prometheusZ

New member
Nov 12, 2013
14
2
0
Does the Galaxy S4 also use the same chipset? The kitkat kernel sources for that (at least the google edition model) just got released too.

We might be able to do a diff on the usb trees inside the kernel source and see if there's a difference. Probably also makes sense to compare the the source out there for the LG G2 model too, since that's going to be very close to our model.

Also have you seen the work they're trying to do with the LG G2 with qpst here: http://forum.xda-developers.com/showthread.php?t=2493659?

We might want to combine our efforts.
my friends and i recompile the kernel with choosing "usb qualcomn diagnostic bridge driver" option, and made a boot.img. after flash the boot.img, the diag mode still can not open and the error messages are the same
 

Attachments

satadru

New member
Oct 31, 2008
102
11
0
my friends and i recompile the kernel with choosing "usb qualcomn diagnostic bridge driver" option, and made a boot.img. after flash the boot.img, the diag mode still can not open and the error messages are the same
Is the qualcomm bridge driver loaded in the LG G2 kernel?

If it isn't enabled in the N5 kernel, it's possible that they didn't bother updating the code for it. Will the LG G2 kernel load on our device? They're definitely able to get diag mode on their device.
 

prometheusZ

New member
Nov 12, 2013
14
2
0
Is the qualcomm bridge driver loaded in the LG G2 kernel?

If it isn't enabled in the N5 kernel, it's possible that they didn't bother updating the code for it. Will the LG G2 kernel load on our device? They're definitely able to get diag mode on their device.
wo tried and succeed. finally the diag mode is opened. you can try recompile the kernel by choosing these options
 

satadru

New member
Oct 31, 2008
102
11
0
Awesome. Can somebody upload the modified kernel image with the diag kernel?

Sent from my SCH-I535 using XDA Premium 4 mobile app