Discussion:
[libhid-discuss] USB libhid is writing to PIC but errors out reading from it.
Daniel Yount
2011-11-14 10:46:12 UTC
Permalink
Using Linux 3.x kernel and debian 6.0 stable distro.


USB flash program 1.3

http://code.google.com/p/mphidflash/


libhid 0.2.16


I have installed a Generic HID bootloader? and a basic p18F2455 circuit setup for reading and writing USB data.
20mhz crystal no LEDs one jumper for bootloader mode and a switch for reset., nothing special.?

When I plug it in and use the "dmesg" commandline program I get.

[19195.480407] usb 1-1.2: reset full speed USB device number 6 using ehci_hcd
[19238.616399] usb 1-1.4: new full speed USB device number 50 using ehci_hcd
[19238.711891] usb 1-1.4: New USB device found, idVendor=2233, idProduct=7001
[19238.711900] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[19238.711907] usb 1-1.4: Product: Generic HID
[19238.711912] usb 1-1.4: Manufacturer: Test
[19238.714576] generic-usb 0003:2233:7001.000F: hiddev0,hidraw3: USB HID v1.11 Device [Test Generic HID] on usb-0000:00:13.5-1.4/input0


I type "lsusb -v" and get.


Bus 001 Device 050: ID 2233:7001 RadioShack Corporation
Device Descriptor:
? bLength??????????????? 18
? bDescriptorType???????? 1
? bcdUSB?????????????? 2.00
? bDeviceClass??????????? 0 (Defined at Interface level)
? bDeviceSubClass???????? 0
? bDeviceProtocol???????? 0
? bMaxPacketSize0???????? 8
? idVendor?????????? 0x2233 RadioShack Corporation
? idProduct????????? 0x7001
? bcdDevice??????????? 0.01
? iManufacturer?????????? 1 Test
? iProduct??????????????? 2 Generic HID
? iSerial???????????????? 0
? bNumConfigurations????? 1
? Configuration Descriptor:
??? bLength???????????????? 9
??? bDescriptorType???????? 2
??? wTotalLength?????????? 41
??? bNumInterfaces????????? 1
??? bConfigurationValue???? 1
??? iConfiguration????????? 0
??? bmAttributes???????? 0xc0
????? Self Powered
??? MaxPower????????????? 100mA
??? Interface Descriptor:
????? bLength???????????????? 9
????? bDescriptorType???????? 4
????? bInterfaceNumber??????? 0
????? bAlternateSetting?????? 0
????? bNumEndpoints?????????? 2
????? bInterfaceClass???????? 3 Human Interface Device
????? bInterfaceSubClass????? 0 No Subclass
????? bInterfaceProtocol????? 0 None
????? iInterface????????????? 0
??????? HID Device Descriptor:
????????? bLength???????????????? 9
????????? bDescriptorType??????? 33
????????? bcdHID?????????????? 1.11
????????? bCountryCode??????????? 0 Not supported
????????? bNumDescriptors???????? 1
????????? bDescriptorType??????? 34 Report
????????? wDescriptorLength????? 47
????????? Report Descriptor: (length is 47)
??????????? Item(Global): Usage Page, data= [ 0xa0 0xff ] 65440
??????????????????????????? (null)
??????????? Item(Local ): Usage, data= [ 0x01 ] 1
??????????????????????????? (null)
??????????? Item(Main? ): Collection, data= [ 0x01 ] 1
??????????????????????????? Application
??????????? Item(Local ): Usage, data= [ 0x03 ] 3
??????????????????????????? (null)
??????????? Item(Global): Logical Minimum, data= [ 0x00 ] 0
??????????? Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
??????????? Item(Global): Report Size, data= [ 0x08 ] 8
??????????? Item(Global): Report Count, data= [ 0x02 ] 2
??????????? Item(Main? ): Input, data= [ 0x02 ] 2
??????????????????????????? Data Variable Absolute No_Wrap Linear
??????????????????????????? Preferred_State No_Null_Position Non_Volatile Bitfield
??????????? Item(Local ): Usage, data= [ 0x04 ] 4
??????????????????????????? (null)
??????????? Item(Global): Logical Minimum, data= [ 0x00 ] 0
??????????? Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
??????????? Item(Global): Report Size, data= [ 0x08 ] 8
??????????? Item(Global): Report Count, data= [ 0x02 ] 2
??????????? Item(Main? ): Output, data= [ 0x02 ] 2
??????????????????????????? Data Variable Absolute No_Wrap Linear
??????????????????????????? Preferred_State No_Null_Position Non_Volatile Bitfield
??????????? Item(Local ): Usage, data= [ 0x05 ] 5
??????????????????????????? (null)
??????????? Item(Global): Logical Minimum, data= [ 0x00 ] 0
??????????? Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
??????????? Item(Global): Report Size, data= [ 0x08 ] 8
??????????? Item(Global): Report Count, data= [ 0x02 ] 2
??????????? Item(Main? ): Feature, data= [ 0x02 ] 2
??????????????????????????? Data Variable Absolute No_Wrap Linear
??????????????????????????? Preferred_State No_Null_Position Non_Volatile Bitfield
??????????? Item(Main? ): End Collection, data=none
????? Endpoint Descriptor:
??????? bLength???????????????? 7
??????? bDescriptorType???????? 5
??????? bEndpointAddress???? 0x81? EP 1 IN
??????? bmAttributes??????????? 3
????????? Transfer Type??????????? Interrupt
????????? Synch Type?????????????? None
????????? Usage Type?????????????? Data
??????? wMaxPacketSize???? 0x0040? 1x 64 bytes
??????? bInterval?????????????? 1
????? Endpoint Descriptor:
??????? bLength???????????????? 7
??????? bDescriptorType???????? 5
??????? bEndpointAddress???? 0x01? EP 1 OUT
??????? bmAttributes??????????? 3
????????? Transfer Type??????????? Interrupt
????????? Synch Type?????????????? None
????????? Usage Type?????????????? Data
??????? wMaxPacketSize???? 0x0040? 1x 64 bytes
??????? bInterval?????????????? 1
Device Status:???? 0x0000
? (Bus Powered)




Now this I had hacked around on mphidflsh to see if I could track it down.

./mphidflash -v 2233 -p 7001 -e


Turned on debugging and added some extra check points and I added data into the default buffer and added a second buffer to make sure it read it to a clean buffer. As you see the only data that is read back is one byte into the second buffer.Writing of the initial buffer gave no errors.


USB HID device found
Sending:
31 32 33 34 35 36 37 38 : 39 30 61 62 63 64 65 66 67 68 69 6a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

About To Write

Done Write

About to read into empty buffer
Done reading
Received:
31 59 00 00 00 00 00 00 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

./mphidflash Error: USB read error



Tracked the error down to this function in mphidflash.usb-linux.c


??? if(HID_RET_SUCCESS != hid_interrupt_read(hid,0x81,usbBuf2,64,0))

What would cause libhid to return error on reading while writing is fine?


Daniel Yount
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20111114/fc1465f0/attachment.html>
Xiaofan Chen
2011-11-14 12:50:43 UTC
Permalink
Post by Daniel Yount
Using Linux 3.x kernel and debian 6.0 stable distro.
USB flash program 1.3
http://code.google.com/p/mphidflash/
libhid 0.2.16
I have installed a Generic HID bootloader? and a basic p18F2455 circuit
setup for reading and writing USB data.
20mhz crystal no LEDs one jumper for bootloader mode and a switch for
reset., nothing special.
If you download the latest Microchip USB stack, there is an HIDAPI
based cross-platform HID bootloader, you may want to try that one,
it works for me whereas mphidflash did not seem to work for me
(PIC18F87J50 USB PIM) last time I tried it.
--
Xiaofan
Daniel Yount
2011-11-15 08:08:14 UTC
Permalink
Ok could not compile Qt4.7 packages because of the? Debian 6.0 stable distro,
it seems compiling for the Microchip HIDAPI needed some newer libuuid functions
.so I changed my /etc/apt/sources.list distro setting for source downloads to testing instead of stable

deb-src http://ftp.us.debian.org/debian/ testing main contrib non-free

updated my apt repo :

apt-get update


downloaded the source for util-linux which contains the libuuid

apt-get source util-linux

uncompressed the tarball ,recompiled and installed and qtcreator compiled fine..
http://qt.nokia.com/downloads


Next will be to see if the compiled bootloader actually works now. Thanks for the help.



________________________________
From: Xiaofan Chen <xiaofanc at gmail.com>
To: Daniel Yount <factorf2 at yahoo.com>
Cc: "libhid-discuss at lists.alioth.debian.org" <libhid-discuss at lists.alioth.debian.org>
Sent: Monday, November 14, 2011 6:50 AM
Subject: Re: [libhid-discuss] USB libhid is writing to PIC but errors out reading from it.
Post by Daniel Yount
Using Linux 3.x kernel and debian 6.0 stable distro.
USB flash program 1.3
http://code.google.com/p/mphidflash/
libhid 0.2.16
I have installed a Generic HID bootloader? and a basic p18F2455 circuit
setup for reading and writing USB data.
20mhz crystal no LEDs one jumper for bootloader mode and a switch for
reset., nothing special.
If you download the latest Microchip USB stack, there is an HIDAPI
based cross-platform HID bootloader, you may want to try that one,
it works for me whereas mphidflash did not seem to work for me
(PIC18F87J50 USB PIM) last time I tried it.
--
Xiaofan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20111115/62ded0ba/attachment.html>
Daniel Yount
2011-11-15 09:28:53 UTC
Permalink
I tried to get the Microchip HIDAPI Bootloader to find my 18f2455 chip

and it would not. Just says disconnected at the bottom and give me no
options other than to kill the window.? The chip is in boot loader mode
i.e RB4 to ground and 10k to 5v usb + bus. It also shows up in the dmesg & lsusb list.



________________________________
From: Daniel Yount <factorf2 at yahoo.com>
To: Xiaofan Chen <xiaofanc at gmail.com>
Cc: "libhid-discuss at lists.alioth.debian.org" <libhid-discuss at lists.alioth.debian.org>
Sent: Tuesday, November 15, 2011 2:08 AM
Subject: Re: [libhid-discuss] USB libhid is writing to PIC but errors out reading from it.


_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20111115/10447788/attachment.html>
Daniel Yount
2011-11-15 14:44:13 UTC
Permalink
I was in the wrong on this one, I was using the Bootloader firmware form the Generic HID Bootloader.
I installed the accompanying HID Bootloader for the HIDBootloader and it all worked. or at least found
it will now test the uploading.

Thanks for your help.



________________________________
From: Daniel Yount <factorf2 at yahoo.com>
To: Xiaofan Chen <xiaofanc at gmail.com>
Cc: "libhid-discuss at lists.alioth.debian.org" <libhid-discuss at lists.alioth.debian.org>
Sent: Tuesday, November 15, 2011 3:28 AM
Subject: Re: [libhid-discuss] USB libhid is writing to PIC but errors out reading from it.


I tried to get the Microchip HIDAPI Bootloader to find my 18f2455 chip

and it would not. Just says disconnected at the bottom and give me no
options other than to kill the window.? The chip is in boot loader mode
i.e RB4 to ground and 10k to 5v usb + bus. It also shows up in the dmesg & lsusb list.



________________________________
From: Daniel Yount <factorf2 at yahoo.com>
To: Xiaofan Chen <xiaofanc at gmail.com>
Cc: "libhid-discuss at lists.alioth.debian.org" <libhid-discuss at lists.alioth.debian.org>
Sent: Tuesday, November 15, 2011 2:08 AM
Subject: Re: [libhid-discuss] USB libhid is writing to PIC but errors out reading from it.


_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/


_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20111115/835e04ce/attachment.html>
Daniel Yount
2011-11-15 15:19:36 UTC
Permalink
Well I had tried out the bootloader and I get the same problem. It writes to it as it says Querying Chip.
but then it gets disconnected when trying to write from the chip. No difference in the problem of either program.

I was told that D+ was the write to chip line and D- was the Read from chip line.?
checked out the connections they seemed to be good, but will debug the lines later
have to go somewhere. Wondering what could be the deal on this chip and bootloader if it has a not
read option or should it be readable from the get go?




________________________________
From: Daniel Yount <factorf2 at yahoo.com>
To: Xiaofan Chen <xiaofanc at gmail.com>
Cc: "libhid-discuss at lists.alioth.debian.org" <libhid-discuss at lists.alioth.debian.org>
Sent: Tuesday, November 15, 2011 8:44 AM
Subject: Re: [libhid-discuss] USB libhid is writing to PIC but errors out reading from it.


I was in the wrong on this one, I was using the Bootloader firmware form the Generic HID Bootloader.
I installed the accompanying HID Bootloader for the HIDBootloader and it all worked. or at least found
it will now test the uploading.

Thanks for your help.



________________________________
From: Daniel Yount <factorf2 at yahoo.com>
To: Xiaofan Chen <xiaofanc at gmail.com>
Cc: "libhid-discuss at lists.alioth.debian.org" <libhid-discuss at lists.alioth.debian.org>
Sent: Tuesday, November 15, 2011 3:28 AM
Subject: Re: [libhid-discuss] USB libhid is writing to PIC but errors out reading from it.


I tried to get the Microchip HIDAPI Bootloader to find my 18f2455 chip

and it would not. Just says disconnected at the bottom and give me no
options other than to kill the window.? The chip is in boot loader mode
i.e RB4 to ground and 10k to 5v usb + bus. It also shows up in the dmesg & lsusb list.



________________________________
From: Daniel Yount <factorf2 at yahoo.com>
To: Xiaofan Chen <xiaofanc at gmail.com>
Cc: "libhid-discuss at lists.alioth.debian.org" <libhid-discuss at lists.alioth.debian.org>
Sent: Tuesday, November 15, 2011 2:08 AM
Subject: Re: [libhid-discuss] USB libhid is writing to PIC but errors out reading from it.


_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/


_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/


_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20111115/d6d2787d/attachment.html>
Xiaofan Chen
2011-11-16 11:49:56 UTC
Permalink
Post by Daniel Yount
I was told that D+ was the write to chip line and D- was the Read from chip
line.? checked out the connections they seemed to be good, but will debug
the lines later have to go somewhere. Wondering what could be the deal
on this chip and bootloader if it has a not
read option or should it be readable from the get go?
Hmm, it seems you need to read the ABCs of USB before embarking
on this project.
http://www.usbmadesimple.co.uk/

As for your issue, you may want to check if your hardware and
firmware are correct or not. If possible, get a known-good hardware
(eg: the dev kits from Microchip) and then use the known-good
Microchip USB firmware framework to get familiar with the
stack first.
--
Xiaofan
Loading...