Open Nathan-Stohs opened 10 years ago
There's already a CRC method in MF: http://msdn.microsoft.com/en-us/library/ee431960.aspx. I have no idea about the algorithm or the performance. It would be nice to know if it's something standard.
Existing CRC implementation uses 1KB of memory for CRCTable, so that might be saved. CRC is used in many places: Heap_Persistence, Cache, CLR_RT_HeapBlock, TypeSystem, Debugger, CLRStartup.cpp, BS_WearLeveling_Driver, FAT_SectorCache, MFUpdate, tinyhal, ConfigHelper, SimpleStorage, and WireProtocol.
Even if we don't current use some of those features, I think it's safe to say CRC hardware support may help speed up Debugger response.
Existing implementation file is Support/crc/CRC.cpp. C# copycat implementation is at Framework\Core\Drivers\802_15_4\Stack\Physical\CC2420\Crc.cs MFUpdate does CRC checks on the data. Goes through provider CrcUpdateValidation to call SUPPORT_ComputeCRC. DallasSemiconductor's OneWire library implements 8 and 16-bit CRC in crcutil.cpp.
I found this discussion about the MF Utility.ComputeCRC algorithm: http://forums.netduino.com/index.php?/topic/3101-utilitycomputecrc/. It's apparently different than other similar CRC algorithms. One of the contributors to the discussion gives an implementation in C# so it should be easy to match on the PC.
Was speaking to Bill about data integrity checks and I mentioned that our STM32F1 includes a humble but potentially use hardware CRC unit. We don't currently expose it.
This is a low-priority item that is a trivial exercise but would be nice to have. The only work is adding the interop. All of the actual driver code we need is already part of the standard STM32F1 support package which provides:
Potentially we should write an eMote platform CRC driver, or at least a skeleton implementation backed by this in the case of the .NOW. The CRC polynomial is fixed to 0x4C11DB7 (Ethernet) so the unit isn't flexible.
I will add this as a low-priority item for myself since I want to learn how to do interops anyway.