#!/usr/bin/env python # Copyright 2013 Jared Boone # # Display the LPC43xx Clock Generation Unit (CGU) registers in an # easy-to-read format. # # This file is part of HackRF. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. """ In GDB: dump binary memory cgu.bin 0x40050014 0x400500cc """ import sys from struct import unpack address = 0x40050014 f = open(sys.argv[1], 'read') d = '\x00' * 20 + f.read() length = len(d) f.close() def print_data(d): for i in range(0, length, 16): values = unpack('> low_bit) & ((1 << count) - 1) field_bits = bin(field_value)[2:].zfill(count) + ' ' * low_bit field_bits = field_bits.rjust(32) print('%03s %20s %s = %8x %s' % ('', '', field_bits, field_value, name))