Skip to main content

System View Description parser

Project description

Latest version on PyPi Python versions License Build state Coverage

pysvd

A System View Description v1.3.5 parser package for Python 3.5+.

What is SVD?

SVD is a XML based file format developed by ARM to describe the software sight of a microcontroller device. It contains all peripherals, registers, bitfields and enumeration values to access every part on a device. For further information have a look at the format description.

Motivation

SVD is a great format to develop embedded systems on. Existing parser out in the field did not support all features (derive, dimension) supported by the format.

With the parsed system view tree, you can do several cool things:

  • Automatic register generation (BSP skeleton)
  • Linker file generation
  • GDB register debug symbol generation
  • Custom datasheet generation

Conformance

This parser is build to reflect 1:1 the XSD format behind SVD. The only compromis has been made by the nodes peripherals, registers and fields that are simple container objects.

The node names and attributes follow the same naming convention in XML as in Python to map them easier between the languages.

Installation

Install from PyPI using pip:

$ pip3 install pysvd

Install latest master from GitHub:

$ pip3 install https://github.com/bfueldner/pysvd/archive/master.zip

If you want to be able to change the code while using it, clone it and install the required pip packages:

$ git clone https://github.com/bfueldner/pysvd.git
$ cd pysvd
$ pip3 install -e .

Script

On example of the parser is the script svd_duplicates to check a SVD file for possible duplicate peripherals, registers, fields and enumeratedValues:

$ svd_duplicate --help
usage: svd_duplicates [-h] --svd FILE [--output FILE] [--level {all,hint,warning}] [--depth {peripherals,registers,fields,enumeratedValues}] [--sort]

Read SVD file, order elements, check forvalid elements to generate register access structs and displays possible substitutions.

optional arguments:
  -h, --help            show this help message and exit
  --svd FILE            System view description (SVD) file
  --output FILE, -o FILE
                        Save ordered SVD output file
  --level {all,hint,warning}, -l {all,hint,warning}
                        Select level of output messages
  --depth {peripherals,registers,fields,enumeratedValues}, -d {peripherals,registers,fields,enumeratedValues}
                        Select depth of analysis
  --sort                Sort elements before comparing

Running svd_duplicates on a STM32F407 definition would generate this output (cut):

svd_duplicates console output

Example

As another example of the parser, a "SVD to ReST" converter svd2rst is included as a command line tool:

$ svd2rst --help
usage: svd2rst [-h] --svd FILE --output FILE

SVD to ReST converter

optional arguments:
  -h, --help              show this help message and exit
  --svd FILE              System view description (SVD) file
  --output FILE, -o FILE  ReST output file
  --version               show program's version number and exit

Running svd2rst on a Cortex-M3 core definition would generate this output:

Device
======

:Name: ARMCM3
:Description: ARM 32-bit Cortex-M3 Microcontroller based device, CPU clock up to 80MHz, etc.
:Series: ARMCM
:Version: 1.2
:Vendor: ARM Ltd.

:Address unit bits: 8
:Data width: 32

CPU
===

:Name: Cortex-M3
:Revision: r2p1
:Endian: little
:MPU: no
:FPU: no
:VTOR: yes
:Interrupts: 16
:Interrupt priorities: 16
:Vendor SYSTICK: no

Memory mapping
==============

========== ==========
Peripheral  Address
========== ==========
SYSTICK_   0xE000E010
NVIC_      0xE000E100
SCB_       0xE000ED00
MPU_       0xE000ED90
========== ==========

Interrupt mapping
=================

========== =========
Peripheral Interrupt
========== =========
SCB_       1
SYSTICK_   15
========== =========

Peripheral
==========

.. _SYSTICK:

System timer register (SYSTICK)
-------------------------------

:Address: 0xE000E010
:Size: 0x0010
:Usage: registers
:Interrupt: 15

========================= ======
      Register          Offset
========================= ======
`CSR <SYSTICK.CSR_>`_     0x00
`RVR <SYSTICK.RVR_>`_     0x04
`CVR <SYSTICK.CVR_>`_     0x08
`CALIB <SYSTICK.CALIB_>`_ 0x0C
========================= ======

.. _SYSTICK.CSR:

Control and Status Register
^^^^^^^^^^^^^^^^^^^^^^^^^^^

:Name: CSR
:Size: 32
:Offset: 0x00
:Reset: 0x00000000
:Access: read-write

- Bit 0 (read-write) - ENABLE
 Enable Timer

- Bit 1 (read-write) - TICKINT
 Generate Exception

- Bit 2 (read-write) - CLKSOURCE
 Clock source

 - 0 - EXTERNAL
    External Clock
 - 1 - PROCESSOR
    CPU Clock

- Bit 16 (read-write) - COUNTFLAG
 Counted to zero

.. _SYSTICK.RVR:

Reload Value Register
^^^^^^^^^^^^^^^^^^^^^

:Name: RVR
:Size: 32
:Offset: 0x04
:Reset: 0x00000000
:Access: read-write

- Bits 23:0 (read-write) - RELOAD
 Reload value for CVR when counter reaches zero

.. _SYSTICK.CVR:

Current Value Register
^^^^^^^^^^^^^^^^^^^^^^

:Name: CVR
:Size: 32
:Offset: 0x08
:Reset: 0x00000000
:Access: read-write

- Bits 31:0 (read-write) - CURRENT
 Current counter value

.. _SYSTICK.CALIB:

Calibration Value Register
^^^^^^^^^^^^^^^^^^^^^^^^^^

:Name: CALIB
:Size: 32
:Offset: 0x0C
:Reset: 0x00000000
:Access: read-only

- Bits 23:0 (read-only) - TENMS
 Reload value to use for 10ms timing

- Bit 30 (read-only) - SKEW
 Clock Skew

 - 0 - EXACT
    10ms calibration value is exact
 - 1 - INEXACT
    10ms calibration value is inexact, because of the clock frequency

- Bit 31 (read-only) - NOREF
 No Ref

 - 0 - AVAILABLE
    Reference clock available
 - 1 - UNAVAILABLE
    Reference clock is not available

...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysvd-0.2.3.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

pysvd-0.2.3-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

Details for the file pysvd-0.2.3.tar.gz.

File metadata

  • Download URL: pysvd-0.2.3.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.49.0 importlib-metadata/4.0.1 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10

File hashes

Hashes for pysvd-0.2.3.tar.gz
Algorithm Hash digest
SHA256 53d891426307dacc717ae9d538a82bebc55161df4f2418c200d4cc103efe47ff
MD5 010f702f1c32ed00df809eabcb6aa58b
BLAKE2b-256 c98ac2ddf9aad602080a6a739b8907458dde5d05aa1490c8aa8528066e4280a6

See more details on using hashes here.

File details

Details for the file pysvd-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: pysvd-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.49.0 importlib-metadata/4.0.1 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10

File hashes

Hashes for pysvd-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4a428671dd062465b540a46347f826db5402de1dad130a62f7e339cb5082150c
MD5 8ef3c20d3e5bcdfe7610651f520e6ee6
BLAKE2b-256 30d9ac3e94a3f2986ff3f8a9c0ecd50cae519a51d8cbb252217310a7290a1114

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page