Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.
This repository was archived by the owner on Jun 16, 2026. It is now read-only.

"Select Compiler" configuration causes modification of defines in csolution.yml #217

Closed

Description

@VladimirUmek

Type: Bug Report

Describe the bug

  • OS and Version: Windows 11
  • VS Code Version: 1.98.2
  • Extension Version: Arm CMSIS Solution 1.50.0

I have a csolution.yml with select compiler options (and without compiler selected):

solution
  select-compiler:
    - compiler: AC6
    - compiler: GCC
    - compiler: CLANG
    - compiler: IAR

This same solution file has target types:

solution:
  target-types:
    - type: CM33
      device: ARMCM33
      define:
        - NS_APP_START_ADDRESS: 0x00200000
      variables:
        - Target-Layer: ../../../Target/CM33/Target.clayer.yml

When I open this solution with VS Code, CMSIS Solution extensions opens "Configure Solution" tab with "Select Compiler" options to select compiler. After I click "OK" my csolution.yml gets modified:

  • compiler node is added
  • all defines in target type get modified

The target type gets modified to:

    - type: CM33
      device: ARMCM33
      define:
        - NS_APP_START_ADDRESS: "2097152"
      variables:
        - Target-Layer: ../../../Target/CM33/Target.clayer.yml

To Reproduce
Use CMSIS-FreeRTOS Examples to reproduce the behavior. Open "Examples" directory with VS Code.

Expected behavior
Only compiler node shall be added, the rest of the solution file shall be unmodified.

Activity

  1. added
    bug
    on Mar 27, 2025
  2. added theissue type on Mar 31, 2025
  3. JonatanAntoni commented on Mar 31, 2025

    @JonatanAntoni
    Member

    This looks like a serialization-deserialization issue in the yaml writer. I.e., in the given example the define's value is provided in hexadecimal format and gets converted into decimal format on write.
    cc @edriouk

  4. moved this from Backlog to In progress in CMSIS Solution Extensionon Apr 3, 2025
  5. JonatanAntoni commented on Apr 3, 2025

    @JonatanAntoni
    Member

    @VladimirUmek, as already suspected, this conversion is done by the yaml parser. I.e., it detects 0x00200000 as a valid integer value and discards the formatting information. On write the integer is then serialized in decimal format.

    As a workaround, one could wrap the value in double quotes like "0x00200000". This prevents the yaml parser to convert the value to integer and keep it as string, instead.

    For a permanent fix, we'd need to decide how we want to handle numbers.

  6. edriouk commented on Apr 4, 2025

    @edriouk
    Collaborator

    I'll try Implementation suggested by ChatGPT:

    
    To detect and preserve hex numbers like 0x00200000, you can use custom YAML types in js-yaml.
    
    ✅ Solution: Define a custom YAML type for hex numbers
    Here's how you can create a custom type that treats values starting with 0x as strings or stores them as custom types to preserve formatting.
    
    1. Install js-yaml
    bash
    Copy
    Edit
    npm install js-yaml
    2. Sample code to parse and stringify hex values:
    js
    Copy
    Edit
    const yaml = require('js-yaml');
    
    // Define custom hex type
    const HEX_TYPE = new yaml.Type('tag:yaml.org,2002:hex', {
      kind: 'scalar',
      resolve: (data) => typeof data === 'string' && /^0x[0-9a-fA-F]+$/.test(data),
      construct: (data) => data, // Keep it as string
      instanceOf: String,
      represent: (data) => data
    });
    
    // Create custom schema
    const CUSTOM_SCHEMA = yaml.DEFAULT_SCHEMA.extend([HEX_TYPE]);
    
    const input = `
    define:
      - NS_APP_START_ADDRESS: 0x00200000
    `;
    
    const doc = yaml.load(input, { schema: CUSTOM_SCHEMA });
    
    console.log(doc); // It will keep 0x00200000 as a string
    
    // When dumping it back:
    const output = yaml.dump(doc, { schema: CUSTOM_SCHEMA });
    console.log(output);
    
  7. edriouk commented on Apr 6, 2025

    @edriouk
    Collaborator

    Fixed in PR https://github.com/Arm-Debug/vscode-cmsis-csolution/pull/2215
    It ensures all numbers are stored as strings in the original format.

    This however does not fix the issue entirely, since YAML library forces quotes to the output strings representing numbers.
    Changes suggested by ChatGPT do not solve the problem since the emitter adds quotes afterwards and there is no way to alter that behavior.
    Thus the fix ensures that only quotes added to the original format by save:

    define:
            - NS_APP_START_ADDRESS: 0x00200000
    

    becomes

    define:
            - NS_APP_START_ADDRESS: "0x00200000"
    

    further saves do not change the quotes

  8. moved this from In progress to In review in CMSIS Solution Extensionon Apr 6, 2025
  9. moved this from In review to Done in CMSIS Solution Extensionon Apr 8, 2025
  10. closed this as completedby moving to Done in CMSIS Solution Extensionon Apr 8, 2025
  11. VladimirUmek commented on Apr 8, 2025

    @VladimirUmek
    Author

    Is current fix treated as temporary workaround?

    Note that the value of the define is also passed to the compiler executable as argument in the command string. Compiler will therefore also be invoked with something like

    armclang --target=arm-arm-none-eabi -DARMCM33 ... -DNS_APP_START_ADDRESS=2097152 ...
    

    which may be undesired as it is harder to read.

  12. VladimirUmek commented on Apr 8, 2025

    @VladimirUmek
    Author

    @brondani I understand now that what I am mentioning in my last comment is related to cbuild. Do I raise new issue in CMSIS-Toolbox repo?

  13. brondani commented on Apr 8, 2025

    @brondani
    Collaborator

    I understand now that what I am mentioning in my last comment is related to cbuild. Do I raise new issue in CMSIS-Toolbox repo?

    @VladimirUmek Yes the hexadecimal value is converted to decimal by cbuild2cmake. Please raise a new issue in CMSIS-Toolbox or in cbuild2cmake repo.

  14. edriouk commented on Apr 8, 2025

    @edriouk
    Collaborator

    I have merged new fix for VS code extension:
    https://github.com/Arm-Debug/vscode-cmsis-csolution/pull/2226
    This ensures that format for numbers (decimal and hex as well as float and boolean values is preserved.
    No quotes are added.

    Note:

    • This change will only be part of Arm CMSIS Solution extension Version 1.54
    • This is not related to the cbuild issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions