示例#1
0
    def reset(self, line=''):
        """Reset and reopen the USB interface."""
        args = parse_argstring(self.reset, line)
        d = self.shell.user_ns.get('d_remote')

        if not d:
            # Recover from starting up without a device
            d = remote.Device()
            self.shell.user_ns['d_remote'] = d
            self.shell.user_ns['d'] = d

        d.reset()
        if args.arm:
            reset_arm(d)
示例#2
0
        if address not in address_to_column:
            add_column(address)
            legend_countdown = 0

        # Print the legend when we get new columns, or every 'legend_interval' lines
        if legend_countdown == 0:
            yield timestamp_blank + ' ' + ' '.join(['_' * 8 for a in column_to_address])
            yield timestamp_blank + ' ' + ' '.join(['%08x' % a for a in column_to_address])
            yield timestamp_blank + ' ' + '+'.join(['-' * 8 for a in column_to_address])
            legend_countdown = legend_interval

        # Put this change in the right column, show before-and-after
        yield timestamp_blank + ' ' * (9 * address_to_column[address]) + ' %08x>' % old_value
        yield timestamp_str   + ' ' * (9 * address_to_column[address]) + '>%08x' % new_value
        legend_countdown -= 1


if __name__ == "__main__":
    import remote

    if len(sys.argv) < 2:
        print("usage: %s address [addresses ...]" % sys.argv[0])
        print("  Each address can be a single word or a range a:b including both ends")
        sys.exit(1)

    d = remote.Device()      
    addrs = [tuple(int(n.replace('_',''), 16) for n in arg.split(':')) for arg in sys.argv[1:]]
    changes = watch_scanner(d, addrs)
    for line in watch_tabulator(changes):
        print(line)
示例#3
0
                    output_timestamp = now

            except IOError:
                # The device layer will already complain for us.
                # Wait a tiny bit to let the device cool off...
                time.sleep(0.1)
                continue

            except ConsoleOverflowError as e:
                # Warn loudly that we missed some data
                sys.stderr.write('\n\n======== %s ========\n\n' % e)

    except KeyboardInterrupt:
        return

    finally:
        # On our way out, update the buffer FIFO so the next console knows where to start
        console_buffer.flush()
        if log_file:
            log_file.close()


if __name__ == "__main__":
    import remote

    if len(sys.argv) != 1:
        print("usage: %s" % sys.argv[0])
        sys.exit(1)

    console_mainloop(remote.Device())
示例#4
0
            if delay:
                time.sleep(delay)


def bitfuzz_round(d, address, wordcount, pattern):
    values = []
    pattern_str = pattern is not None and hex(pattern)[-1:] or ' '

    for word in range(wordcount):
        if pattern is not None:
            d.poke(address + word * 4, pattern)
        values.append(d.peek(address + word * 4))

    return "%s %s" % (pattern_str, '  '.join(word_bits(w) for w in values))


def bitfuzz_heading(address, wordcount):
    return '  ' + ''.join(
        ['%-37s' % '%08x' % (address + i * 4) for i in range(wordcount)])


if __name__ == "__main__":
    import remote
    if len(sys.argv) != 3:
        print("usage: %s address wordcount" % sys.argv[0])
        sys.exit(1)
    for line in bitfuzz_rounds(remote.Device(),
                               int(sys.argv[1].replace('_', ''), 16),
                               int(sys.argv[2].replace('_', ''), 16)):
        print(line)
示例#5
0
def dma():
    # DMA memory space, starting with DRAM.
    memsquare(remote.Device(), 'memsquare-dma-000000-ffffff.png', 0, 16, 1024,
              'dma')
示例#6
0
    if check_fast:
        assert read_block(d,
                          address,
                          size,
                          fast=not fast,
                          addr_space=addr_space) == data
    sys.stdout.write(hexdump(data, 16, address, log_file))


def dump_words(d,
               address,
               wordcount,
               log_file='result.log',
               fast=False,
               addr_space='arm'):
    data = read_block(d,
                      address,
                      wordcount * 4,
                      fast=fast,
                      addr_space=addr_space)
    sys.stdout.write(hexdump_words(data, 8, address, log_file))


if __name__ == "__main__":
    import remote
    if len(sys.argv) != 3:
        print "usage: %s address size" % sys.argv[0]
        sys.exit(1)
    dump(remote.Device(), int(sys.argv[1].replace('_', ''), 16),
         int(sys.argv[2].replace('_', ''), 16))
示例#7
0
def sram():
    # Small 8kB mapping, looks like SRAM. 2-byte scale.
    memsquare(remote.Device(), 'memsquare-02000000-02001fff.png', 0x02000000,
              2, 64)
示例#8
0
def dram():
    # Fast dump of DRAM. 512x512, 16 byte scale.
    # Runs in a few minutes, okay for differential testing.
    memsquare(remote.Device(), 'memsquare-01c00000-01ffffff.png', 0x01c00000,
              16, 512)
示例#9
0
def mmio():
    # Map every byte in 4MB of MMIO space
    memsquare(remote.Device(), 'memsquare-04000000-043fffff.png', 0x04000000,
              1, 2048)
示例#10
0
def low64():
    # Just the active region in the low 64MB of address space.
    # Each pixel is 4 bytes, so this is about as much resolution as we could want.
    memsquare(remote.Device(), 'memsquare-00000000-3fffffff.png', 0, 4)
示例#11
0
def survey():
    # Survey of all address space, each pixel is 0x100 bytes
    memsquare(remote.Device(), 'memsquare-00000000-ffffffff.png', 0, 0x100)