From 0d4c537eded79faa9e46b2efa6910ad7be8ae519 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 8 Jul 2020 11:05:04 +0200 Subject: [PATCH] version info for FeliCa fpga image --- tools/fpga_compress/fpga_compress.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/fpga_compress/fpga_compress.c b/tools/fpga_compress/fpga_compress.c index b03caabf4..5da59f2db 100644 --- a/tools/fpga_compress/fpga_compress.c +++ b/tools/fpga_compress/fpga_compress.c @@ -50,10 +50,13 @@ static int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile) { if (total_size >= num_infiles * FPGA_CONFIG_SIZE) { fprintf(stderr, "Input files too big (total > %li bytes). These are probably not PM3 FPGA config files.\n" - , num_infiles * FPGA_CONFIG_SIZE); + , num_infiles * FPGA_CONFIG_SIZE + ); + for (uint16_t j = 0; j < num_infiles; j++) { fclose(infile[j]); } + free(fpga_config); return (EXIT_FAILURE); } @@ -188,8 +191,10 @@ static int zlib_decompress(FILE *infile, FILE *outfile) { * length. */ static int bitparse_find_section(FILE *infile, char section_name, unsigned int *section_length) { - int result = 0; + #define MAX_FPGA_BIT_STREAM_HEADER_SEARCH 100 // maximum number of bytes to search for the requested section + + int result = 0; uint16_t numbytes = 0; while (numbytes < MAX_FPGA_BIT_STREAM_HEADER_SEARCH) { char current_name = (char)fgetc(infile); @@ -252,6 +257,8 @@ static int FpgaGatherVersion(FILE *infile, char *infile_name, char *dst, int len strncat(dst, "LF", len - strlen(dst) - 1); else if (!memcmp("fpga_hf", basename(infile_name), 7)) strncat(dst, "HF", len - strlen(dst) - 1); + else if (!memcmp("fpga_felica", basename(infile_name), 7)) + strncat(dst, "HF FeliCa", len - strlen(dst) - 1); strncat(dst, " image built", len - strlen(dst) - 1); if (bitparse_find_section(infile, 'b', &fpga_info_len)) {