Giter VIP home page Giter VIP logo

pyhwtest's Introduction

PYHWTEST

This is a python module for reading and writing to memory on devices in python. Currently it will only work on Linux. The intent is for users to be able to make quick python scripts and import them into the interpreter with the '-i' flag to python.

This makes some basic hardware tests very simple if you have registers mapped into the host memory space.

INSTALLATION

To install the hwtest extension make sure the python development headers are installed for you system. On yum based systems:

# yum install python-devel
# python setup.py install

You will also need to build and install the driver separately right now. First make sure your kernel headers are installed. On RPM based systems:

# yum install kernel-devel

or on Debian based systems:

# apt-get install linux-headers-`uname -r`

Now build and install the khwtest module:

# make -C /lib/modules/`uname -r`/build M=`pwd` modules
# cp khwtest.ko /lib/modules/`uname -r`/kernel/
# depmod -a

Also, please disable selinux or apparmor on your system. pyhwtest tries to map memory, which can be prevented by selinux depending on how pyhwtest is installed.

USAGE

You must be root in order to use the hwtest module since it can access physical memory and IO ports.

You can always get the built in help information with:

>>> import hwtest
>>> help(hwtest)

Assume you have a custom PCI device with BAR0 mapped into 0xfc000000. You can access those registers like:

>>> from hwtest import *
>>> readlw(0xfc000000)
4294967295L
>>> hex(_)
'0xFFFFFFFFL'
>>> hex(readlw(0xfc000000))
'0xFFFFFFFFL'
>>> writelw(0xfc000000, 0x80000000)

The hwtest module also provides a way to allocate host memory for use in testing out DMA operations:

>>> phys_address = hwtest.alloc_dma_page()

The phys_address value can be written into device registers, and readlw / writelw can be used to access those pages just like any other memory.

pyhwtest's People

Contributors

sruffell avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

lixiaoyaogg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.