USB control message to endpoint 0x80 in libusb-1? - usb

USB soundcard Creative X-Fi switches from USB1.1 to USB2.0 when its proprietary windows driver is used, allowing faster samplerates in its USB2 configuration. A capture of USB packets by wireshark shows several commands are sent by the proprietary driver just before the device disconnects and re-connects at USB2. I am trying to replay the commands to the device in linux, to be able to add the same feature to the existing linux usb-audio driver.
I want to use python, presumably the libusb1 wrapper around libusb-1 library. The captured packet shows the driver sends usb control request to endpoint 0x80 with wIndex 0. Please is there a way to format and send such a packet with libusb-1? I found this answer https://stackoverflow.com/a/39343813/15717902 but do not know if it still holds.
The captured packet:
USB URB
[Source: host]
[Destination: 3.5.0]
USBPcap pseudoheader length: 28
IRP ID: 0xfffffa8009ebd3e0
IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
URB Function: URB_FUNCTION_VENDOR_OTHER (0x0020)
IRP information: 0x00, Direction: FDO -> PDO
URB bus id: 3
Device address: 5
Endpoint: 0x80, Direction: IN
URB transfer type: URB_CONTROL (0x02)
Packet Data Length: 8
[Response in: 20]
Control transfer stage: Setup (0)
[bInterfaceClass: Unknown (0xffff)]
Setup Data
bmRequestType: 0xc3
bRequest: 42
wValue: 0x0000
wIndex: 0 (0x0000)
wLength: 2

Related

Vulkan physical device

I'm learning Vulkan by API spec (http://vulkan-spec-chunked.ahcox.com/ch02s09.html), and I'm little confused about how physical devices are in Vulkan. I do have only one intel physical video card device, but vkEnumeratePhysicalDevices returns count of 2. The devices are identical, but the queue flags seems differ, and the queue flags are undocumented (actually they are, but only to flag 8, in second queue I do have the flag values 16 and 32).
typedef enum VkQueueFlagBits {
VK_QUEUE_GRAPHICS_BIT = 0x00000001,
VK_QUEUE_COMPUTE_BIT = 0x00000002,
VK_QUEUE_TRANSFER_BIT = 0x00000004,
VK_QUEUE_SPARSE_BINDING_BIT = 0x00000008,
} VkQueueFlagBits;
here is the output of my vulkan code:
GPU count: 2 ( physical devices )
Physical Device 0:
Device API version: 1.0.42 - 4194346
Device Vendor Id: 0x8086
Device Id: 1916
Device Driver version: 0.0.1 - 1
Device type: 1
Device Name: Intel(R) HD Graphics 520 (Skylake GT2)
Device Pipeline UID: f557cfd4
Queue Properties:
Flags: 7
Count: 1
ts Valid Bits: 24
Physical Device 1:
Device API version: 1.0.42 - 4194346
Device Vendor Id: 0x8086
Device Id: 1916
Device Driver version: 0.0.1 - 1
Device type: 1
Device Name: Intel(R) HD Graphics 520 (Skylake GT2)
Device Pipeline UID: f557cfd4
Queue Properties:
Flags: 49
Count: 0
ts Valid Bits: 1
Someone can help me understand why there is 2 physical devices for the same real device and the missing flags ?
The count=0 of the second device is curious. More seriously, its flags and tsVB values are corrupted (49 is not an valid value for flags and 1 not valid for tsVB).
This pretty much boils down to there being one extraneous *.json file on your system.
These *.json files store informations about ICDs present on the machine. They are stored in standard location(s).
vkEnumeratePhysicalDevices+vkGetPhysicalDeviceProperties are relatively dumb commands doing nothing much else than reading said *.json file(s) and returning its contents. I think though that calling something "real" like vkCreateDevice would not work on the badly installed driver.
What exactly happened to creare this problem is up to your curiosity to explore. For starters I believe on Linux distros there is a command to map a file to its originating package. It will probably be something about bad cleanup of previous driver, or possibly bug in the installation script of the new one. At least one person had this problem before.
Based on what I explained here, I believe this is relatively benign bug. The first device should work just fine. And you can just ignore the second one. Or simply delete its *.json manifest to prevent it from showing up in vkEnumeratePD.

CCID IccPowerOn Status 00h and Error 80h

I send PowerOn CCID command on card insertion to receive ATR. But instead I always get this error:
PC_to_RDR_IccPowerOn (00h Automatic):
bStatus: 0x0
bError: 0x80
Error 80h according to CCID spec "Reserved for future use".
But same code working correctly with other CCID device I have and this device works with other apps. So how I can find what I'm doing wrong?
I have tried different voltages 3v,5v, 1.8v, but for all of them I get exactly same error.
Even when this happens I get correct ATR. So then I'm trying to send APDU (select non existing file to warm up connection) and then I get:
Slot Status: 40h "An ICC is present and inactive (not activated or
shut down by hardware error)"
So what does it mean "inactive" What I should do?
CCID device descriptor:
CCID Device Descriptor:
bcdCCID: 0110
5V Support true
3V Support true
1.8V Support true
dwDefaultClock: 3.75 MHz
dwMaximumClock: 7.5 MHz
dwDataRate: 10080 bps
dwMaxDataRate: 10080 bps
T0 Support true
T1 Support true
dwFeatures * 0x4c4b400
* Automatic IFSD exchange as first exchange
* Short and Extended APDU exchange level support
dwMaxCCIDMessageLength 271 bytes
wLcdLayout 0000
bMaxCCIDBusySlots 01

using gammu and a DKU2 cable to write a vCard to a nokia 6303i classic

I am trying out gammu for the 1st time because I want to transfer some google contacts back to a nokia 6303i .
While the phone database section in Gammu website states that a number of bluetooth connection settings can be used with this phone, I have no bluetooth connection and will thus have to resort to a DKU2 usb cable that I have. The cable is actually a CA-101 nokia cable but according to gnokii wiki they are technically the same.
I have attempted several different connection types. from the ~/.gammurc
[gammu]
#model = NAUTO
device = 01a5:-1
connection = dku2
synchronizetime = yes
logfile = gammu0.log
logformat = text
use_locking =
gammuloc =
[gammu1]
device = /dev/ttyACM0
connection = at
synchronizetime = yes
logfile = gammu1.log
logformat = text
use_locking =
gammuloc =
[gammu2]
#model = NAUTO
device = /dev/ttyACM0
connection = fbus
synchronizetime = yes
logfile = gammu2.log
logformat = text
use_locking =
gammuloc =
[gammu3]
#model = NAUTO
device = 01a5:-1
connection = fbususb
synchronizetime = yes
logfile = gammu2.log
logformat = text
use_locking =
gammuloc =
I have managed to use the "at" connection with gammu -s 1 identify and correctly read phone info. Then I tried to copy a simple (albeit non gammu generated) vCard from those I exported from google contacts.
It was typically formatted like so:
BEGIN:VCARD
VERSION:2.1
FN:Name Surname
N:Surname;Name
EMAIL;CHARSET=UTF-8;ENCODING=8BIT:name.surname#domain.com
TEL;TYPE=CELL:+10123456789
TEL;TYPE=CELL:+19876543210
END:VCARD
What is frustrating is that from a Windows Pc running nokia PC suite I was able to correctly send that same vCard to the nokia 6303i over the same cable.
However from gammu I have -at most- been able to send the surname from the "N:Surname;Name;;;" field (the contact only shows up with the surname) and the 1st telephone number. So the email and the 2nd phone number have been omitted.
This is not enough for me , because I need all phones, all emails and notes to be transferred. I have not found any information abotu whether the "at" connection supports the "enhancedphonebook" functionality (it appears that it does not), but I apart from "bluefbus" which supposedly supported the "enhancedphonebook" in the "Nokia 6303i Cliassic" I don't know which other cabled connection supports it.
so I have tried
the variations gammu(0) , gammu2 and gammu3 as seen in the config file
but these two do not work.
The gammu and gammu3 dump the following in the log
[Gammu - 1.31.0 built 12:51:10 Jul 24 2016 using GCC 4.7]
[Connection - "dku2"] #or "fbususb for gammu3
[Connection index - 0]
[Model type - ""]
[Device - "01a5:-1"]
[Running on - Linux, kernel 3.2.29-gaze5 (#1 SMP Sat Apr 20 13:57:31 EEST 2013)]
Checking 1d6b:0002 (bus 1, device 1)
Checking 1d6b:0002 (bus 2, device 1)
Checking 1d6b:0001 (bus 3, device 1)
Checking 1d6b:0001 (bus 4, device 1)
Checking 1d6b:0001 (bus 5, device 1)
Checking 1d6b:0001 (bus 6, device 1)
Checking 1d6b:0001 (bus 7, device 1)
Checking 0421:0359 (bus 7, device 35)
Extra CDC subheader: 171
Trying to open device, config=1, c_iface=2, c_alt=0, d_iface=3, d_alt=1
Configuration change not required, unhooking only required interfaces!
Detaching kernel driver from inteface 2
Claiming USB control interface...
Configuring USB control interface...
Claiming USB data interface...
Configuring USB data interface...
Connected!
[Module - "auto"]
Getting model
SENDING frametype 0xD1/length 0x05/5
00 |01 |00 |03 |00 .....
Failed to read from usb (-99)!
Other error
Failed to read from usb (-99)!
Other error
Failed to read from usb (-99)!
Other error
and gammu2
[Gammu - 1.31.0 built 12:51:10 Jul 24 2016 using GCC 4.7]
[Connection - "fbus"]
[Connection index - 0]
[Model type - ""]
[Device - "/dev/ttyACM0"]
[Running on - Linux, kernel 3.2.29-gaze5 (#1 SMP Sat Apr 20 13:57:31 EEST 2013)]
Setting speed to 115200
Serial device: DTR is up, RTS is down, CAR is down, CTS is up
(... and it gets stuck here)
So the main question is: how can I achieve transferring the vCard (and many others) to the phone, over a usb cable???????
Thank you

Google Cloud - Compute Engine - Error starting instance when attached disk in READ_ONLY

I have a instance (F1-Micro) and a root persistent disk (10GB) on Google Cloud, Compute Engine service. When I start an instance and attach a disk in READ_WRITE the instance starts normally, executes my startup script and I can access through SSH. However, when I change the disk mode parameter to READ_ONLY the instance apparently starts normally and I can't do SSH giving me a timeout connection. Also, my startup script does not start. I suspect that or I need to attach more one root persistent disk with READ_WRITE permission or I need to setup some configuration in my disk. Someone could give me insight about what are happening? Below I give some data and logs:
Body Request:
instance = {
'name': instance_name,
'machineType': machine_type_url,
'disks': [{
'index' : 0,
'autoDelete': 'false',
'boot': 'true',
'type': 'PERSISTENT',
'mode' : 'READ_ONLY', # READ_ONLY, READ_WRITE
'deviceName' : root_disk_name,
'source' : source_root_disk
}],
'networkInterfaces': [{
'accessConfigs': [{
'type': 'ONE_TO_ONE_NAT',
'name': 'External NAT'
}],
'network': network_url
}],
'serviceAccounts': [{
'email': service_email,
'scopes': scopes
}]
}
Log of started instance on GC-CE:
Changing serial settings was 0/0 now 3/0
Start bios (version 1.7.2-20131007_152402-google)
No Xen hypervisor found.
Unable to unlock ram - bridge not found
Ram Size=0x26600000 (0x0000000000000000 high)
Relocating low data from 0x000e10a0 to 0x000ef780 (size 2161)
Relocating init from 0x000e1911 to 0x265d07a0 (size 63291)
CPU Mhz=2601
=== PCI bus & bridge init ===
PCI: pci_bios_init_bus_rec bus = 0x0
=== PCI device probing ===
Found 4 PCI devices (max PCI bus is 00)
=== PCI new allocation pass #1 ===
PCI: check devices
=== PCI new allocation pass #2 ===
PCI: map device bdf=00:03.0 bar 0, addr 0000c000, size 00000040 [io]
PCI: map device bdf=00:04.0 bar 0, addr 0000c040, size 00000040 [io]
PCI: map device bdf=00:04.0 bar 1, addr febff000, size 00001000 [mem]
PCI: init bdf=00:01.0 id=8086:7110
PIIX3/PIIX4 init: elcr=00 0c
PCI: init bdf=00:01.3 id=8086:7113
Using pmtimer, ioport 0xb008, freq 3579 kHz
PCI: init bdf=00:03.0 id=1af4:1004
PCI: init bdf=00:04.0 id=1af4:1000
Found 1 cpu(s) max supported 1 cpu(s)
MP table addr=0x000fdaf0 MPC table addr=0x000fdb00 size=240
SMBIOS ptr=0x000fdad0 table=0x000fd9c0 size=269
Memory hotplug not enabled. [MHPE=0xffffffff]
ACPI DSDT=0x265fe1f0
ACPI tables: RSDP=0x000fd990 RSDT=0x265fe1c0
Scan for VGA option rom
WARNING - Timeout at i8042_flush:68!
All threads complete.
Found 0 lpt ports
Found 0 serial ports
found virtio-scsi at 0:3
Searching bootorder for: /pci#i0cf8/*#3/*#0/*#0,0
Searching bootorder for: /pci#i0cf8/*#3/*#0/*#1,0
virtio-scsi vendor='Google' product='PersistentDisk' rev='1' type=0 removable=0
virtio-scsi blksize=512 sectors=20971520
Searching bootorder for: /pci#i0cf8/*#3/*#0/*#2,0
...
Searching bootorder for: /pci#i0cf8/*#3/*#0/*#255,0
Scan for option roms
Searching bootorder for: HALT
drive 0x000fd950: PCHS=0/0/0 translation=lba LCHS=1024/255/63 s=20971520
Space available for UMB: 000c0000-000eb800
Returned 122880 bytes of ZoneHigh
e820 map has 6 items:
0: 0000000000000000 - 000000000009fc00 = 1 RAM
1: 000000000009fc00 - 00000000000a0000 = 2 RESERVED
2: 00000000000f0000 - 0000000000100000 = 2 RESERVED
3: 0000000000100000 - 00000000265fe000 = 1 RAM
4: 00000000265fe000 - 0000000026600000 = 2 RESERVED
5: 00000000fffbc000 - 0000000100000000 = 2 RESERVED
Unable to lock ram - bridge not found
Changing serial settings was 3/2 now 3/0
enter handle_19:
NULL
Booting from Hard Disk...
Booting from 0000:7c00
[ 1.386940] i8042: No controller found
Loading, please wait...
INIT: version 2.88 booting
[[36minfo[39;49m] Using makefile-style concurrent boot in runlevel S.
[....] Starting the hotplug events dispatcher: udevd[?25l[?1c7[1G[[32m ok [39;49m8[?25h[?0c.
[....] Synthesizing the initial hotplug events...[?25l[?1c7[1G[[32m ok [39;49m8[?25h[?0cdone.
[....] Waiting for /dev to be fully populated...[ 8.524814] piix4_smbus 0000:00:01.3: SMBus base address uninitialized - upgrade BIOS or use force_addr=0xaddr
[?25l[?1c7[1G[[32m ok [39;49m8[?25h[?0cdone.
[....] Activating swap...[?25l[?1c7[1G[[32m ok [39;49m8[?25h[?0cdone.
[....] Checking root file system...fsck from util-linux 2.20.1
fsck.ext4: Operation not permitted while trying to open /dev/sda1
You must have r/w access to the filesystem or be root
fsck died with exit status 8
[?25l[?1c7[1G[[31mFAIL[39;49m8[?25h[?0c[31mfailed (code 8).[39;49m
[....] An automatic file system check (fsck) of the root filesystem failed. A manual fsck must be performed, then the system restarted. The fsck should be performed in maintenance mode with the root filesystem mounted in read-only mode. ...[?25l[?1c7[1G[[31mFAIL[39;49m8[? 25h[?0c [31mfailed![39;49m
[....] The root filesystem is currently mounted in read-only mode. A maintenance shell will now be started. After performing system maintenance, press CONTROL-D to terminate the maintenance shell and restart the system. ...[?25l[?1c7[1G[[33mwarn[39;49m8[?25h[?0c [33m(warning).[39;49m
sulogin: root account is locked, starting shell
root#localhost:~#
Thanks!
You're correct in assuming that the boot disk for a GCE instance needs to appear in read-write mode. The documentation for root persistent disks says:
To start an instance with an existing root persistent disk in gcutil,
provide the boot parameter when you attach the disk. When you create a
root persistent disk using a Google-provided image, you must attach it
to your instance in read-write mode. If you try to attach it in
read-only mode, your instance may be created successfully, but it
won't boot up correctly.

Discarded UDP datagram over MTU size with IPv6

I've found out that when I send an UDP datagram that gets fragmented (over 1452 bytes with MTU=1500), according to tcpdump, all the fragments are received on the target machine but then no message is received on the socket. This happens only with IPv6 addresses (both global and link-local), with IPv4 everything works as expected (and with non-fragmented datagrams as well).
As the datagram is discarded, there is this ICMP6 message:
05:10:59.887920 IP6 (hlim 64, next-header ICMPv6 (58) payload length: 69) 2620:52:0:105f::ffff:74 > 2620:52:0:105f::ffff:7b: [icmp6 sum ok] ICMP6, destination unreachable, length 69, unreachable port[|icmp6]
There's some repeated neighbour solicitation/advertisements going on and I see that it gets to the ARP cache (via ip neigh).
One minute later I get another ICMP6 messages saying that the fragment has timeout out.
What's wrong with the settings? The reassembled packet should not be discarded, when it can be delivered, right?
System is RHEL6 2.6.32-358.11.1.el6.x86_64