|
From: Roger B. <an...@xp...> - 2018-08-01 20:26:01
|
On 1 Aug 2018 at 11:58, David Gálvez wrote: > Hi Roger, thanks for the bug report. > > 2018-08-01 3:28 GMT+02:00 Roger Burrows <an...@xp...>: > > Hi all, > > There's a problem in isp116x-hcd.c (present in both the Ethernat & > NetUSBee > > controller drivers). If the buffer is not word-aligned, the data is > > byte-swapped by the read or write process. Word-aligned buffers are OK. > The > > error is in read_ptddata_from_fifo()/write_ptddata_to_fifo(). > > > > The data should be byte-swapped, the word-align buffers do it too. > Could you please be more specific? Perhaps you mean we shouldn't swap > bytes in the latest two bytes in the data chunk when the length is an > odd number?, lines 556 and 595 in the NetUSBee driver code. > Indeed, when the length is odd, the last bytes are handle incorrectly, but I wasn't able to figure out a simple way of forcing an odd length to a device for testing. But that's a separate bug, and wouldn't cause any problems with memory sticks AFAICS. The bug is that the entire sector is byte-swapped. To prove it, first I wrote a simple program that uses Rwabs() to read the boot sector of a FAT16 file system into both an unaligned & a word-aligned buffer. The results are different: all of the data in the unaligned buffer is byte-swapped. Having done that, I wrote another program using Rwabs() to write to a sector using both aligned and unaligned buffers, and to read back the contents into a word-aligned buffer. Again, the bytes are swapped when the sector is written from the unaligned buffer. It's probably faster for you to write the programs yourself, but if you need them, I can dig them out. Be warned, they are hacks of other programs so the source is a bit ugly, and they are written for LatticeC. Roger |