And indeed I was right!<br><br>This week I received an email from a user who had trouble making his xircom device work. Then he googled it and discovered a message I sent to the linux kernel mailing list. Based on information provided by my investigation, he patched the firmware file and then it worked perfectly with the actual device, confirming my theory that there was a bug in that byte :-)<br>
<br>happy hacking<br>Felipe "Juca" Sanches<br><br><div class="gmail_quote">On Tue, Jan 4, 2011 at 12:34 AM, Felipe Sanches <span dir="ltr"><<a href="mailto:juca@members.fsf.org" target="_blank">juca@members.fsf.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Mon, Jan 3, 2011 at 9:37 PM, Alexandre Oliva <<a href="mailto:lxoliva@fsfla.org">lxoliva@fsfla.org</a>> wrote:<br>

> On Jan  3, 2011, Felipe Sanches <<a href="mailto:juca@members.fsf.org">juca@members.fsf.org</a>> wrote:<br>
><br>
>> What I meant is that the kernel source shouldnt ship binaries.<br>
><br>
> Why not?  It doesn't harm any freedom to ship them along with the<br>
> sources, and it makes perfect sense IMHO to not require people who build<br>
> their own kernel binaries to have to have assemblers and compilers and<br>
> FPGA tools etc for tons of different targets.<br>
<br>
</div>My personal opinion is that there should be a clear separation of<br>
source code repositories and packages of pre-built binaries. I agree<br>
that there is no freedom harm in shipping binaries even if you have<br>
the source code to build too. But not building something from source<br>
may lead to a situation where the source code may get neglected and<br>
people may eventually update the binaries without updating the source<br>
and it would not be trivial to keep track of it. You have asked me<br>
whether the shipped binary for dabusb 8051 fimrware is equivalent to<br>
the firmware source code. That is not an easy question to answer. The<br>
safest way to be sure that the shipped binary is equivalent to the<br>
free code is by making sure it is always the result of a firmware<br>
build directly from source code.<br>
<br>
People would have to install the development tools for the selected<br>
targets they have setup in their kernel configuration.  For instance,<br>
it is acceptable that for a certain application, people have to<br>
install libwhatever package if they want to build a certain feature<br>
that uses such lib, but they dont have to install other libraries that<br>
are only required for other non-selected features. Let me stretch it a<br>
bit just for fun: people have to install gcc if they whant to build<br>
their C code :-D<br>
<br>
People who are concerned about the possible hassle of having to<br>
install fpga development tools and assemblers for several different<br>
targets (for example people in charge of preparing kernel packages for<br>
distros) can make use of a separate package of pre-built images (that<br>
somebody else could be held responsible for mantaining, perhaps), but<br>
the kernel source code should stick to source code only, while the<br>
proper place for pre-built binaries is in pre-built kernel<br>
images/packages. And yes, perhaps pcmcia .ct files should also be<br>
always translated into CIS files at build time too for the same<br>
reason.<br>
<br>
Here is a more pragmatic argument, though:<br>
<br>
In the firmware/keyspan_pda/ directory there is both source code:<br>
keyspan_pda.S and xircom_pgs.S<br>
and pre-built firmware:<br>
keyspan_pda.HEX and xircom_pgs.HEX<br>
<br>
These files are in Linux since 2002 at least. So the question "did<br>
firmware images and firmware source code diverge along these past 8 or<br>
9 years?" can only be answered by building the code and comparing the<br>
results byte-by-byte. I did it and got a positive result for xircom.<br>
The resulting HEX file is not identical to the pre-built one, but the<br>
files are equivalent. Mind the first few lines of the original and<br>
rebuilt hex files:<br>
<br>
xircom_pgs.HEX<br>
:03000000020200F9<br>
:0400230002055F0073<br>
:0400430002010000B6<br>
:050030000000000000CB<br>
:10010000020296000200000002000000020000004F<br>
:1001100002000000020000000200000002000000D7<br>
:1001200002000000020000000204610002048900D5<br>
<br>
xircom_pgs_rebuilt.HEX<br>
:03000000020200F9<br>
:0400230002059B0037<br>
:0400430002010000B6<br>
:050030000000000000CB<br>
:0D0100000202BA000200000002000000022E<br>
:0E010D000000000200000002000000020000DE<br>
:0E011B000002000000020000000200000002CE<br>
:070129000485000204B90087<br>
<br>
HEX format is:<br>
:<8bit counter><16bit address><0x00><"counter" bytes of data><checksum byte><br>
<br>
If you compare these two files you can see they are 2 alternative<br>
representation of the same memory block. It is not trivial to check. I<br>
had to write a python script to parse IntelHex and generate a memory<br>
image dump (with zeroes in the addresses not referenced by the HEX<br>
data and then compare the resulting firmware images byte-by-byte.<br>
<br>
By doing that I got positive result indicating that xircom_pgs.S and<br>
xircom_pgs.HEX match perfectly indeed. But I got a one-byte diference<br>
between the original image of keyspan_pda.HEX and the result of<br>
building keyspan_pda.S The byte value divergence is at memory address<br>
0x0266. The prebuilt image has 0x00 at this address, while the image<br>
built from source have 0x53. This address corresponds to the following<br>
line in the source code:<br>
<br>
        ;; setup the serial port. 9600 8N1.<br>
        mov a,#0b01010011               ; mode 1, enable rx, clear int<br>
        mov SCON, a<br>
<br>
It is configuring the serial port by writting configuration bits to<br>
the 8051 SCONS Special Function Register. So let's check the 8051<br>
documentation to see what is the result of storing zero instead of<br>
0x53 (the 0b01010011 in the source code above) in this register.<br>
<br>
 Bits 7 (SM0) and 6 (SM1) let us set the serial mode to a value<br>
between 0 and 3, inclusive.<br>
SM = 01 in the source code meaning mode 1: 8 bit UART (just like it<br>
states in the comments) and SM=00 in the prebuilt firmware, which<br>
would mean Mode 0: 8bit shift register...<br>
<br>
As the main function of this device is to behave as a USB-Serial<br>
interface, I conclude that the prebuilt firmware is probably<br>
completely broken because of this single byte. Does anybody actually<br>
have one of these keyspan_pda devices to check ?<br>
<br>
That's the kind of failure I know we'll potentially face again if we<br>
continue blindly trusting pre-built firmware.<br>
<br>
I may also assume that this is not a popular device, since the<br>
firmware bug would be simple to detect if people were actually using<br>
it: the device would simply not work (I guess).<br>
<br>
Now here is something really weird:<br>
<a href="http://www.mail-archive.com/linux-serial@vger.rutgers.edu/msg00473.html" target="_blank">http://www.mail-archive.com/linux-serial@vger.rutgers.edu/msg00473.html</a><br>
The initial patch that added support for keyspan_pda in Linux 2.2.50<br>
back in march 2000 already have the 0x00 byte at addrees 0x266 :-P I<br>
dont know how to explain that!<br>
<span class="HOEnZb"><font color="#888888"><br>
Felipe Sanches<br>
</font></span></blockquote></div><br>