Skip to content
Snippets Groups Projects
Commit 6c908018 authored by Sri Krishna Madireddy's avatar Sri Krishna Madireddy
Browse files

lrdp-v2: dcc_parser: Add support to parse DCC BIN file

Add support for generating sram.bin from DCC_SRAM.BIN
With this NEW sram will call version 2 of DCC driver
for parsing.

Change-Id: If8012b1f38ba29daa5bdac2fd15820de51ea9cab
parent 614fd5b3
No related branches found
No related tags found
No related merge requests found
# 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
......@@ -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])
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment