Re: [Fx2lib-devel] String 0 descriptor bug
Status: Beta
Brought to you by:
mulicheng
From: Chris M. <fx...@m3...> - 2011-06-06 14:40:39
|
String descriptor zero is not really a string, it is just a list of supported 16-bit language codes. Furthermore, string descriptor zero is the only one which contains any language codes. Thus, for devices supporting English it is correctly declared in fw/dscr.a51: string0: .db string0end - string0 ; len .db DSCR_STRING_TYPE .db 0x09, 0x04 ; 0x0409 is the language code for English. string0end: If you wanted to support another language in addition to English the intent was that you would add another entry on to the end of that list, e.g Polish is 0x0415. When the host requests a string with GET_DESCRIPTOR, it supplies the language code (guaranteed to be either 0x0409 or 0x0415 in this case since that's the list returned by descriptor zero) in wIndex. Unfortunately, handle_get_descriptor() in setupdat.c does not consider the language code in wIndex; it assumes there is only one language. So fx2lib works OK as long as there is only one language (whether English or something else), but querying for the same descriptor in multiple languages always returns the same string. This is a bug. I propose to add an extra structure in fw/dscr.a51 which selects which string table to use based on the supplied language code. Something like this: _lang_table: .word 0x0409, eng_string1_begin .word 0x040c, fra_string1_begin _string0: .db string0_end - _string0 ; len .db DSCR_STRING_TYPE .db 0x09, 0x04 ; 0x0409 is the language code for US English. .db 0x0c, 0x04 ; 0x040c is the language code for French string0_end: eng_string1_begin: .db eng_string1_end - eng_string1_begin .db DSCR_STRING_TYPE .ascii "The Dog" ; Actually a list of .ascii 'T'; .db 0 for each char eng_string1_end: eng_string2_begin: .db eng_string2_end - eng_string2_begin .db DSCR_STRING_TYPE .ascii "FooBar v1" eng_string2_end: .dw 0x0000 fra_string1_begin: .db fra_string1_end - fra_string1_begin .db DSCR_STRING_TYPE .ascii "Le Chien" fra_string1_end: fra_string2_begin: .db fra_string2_end - fra_string2_begin .db DSCR_STRING_TYPE .ascii "FooBar v1" fra_string2_end: .dw 0x0000 ...then modify handle_get_descriptor() to select a string table from _lang_table based on the langid supplied in wIndex. For the single-language case it should be possible to use some conditional compilation, omit the lang_table and fall back to the current behaviour. Any objections to that approach? Chris On Sun, 2011-06-05 at 12:04 +0200, Zbigniew Karkuszewski wrote: > Hi, > > I keep getting a string 0 descriptor error message on linux while > downloading my firmware build with fx2lib. I have noticed that in dscr_asm > file there is only one byte devoted to the language id in the string 0 > descriptor. The USB 2.0 TRM says it should be two bytes (word) since the > language codes are 16-bit long. > > Same thing for the STRING_DSCR structure in setupdat.h. > > > Cheers! > zbyszek > |