Calculating 32 bit CRCs

From GumstixDocsWiki

Jump to: navigation, search

When transferring files, it is sometimes desirable to verify that the file was transferred properly. One of the simplest ways of doing this is to calculate a 32-bit CRC before and after transferring the file.

Using zip & unzip

The zip and unzip utilities calculate a 32-bit CRC for each file stored in the zip archive. You can determine this CRC by doing the following:

zip test.zip somefile
unzip -lv test.zip

Using U-Boot

U-Boot has a builtin command called crc32 which will calculate over a region of memory. This is most useful after transferring a file into memory. In this scenario, a tyical invocation would look like:

crc32 a2000000 ${filesize}

Using a standalone program

You can also compile a stanalone program which will run on your host machine and/or the gumstix. Copy crc32.c and the Makefile to a directory on your build machine.

The Makefile assumes that you create a directory parallel to the gumstix-buildroot (i.e. on my system, gumstix-build root can be found at /home/dhylands/gumstix/gumstix-buildroot, so for this project I'd create /home/dhylands/gumstix/crc32). Typing make will build both the local version (called crc32) and the version which runs on the gumstix (arm-crc32).

The crc32 and arm-crc32 programs both take a single argument, the name of the file to calculate the 32-bit CRC of.

Personal tools