AdaCore / AdaCore/svd2ada

Arrays are not always expanded resulting in invalid subtype declarations.

Open
#106 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ada
Stars
71
Forks
41
PR merge metrics
No merged PRs in 30d

Description

Running svd2ada on (for example) https://github.com/espressif/svd/blob/main/svd/esp32s3.svd does not always handle arrays correctly.

Taking the excerpt:

<register>
          <name>INT_RAW</name>
          <description>Raw interrupt status</description>
          <addressOffset>0x70</addressOffset>
          <size>0x20</size>
          <fields>
            <field>
              <dim>4</dim>
              <dimIncrement>0x1</dimIncrement>
              <dimIndex>0-3</dimIndex>
              <name>CH%s_TX_END</name>
              <description>The interrupt raw bit for CHANNEL%s. Triggered when transmission done.</description>
              <bitOffset>0</bitOffset>
              <bitWidth>1</bitWidth>
              <access>read-write</access>
            </field>
            <field>
              <dim>4</dim>
              <dimIncrement>0x1</dimIncrement>
              <dimIndex>0-3</dimIndex>
              <name>CH%s_TX_ERR</name>
              <description>The interrupt raw bit for CHANNEL%s. Triggered when error occurs.</description>
              <bitOffset>4</bitOffset>
              <bitWidth>1</bitWidth>
              <access>read-write</access>
            </field>

Will create:

subtype INT_RAW_CH%s_TX_END_Field is ESP32-S3.Bit;
  subtype INT_RAW_CH%s_TX_ERR_Field is ESP32-S3.Bit;
  subtype INT_RAW_CH%s_TX_THR_EVENT_Field is ESP32-S3.Bit;
  subtype INT_RAW_CH%s_TX_LOOP_Field is ESP32-S3.Bit;
  subtype INT_RAW_CH%s_RX_END_Field is ESP32-S3.Bit;
  subtype INT_RAW_CH%s_RX_ERR_Field is ESP32-S3.Bit;
  subtype INT_RAW_CH%s_RX_THR_EVENT_Field is ESP32-S3.Bit;
  subtype INT_RAW_TX_CH3_DMA_ACCESS_FAIL_Field is ESP32-S3.Bit;
  subtype INT_RAW_RX_CH7_DMA_ACCESS_FAIL_Field is ESP32-S3.Bit;

--  Raw interrupt status
  type INT_RAW_Register is record
     --  The interrupt raw bit for CHANNEL%s. Triggered when transmission
     --  done.
     CH%s_TX_END            : INT_RAW_CH%s_TX_END_Field := 16#0#;
     --  unspecified
     Reserved_1_3           : ESP32-S3.UInt3 := 16#0#;
     --  The interrupt raw bit for CHANNEL%s. Triggered when error occurs.
     CH%s_TX_ERR            : INT_RAW_CH%s_TX_ERR_Field := 16#0#;
     --  unspecified
     Reserved_5_7           : ESP32-S3.UInt3 := 16#0#;
     --  The interrupt raw bit for CHANNEL%s. Triggered when transmitter sent
     --  more data than configured value.
     CH%s_TX_THR_EVENT      : INT_RAW_CH%s_TX_THR_EVENT_Field := 16#0#;
     --  unspecified

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with svd2ada and the esp32s3.svd example linked in the report, then trace how array fields are expanded into subtype declarations and register records. The fix is complete when the generated declarations no longer contain literal % placeholders and remain valid for the shown SVD input.

Written by the indexing model from the issue text.

Assessment

Tech stack
xml
Domain
embedded-iot, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.