示例#1
0
def dump(dump_path, memory, debug_info, target_family):
    global ee_names
    ee_names = ee_names_family[target_family]
    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['rpm_core_dump'].vartype
    rpm_core_dump = decode_object('rpm_core_dump', address, dump_type, memory,
                                  debug_info)

    #import pdb; pdb.set_trace()
    rpm = cast(rpm_core_dump.rpmserver_state, 'SystemData', memory, debug_info)
    '''
    rpm_type = rpm_core_dump._find_basic_type(debug_info.variables['rpm'].die)
    rpm_type = rpm_core_dump._unwrap(rpm_type) # "dereference" the type--rpm_core_dump already points at the state itself
    rpm_type = rpm_core_dump._find_basic_type(rpm_type)
    rpm_state = rpm_core_dump.rpmserver_state.address
    rpm = decode_object('rpm', rpm_state, None, memory, debug_info, die=rpm_type)
    '''

    #save_logger_level = logging.getLogger('dwarf').getEffectiveLevel()
    #logging.getLogger('dwarf').setLevel(logging.DEBUG)
    dump_ee_status(dump_path, rpm, memory, debug_info)
    #logging.getLogger('dwarf').setLevel(save_logger_level)
    dump_ee_requests(dump_path, rpm, memory, debug_info)
    dump_resource_requests(dump_path, rpm, memory, debug_info)
    dump_lookup_table(dump_path, rpm, memory, debug_info)
    dump_estimate_cache(dump_path, rpm, memory, debug_info)
示例#2
0
def dump(dump_path, memory, debug_info):
    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['rpm_core_dump'].vartype
    rpm_core_dump = decode_object('rpm_core_dump', address, dump_type, memory,
                                  debug_info)
    dev_num = rpm_core_dump.hw_version.parts.device_number

    rpm = cast(rpm_core_dump.rpmserver_state, 'SystemData', memory, debug_info)

    if 'rpm_image_section_array' not in debug_info.variables:
        print_p('\t rpm_image_section_array not found in debug')

    else:
        try:
            rbcpr_type = debug_info.variables['rbcpr_stats_header'].vartype
            rbcpr_address = debug_info.variables[
                'rpm_image_section_array'].address
            rbcpr_address = rbcpr_address + 24
            rbcpr_stats = decode_object('rbcpr_stats', rbcpr_address,
                                        rbcpr_type, memory, debug_info)
        except:
            rbcpr_die = debug_info.variables['rbcpr_stats_header'].die
            rbcpr_address = debug_info.variables[
                'rpm_image_section_array'].address
            rbcpr_address = rbcpr_address + 24
            rbcpr_stats = decode_object('rbcpr_stats',
                                        rbcpr_address,
                                        None,
                                        memory,
                                        debug_info,
                                        die=rbcpr_die)

    dump_rbcpr(dump_path, rpm, rbcpr_stats, memory, debug_info, dev_num)
示例#3
0
def dump(dump_path, memory, debug_info, ocimem_load, pmic_rtc_load):
    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['rpm_core_dump'].vartype
    rpm_core_dump = decode_object('rpm_core_dump', address, dump_type, memory, debug_info)

    #import pdb; pdb.set_trace()
    rpm = cast(rpm_core_dump.rpmserver_state, 'SystemData', memory, debug_info)

    #save_logger_level = update_logger(logging.DEBUG, logging)
    dump_wdog(dump_path, rpm, memory, debug_info, ocimem_load, pmic_rtc_load)
示例#4
0
def dump(dump_path, memory, debug_info):
    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['rpm_core_dump'].vartype
    rpm_core_dump = decode_object('rpm_core_dump', address, dump_type, memory, debug_info)

    #import pdb; pdb.set_trace()
    rpm = cast(rpm_core_dump.rpmserver_state, 'SystemData', memory, debug_info)

    #save_logger_level = logging.getLogger('dwarf').getEffectiveLevel()
    #print(save_logger_level)
    #logging.getLogger('dwarf').setLevel(logging.DEBUG)
    #print(logging.getLogger('dwarf').getEffectiveLevel())
    dump_railway(dump_path, rpm, memory, debug_info)
示例#5
0
def dump(dump_path, memory, debug_info):
    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['rpm_core_dump'].vartype
    rpm_core_dump = decode_object('rpm_core_dump', address, dump_type, memory, debug_info)

    npa_type = debug_info.variables['npa'].vartype
    npa_state = rpm_core_dump.npa_state.address
    npa = decode_object('npa', npa_state, npa_type, memory, debug_info)

    dump_file = open(os.path.join(dump_path, 'npa-dump.txt'), 'w')

    link = npa.resources
    while link.address != 0:
        dump_link(dump_file, link)
        link = link.next
示例#6
0
def dump(debug_data):  #dump_path, memory, debug_info):
    memory = debug_data['rpm_memory']
    debug_info = debug_data['debug_info']
    dump_path = debug_data['dump_path']

    debug_data['printer'].p("Dumping sleep stats...")

    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['aop_core_dump'].vartype
    aop_core_dump = decode_object('aop_core_dump', address, dump_type, memory,
                                  debug_info)

    rpm = 0  #cast(aop_core_dump.rpmserver_state, 'SystemData', memory, debug_info)

    if (check_member('sleep_stats', aop_core_dump)):
        #sleep_stats in in core dump
        sleep = aop_core_dump.sleep_stats
        sleep = cast(sleep, 'sleep_stats_type', memory, debug_info)
    else:
        try:
            sleep_type = debug_info.variables['sleep_stats'].die
        except:
            sleep_file_name = os.path.join(dump_path, 'sleep_stats.txt')
            with open(sleep_file_name, 'w') as sleep_file:
                print(
                    "\n !!! SLEEP_STATS DOES NOT EXIST, SLEEP IS LIKELY NOT ENABLED !!! \n",
                    file=sleep_file)
            return
        try:
            #not in core dump, but elf is close enough to provide a correct pointer
            sleep_address = debug_info.variables[
                'sleep_stats'].address  # FIXME: get right address by magic
            sleep = decode_object('sleep_stats',
                                  sleep_address,
                                  None,
                                  memory,
                                  debug_info,
                                  die=sleep_type)
        except:
            sleep_file_name = os.path.join(dump_path, 'sleep_stats.txt')
            with open(sleep_file_name, 'w') as sleep_file:
                print(
                    "\n !!! SLEEP_STATS DOES NOT EXIST, SLEEP IS LIKELY NOT ENABLED !!! \n",
                    file=sleep_file)
            return
    dump_sleep(dump_path, rpm, sleep, memory, debug_info)
示例#7
0
def dump(dump_path, memory, debug_info):
    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['rpm_core_dump'].vartype
    rpm_core_dump = decode_object('rpm_core_dump', address, dump_type, memory,
                                  debug_info)

    rpm = cast(rpm_core_dump.rpmserver_state, 'SystemData', memory, debug_info)

    if (check_member('sleep_stats', rpm_core_dump)):
        #sleep_stats in in core dump
        sleep = rpm_core_dump.sleep_stats
        sleep = cast(sleep, 'sleep_stats_type', memory, debug_info)
    else:
        try:
            #not in core dump, but elf is close enough to provide a correct pointer
            sleep_type = debug_info.variables['sleep_stats'].die
            sleep_address = debug_info.variables[
                'sleep_stats'].address  # FIXME: get right address by magic
            sleep = decode_object('sleep_stats',
                                  sleep_address,
                                  None,
                                  memory,
                                  debug_info,
                                  die=sleep_type)
        except:
            #not correct in elf, find absolute address (very hacky)
            sleep_type = debug_info.variables['sleep_stats'].die
            sleep_address = find_value(0x0019DBA0, 4, 0x00190000, 0x0019FFFF,
                                       memory)
            sleep = decode_object('sleep_stats',
                                  sleep_address,
                                  None,
                                  memory,
                                  debug_info,
                                  die=sleep_type)
    '''
    print(debug_info.variables['sleep_stats'].die)
    #sleep_address = 0x0019DBA0
    sleep_address = debug_info.variables['sleep_stats'].address
    sleep = decode_object('sleep_stats', sleep_address, sleep_type, memory, debug_info)
    '''

    #save_logger_level = update_logger(logging.DEBUG, logging)
    dump_sleep(dump_path, rpm, sleep, memory, debug_info)
示例#8
0
def dump(debug_data): #dump_path, memory, debug_info):
    memory = debug_data['rpm_memory']
    debug_info = debug_data['debug_info']
    dump_path = debug_data['dump_path']

    debug_data['printer'].p("Dumping Frequency switch info...")

    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['aop_core_dump'].vartype
    aop_core_dump = decode_object('aop_core_dump', address, dump_type, memory, debug_info)

    rpm = 0#cast(aop_core_dump.rpmserver_state, 'SystemData', memory, debug_info)

    if (check_member('freq_switch_table_ptr ', aop_core_dump)):
        #freq_switch_table_ptr in in core dump
        freq_switch = aop_core_dump.freq_switch_table_ptr
        freq_switch = cast(freq_switch, 'ddr_stats_type', memory, debug_info)
    else:
        try:
            freq_switch_type = debug_info.variables['freq_switch_table_ptr'].die
        except:
            freq_switch_file_name = os.path.join(dump_path, 'ddr_stats.txt')
            with open(freq_switch_file_name, 'a') as freq_switch_file:
                print("\n !!! FREQ SWITCH INFO DOES NOT EXIST !!! \n", file=freq_switch_file)
            return
        try:
            #not in core dump, but elf is close enough to provide a correct pointer
            freq_switch_address = debug_info.variables['freq_switch_table_ptr'].address # FIXME: get right address by magic
            freq_switch = decode_object('freq_switch_table_ptr', freq_switch_address, None, memory, debug_info, die=freq_switch_type)
        except:
            freq_switch_file_name = os.path.join(dump_path, 'ddr_stats.txt')
            with open(freq_switch_file_name, 'a') as freq_switch_file:
                print("\n !!! FREQ SWITCH INFO DOES NOT EXIST !!! \n", file=freq_switch_file)
            return
	
	#import pdb; pdb.set_trace()
	dump_ddr(dump_path, rpm, freq_switch, memory, debug_info)
示例#9
0
def dump(debug_data):  #dump_path, memory, debug_info):
    global dump_error
    dump_error = 0
    memory = debug_data['rpm_memory']
    debug_info = debug_data['debug_info']
    dump_path = debug_data['dump_path']
    reclaim = debug_data['reclaim_pool']

    debug_data['printer'].p("Dumping NPA state...")

    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['aop_core_dump'].vartype
    aop_core_dump = decode_object('aop_core_dump', address, dump_type, memory,
                                  debug_info)

    unpa_type = debug_info.variables['unpa'].die
    unpa_address = debug_info.variables['unpa'].address
    unpa = decode_object('unpa',
                         unpa_address,
                         None,
                         memory,
                         debug_info,
                         die=unpa_type)

    dump_file = open(os.path.join(dump_path, 'npa-dump.txt'), 'w')

    link = unpa.resources
    while link.address != 0:
        dump_link(dump_file, link, reclaim)
        link = link.next

    if dump_error != 0:
        debug_data['printer'].p(
            "\t...Non-critical errors occured in processing dump, continuing")
    else:
        debug_data['printer'].p("\t...DONE")
示例#10
0
def dump_bcm_vts(dump_path, memory, target, debug_info, fill_char,
                 bcm_json_dir):

    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['aop_core_dump'].vartype
    aop_core_dump = decode_object('aop_core_dump', address, dump_type, memory,
                                  debug_info)
    json_file_name = os.path.join(bcm_json_dir, str(target) + "/VCD.json")

    with open(json_file_name, 'r') as data_file:
        data = json.load(data_file)
####################################################################################################################

    if (check_member('global_ddr_cfg ', aop_core_dump)):
        ddr_cfg = aop_core_dump.global_ddr_cfg
        ddr_cfg = cast(ddr_cfg, 'DDRCfgType', memory, debug_info)
    else:
        try:
            ddr_cfg_address = debug_info.variables['global_ddr_cfg'].die
        except:
            ddr_file_name = os.path.join(dump_path, 'ddr_stats.txt')
            with open(ddr_file_name, 'w') as ddr_file:
                print("\n !!! DDR_CFG DOES NOT EXIST !!! \n", file=ddr_file)

        try:
            #not in core dump, but elf is close enough to provide a correct pointer
            ddr_gbl_address = debug_info.variables[
                'global_ddr_cfg'].address  # FIXME: get right address by magic
            ddr_cfg = decode_object('global_ddr_cfg',
                                    ddr_gbl_address,
                                    None,
                                    memory,
                                    debug_info,
                                    die=ddr_cfg_address)
        except:
            #not correct in elf, find absolute address (very hacky)
            with open(ddr_file_name, 'w') as ddr_file:
                print("\n !!! DDR_cfg DOES NOT EXIST !!! \n", file=ddr_file)
    ####################################################################################################################
    if (check_member('ddr_status', aop_core_dump)):
        #ddr_status in in core dump
        ddr_status = aop_core_dump.ddr_status
        ddr_status = cast(ddr_status, 'ddr_state', memory,
                          debug_info)  ###################################
    else:
        try:
            freq_switch_address = debug_info.variables[
                'ddr_status'].die  ###################################
        except:
            ddr_file_name = os.path.join(dump_path, 'ddr_stats.txt')
            with open(ddr_file_name, 'w') as ddr_file:
                print("\n !!! DDR_STATUS DOES NOT EXIST !!! \n", file=ddr_file)
            return
        try:
            #not in core dump, but elf is close enough to provide a correct pointer
            ddr_status_address = debug_info.variables[
                'ddr_status'].address  # FIXME: get right address by magic
            ddr_status = decode_object('ddr_status',
                                       ddr_status_address,
                                       None,
                                       memory,
                                       debug_info,
                                       die=freq_switch_address)
        except:
            #not correct in elf, find absolute address (very hacky)
            with open(ddr_file_name, 'w') as ddr_file:
                print("\n !!! DDR_STATUS DOES NOT EXIST !!! \n", file=ddr_file)
            ####################################################################################################################

    dump_path = os.path.join(dump_path, 'reqs_for_resources')
    if not os.path.exists(dump_path):
        os.makedirs(dump_path)
    bcm_file_name = os.path.join(dump_path, 'bcm_vt.txt')
    summary_file_name = os.path.join(dump_path, 'rpmh_summary.txt')

    with open(bcm_file_name, 'w') as bcm_file, open(summary_file_name,
                                                    'a') as summary_file:

        print("\n\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
              file=bcm_file)
        print("\t| VCD |                  Nodes                  |",
              file=bcm_file)
        print("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
              file=bcm_file)
        for x in range(0, no_vcds):
            print("\t|{0:>5d}|{1:>41s}|".format(x, vcd_map_table[x]),
                  file=bcm_file)
        print("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
              file=bcm_file)

        print("\n ~~BCM Status Front End~~", file=bcm_file)
        print(
            "\n\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
            file=bcm_file)
        print(
            "\t|       VCD             | AGG_BW | Final_CP | AGG_CP | DDR MGR Override AGG_CP |                   Freq_khz                     |",
            file=bcm_file)
        print(
            "\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
            file=bcm_file)
        for x in range(0, no_vcds):
            address = bcm_status_fe + (0x4 * x)
            fe_data = memory.read(address, 4)
            fe_status = struct.unpack('<L', fe_data)[0]
            agg_cp = fe_status & 0xF
            final_cp = ((fe_status >> 4) & 0xF)
            agg_bw = ((fe_status >> 16) & 0x3FFF)

            # if x==0: #mc
            # for x in range(0, ddr_cfg.nNumMCStates):
            # if (ddr_cfg.pMCCfg[x].clk_idx==agg_cp):
            # frq=ddr_cfg.pMCCfg[x].freq_khz

            # elif x==1: #shub
            # for y in range(0, ddr_cfg.nNumSHUBStates):
            # if (ddr_cfg.pSHUBCfg[y].clk_idx==agg_cp):
            # frq=ddr_cfg.pSHUBCfg[y].freq_khz

            ddr_mc_cp = hex(ddr_status.current_mc_cp)
            ddr_shub_cp = hex(ddr_status.current_shub_cp)

            flag = 0
            for key, value in data.items():
                if (data[key]["VCD Index"] == x):
                    if (x == 0):
                        v5 = str(ddr_mc_cp)
                        if (ddr_mc_cp != 0x0):
                            flag = 1
                            var_print = key
                            v1 = hex(agg_bw)
                            v2 = hex(final_cp)
                            v3 = hex(agg_cp)
                            v4 = str(x) + ":"
                            for y in data[key]["Clock Domains"]:
                                print(
                                    "\t|{0:3s}{1:>20s}|{2:>8s}|{3:>10s}|{4:>8s}|{5:>25s}|{6:30s}: {7:>17s}|"
                                    .format(v4, var_print, v1, v2, v3, v5,
                                            y["domain"], (str(y["freq"][int(
                                                ddr_mc_cp,
                                                16)]).split(":")[1])[3:-2]),
                                    file=bcm_file)
                                var_print = ""
                                v1 = ""
                                v2 = ""
                                v3 = ""
                                v4 = ""
                                v5 = ""

                    elif (x == 1):
                        v5 = str(ddr_shub_cp)
                        if (ddr_shub_cp != 0x0):
                            flag = 1
                            var_print = key
                            v1 = hex(agg_bw)
                            v2 = hex(final_cp)
                            v3 = hex(agg_cp)
                            v4 = str(x) + ":"
                            for y in data[key]["Clock Domains"]:
                                print(
                                    "\t|{0:3s}{1:>20s}|{2:>8s}|{3:>10s}|{4:>8s}|{5:>25s}|{6:30s}: {7:>17s}|"
                                    .format(v4, var_print, v1, v2, v3, v5,
                                            y["domain"], (str(y["freq"][int(
                                                ddr_shub_cp,
                                                16)]).split(":")[1])[3:-2]),
                                    file=bcm_file)
                                var_print = ""
                                v1 = ""
                                v2 = ""
                                v3 = ""
                                v4 = ""
                                v5 = ""
                    else:
                        v5 = "NA"
                        if (agg_cp != 0):
                            flag = 1
                            var_print = key
                            v1 = hex(agg_bw)
                            v2 = hex(final_cp)
                            v3 = hex(agg_cp)
                            v4 = str(x) + ":"
                            for y in data[key]["Clock Domains"]:
                                print(
                                    "\t|{0:3s}{1:>20s}|{2:>8s}|{3:>10s}|{4:>8s}|{5:>25s}|{6:30s}: {7:>17s}|"
                                    .format(
                                        v4, var_print, v1, v2, v3, v5,
                                        y["domain"],
                                        (str(y["freq"][agg_cp]).split(":")[1]
                                         )[3:-2]),
                                    file=bcm_file)
                                var_print = ""
                                v1 = ""
                                v2 = ""
                                v3 = ""
                                v4 = ""
                                v5 = ""

            if (flag == 0):
                v6 = str(x) + ":"
                print("\t|{0:<23s}|{1:>8s}|{2:>10s}|{3:>8s}|{4:>25s}|{5:50s}|".
                      format(v6, hex(agg_bw), hex(final_cp), hex(agg_cp), "NA",
                             ""),
                      file=bcm_file)
            print(
                "\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
                file=bcm_file)

        print("\n ~~BCM Status Back End~~", file=bcm_file)
        print(
            "\n\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
            file=bcm_file)
        print(
            "\t| VCD | Clk_dest_state | Combined_CP | SW_CP_SNAP | Written_CP | CURR_CP |",
            file=bcm_file)
        print(
            "\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
            file=bcm_file)
        for x in range(0, no_vcds):
            address = bcm_status_be + (0x4 * x)
            fe_data = memory.read(address, 4)
            fe_status = struct.unpack('<L', fe_data)[0]
            curr_cp = fe_status & 0xF
            written_cp = ((fe_status >> 4) & 0xF)
            sw_cp = ((fe_status >> 8) & 0xF)
            combined_cp = ((fe_status >> 12) & 0xF)
            clk_dest = ((fe_status >> 16) & 0xF)
            print("\t|{0:>5d}|{1:>16s}|{2:>13s}|{3:>12s}|{4:>12s}|{5:>9s}|".
                  format(x, hex(clk_dest), hex(combined_cp), hex(sw_cp),
                         hex(written_cp), hex(curr_cp)),
                  file=bcm_file)
        print(
            "\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
            file=bcm_file)

        print("\n ~~BCM Back End Sequencer~~", file=bcm_file)
        print("\n ~~BCM Status~~", file=summary_file)
        print("\n\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~", file=bcm_file)
        print("\t| VCD | SEQ_CURR_PC | IDLE |", file=bcm_file)
        print("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", file=bcm_file)
        for x in range(0, no_vcds):
            address = bcm_status_be_seq + (0x4 * x)
            fe_data = memory.read(address, 4)
            fe_status = struct.unpack('<L', fe_data)[0]
            seq_state = fe_status & 0x1
            curr_pc = ((fe_status >> 8) & 0xFF)
            print("\t|{0:>5d}|{1:>8s}|{2:>10s}|".format(
                x, hex(curr_pc), hex(seq_state)),
                  file=bcm_file)
            if seq_state:
                print("\tVCD %d is Idle" % (x), file=summary_file)
            else:
                print("\tVCD %d is Busy" % (x), file=summary_file)
        print("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", file=bcm_file)

        print("\n\n ~~BCM Resource Summary~~", file=bcm_file)
        #import pdb; pdb.set_trace()
        for regs in range(0, no_regs):
            if bcm_map_table[regs] == ' ':
                continue
            print('\n\n\t BCM [%d] : %s ' % (regs, bcm_map_table[regs]),
                  file=bcm_file)
            print("\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
                  file=bcm_file)
            print("\t\t|    DRV   | ID | Valid |   AB   |   IB   |",
                  file=bcm_file)
            print("\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
                  file=bcm_file)

            for drv in range(0, no_drv):
                address = vt_base_address + (0x10000 * drv) + (0x4 * regs)
                bcm_data = memory.read(address, 4)
                bcm_vt = struct.unpack('<L', bcm_data)[0]
                vote_valid = ((bcm_vt >> 29) & 0x1)
                vote_x = ((bcm_vt >> 14) & 0x3FFF)
                vote_y = (bcm_vt & 0x3FFF)
                if bcm_vt != 0:
                    print("\t\t|{0:>10s}|{1:>4d}|{2:>7d}|{3:>8s}|{4:>8s}|".
                          format((targ_spec_config[target]['drv'][drv]), drv,
                                 vote_valid, hex(vote_x), hex(vote_y)),
                          file=bcm_file)
                BCM_votetable[regs][drv] = [vote_valid, vote_x, vote_y]
示例#11
0
def dump(debug_data
         ):  #dump_path, parse_path, memory, debug_info, target, branch):
    memory = debug_data['rpm_memory']
    debug_info = debug_data['debug_info']
    dump_path = debug_data['dump_path']
    parse_path = debug_data['args'].parser
    target = debug_data['target']
    branch = debug_data['branch']
    parse_tbl = debug_data['parser_tbl']
    debug_data['printer'].p("Dumping ulogs...")

    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['aop_core_dump'].vartype
    aop_core_dump = decode_object('aop_core_dump', address, dump_type, memory,
                                  debug_info)

    rpm_ulogContext_type = debug_info.variables['rpm_ulogContext'].vartype
    ulog_state = aop_core_dump.ulog_state.address
    rpm_ulogContext = decode_object('rpm_ulogContext', ulog_state,
                                    rpm_ulogContext_type, memory, debug_info)

    log = rpm_ulogContext.logHead
    if log.address == 0:
        logger.error(
            'Failed to find any RPM ulogs (rpm_ulogContext.logHead == NULL)!')
        return

    if log.version != 0x1000:
        logger.error(
            'This script only knows how to dump RPM ULog version 0x1000 (Originating July 2012)'
        )
        if log.version in [2, 3, 4]:
            logger.error('It appears your logs are version %d' % log.version)
        else:
            logger.error(
                'Your log version (%d) is unknown to this script.  Is your log corrupted?'
                % log.version)
        return

    while log.address != 0:
        log_name = ''.join(
            itertools.takewhile(lambda c: c != '\0',
                                (chr(c) for c in log.name)))

        log_enabled = (log.logStatus & 0x2) != 0
        if not log_enabled:
            logger.debug('Not dumping ulog (disabled): %d' % log_name)
            continue

        use_64_bit_timestamps = (log.feature_flags1 & 0x1) != 0

        logger.debug('Dumping ulog: %s' % log_name)
        log_file_name = os.path.join(dump_path, '%s.ulog' % log_name)
        with open(log_file_name, 'w') as log_file:
            log_buffer = log.buffer
            log_size = log.bufSize
            log_mask = log.bufSizeMask
            read = log.readWriter
            readers_read = log.read
            write = log.write
            bytes_in_log = write - read

            if bytes_in_log > log_size:
                logger.warning(
                    'While parsing ulog "%s" -> reported log size %d bigger than the expected log size %d'
                    % (log_name, bytes_in_log, log_size))
                logger.warning(
                    'The most common cause of this is memory corruption, under-voltage, or writes to unpowered RAM.'
                )
                logger.warning(
                    'Will try to continue with this ULog decode, but results may be unpredictable.'
                )

            while read < write:
                # Advance past the message format value
                read = read + 2

                # Read the number of bytes in this message
                msg_length = log_buffer[read & log_mask] + (log_buffer[
                    (read + 1) & log_mask] << 8)

                # Back up to the format for later
                read = read - 2

                # Handle the current ULog message
                dump_ulog_msg(log_file, log_buffer, log_mask, read, msg_length)

                # Move our read pointer past the message we just finished (and 4 byte align it)
                read = read + ((msg_length + 3) & 0xFFFFFFFC)

        log = log.next

    # Now run the second-stage parsing script, if applicable.
    rpm_external_log = os.path.join(dump_path, 'AOP External Log.ulog')
    if os.path.exists(rpm_external_log):
        print_p('\t\tPost-processing the AOP "external" log...')
        parser = parse_path + 'aop_log_hfam.py'
        parser2 = parse_tbl + 'tracer_event_tbl.h'
        parser_params = [
            'python', parser, '-f', rpm_external_log, '-t', target, '-tbl',
            parser2
        ]  #, '-b', branch]

        try:
            pretty_output = subprocess.check_output(parser_params)
            pretty_output = pretty_output.replace('\r\n', '\n')
        except subprocess.CalledProcessError:
            pretty_output = '<failed to run log parser>\n'
        with open(os.path.join(dump_path, 'aop-rawts.txt'), 'w') as pretty_log:
            pretty_log.write(pretty_output)

        try:
            parser_params = parser_params + ['-p']
            raw_output = subprocess.check_output(parser_params)
            raw_output = raw_output.replace('\r\n', '\n')
        except subprocess.CalledProcessError:
            raw_output = '<failed to run log parser>\n'
        with open(os.path.join(dump_path, 'aop-log.txt'), 'w') as raw_log:
            raw_log.write(raw_output)

    #import pdb; pdb.set_trace()
    # Now run the second-stage parsing script, if applicable.
    ddr_external_log = os.path.join(dump_path, 'AOP DDR Log.ulog')
    if os.path.exists(rpm_external_log):
        print_p('\t\tPost-processing the AOP "DDR" log...')
        parser = parse_path + 'aop_log_hfam.py'
        parser2 = parse_tbl + 'tracer_event_tbl.h'
        parser_params = [
            'python', parser, '-f', ddr_external_log, '-t', target, '-tbl',
            parser2
        ]  #, '-b', branch]

        try:
            pretty_output = subprocess.check_output(parser_params)
            pretty_output = pretty_output.replace('\r\n', '\n')
        except subprocess.CalledProcessError:
            pretty_output = '<failed to run log parser>\n'
        with open(os.path.join(dump_path, 'ddr-rawts.txt'), 'w') as pretty_log:
            pretty_log.write(pretty_output)

        try:
            parser_params = parser_params + ['-p']
            raw_output = subprocess.check_output(parser_params)
            raw_output = raw_output.replace('\r\n', '\n')
        except subprocess.CalledProcessError:
            raw_output = '<failed to run log parser>\n'
        with open(os.path.join(dump_path, 'ddr-log.txt'), 'w') as raw_log:
            raw_log.write(raw_output)
示例#12
0
def dump(debug_data):  #dump_path, memory, debug_info):
    memory = debug_data['rpm_memory']
    debug_info = debug_data['debug_info']
    dump_path = debug_data['dump_path']

    debug_data['printer'].p("Dumping DDR stats...")

    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['aop_core_dump'].vartype
    aop_core_dump = decode_object('aop_core_dump', address, dump_type, memory,
                                  debug_info)

    if (check_member('ddr_stats', aop_core_dump)):
        #ddr_stats in in core dump
        ddr = aop_core_dump.ddr_stats
        ddr = cast(ddr, 'ddr_stats_type', memory, debug_info)
    else:
        try:
            freq_switch_address = debug_info.variables['ddr_stats'].die
        except:
            ddr_file_name = os.path.join(dump_path, 'ddr_stats.txt')
            with open(ddr_file_name, 'w') as ddr_file:
                print("\n !!! DDR_STATS DOES NOT EXIST !!! \n", file=ddr_file)
            return
        try:
            #not in core dump, but elf is close enough to provide a correct pointer
            ddr_address = debug_info.variables[
                'ddr_stats'].address  # FIXME: get right address by magic
            ddr = decode_object('ddr_stats',
                                ddr_address,
                                None,
                                memory,
                                debug_info,
                                die=freq_switch_address)
        except:
            #not correct in elf, find absolute address (very hacky)
            with open(ddr_file_name, 'w') as ddr_file:
                print("\n !!! DDR_STATS DOES NOT EXIST !!! \n", file=ddr_file)
            return
################################################################################################################################
#import pdb; pdb.set_trace()
        if (check_member('ddr_status', aop_core_dump)):
            #ddr_status in in core dump
            ddr_status = aop_core_dump.ddr_status
            ddr_status = cast(ddr_status, 'ddr_state', memory,
                              debug_info)  ###################################
        else:
            try:
                freq_switch_address = debug_info.variables[
                    'ddr_status'].die  ###################################
            except:
                ddr_file_name = os.path.join(dump_path, 'ddr_stats.txt')
                with open(ddr_file_name, 'w') as ddr_file:
                    print("\n !!! DDR_STATUS DOES NOT EXIST !!! \n",
                          file=ddr_file)
                return
            try:
                #not in core dump, but elf is close enough to provide a correct pointer
                ddr_status_address = debug_info.variables[
                    'ddr_status'].address  # FIXME: get right address by magic
                ddr_status = decode_object('ddr_status',
                                           ddr_status_address,
                                           None,
                                           memory,
                                           debug_info,
                                           die=freq_switch_address)
            except:
                #not correct in elf, find absolute address (very hacky)
                with open(ddr_file_name, 'w') as ddr_file:
                    print("\n !!! DDR_STATUS DOES NOT EXIST !!! \n",
                          file=ddr_file)
                return


################################################################################################################################
    if (check_member('global_ddr_cfg ', aop_core_dump)):
        #global_ddr_cfg  in in core dump
        ddr_cfg = aop_core_dump.global_ddr_cfg
        ddr_cfg = cast(ddr_cfg, 'DDRCfgType', memory, debug_info)
    else:
        try:
            ddr_cfg_address = debug_info.variables['global_ddr_cfg'].die
        except:
            ddr_file_name = os.path.join(dump_path, 'ddr_stats.txt')
            with open(ddr_file_name, 'w') as ddr_file:
                print("\n !!! DDR_CFG DOES NOT EXIST !!! \n", file=ddr_file)
            return
        try:
            #not in core dump, but elf is close enough to provide a correct pointer
            ddr_gbl_address = debug_info.variables[
                'global_ddr_cfg'].address  # FIXME: get right address by magic
            ddr_cfg = decode_object('global_ddr_cfg',
                                    ddr_gbl_address,
                                    None,
                                    memory,
                                    debug_info,
                                    die=ddr_cfg_address)
        except:
            #not correct in elf, find absolute address (very hacky)
            with open(ddr_file_name, 'w') as ddr_file:
                print("\n !!! DDR_cfg DOES NOT EXIST !!! \n", file=ddr_file)
            return

    #import pdb; pdb.set_trace()
    #save_logger_level = update_logger(logging.DEBUG, logging)
    dump_ddr(dump_path, ddr_cfg, ddr, ddr_status, memory, debug_info)
示例#13
0
def dump(debug_data): #dump_path, memory, debug_info, base_address):
    memory = debug_data['rpm_memory']
    debug_info = debug_data['debug_info']
    dump_path = debug_data['dump_path']
    base_address = debug_data['image_strings_addr']
    global chip_version 
    dump = open(os.path.join(dump_path, 'aop-summary.txt'), 'w')

    try:
        chipFamilyNum_die = debug_info.variables['chipFamilyNum'].die
        chipDeviceNum_die = debug_info.variables['chipDeviceNum'].die
        chipMinor_die = debug_info.variables['chipMinor'].die
        chipMajor_die = debug_info.variables['chipMajor'].die		
    except:
        print("\n !!! ChipInfoCtxt DOES NOT EXIST !!! \n", file=ddr_file)
        return
    try:
        #not in core dump, but elf is close enough to provide a correct pointer
        chipFamilyNum_address = debug_info.variables['chipFamilyNum'].address # FIXME: get right address by magic
        chipFamilyNum = decode_object('chipFamilyNum', chipFamilyNum_address, None, memory, debug_info, die=chipFamilyNum_die)

        chipDeviceNum_address = debug_info.variables['chipDeviceNum'].address # FIXME: get right address by magic
        chipDeviceNum = decode_object('chipDeviceNum', chipDeviceNum_address, None, memory, debug_info, die=chipDeviceNum_die)

        chipMinor_address = debug_info.variables['chipMinor'].address # FIXME: get right address by magic
        chipMinor = decode_object('chipMinor', chipMinor_address, None, memory, debug_info, die=chipMinor_die)

        chipMajor_address = debug_info.variables['chipMajor'].address # FIXME: get right address by magic
        chipMajor = decode_object('chipMajor', chipMajor_address, None, memory, debug_info, die=chipMajor_die)
    except:
        print("\n !!! ChipInfoCtxt DOES NOT EXIST !!! \n", file=ddr_file)
        return
    chip_version = chipMajor
	
    version_address_start = base_address + 0x0
    version_address_end   = version_address_start + 0x1000
    
    #regex to match the RPM branch name:
    regex = '^AOP\.HO\.\d\.\d.*(?=-)'
    


    address = locate_core_dump(memory, debug_info)
    dump_type = debug_info.variables['aop_core_dump'].vartype
    aop_core_dump = decode_object('aop_core_dump', address, dump_type, memory, debug_info)

    
    chip_name = '<unknown device -> family %d device %d>' % (chipFamilyNum, chipDeviceNum)
    target_chip = chips.get(chipFamilyNum, {}).get(chipDeviceNum, {})
    chip_name = target_chip.get('MSM_ID', chip_name)
    print('\nCollected from %s %d.%d\n' % (chip_name, chipMajor, chipMinor), file=dump)
    
    rpm_ver_type = debug_info.variables['aop_core_dump'].vartype
    
    #rpm_build_date_type = debug_info.variables['gBuildDate'].die
    #rpm_build_date_address = debug_info.variables['gBuildDate'].address
    #rpm_build_time_type = debug_info.variables['gBuildTime'].die
    #rpm_build_time_address = debug_info.variables['gBuildTime'].address
    #rpm_build_date = decode_object('gBuildDate', rpm_build_date_address, None, memory, debug_info, die=rpm_build_date_type)
    #rpm_build_time = decode_object('gBuildTime', rpm_build_time_address, None, memory, debug_info, die=rpm_build_time_type)
    #
    #QC_IMAGE_VERSION = find_version_info("QC_IMAGE_VERSION_STRING=",version_address_start, version_address_end, memory)
    #print("QC_IMAGE_VERSION_STRING:  %s" % QC_IMAGE_VERSION, file=dump)
    #print("IMAGE_VARIANT_STRING:     %s" % find_version_info("IMAGE_VARIANT_STRING=",version_address_start, version_address_end, memory), file=dump)
    #print("OEM_IMAGE_VERSION_STRING: %s" % find_version_info("OEM_IMAGE_VERSION_STRING=",version_address_start, version_address_end, memory), file=dump)
    #
    #print("\nBuild Date: %s" % pointer_to_str(rpm_build_date), file=dump)
    #print("Build Time: %s" % pointer_to_str(rpm_build_time), file=dump)
    
    if aop_core_dump.dumped_at == 0:
        print('\nThe AOP is ok.', file=dump)
        # return chip name and RPM branch
        return [target_chip.get('num', '????')]#, re.compile(regex).match(QC_IMAGE_VERSION).group()]
    
    print('\nThe AOP crashed (@ time = 0x%x)' % aop_core_dump.dumped_at, file=dump)
    xpsr = aop_core_dump.registers.xPSR
    
    ipsr = xpsr & 0xff
    if ipsr == 0:
        print('\tNot in an exception context; vanilla fatal error scenario.', file=dump)
    elif ipsr < 16:
        fault_types = {
            2  : 'NMI',
            3  : 'Hard Fault',
            4  : 'Memory Management Fault',
            5  : 'Bus Fault',
            6  : 'Usage Fault',
            11 : 'SVCall',
            12 : 'Debug Monitor',
            14 : 'PendSV',
            15 : 'SysTick',
        }
        print('\tIn a fault context -> %s' % fault_types[ipsr], file=dump)
    else:
        print('\tFatal error inside ISR #%d' % (ipsr - 16), file=dump)
    
    
    def decode_bitfield(name, bit_definitions, data, joiner = ' | '):
        known_bits = 0
        for id in bit_definitions:
            known_bits |= (1 << id)
        unknown_data = data - (data & known_bits)
        string = joiner.join(['[' + bit_definitions[x] + ']' for x in bit_definitions if (1 << x) & data])
        if unknown_data:
            if string:
                string += ' ...and '
            multi_or_single = ''
            if log(unknown_data, 2) != int(log(unknown_data, 2)):
                multi_or_single = 's'
            string += 'unknown %s%s 0x%0.8x' % (name, multi_or_single, unknown_data)
        return string
    
    
    fault_regs = aop_core_dump.fault_detail
    
    shcas_bits = {
        0  : 'Memory fault in progress',
        1  : 'Bus fault in progress',
        3  : 'Usage fault in progress',
        7  : 'SVCall in progress',
        8  : 'Debug Monitor in progress',
        10 : 'PendSV in progress',
        11 : 'SysTick in progress',
        12 : 'Usage fault pended',
        13 : 'Memory management fault pended',
        14 : 'Bus fault pended',
        15 : 'SVCall pended',
        16 : 'Memory management fault enabled (this is not a problem)',
        17 : 'Bus fault enabled (this is not a problem)',
        18 : 'Usage fault enabled (this is not a problem)',
    }
    
    print('\nSystem handler status {\n\t%s\n}' % decode_bitfield('bits', shcas_bits, fault_regs.SystemHandlerCtrlAndState, '\n\t'), file=dump)
    
    cfs_bits = {
        0  : 'Attempt to fetch an instruction from a non-executable region.',
        1  : 'Attempt to load or store a location that does not permit it.',
        3  : 'Unstacking from an exception return has caused one or more access violations.',
        4  : 'Stacking for an exception has caused one or more access violations.',
        7  : 'Memory manage address register (MMAR) is valid.',
        8  : 'Instruction bus error.',
        9  : 'Precise data bus error.',
        10 : 'Imprecise data bus error.',
        11 : 'Unstack from exception has caused one or more bus errors.',
        12 : 'Stacking for exception has caused one or more bus errors.',
        15 : 'Bus fault address register (BFAR) is valid.',
        16 : 'Undefined instruction exception.',
        17 : 'Invalid state exception.',
        18 : 'Illegal attempt to load EXC_RETURN into PC.',
        19 : 'Attempt to use a coprocessor instruction.',
        24 : 'Unaligned memory access.',
        25 : 'Divide by zero.',
    }
    
    print('\nConfigurable fault status {\n\t%s\n}' % decode_bitfield('bits', cfs_bits, fault_regs.ConfigurableFaultStatus, '\n\t'), file=dump)
    
    hfs_bits = {
        0  : 'Fault on vector table read during exception processing.',
        30 : 'Hard Fault activated because a configurable fault was received and cannot activate because of priority or it is disabled.',
        31 : 'Fault related to debug.',
    }
    
    print('\nHard fault status {\n\t%s\n}' % decode_bitfield('bits', hfs_bits, fault_regs.HardFaultStatus, '\n\t'), file=dump)
        
    dfs_bits = {
        0  : 'Halt requested by NVIC.',
        1  : 'BKPT instruction execution.',
        2  : 'DWT match.',
        3  : 'Vector fetch occurred.',
        4  : 'EDBGRQ signal asserted.',
    }
    
    print('\nDebug fault status {\n\t%s\n}' % decode_bitfield('bits', hfs_bits, fault_regs.DebugFaultStatus, '\n\t'), file=dump)
    
    if 0 != (fault_regs.ConfigurableFaultStatus & (1 << 7)):
        print('\nMemory manage fault address: 0x%0.8x' % fault_regs.MemManageAddress, file=dump)
    
    if 0 != (fault_regs.ConfigurableFaultStatus & (1 << 15)):
        print('\nMemory manage fault address: 0x%0.8x' % fault_regs.BusFaultAddress, file=dump)
    
    print('\nAuxilary fault address register: 0x%0.8x' % fault_regs.AuxFaultStatus, file=dump)
    dump.close()
    
    # return chip name and RPM branch
    return [target_chip.get('num', '????')]#, re.compile(regex).match(QC_IMAGE_VERSION).group()]