From 8cc9a74a3f6bf363645efda6db417f8dadd3d844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Mon, 5 Jul 2021 11:54:26 +0200 Subject: firmware-utils: update to version 2021-10-05 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Includes following changes: db65821f006c cmake: fix missing install target 3a0cfc856991 Add initial GitLab CI support 8f47adea6f87 Add missing includes for byte swap operations fbafae9f8037 Convert to CMake based project Additionaly moves source code into separate Git project repository and converts the package build to utilize CMake. Signed-off-by: Petr Štetiar [rmilecki: rebase, update to the latest repo git & rm -r src] Signed-off-by: Rafał Miłecki --- tools/firmware-utils/src/encode_crc.c | 138 ---------------------------------- 1 file changed, 138 deletions(-) delete mode 100644 tools/firmware-utils/src/encode_crc.c (limited to 'tools/firmware-utils/src/encode_crc.c') diff --git a/tools/firmware-utils/src/encode_crc.c b/tools/firmware-utils/src/encode_crc.c deleted file mode 100644 index 80f44f133e..0000000000 --- a/tools/firmware-utils/src/encode_crc.c +++ /dev/null @@ -1,138 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* ************************************************************************** - - This program creates a CRC checksum and encodes the file that is named - in the command line. - - Compile with: gcc encode_crc.c -Wall -o encode_crc - - Author: Michael Margraf (michael.margraf@freecom.com) - Copyright: Freecom Technology GmbH, Berlin, 2004 - www.freecom.com - - ************************************************************************* */ - - -#include -#include -#include -#include - -// ******************************************************************* -// CCITT polynom G(x)=x^16+x^12+x^5+1 -#define POLYNOM 0x1021 - -// CRC algorithm with MSB first -int make_crc16(int crc, char new) -{ - int i; - crc = crc ^ (((int)new) << 8); - - for(i=0; i<8; i++) { // work on 8 bits in "new" - crc <<= 1; // MSBs first - if(crc & 0x10000) crc ^= POLYNOM; - } - return crc & 0xFFFF; -} - -// ******************************************************************* -// Reads the file "filename" into memory and returns pointer to the buffer. -static char *readfile(char *filename, int *size) -{ - FILE *fp; - char *buffer; - struct stat info; - - if (stat(filename,&info)!=0) - return NULL; - - if ((fp=fopen(filename,"r"))==NULL) - return NULL; - - buffer=NULL; - for (;;) - { - if ((buffer=(char *)malloc(info.st_size+1))==NULL) - break; - - if (fread(buffer,1,info.st_size,fp)!=info.st_size) - { - free(buffer); - buffer=NULL; - break; - } - - buffer[info.st_size]='\0'; - if(size) *size = info.st_size; - - break; - } - - (void)fclose(fp); - - return buffer; -} - - -// ******************************************************************* -int main(int argc, char** argv) -{ - if(argc < 3) { - printf("ERROR: Argument missing!\n\n"); - return 1; - } - - int count; // size of file in bytes - char *p, *master = readfile(argv[1], &count); - if(!master) { - printf("ERROR: File not found!\n"); - return 1; - } - - int crc = 0xFFFF, z; - - p = master; - for(z=0; z 2) { // with flag for device recognition ? - p = argv[2]; - for(z=strlen(p); z>0; z--) { - crc ^= (int)(*p); - *(p++) = (char)crc; // encode device flag - } - } - */ - - p = master; - for(z=0; z 3) { // add flag for device recognition ? - fwrite(argv[3], strlen(argv[3]), sizeof(char), fp); - } - else { - // Device is an FSG, so byte swap (IXP4xx is big endian) - crc16 = ((crc16 >> 8) & 0xFF) | ((crc16 << 8) & 0xFF00); - } - - fwrite(&crc16, 1, sizeof(short), fp); // first write CRC - - fwrite(master, count, sizeof(char), fp); // write content - fclose(fp); - - free(master); - return 0; -} -- cgit v1.2.3