prjbureau icon indicating copy to clipboard operation
prjbureau copied to clipboard

Issues with transmission checksum of JED files when using jesd3.py

Open peterzieba opened this issue 1 year ago • 4 comments

Hi,

I think the transmission checksum calculation of JED files is incorrect within jesd3.py

I am using a file which was generated by CUPL and am following the spec verbatim wherein it says: The transmission checksum is the 16-bit sum (i.e., modulo 65,535) of all ASCII characters transmitted between and including the STX and ETX...

I've included a file as a testcase where the sum I calculate to be is 0x7F8A, which matches what is within the file.

jesd3.py calculates the actual sum to be 7B05, which I believe to be incorrect.

testcase.jed.txt

The more important bit (the fusemap checksum) I believe is working as expected.

peterzieba avatar Jul 06 '23 23:07 peterzieba

The issue appears to be that the file is opened as "text" mode. It looks like the CRLF from a Windows/DOS .JED file ends up as just LF in the buffer.

This ultimately looks like what is breaking the transmission checksum.

Unfortunately, opening the file as binary breaks a bunch of the regular expression searches...

peterzieba avatar Jul 10 '23 21:07 peterzieba

Ah that would make sense.

whitequark avatar Jul 10 '23 21:07 whitequark

This actually affects things on Linux just as it affects them on Windows.

whitequark avatar Oct 21 '23 11:10 whitequark

This is now fixed in Glasgow (once https://github.com/GlasgowEmbedded/glasgow/pull/450 is merged). @peterzieba Could you please copy the file out of the Glasgow source tree (https://github.com/GlasgowEmbedded/glasgow/blob/main/software/glasgow/protocol/jesd3.py), put it in this project, update the file open mode (r to rb) and test the resulting changes?

whitequark avatar Oct 21 '23 12:10 whitequark