waywardgeek / infnoise

The world's easiest TRNG to get right
Creative Commons Zero v1.0 Universal
723 stars 99 forks source link

Wrong ftdi_set_bitmode() and ftdi_set_baudrate() ordering #94

Open trosenkranz opened 2 years ago

trosenkranz commented 2 years ago

Hi Bill,

while trying to understand how the InfiniteNoise driver works, I found that the ftdi_set_baudrate()-method in libftdi applies a factor of 4 to the set baudrate when bitbang-mode is enabled (cf. libftdi-repository). So in my understanding the driver first has to call ftdi_set_bitmode() and then ftdi_set_baudrate().

Currently in the code first the ftdi_set_baudrate() and then the ftdi_set_bitmode()-method is called.

Am I missing something?

Tobias

waywardgeek commented 2 years ago

You're probably right. I originally picked the baud rate experimentally, finding a value that worked well, and I was looking at the big-bang toggle rate, and did not worry about what the baud rate was set to. The current square waves from the FTDI chip are correct, but there may be a factor of 4 difference in the baud rate and what we see on the oscilloscope.

On Mon, Aug 1, 2022 at 3:19 PM Tobias Rosenkranz @.***> wrote:

Hi Bill,

while trying to understand how the InfiniteNoise driver works, I found that the ftdi_set_baudrate()-method in libftdi applies a factor of 4 to the set baudrate when bitbang-mode is enabled (cf. libftdi-repository http://developer.intra2net.com/git/?p=libftdi;a=blob;f=src/ftdi.c;h=0a7fb274dd927d45615bbd26c11e950155164e46;hb=HEAD#l1470). So in my understanding the driver first has to call ftdi_set_bitmode() and then ftdi_set_baudrate().

Currently in the code first the ftdi_set_baudrate() https://github.com/waywardgeek/infnoise/blob/66075cc79988bc891d37058724839487db0d3216/software/libinfnoise.c#L248 and then the ftdi_set_bitmode()-method https://github.com/waywardgeek/infnoise/blob/66075cc79988bc891d37058724839487db0d3216/software/libinfnoise.c#L262 is called.

Am I missing something?

Tobias

— Reply to this email directly, view it on GitHub https://github.com/waywardgeek/infnoise/issues/94, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACVQYUKGKBOT3J2XN5TUCLVXBENPANCNFSM55JBS4SA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

trosenkranz commented 2 years ago

So am I right to assume, that the clock rate for reading/writing is 30kHz? If yes, this issue can be closed.

Thanks