ucrc16: provide lightweight CRC16 implementation#6112
ucrc16: provide lightweight CRC16 implementation#6112LudwigKnuepfer merged 2 commits intoRIOT-OS:masterfrom
Conversation
31a0166 to
cc0f975
Compare
|
Some thoughts:
|
This is pretty much the standard version of the algorithm (the table version is the special optimized one ;-)), so you find it in any standard literature on the topic. In my case it's from Wikipedia, but its also e.g. written down in the reference you gave in your unittests for CRC16-CCITT. (OT: For what is that particular implementation for? The seed you used isn't mention in any spec I saw).
With cosy (from the unittests) on iotlab-m3: on samr21-xpro: on z1: So the sizes of the actual code are comparable with the lookup-table being the caveat of the table version (which also grows linear if e.g. two CRC versions are present in the code).
Did not test, but since the table-version goes byte-wise, while the non-table-version goes bit-wise, it is expected, that the non-table-version is 8 times slower ;-).
This makes no sense at all IMHO. In most use-cases relevant for RIOT CRC is used to calculate a checksum for a packet going over the wire (mostly e.g. for PPP in big endian, for IEEE 802.15.4 in little endian).
Can do, but the simple explanation is: if you don't have memory (especially if your code demands more than one flavor of CRC16): use ucrc16. Else use crc16_ccitt (with caution). Or to quote Wikipedia:
So exactly what most of our target platforms are ;-) |
Done |
CRCs are also used for integrity checks on (RAM, ROM, flash etc.) memory. So IMHO this is a relevant use-case. There is just no code in RIOT yet that does this ;) |
I can not answer your question anymore and don't have time to re-research but googling around a bit you will find some indication that it actually exists outside RIOT.. |
True, but then it really doesn't matter what byteorder you choose as long as you use the same function for calculating and checking the checksum. => The default could always be |
|
Anyway, would be happy to see this (and maybe #6121?) merged at today's Hack'n"ACK |
I am still not convinced, but if you don't want to do it at this point that's fine with me. |
17d6420 to
56f33b5
Compare
|
Squashed |
56f33b5 to
f80615d
Compare
|
Excluded more boards from linking the unittests and squashed immediately. |
sys/checksum/doc.txt
Outdated
| * flavor of CRC16 (polynomial @$ x^{16} + x^{12} + x^{5} + 1 @$) for big-endian | ||
| * numbers with starting seed `0x1d0f` (though others can be provided), while | ||
| * @ref sys_checksum_ucrc16 is more generalized, since it takes the | ||
| * hexadecimal representation as a parameter and provides functions and |
There was a problem hiding this comment.
reading this again after a while I think it makes sense to specify: the hex representation of what?
|
@miri64 this PR needs love |
|
And would be a better time of the year for that? ;-) |
4d8e0de to
d9dafeb
Compare
d9dafeb to
71f778a
Compare
|
PR loved ;-) |
This is a more flexible, but lightweight (due to not using lookup-tables) alternative to
crc16_ccitt. Might also be extendable for #5471.