def try_extract_frf(self, frf_data: bytes): flash_infos = [ simos18.s18_flash_info, simos1810.s1810_flash_info, dq250mqb.dsg_flash_info, simos184.s1841_flash_info, simos16.s16_flash_info, simos12.s12_flash_info, simos122.s122_flash_info, simos10.s10_flash_info, simos8.s8_flash_info, ] for flash_info in flash_infos: try: (flash_data, allowed_boxcodes) = extract_flash.extract_flash_from_frf( frf_data, flash_info, is_dsg=(flash_info is dq250mqb.dsg_flash_info), ) output_blocks = {} for i in flash_info.block_names_frf.keys(): filename = flash_info.block_names_frf[i] output_blocks[filename] = constants.BlockData( i, flash_data[filename], flash_info.number_to_block_name[i]) return [output_blocks, flash_info] except: pass
def flash_bin_file(self, selected_file, patch_cboot=False): input_bytes = Path(self.row_obj_dict[selected_file]).read_bytes() if str.endswith(self.row_obj_dict[selected_file], ".frf"): self.feedback_text.AppendText("Extracting FRF...\n") ( flash_data, allowed_boxcodes, ) = extract_flash.extract_flash_from_frf( input_bytes, self.flash_info, is_dsg=module_selection_is_dsg( self.module_choice.GetSelection()), ) self.input_blocks = {} for i in self.flash_info.block_names_frf.keys(): filename = self.flash_info.block_names_frf[i] self.input_blocks[filename] = constants.BlockData( i, flash_data[filename]) self.flash_bin(get_info=False, should_patch_cboot=patch_cboot) elif len(input_bytes) == self.flash_info.binfile_size: self.input_blocks = binfile.blocks_from_bin( self.row_obj_dict[selected_file], self.flash_info) self.flash_bin(get_info=False, should_patch_cboot=patch_cboot) else: self.feedback_text.AppendText( "File did not appear to be a valid BIN or FRF\n")
def setUpClass(cls): flash_info = simos1810.s1810_flash_info frf_file = Path("frf_test/FL_5G0906259Q__0005.frf") frf_data = frf_file.read_bytes() (cls.frf_raw_blocks, boxcodes) = extract_flash.extract_flash_from_frf( frf_data, flash_info )
def setUpClass(cls): flash_info = dq250mqb.dsg_flash_info frf_file = Path("frf_test/FL_0D9300012_4938_RcJQ_sw.frf") frf_data = frf_file.read_bytes() (cls.frf_raw_blocks, boxcodes) = extract_flash.extract_flash_from_frf( frf_data, flash_info, True )
def input_blocks_from_frf(frf_path: str) -> dict[str, BlockData]: frf_data = Path(frf_path).read_bytes() (flash_data, allowed_boxcodes) = extract_flash_from_frf(frf_data, flash_info, is_dsg=args.dsg) input_blocks = {} for i in flash_info.block_names_frf.keys(): filename = flash_info.block_names_frf[i] input_blocks[filename] = BlockData(i, flash_data[filename]) return input_blocks
def flash_unlock(self, selected_file): if module_selection_is_dsg(self.module_choice.GetSelection()): self.feedback_text.AppendText( "SKIPPED: Unlocking is unnecessary for DSG\n") return input_bytes = Path(self.row_obj_dict[selected_file]).read_bytes() if str.endswith(self.row_obj_dict[selected_file], ".frf"): self.feedback_text.AppendText("Extracting FRF for unlock...\n") ( flash_data, allowed_boxcodes, ) = extract_flash.extract_flash_from_frf( input_bytes, self.flash_info, is_dsg=module_selection_is_dsg( self.module_choice.GetSelection()), ) self.input_blocks = {} for i in self.flash_info.block_names_frf.keys(): filename = self.flash_info.block_names_frf[i] self.input_blocks[filename] = constants.BlockData( i, flash_data[filename]) cal_block = self.input_blocks[self.flash_info.block_names_frf[5]] file_box_code = str( cal_block.block_bytes[self.flash_info. box_code_location[5][0]:self.flash_info. box_code_location[5][1]].decode()) if (file_box_code.strip() != self.flash_info.patch_info. patch_box_code.split("_")[0].strip()): self.feedback_text.AppendText( f"Boxcode mismatch for unlocking. Got box code {file_box_code} but expected {self.flash_info.patch_box_code}. Please don't try to be clever. Supply the correct file and the process will work." ) return self.input_blocks["UNLOCK_PATCH"] = constants.BlockData( self.flash_info.patch_info.patch_block_index + 5, Path(self.flash_info.patch_info.patch_filename).read_bytes(), ) key_order = list( map(lambda i: self.flash_info.block_names_frf[i], [1, 2, 3, 4, 5])) key_order.insert(4, "UNLOCK_PATCH") input_blocks_with_patch = { k: self.input_blocks[k] for k in key_order } self.input_blocks = input_blocks_with_patch self.flash_bin(get_info=False) else: self.feedback_text.AppendText( "File did not appear to be a valid FRF. Unlocking is possible only with a specific FRF file for your ECU family.\n" )