[Cryptech Tech] never do in software what can be done in hardware
Fredrik Thulin
fredrik at thulin.net
Mon Sep 29 06:26:04 UTC 2014
On Friday, September 26, 2014 05:50:13 PM Benedikt Stockebrand wrote:
> Hi folks,
>
> Fredrik Thulin <fredrik at thulin.net> writes:
> >> Can you just read the least significant byte, or are they not even
> >> double buffered at the byte level?
> >
> > AFAICT, the msp430 reads 16 bits at a time from memory. If I read a single
> > byte, it appears to read a word and discard half of it.
>
> ouch; what does the documentation say on reading consistent data from
> it?
The documentation is sparse on that topic. It explains a scheme for manually
triggering timer captures, and the Internet suggests that it is a work around
for this problem to have a continuous trigger counter running, and when the
trigger event is detected you use software to trigger a second counter that
only reacts to software events. You then read the counter value from the
supposedly stable second capture buffer.
I tried that, but I would say I got to at least 20 clock cycles to detect the
event and trigger the second one and then read the second capture value. Also,
it seemed that the second capture value was unstable in the next few clock
cycles after it was triggered by software (but I didn't do enough tests to
back that claim), so I would have to do a number of nop()s before reading that
value too.
The second workaround suggested by the Internet was to do several readings and
do a majority vote, or several readings until they were consistent. Both those
approaches resulted in less than optimal performance since they effectively
discarded many/all of the higher frequency breakdown/recovery periods, and
would also fail a long running chi-square test.
...
> I have a somewhat similar idea over here: Use a GPIO pin on a Raspberry
> Pi or BeagleBone Black or such. It'll be ugly because it'll likely
> involve writing a kernel driver to get the timing right, but well...
I have the feeling that any OS will get in the way of the proper timing
measurements that seem required, but I've never tried to do something like
that in the kernel so maybe I'm just wrong on that.
/Fredrik
More information about the Tech
mailing list