diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-08-08 01:43:12 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-08-08 02:11:45 +0300 |
commit | 322821a1381f81c4dd480d065bec13803c7e69dc (patch) | |
tree | be56db12522e6e67fa7403e0de82aa0e27dc150d /crc/gen-crc.py | |
parent | 548cc0aa0463c09337962943d3f05317f0f1cc84 (diff) |
crc: Add a utility to compute the CRC of a frame
The discom-crc utility computes the CRC of a frame using the same
algorithm as the DISCOM hardware block. This is useful to precompute CRC
values and then compare them with the hardware-generated values.
The utility computes the CRC on data stored in a file passed as a
command line argument. It supports two optional arguments, --crop and
--size, to specify the crop rectangle and the image size. The size only
needs to be specified if a crop rectangle is set, it is deduced from the
file size otherwise.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'crc/gen-crc.py')
-rwxr-xr-x | crc/gen-crc.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crc/gen-crc.py b/crc/gen-crc.py new file mode 100755 index 0000000..10c5776 --- /dev/null +++ b/crc/gen-crc.py @@ -0,0 +1,14 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# SPDX-FileCopyrightText: 2020 Laurent Pinchart <laurent.pinchart@ideasonboard.com> + +import crcmod +import sys + +# The initial value is ignored, it must instead be passed to the generated C +# function. +crc = crcmod.Crc(0x104c11db7, 0xffffffff, True, 0xffffffff) + +f = open(sys.argv[1], 'w') +crc.generateCode('calculate_crc', f, 'uint8_t', 'uint32_t') +f.close() |