diff --git a/fpga/fpga_icopyx_hf.bit b/fpga/fpga_icopyx_hf.bit index 77d436c59..a7824dd74 100644 Binary files a/fpga/fpga_icopyx_hf.bit and b/fpga/fpga_icopyx_hf.bit differ diff --git a/fpga/fpga_pm3_felica.bit b/fpga/fpga_pm3_felica.bit index b8f8e80cc..386638478 100644 Binary files a/fpga/fpga_pm3_felica.bit and b/fpga/fpga_pm3_felica.bit differ diff --git a/fpga/fpga_pm3_hf.bit b/fpga/fpga_pm3_hf.bit index fdd4bb333..1c159a612 100644 Binary files a/fpga/fpga_pm3_hf.bit and b/fpga/fpga_pm3_hf.bit differ diff --git a/fpga/fpga_pm3_hf_15.bit b/fpga/fpga_pm3_hf_15.bit index f6ee54ecb..055615e71 100644 Binary files a/fpga/fpga_pm3_hf_15.bit and b/fpga/fpga_pm3_hf_15.bit differ diff --git a/fpga/fpga_pm3_lf.bit b/fpga/fpga_pm3_lf.bit index 862b3148e..79485cac1 100644 Binary files a/fpga/fpga_pm3_lf.bit and b/fpga/fpga_pm3_lf.bit differ diff --git a/fpga/strip_date_time_from_binary.py b/fpga/strip_date_time_from_binary.py index 12e34c9dd..cc469ca72 100644 --- a/fpga/strip_date_time_from_binary.py +++ b/fpga/strip_date_time_from_binary.py @@ -15,20 +15,20 @@ def parse_and_split_file(filename): with open(filename, 'rb') as f: # Read as binary to handle non-text files data = f.read(100) # Read first 100 bytes which should contain all information - decoded_data = list(data.decode(errors='ignore')) + decoded_data = bytearray(data) for i in range(len(decoded_data) - 3): # subsequent two bytes after marker are null and the length - next_byte = ord(decoded_data[i+1]) - data_length = ord(decoded_data[i+2]) + next_byte = decoded_data[i+1] + data_length = decoded_data[i+2] - 1 # Don't overwrite terminating char - if decoded_data[i] == split_chars[0] and next_byte == 0x0: + if decoded_data[i] == ord(split_chars[0]) and next_byte == 0x0: start = i+3 - extracted_data.append(''.join(decoded_data[start:start+data_length])) + extracted_data.append(decoded_data[start:start+data_length]) # time, date if split_chars[0] == 'c' or split_chars[0] == 'd': - decoded_data[start:start+data_length] = 'F' * data_length + decoded_data[start:start+data_length] = bytes('F', encoding='ascii') * data_length split_chars.pop(0) @@ -36,7 +36,6 @@ def parse_and_split_file(filename): break print("Extracted data from bitfile: {}".format(extracted_data)) - decoded_data = ''.join(decoded_data).encode() with open(filename, 'r+b') as f: # Write back modified bytes f.seek(0) diff --git a/tools/fpga_compress/fpga_compress.c b/tools/fpga_compress/fpga_compress.c index a623b0b32..a24b035df 100644 --- a/tools/fpga_compress/fpga_compress.c +++ b/tools/fpga_compress/fpga_compress.c @@ -23,6 +23,8 @@ #include "fpga.h" #include "lz4hc.h" +int fileno(FILE *); + #ifndef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) #endif @@ -356,6 +358,8 @@ static int FpgaGatherVersion(FILE *infile, char *infile_name, char *dst, int len for (uint16_t i = 0; i < FPGA_BITSTREAM_FIXED_HEADER_SIZE; i++) { if (fgetc(infile) != bitparse_fixed_header[i]) { fprintf(stderr, "Invalid FPGA file. Aborting...\n\n"); + fprintf(stderr, "File: %s\n", infile_name); + return (EXIT_FAILURE); } }