BootloadHID

Registered forum users can contribute their rating for projects based on V-USB in this forum.

Please rate BootloadHID on a scale from 0 (worst) to 5 (best):

(0)
0
No votes
(1) *
0
No votes
(2) **
0
No votes
(3) ***
0
No votes
(4) ****
1
7%
(5) *****
13
93%
 
Total votes: 14

Guest

Postby Guest » Mon Nov 17, 2008 11:42 am

Hi, Christian!
I have made BootloadHID-2007-10-22 on ATmega8 with your file main.hex. It's OK. I compiled your sources on WinAVR-20080610. It's OK. But I have made BootloadHID-2008-10-23 on ATmega8 under the identical electrical circuit (main.hex, WinAVR-20080610). After that does not work, USB device not found. My question - you have changed now the electrical circuit or sources there are mistakes? What version WinAVR you use?

christian
Objective Development
Objective Development
Posts: 1371
Joined: Thu Nov 09, 2006 11:46 am

Postby christian » Mon Nov 17, 2008 1:57 pm

I'm using gcc 3.4.6 to compile the code. However, it has been tested and works with gcc 4 as well. Just the code size is bigger and it might exceed the size of the boot loader block (2k). You can check the code size with

avr-size main.hex

Guest

Postby Guest » Wed Nov 19, 2008 4:48 pm

The problem in that I have loaded in ATmega8 YOUR file main.hex from 20071022 (everything is all right works). After that I have loaded into the same ATmega8 YOUR file main.hex from 20081023 (does not work). Somebody can repeat this experiment?

christian
Objective Development
Objective Development
Posts: 1371
Joined: Thu Nov 09, 2006 11:46 am

Postby christian » Wed Nov 19, 2008 5:23 pm

The configuration which ships with the code is intended mostly as an example, not a working code. There's a bug in the example code for the 2008-10-22 release: The boot loader condition checks PORTD, the output port, not PIND as it should. We will fix this in the next release.

Guest

USBDEVFS_CONTROL failed

Postby Guest » Fri Jan 16, 2009 12:03 am

hi,

the last version "bootloadHID.2008-11-26.tar.gz" fit in an atmega16 without modification. of course i had to change BOOTLOADER_ADDRESS = 3800, the fuses are the same:
FUSEH = 0xc0
FUSEL = 0x9f

when plugging the device and holding the jumper (PORTD bit 3):
[13631.249951] usb 1-2: new low speed USB device using uhci_hcd and address 13
[13631.328237] usb 1-2: configuration #1 chosen from 1 choice
[13631.350924] hiddev97hidraw0: USB HID v1.01 Device [obdev.at HIDBoot] on usb-0000:00:1a.0-2

lsusb:
Bus 001 Device 014: ID 16c0:05df

but when trying to upload an hex file with commandline, i get this error. i searched the forum but found nothing:

./bootloadHID -r a.hex
Warning: cannot query manufacturer for device: error sending control message: Protocol error
Error opening HIDBoot device: Communication error with device

dmesg
[14371.927634] usb 1-2: usbfs: USBDEVFS_CONTROL failed cmd bootloadHID rqt 128 rq 6 len 256 ret -71

i tried with an atmega8, same problem. i am using a 12MHz, zener diode for the usb datalines (basic setup). i tested in Windows, and the error is: Error opening HIDBoot device: Communication error with device

any idea, anyone having the same issue?
pat

christian
Objective Development
Objective Development
Posts: 1371
Joined: Thu Nov 09, 2006 11:46 am

Postby christian » Fri Jan 16, 2009 5:13 pm

You probably don't have permissions for the USB device. Either you run the boot loader as root, your you configure hotplug to give permissions for your group or user-ID.

Guest

Postby Guest » Fri Jan 16, 2009 10:08 pm

i am root all the time, i really don't why it's not working for me. i tested 2 others related projects:

http://www.fischl.de/avrusbboot/
works fine (lib-usb)

http://1010.co.uk/avrhid.html
works too (hid)

also, i tested on Windows, i don't think there's problem with permission on this platform (well, i don't really know how Windows works...).

anything else i should try? ah yes, i've also tested past release:
bootloadHID.2007-10-23
bootloadHID.2008-10-22

same error:
usb 1-2: usbfs: USBDEVFS_CONTROL failed cmd bootloadHID rqt 128 rq 6 len 256 ret -71

Warning: cannot query manufacturer for device: error sending control message: Protocol error
Error opening HIDBoot device: Communication error with device

pat

christian
Objective Development
Objective Development
Posts: 1371
Joined: Thu Nov 09, 2006 11:46 am

Postby christian » Fri Jan 16, 2009 11:51 pm

Ah, sorry, did not look at the error message closely.

Communication with the device seems to work in the first place, but when more info is requested, it crashes or fails otherwise.

When you say you tested on Windows: Did it fail as well? With what error? Did windows list the device correctly?

There's a known problem on FreeBSD: The HID driver takes the device and does not allow direct access via libusb.

The problem may also be in the command line tool, e.g. because it sends the requests to the wrong authority (device instead of endpoint or vice versa). I have checked this and believe that it's OK, but I may be wrong.

Guest

Postby Guest » Sat Jan 17, 2009 10:03 pm

1) compiling main.c
...
usbdrv/usbdrv.h:211: warning: ‘usbFunctionDescriptor’ used but never defined
usbdrv/usbdrv.h:218: warning: ‘usbSetInterrupt’ declared ‘static’ but never defined
...
avr-size main.bin
text data bss dec hex filename
1776 10 49 1835 72b main.bin


2) compiling commandline
...
In file included from usbcalls.c:19:
usb-libusb.c: In function ‘usbGetReport’:
usb-libusb.c:196: warning: value computed is not used


3) plugging the device and holding the button for loading the bootloader
[ 1811.749194] usb 1-2: configuration #1 chosen from 1 choice
[ 1811.770778] hiddev97hidraw0: USB HID v1.01 Device [obdev.at HIDBoot] on usb-0000:00:1a.0-2

lsusb
Bus 001 Device 010: ID 16c0:05df


4) launching the commandline tool
./bootloadHID a.hex
Warning: cannot query manufacturer for device: error sending control message: Protocol error
Error opening HIDBoot device: Communication error with device

dmesg
[ 1842.242419] usb 1-2: usbfs: USBDEVFS_CONTROL failed cmd bootloadHID rqt 128 rq 6 len 256 ret -71

i can reproduce this problem on ubuntu hardy and gutsy. on Windows when i connect the device for the very first time, it complains that the device might not working properly, a disconnect and reconnect = HidBoot and everything seems to be in order (in device manager). running the commandline i get this error:

Error opening HIDBoot device: Communication error with device

same problem using an atmega16, i have also an attiny45 and atmega168. do you think i should run another test with the tiny45 or mega168?

thanks for your time Christian

Guest

Postby Guest » Sun Jan 18, 2009 12:15 am

sorry for the noise... i tried with an atmega168:

DEVICE = atmega168
BOOTLOADER_ADDRESS = 3800
F_CPU = 12000000
FUSEH = 0xDD
FUSEL = 0xD7

doesn't work. here's some more information using lsusb -vvv

Bus 001 Device 008: ID 16c0:05df
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x16c0
idProduct 0x05df
bcdDevice 1.00
iManufacturer 1
iProduct 2
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.01
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 33
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 200
cannot read device status, Protocol error (71)

report description unavailable, is this normal?
pat

christian
Objective Development
Objective Development
Posts: 1371
Joined: Thu Nov 09, 2006 11:46 am

Postby christian » Sun Jan 18, 2009 12:01 pm

From your last two postings I can see that:
(1) Querying a string descriptor fails with error -71 (whatever that means)
(2) lsusb can't read the report descriptor
(3) lsusb can't read device status.

The device descriptor and all descriptors attached to it have obviously been read correctly, otherwise lsusb would not show any info.

Windows seems to be able to obtain string descriptors, otherwise it would not know that the device's name is HIDBoot. But there seems to be a problem as well, maybe due to the report descriptor.

Can you compile the firmware with debugging enabled and connect a Terminal to the AVR's TxD (19200 bps)? That would dump the communication carried out between the host and the device. Or use a USB sniffer (usbmon?) to see the communication?

Guest

Postby Guest » Sun Jan 18, 2009 8:13 pm

here's the results, but i wasn't sure how to enable debug:
-DDEBUG_LEVEL=1 # -DTEST_MODE?

http://www.11h11.com/temp/usbreport.gif

pat

christian
Objective Development
Objective Development
Posts: 1371
Joined: Thu Nov 09, 2006 11:46 am

Postby christian » Sun Jan 18, 2009 8:37 pm

You would compile a debug version with -DDEBUG_LEVEL=2, then make clean and make. If the code size exceeds the boot section, use -DTEST_MODE=1 so that no flash writes are done.

But the sniffer log reveals one thing: The host sends a "set idle rate" request to the device, which is primarily useful for keyboards (repeat rate). bootloadHID ignores this request, which should be safe since no reply is expected.

After that, the host reads the report descriptor successfully. Then it disconnects, probably because it has found an error in one of the replies.

Maybe the report descriptor can not be parsed because it has a syntax error? I don't know what error -71 is, but it might be a parse error in the report descriptor.

Unfortunately, I'm not an expert for HID report descriptors. Most of them are primarily guesswork.

psc
Rank 1
Rank 1
Posts: 32
Joined: Sat Nov 15, 2008 9:51 pm

Postby psc » Sun Jan 18, 2009 10:41 pm

found the problem and i am very ashamed of myself, wasting your time for nothing. i didn't know that i need to hold the jumper / button down when using ./bootloadHID main.hex!!! still i think it would be nice to just hold it for starting the bootloader, but then release it for using bootloadHID, is it possible?

/me goes hiding

christian
Objective Development
Objective Development
Posts: 1371
Joined: Thu Nov 09, 2006 11:46 am

Postby christian » Sun Jan 18, 2009 10:54 pm

Ah -- I see. This depends on how you write your boot loader condition and init. If you put the check into the init function, it's only performed immediately after startup.


Return to “V-USB Project Ratings”

Who is online

Users browsing this forum: No registered users and 1 guest