ADB device serial number and Android USB Composite kernel driver

1,415 views
Skip to first unread message

Paul Kocialkowski

unread,
Apr 22, 2012, 7:00:27 AM4/22/12
to android...@googlegroups.com
I am currently writing a compatibility layer to get the Linux >= 3.0
Android USB Composite driver working with Gingerbread (while it's
designed for ICS). I have made good progress so far (I have adb working
and integrated), except that I can't find out how to set the correct
device serial number (and USB vendor/product ID/String) to the driver.

I know that with ICS, this is done via getprop and sysfs node at init,
like on Galaxy Nexus init.rc:

on init
write /sys/class/android_usb/android0/iSerial $ro.serialno

on boot
write /sys/class/android_usb/android0/iManufacturer
$ro.product.manufacturer
write /sys/class/android_usb/android0/iProduct $ro.product.model

So I looked at the Gingerbread driver and I have found that some of
these infos are board-specific (on platform_device struct):
#ifdef CONFIG_USB_ANDROID
&s3c_device_android_usb,
which is:
struct platform_device s3c_device_android_usb = {
[…]
.platform_data = &android_usb_pdata,
[…]

with:

static struct android_usb_platform_data android_usb_pdata = {
.vendor_id = S3C_VENDOR_ID,
.product_id = S3C_UMS_PRODUCT_ID,
.manufacturer_name = "Samsung",
.product_name = "Nexus S",
.serial_number = device_serial,
[…]

So here are vendor/product id and manufacturer/product strings, but now
what about serial_number? It's defined as (in the same file):

static char device_serial[MAX_USB_SERIAL_NUM] = "0123456789ABCDEF";

So it apparently isn't set there.
The composite.c file has:

static char *iSerialNumber;
module_param(iSerialNumber, charp, 0);
MODULE_PARM_DESC(iSerialNumber, "SerialNumber string");

but AFAIK the driver isn't built as a module and isn't probed with args,
so it seems that it's not here either.

Could anyone give me details about how that number is given to the USB
composite driver and/or how it's generated (user-space? kernel-side?).

--
Paul Kocialkowski, Replicant developer

Replicant is a fully free Android distribution

Website: http://www.replicant.us
Wiki/Tracker: http://redmine.replicant.us

Paul Kocialkowski

unread,
Apr 22, 2012, 10:08:18 AM4/22/12
to android...@googlegroups.com
> Could anyone give me details about how that number is given to the USB
> composite driver and/or how it's generated (user-space? kernel-side?).

Turns out it was quite easy to figure out:

mach-herring.c:

static void __init herring_machine_init(void)
{
[…]
s3c_usb_set_serial();

which does:
sprintf(device_serial, "%08X%08X", system_serial_high,
system_serial_low);

these same values are also reported by cat /proc/cpuinfo

Reply all
Reply to author
Forward
0 new messages