diff --git a/linux-ramdump-parser-v2/dcc.py b/linux-ramdump-parser-v2/dcc.py index 79bd6c91718b05e9b34eb84b46aee0a717da228a..8081f2eaf226a5abc5a150dc46213f3264fc9366 100644 --- a/linux-ramdump-parser-v2/dcc.py +++ b/linux-ramdump-parser-v2/dcc.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015, The Linux Foundation. All rights reserved. +# Copyright (c) 2015, 2017, The Linux Foundation. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 and @@ -10,6 +10,7 @@ # GNU General Public License for more details. import struct +import os from print_out import print_out_str from ramparse import VERSION @@ -56,9 +57,16 @@ class DccRegDump(): outfile.close() class DccSramDump(): - def __init__(self, start, end): + def __init__(self, start, end, ram_dump): self.start_addr = start self.end_addr = end + self.bin_dir = ram_dump.ram_addr + self.bin_dir="\\".join(self.bin_dir[0][0].split('\\')[:-1]) + self.dcc_bin = os.path.join(self.bin_dir, 'DCC_SRAM.BIN') + + if os.path.isfile(self.dcc_bin): + self.start_addr = 0x6000 + self.end_addr = 0x8000 def dump_sram_img(self, ram_dump): if self.start_addr >= self.end_addr: @@ -66,6 +74,9 @@ class DccSramDump(): rsz = self.end_addr - self.start_addr + if os.path.isfile(self.dcc_bin): + return self.dump_sram_img_bin(ram_dump, self.dcc_bin) + if dcc_regs.has_key('DCC_HW_INFO') == False \ or dcc_regs['DCC_HW_INFO'] == 0: print_out_str('DCC HW Info missing! Skipping sram dump...') @@ -80,6 +91,7 @@ class DccSramDump(): return False sramfile = ram_dump.open_file('sram.bin') + for i in range(0, rsz): val = ram_dump.read_byte(self.start_addr + i, False) sramfile.write(struct.pack('<B', val)) @@ -87,3 +99,17 @@ class DccSramDump(): sramfile.close() return True + + def dump_sram_img_bin(self, ram_dump, dcc_bin): + if self.start_addr >= self.end_addr: + return False + + f = open(dcc_bin, 'rb') + f.seek(self.start_addr, 1) + bin_data=f.read() + sramfile = ram_dump.open_file('sram.bin') + sramfile.write(bin_data) + f.close() + sramfile.close() + + return True diff --git a/linux-ramdump-parser-v2/debug_image_v2.py b/linux-ramdump-parser-v2/debug_image_v2.py index 5e6332a970db917c28675cb722962d21fe52b562..8368f30989ffbf86b77b92c84715184858076a2b 100644 --- a/linux-ramdump-parser-v2/debug_image_v2.py +++ b/linux-ramdump-parser-v2/debug_image_v2.py @@ -198,7 +198,7 @@ class DebugImage_v2(): print_out_str( 'Parsing {0} context start {1:x} end {2:x}'.format(client_name, start, end)) - regs = DccSramDump(start, end) + regs = DccSramDump(start, end, ram_dump) if regs.dump_sram_img(ram_dump) is False: print_out_str('!!! Could not dump SRAM') else: @@ -458,9 +458,14 @@ class DebugImage_v2(): sram_file = os.path.join(out_dir, 'sram.bin') else: return - - p = subprocess.Popen([sys.executable, dcc_parser_path, '-s', sram_file, '--out-dir', out_dir], - stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + bin_dir = ram_dump.ram_addr + bin_dir="\\".join(bin_dir[0][0].split('\\')[:-1]) + if (os.path.isfile(os.path.join(bin_dir, 'DCC_SRAM.BIN'))): + p = subprocess.Popen([sys.executable, dcc_parser_path, '-s', sram_file, '--out-dir', out_dir, '--v2'], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + else: + p = subprocess.Popen([sys.executable, dcc_parser_path, '-s', sram_file, '--out-dir', out_dir], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) print_out_str('--------') print_out_str(p.communicate()[0]) diff --git a/linux-ramdump-parser-v2/ramdump.py b/linux-ramdump-parser-v2/ramdump.py index d6814a8da1463bfe6cc31633b43c463fe535736c..dd58a2088ee99abcce370cc4efd8d3d8574efefe 100644 --- a/linux-ramdump-parser-v2/ramdump.py +++ b/linux-ramdump-parser-v2/ramdump.py @@ -549,6 +549,7 @@ class RamDump(): except ImportError: print "Oops, missing required library for minidump. Check README" sys.exit(1) + self.ram_addr = options.ram_addr if options.ram_addr is not None: # TODO sanity check to make sure the memory regions don't overlap