SVD Validation and Generation Tool

January 26, 2023 ยท View on GitHub

The utility svdconv validates CMSIS-SVD files and generates CMSIS-compliant device header files. It distributed as part of the CMSIS-Toolbox.

svdconv performs the following operations:

  • Checks the syntactical and structural compliance with the specified CMSIS-SVD format.
  • Checks the consistency, correctness, and completeness of the CMSIS-SVD file against the CMSIS-SVD schema file.
  • Generates CMSIS-compliant device header files, which can be used for software development.

**NOTE:** Consider using the--strict` option to receive all pedantic warnings. Some rules are skipped by default due to backward compatibility reasons. All newly developed/updated SVD files should rather respect all rules.

Usage

  svdconv.exe [OPTION...] positional parameters

  -o, --outdir arg            Output directory
      --generate arg          Generate header, partition or SDF/SFR file
      --fields arg            Specify field generation:
                              enum/macro/struct/struct-ansic
      --suppress-path         Suppress inFile path on check output
      --create-folder         Always create required folders
      --show-missingEnums     Show SVD elements where enumerated values
                              could be added
      --strict                Strict error checking (RECOMMENDED!)
  -b, --log arg               Log file
  -x, --diag-suppress arg     Suppress Messages
      --suppress-warnings     Suppress all WARNINGs
  -w arg                      Warning level (default: all)
      --allow-suppress-error  Allow to suppress error messages
  -v, --verbose               Verbose mode. Prints extra process
                              information
      --under-test            Use when running in cloud environment
      --nocleanup             Do not delete intermediate files
      --quiet                 No output on console
      --debug arg             Add information to generated files:
                              struct/header/sfd/break
      --version               Show program version
  -h, --help                  Print usage

Return Codes

SVDConv returns the following codes:

CodeDescriptionAction
0OKNo action required. Validation and conversion performed without errors.
1WARNINGSWarnings should be checked an possibly removed. The header file is created and could be used.
2ERRORSErrors in the SVD description file. Important elements are missing and must be corrected.
3Error in command lineCheck and correct the command line arguments.

Usage Examples

  1. Retrieve help information on screen.

    svdconv
    
  2. Perform a consistency check by passing only the SVD file name. Errors and warnings are printed on screen.

    svdconv ARM_Example.svd 
    

    The result is printed on screen:

    MVCM3110.svd(1688) : info
    `<description>` missing for value '2 : MODE2'
    MVCM3110.svd(1692) : info
    `<description>` missing for value '3 : MODE3'
    MVCM3110.svd(1696) : info
    `<description>` missing for value '4 : MODE4'
    Area of improvements:
    * Description contains 267 `<fields>` defined without associated `<enumeratedValues>
    Found 0 Errors and 1 Warnings
    Return Code: 1 (WARNINGS)
    
  3. Generate the header file. Performs a consistency check. Errors and warnings are printed on screen.

    svdconv ARM_Example.svd --generate=header
    

    Code snippet from the generated header file showing the structure for TIMER0.

    /* ================                     TIMER0                     ================ */
    typedef struct {                                    
      __IO uint32_t  CR;                                
      __IO uint16_t  SR;                                
      __I  uint16_t  RESERVED0[5];
      __IO uint16_t  INT;                               
      __I  uint16_t  RESERVED1[7];
      __IO uint32_t  COUNT;                             
      __IO uint32_t  MATCH;                             
      union {
        __O  uint32_t  PRESCALE_WR;                     
        __I  uint32_t  PRESCALE_RD;                     
      };
      __I  uint32_t  RESERVED2[9];
      __IO uint32_t  RELOAD[4];                         
    } TIMER0_Type;
    
  4. Generate the header file containing bit fields. Performs a consistency check. Errors and warnings are printed on screen.

    svdconv ARM_Example.svd --generate=header --fields=struct
    

    Code snippet from the generated header file showing the structure for TIMER0. Compare to the code snippet above.

    /* ================                     TIMER0                     ================ */
    typedef struct {                                    
      union {
        __IO uint32_t  CR;                              
        struct {
          __IO uint32_t  EN         :  1;               
          __O  uint32_t  RST        :  1;               
          __IO uint32_t  CNT        :  2;               
          __IO uint32_t  MODE       :  3;               
          __IO uint32_t  PSC        :  1;               
          __IO uint32_t  CNTSRC     :  4;               
          __IO uint32_t  CAPSRC     :  4;               
          __IO uint32_t  CAPEDGE    :  2;               
               uint32_t             :  2;
          __IO uint32_t  TRGEXT     :  2;               
               uint32_t             :  2;
          __IO uint32_t  RELOAD     :  2;               
          __IO uint32_t  IDR        :  2;               
               uint32_t             :  3;
          __IO uint32_t  S          :  1;               
        } CR_b;                                         
      };
      
      union {
        __IO uint16_t  SR;                              
        struct {
          __I  uint16_t  RUN        :  1;               
               uint16_t             :  7;
          __IO uint16_t  MATCH      :  1;               
          __IO uint16_t  UN         :  1;               
          __IO uint16_t  OV         :  1;               
               uint16_t             :  1;
          __I  uint16_t  RST        :  1;               
               uint16_t             :  1;
          __I  uint16_t  RELOAD     :  2;               
        } SR_b;                                         
      };
      __I  uint16_t  RESERVED0[5];
      
      union {
        __IO uint16_t  INT;                             
        struct {
          __IO uint16_t  EN         :  1;               
               uint16_t             :  3;
          __IO uint16_t  MODE       :  3;               
        } INT_b;                                        
      };
      __I  uint16_t  RESERVED1[7];
      __IO uint32_t  COUNT;                             
      __IO uint32_t  MATCH;                             
      union {
        __O  uint32_t  PRESCALE_WR;                     
        __I  uint32_t  PRESCALE_RD;                     
      };
      __I  uint32_t  RESERVED2[9];
      __IO uint32_t  RELOAD[4];                         
    } TIMER0_Type;
    

Error and Warning Messages

The following table shows the errors and warnings issued by svdconv.

Help messages

Message NumberTypeMessage TextDetails/Action
M020TEXTSVD_STRING_OPTIONSDisplays programm help.
M021TEXT'DESCR' 'VER' 'COPYRIGHT'Displays module name 'DESCR', version 'VER' and copyright information 'COPYRIGHT'.
M022TEXTFound 'ERR' Error(s) and 'WARN' Warning(s).Displays the number of errors/warnings.
M023TEXTPhase 'CHECK'Information about the check phase.
M024TEXTArguments: 'OPTS'Specify arguments.

Informative messages

Message NumberTypeMessage TextDetails/Action
M040Info'NAME': 'TIME' ms. Passed
M041InfoOverall time: 'TIME' ms.
M050InfoCurrent Working Directory: 'PATH'
M051InfoReading SVD File: 'PATH'
M061InfoChecking SVD Description

Invocation errors

Message NumberTypeMessage TextAction
M101ERRORUnknown error!Please contact support.
M102ERRORMFC initialization failedPlease contact support.
M103ERRORInternal Error: 'REF'Please contact support.
M104CRITICAL'MSG'Please contact support.
M105ERRORCannot add Register to group sorter: 'NAME'
M106ERRORCommand 'NAME' failed: 'NUM': 'MSG'
M107ERRORLost xml file stream.Check SVD file.
M108ERRORSfrDis not supported.Disassembly not supported.
M109ERRORCannot find 'NAME'Check specified file.
M111PROGRESS'NAME' failedCheck specified file.
M120ERRORInvalid arguments!Provide a list of valid arguments.
M121ERRORFile not found 'NAME' Check specified file.
M122ERRORName of command file should follow '@'Check specified command.
M123ERRORFile not found: 'PATH'!Check speficied path.
M124ERRORCannot execute SfrCC2: 'PATH'!"Check path to SfrCC2.
M125WARNINGSfrCC2 report: 'MSG' SfrCC2 report end.
M126WARNINGSfrDis: 'MSG'
M127ERRORSfrCC2 reports errors!Check SVD file.
M128WARNINGSfrCC2 reports warnings!Check SVD file.
M129ERROROption unknown: 'OPT'Check given option 'OPT'.
M130ERRORCannot create file 'NAME'Check user rights.
M132ERRORSfrCC2 report: 'MSG' SfrCC2 report end."

Validation errors

Message NumberTypeMessage TextAction
M201ERRORTag <'TAG'> unknown or not allowed on this level."Check tag
M202ERRORParse error: <'TAG'> = 'VALUE'Check tag/value.
M203ERRORValue already set: <'TAG'> = 'VALUE'Check tag/value.
M204ERRORParse Error: 'VALUE'Check value.
M205WARNINGTag <'TAG'> emptyAssign value to tag.
M206ERRORDerivedFrom not found: 'NAME'Check derivate.
M207ERRORExpression marker found but no <dim> specified: 'NAME'Specify dimension.
M208ERRORIgnoring <dimIndex> because specified <name> requires Array generation.Generate an array.
M209WARNINGCPU section not set. This is required for CMSIS Headerfile generation and debug support.Add CPU section.
M210WARNINGUse new Format CMSIS-SVD >= V1.1 and add <CPU> Section.Update schema and add CPU section.
M211ERRORIgnoring 'LEVEL' 'NAME' (see previous message)
M212ERRORAddress Block <usage> parse error: 'NAME'Correct address block.
M213ERRORExpression for 'NAME' incomplete, <'TAG'> missing.Add tag.
M214ERRORPeripheral 'NAME' <dim> single-instantiation is not supported (use Array instead).Correct Regs to Reg[s].
M215WARNINGSize of <dim> is only one element for 'NAME', is this intended?Check single element.
M216WARNINGUnsupported character found in 'NAME' : 'HEX'.Correct name.
M217WARNINGForbidden Trigraph '??CHAR' found in 'NAME'.
M218WARNINGUnsupported ESC sequence found in 'NAME' : 'CHAR'.Correct escape sequence.
M219ERRORC Code generation error: 'MSG'
M220WARNINGC Code generation warning: 'MSG'
M221WARNINGInput filename must end with .svd: 'NAME'Correct input filename extension.
M222WARNINGInput filename has no extension: 'NAME'Correct input filename extension.
M223ERRORInput File Name 'INFILE' does not match the tag <name> in the <device> section: 'NAME'Correct the MCU name.
M224WARNINGDeprecated: 'NAME' Use 'NAME2' insteadUpdate SVD file.
M225ERRORUpper/lower case error: 'NAME', should be 'NAME2'"Update SVD file.
M226ERRORSFD Code generation error: 'MSG'
M227WARNINGSFD Code generation warning: 'MSG'
M228ERROREnumerated Value Container: Only one Item allowed on this Level!Remove additional items.
M229ERRORRegister 'NAME' is not an array, <dimArrayIndex> is not applicableCorrect SVD.
M230ERRORValue 'NAME':'NUM' out of Range for 'LEVEL' 'NAME2'['NUM2'].Correct SVD.
M231ERRORValue <isDefault> not allowed for 'LEVEL'.Correct SVD.
M232ERRORTag <'TAG'> name 'NAME' must not have specifier 'CHAR'. Ignoring entry."Correct SVD.
M233ERRORParse error: <'TAG'> = 'VALUE'Correct SVD.
M234ERRORNo valid items found for 'LEVEL' 'NAME'Correct SVD.
M235ERROR'LEVEL' 'NAME' cannot be an array.Correct SVD.
M236ERRORExpression for <'TAG'> 'NAME' not allowed.Correct SVD.
M237ERRORNameless 'LEVEL' must have <'TAG'>.Correct SVD.
M238ERROR'LEVEL' must not have <'TAG'>."Correct SVD.
M239ERRORDimed 'LEVEL' 'NAME' must have an expression.Correct SVD.
M240ERRORTag <'TAG'> unknown or not allowed on 'LEVEL2':'LEVEL'.Correct SVD.
M241ERRORParse Error: 'VALUE' invalid for Array generationCorrect SVD.
M242WARNING'LEVEL' 'NAME' <dimArrayIndex> found, but no <dim>Correct SVD.
M243WARNING'LEVEL' 'NAME' <dimArrayIndex> found, but <dim> does not describe an arrayCorrect SVD.

Data Check Errors

Message NumberTypeMessage TextAction
M301ERRORInterrupt number 'NUM' : 'NAME' already defined: 'NAME2' 'LINE'
M302ERRORSize of Register 'NAME':'NUM' must be 8, 16 or 32 Bits
M303WARNINGRegister name 'NAME' is prefixed with Peripheral name 'NAME2'RegName = USART_CR ==>` USART->USART_CR
M304WARNINGInterrupt number overwrite: 'NUM' : 'NAME' 'LINE'
M305ERRORName not C compliant: 'NAME' : 'HEX', replaced by '_'
M306ERRORSchema Version not set for <device>.
M307ERRORName is equal to Value: 'NAME'
M308ERRORNumber of <dimIndex> Elements 'NUM' is different to number of <dim> instances 'NUM2'
M309ERRORField 'NAME': Offset error: 'NUM'
M310ERRORField 'NAME': BitWidth error: 'NUM'
M311ERRORField 'NAME': Calculation: MSB or LSB == -1
M312ERRORAddress Block missing for Peripheral 'NAME'
M313ERRORField 'NAME': LSB > MSB: BitWith calculates to 'NUM'
M314ERRORAddress Block: <offset> or <size> not set.
M315ERRORAddress Block: <size> is zero.
M316ERROR'LEVEL' <name> not set.
M317WARNING'LEVEL' <description> not set.
M318WARNING'LEVEL' 'NAME' <'TAG'> is equal to <name>
M319WARNING'LEVEL' <'TAG'> 'NAME' ends with newline, is this intended?
M320WARNING'LEVEL' <description> 'NAME' is not very descriptive
M321WARNING'LEVEL' <'ITEM'> 'NAME' starts with '_', is this intended?
M322ERROR'LEVEL' 'ITEM' 'NAME' is meaningless text. Deleted.
M323WARNING'LEVEL' <'ITEM'> 'NAME' contains text 'TEXT'
M324ERRORField 'NAME' 'BITRANGE' does not fit into Register 'NAME2':'NUM' 'LINE'
M325ERRORCPU Revision is not set"
M326ERROREndianess is not set, using default (little)
M327ERRORNVIC Prio Bits not set or wrong value, must be 2..8. Using default (4)
M328WARNING'LEVEL' 'NAME' has no Registers, ignoring 'LEVEL'.
M329ERRORCPU Type is not set, using default (Cortex-M3)
M330ERRORInterrupt 'NAME' Number not set.
M331ERRORInterrupt 'NAME' Number 'NUM' greater 239.
M332WARNING'LEVEL' 'NAME' has only one Register.
M333ERRORDuplicate <enumeratedValue> 'NUM': 'NAME' ('USAGE'), already used by 'NAME2' ('USAGE2') 'LINE'
M334WARNING'LEVEL' <'ITEM'> 'NAME' is very long, use <description> and a shorter <name>
M335ERRORValue 'NAME':'NUM' does not fit into field 'NAME2' 'BITRANGE'.
M336ERROR'LEVEL' 'NAME' already defined 'LINE'
M337ERROR'LEVEL' 'NAME' already defined 'LINE'
M338ERRORField 'NAME' 'BITRANGE' ('ACCESS') overlaps 'NAME2' 'BITRANGE2' ('ACCESS2') 'LINE'
M339ERRORRegister 'NAME' ('ACCESS') (@'ADDRSIZE') has same address or overlaps 'NAME2' ('ACCESS2') (@'ADDRSIZE2') 'LINE'
M340ERRORNo Devices found.
M341ERRORMore than one devices found, only one is allowed per SVD File.
M342ERRORDim-extended 'LEVEL' 'NAME' must not have <headerStructName>
M343ERROR'LEVEL' 'NAME' (@'ADDR') has same address as 'NAME2' 'LINE'
M344ERRORRegister 'NAME' (@'ADDRSIZE') is outside or does not fit any <addressBlock> specified for Peripheral 'NAME2' 'TEXT'
M345ERRORField 'NAME' 'BITRANGE' does not fit into Register 'NAME2':'NUM'
M346WARNINGRegister 'NAME' (@'ADDR') offset is equal or is greater than it's Peripheral base address 'NAME2' (@'ADDR2'), is this intended?
M347WARNINGField 'NAME' (width < 6Bit) without any <enumeratedValue> found.
M348ERRORAlternate 'LEVEL' 'NAME' does not exist at 'LEVEL' address (@'ADDR')
M349ERRORAlternate 'LEVEL' 'NAME' is equal to 'LEVEL' name 'NAME2'
M350WARNINGPeripheral 'NAME' (@'ADDR') is not 4Byte-aligned.
M351WARNINGPeripheral 'TYPE' 'NAME' is equal to Peripheral name.
M352WARNINGAddressBlock of Peripheral 'NAME' (@'ADDR') 'TEXT' overlaps 'NAME2' (@'ADDR2') 'TEXT2' 'LINE'
M353WARNINGPeripheral group name 'NAME' should not end with '_'
M354ERRORInterrupt ''NUM':'NAME' specifies a Core Interrupt. Core Interrupts must not be defined, they are set through <cpu><name>.
M355ERRORNo Interrupts found on pos. 0..15. External (Vendor-)Interrupts possibly defined on position 16+. External Interrupts must start on position 0
M356WARNINGNo Interrupt definitions found.
M357ERRORCore Interrupts found. Interrupt Numbers are wrong. Internal Interrupts must not be described, External Interrupts must start at 0.
M358ERRORAddressBlock of Peripheral 'NAME' 'TEXT' overlaps AddressBlock 'TEXT2' in same peripheral 'LINE'
M359ERRORAddress Block: <usage> not set.
M360ERRORAddress Block: found <'TAG'> ('HEXNUM') > 'HEXNUM2'.
M361ERROR'LEVEL' 'ITEM' 'NAME': 'RESERVED' items must not be defined.
M362WARNING'LEVEL' 'ITEM' 'NAME': 'RESERVED' items must not be defined.
M363ERRORCPU: <sauNumRegions> not set.
M364ERRORCPU: <sauNumRegions> value 'NUM' greater than SAU max num ('NUM2')
M365WARNINGRegister 'NAME' ('ACCESS') (@'ADDRSIZE') has same address or overlaps 'NAME2' ('ACCESS2') (@'ADDRSIZE2') 'LINE'
M366ERRORRegister 'NAME' size ('NUM'Bit) is greater than <dimIncrement> * <addressBitsUnits> ('NUM2'Bit).
M367WARNINGAccess Type: Field 'NAME' ('ACCESS') does not match Register 'NAME2' ('ACCESS2')
M368WARNING'LEVEL' 'NAME' (@'ADDR') has same address as 'NAME2' 'LINE'
M369ERROREnumerated Value 'NAME': <value> not set.
M370ERROR'LEVEL' 'NAME': <offset> not set.
M371ERROR'LEVEL' 'NAME' <headerStructName> is equal to hierarchical name
M372ERROR'LEVEL' <'TAG'> 'NAME' already defined 'LINE'
M373ERROR'LEVEL' <'TAG'> 'NAME' already defined 'LINE'
M374WARNING<enumeratedValues> can be one <enumeratedValues> container for all <enumeratedValue>s, where <usage> can be read, write, or read-write or two <enumeratedValues> containers, where one is set to <usage> read and the other is set to <usage> write
M375ERROR'LEVEL' 'NAME' (<enumeratedValues> 'NAME2'): Too many <enumeratedValues> container specified.
M376ERROR'LEVEL' 'NAME' (<enumeratedValues> 'NAME2'): 'USAGE' container already defined in 'LINE'.
M377ERROR'LEVEL' 'NAME' (<enumeratedValues> 'NAME2'): 'USAGE' container conflicts with 'NAME3' 'LINE'.
M378ERRORRegister Array: Register 'NAME' size ('NUM'Bit) does not match <dimIncrement> ('NUM2'Bit).
M379ERRORXBin Number 'NAME' too large, skipping evaluation.
M380ERRORAddressBlock of Peripheral 'NAME' (@'ADDR') 'TEXT' does not fit into 32Bit Address Space.
M381ERRORInterrupt 'NAME' Number 'NUM' greater or equal deviceNumInterrupts ('NUM2').
M382ERROR'LEVEL' 'NAME': 'NAME2' 'HEXNUM' does not fit into 'LEVEL' width: 'NUM' Bit.

Data modification errors

Message NumberTypeMessage TextAction
M517WARNINGSFD Code generation: Forbidden Trigraph '??CHAR' found in 'NAME'.
M516WARNINGSFD Code generation: Unsupported character found in 'NAME' : 'HEX'.
M518WARNINGSFD Code generation: Unsupported ESC sequence found in 'NAME' : 'CHAR'.