项目作者: kylemanna

项目描述 :
Python interface to /dev/mem
高级语言: Python
项目地址: git://github.com/kylemanna/pydevmem.git
创建时间: 2011-11-28T06:52:24Z
项目社区:https://github.com/kylemanna/pydevmem

开源协议:MIT License

下载


Python DevMem

This is designed primarily for use with accessing /dev/mem on OMAP platforms.
It should work on other platforms and work to mmap() files rather then just
/dev/mem, but these use cases aren’t well tested.

All file accesses are aligned to DevMem.word bytes, which is 4 bytes on ARM
platforms to avoid data abort faults when accessing peripheral registers.

Usage

  1. Usage: devmem.py [options]
  2. Options:
  3. -h, --help show this help message and exit
  4. -r ADDR, --read=ADDR read a value
  5. -w ADDR VALUE, --write=ADDR VALUE
  6. write a value
  7. -n NUM, --num=NUM number of words to read
  8. -s WORD_SIZE, --word-size=WORD_SIZE
  9. size of word when displayed
  10. -m FILE, --mmap=FILE file to open with mmap()
  11. -v provide more information regarding operation
  12. -d provide debugging information

Speed

Initial testing on a BeagleBoard-xM (Cortex-A8 in a TI DM3730) shows that
starting up the python interpreter is pretty slow:

  1. # time (echo | python)
  2. real 0m0.859s
  3. user 0m0.750s
  4. sys 0m0.102s
  5. # time python ./pydevmem.py -r 0x4830a204 -n 8
  6. 0x4830a204: 1b89102f 00000000 00000000 000000f0
  7. 0x4830a214: cafeb891 0c030016 015739eb 1ff00000
  8. real 0m1.109s
  9. user 0m0.977s
  10. sys 0m0.133s
  11. # time python -S ./pydevmem.py -r 0x4830a204 -n 8
  12. 0x4830a204: 1b89102f 00000000 00000000 000000f0
  13. 0x4830a214: cafeb891 0c030016 015739eb 1ff00000
  14. real 0m0.659s
  15. user 0m0.602s
  16. sys 0m0.047s
  17. # time python -S ./pydevmem.pyc -r 0x4830a204 -n 8
  18. 0x4830a204: 1b89102f 00000000 00000000 000000f0
  19. 0x4830a214: cafeb891 0c030016 015739eb 1ff00000
  20. real 0m0.647s
  21. user 0m0.508s
  22. sys 0m0.133s

System information for those tests:

  1. Linux omap 3.0.6-x3 #1 SMP Wed Oct 5 07:19:24 UTC 2011 armv7l GNU/Linux
  2. python 2.7.2-7ubuntu2
  3. python-configobj 4.7.2+ds-3
  4. python-minimal 2.7.2-7ubuntu2
  5. python2.7 2.7.2-5ubuntu1
  6. python2.7-minimal 2.7.2-5ubuntu1

Something needs to be sped up to make python start-up in a reasonable amount
of time.