Skip to content

Unable to modify the name tag of enumeratedValues #294

@MarshTheBacca

Description

@MarshTheBacca

svdtools v0.5.0

When attempting to rename a field's enum, I get the following error:

[2026-01-18T22:15:41Z ERROR svdtools::cli] by svdtools (0.5.0)
    
    Caused by:
        0: Processing device `SIMPLE_DEVICE`
        1: According to `SIMPLE_PERIPHERAL`
        2: Processing peripheral `SIMPLE_PERIPHERAL`
        3: According to `SIMPLE_REGISTER`
        4: Processing register `SIMPLE_REGISTER`
        5: Processing field matched to `SIMPLE_FIELD`
        6: Adding read-write enumeratedValues
        7: `EnumeratedValues error: EnumeratedValues is empty
        8: EnumeratedValues is empty

I suspect svdtools sees the enum is renamed, and also expects the patch to also provide the enum variants, even if they're already present in the SVD.

This issue arose when trying to patch the hundreds of ENUM names in this SVD for the LPC176x5x MCUs.

Example SVD:

<?xml version="1.0" encoding="utf-8"?>
<device schemaVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="CMSIS-SVD.xsd">
  <name>SIMPLE_DEVICE</name>
  <peripherals>
    <peripheral>
      <name>SIMPLE_PERIPHERAL</name>
      <baseAddress>0x40000000</baseAddress>
      <registers>
        <register>
          <name>SIMPLE_REGISTER</name>
          <description>Example register.</description>
          <addressOffset>0x000</addressOffset>
          <fields>
            <field>
              <name>SIMPLE_FIELD</name>
              <bitRange>[0:0]</bitRange>
              <enumeratedValues>
                <name>ENUM</name>
                <enumeratedValue>
                  <name>STOP</name>
                  <value>0</value>
                </enumeratedValue>
                <enumeratedValue>
                  <name>RUN</name>
                  <value>1</value>
                </enumeratedValue>
              </enumeratedValues>
            </field>
          </fields>
        </register>
      </registers>
    </peripheral>
  </peripherals>
</device>

Example patch:

_svd: enum-issue.svd

SIMPLE_PERIPHERAL:
  SIMPLE_REGISTER:
    SIMPLE_FIELD:
      _name: "NEW_ENUM_NAME"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions