CMSIS-SVD environment and scripts

Revision as of 10:27, 29 November 2019 by Registered User

1. Article purpose[edit source]

This article provides information for using CMSIS-SVD file through GDB for accessing STM32MPU Internal peripherals registers for reading and/or writing.

2. Information about CMSIS-SVD files[edit source]

Extracted from Arm Keil web page[1]:

The CMSIS System View Description format(CMSIS-SVD) formalizes the description of the system contained in Arm Cortex-M processor-based microcontrollers, in particular, the memory mapped registers of peripherals. The detail contained in system view descriptions is comparable to the data in device reference manuals. The information ranges from high level functional descriptions of a peripheral all the way down to the definition and purpose of an individual bit field in a memory mapped register.

Arm also precise in an other web page about CMSIS-SVD[2] that this is not only for Cortex-M:

For every supported microcontroller, debuggers can provide detailed views to the device peripherals that display the current register state.

3. Python scripts environment for GDB[edit source]

3.1. CMSIS-SVD file parser[edit source]

A CMSIS-SVD file parser is proposed and shared by Paul Osborne on github: https://github.com/posborne/cmsis-svd.

This package is reused as it is, and by adding the CMSIS-SVD files for STM32MPU microprocessor if missing.

About License, following information is provided:
In general, the following rules apply:

  • Under data, the license from each Vendor is provided along with the SVDs from that vendor. Please review this license before use of the SVDs contained therein. Look for files named the following for license information.
  • All other code is licensed under the terms of the Apache License v2.0 (See LICENSE-APACHE).

In our case, we will only add new files in data/STMicro sub-directory, so STMicroelectronics license is applied.


This package is part of the OpenSTLinux Developer Package.


3.2. Python scripts for GDB[edit source]

svd-tools[3] github repository provides a gdb-svd python module for gdb which adds some commands to:

  • get information on peripherals | registers | fields
  • get registers values | register fields
  • set registers values | register fields

For more detail, please refer to the README[4] file of the repository.

This package is part of the OpenSTLinux Developer Package.


3.3. Setting environment[edit source]

As pre-requisites, gdb setup must be installed and running.

As CMSIS-SVD scripts are also part of the OpenSTLinux Developer Package, the environment is set by using below commands:

 cd $OECORE_NATIVE_SYSROOT
 source usr/share/svd-tools/gdb-svd.py

4. Python scripts usage for GDB[edit source]

Under construction.png Coming soon

4.1. Load svd file for the requested SoC[edit source]

By using svd command, you are able to load the corresponding svd files for your SoC.

Here is an example for the STM32MP15xxx:

 svd cmsis-svd/cmsis_svd/data/STMicro/STM32MP15xxx.svd

4.2. Reading register value[edit source]

Please refer to the following examples.

  • Getting an entire peripheral:
(gdb) svd_get DLYBSD1
 DLYBSD1 @ 0x58006000
 DLYB_CR
         DEN=0 SEN=0
 DLYB_CFGR
         SEL=0 UNIT=0 LNG=0 LNGF=1
 DLYB_VERR
         MINREV=0 MAJREV=0
 DLYB_IPIDR
         ID=0
 DLYB_SIDR
         SID=0
  • Getting just one register:
(gdb) svd_get DLYBSD1 DLYB_CFGR
 DLYB_CFGR
         SEL=0 UNIT=0 LNG=0 LNGF=1
  • Getting field values in hex:
(gdb) svd_get/x DLYBSD1 DLYB_CFGR
 DLYB_CFGR
         SEL=0 UNIT=00 LNG=000 LNGF=1
  • Getting field values in binary:
(gdb) svd_get/b DLYBSD1 DLYB_CFGR
 DLYB_CFGR
         SEL=0000 UNIT=0000000 LNG=000000000000 LNGF=1
  • Get whole register value in binary:
(gdb) svd_get/i DLYBSD1 DLYB_CFGR
 DLYB_CFGR 10000000000000000000000000000000
         SEL=0 UNIT=0 LNG=0 LNGF=1
  • Getting register offsets:
(gdb) svd_get/f DLYBSD1 DLYB_CFGR
 DLYB_CFGR 0x0004
         SEL=0 UNIT=0 LNG=0 LNGF=1

4.3. Writing register value[edit source]

Please refer to the following examples.

  • Set register values:
(gdb) svd_set QUADSPI QUADSPI_LPTR 0x50
  • Set field values:
(gdb) svd_set QUADSPI QUADSPI_LPTR TIMEOUT 0x10

4.4. Loading from an external SVD file[edit source]

This is possible to load an external SVD file:

 (gdb) svd_load_file </path/to/your_file.svd>

5. References[edit source]