You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 16, 2026. It is now read-only.
Repository navigation
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
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:
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
@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.
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);
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:
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
Activity
JonatanAntoni commentedon Mar 31, 2025
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
JonatanAntoni commentedon Apr 3, 2025
@VladimirUmek, as already suspected, this conversion is done by the yaml parser. I.e., it detects
0x00200000as 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.
edriouk commentedon Apr 4, 2025
I'll try Implementation suggested by ChatGPT:
edriouk commentedon Apr 6, 2025
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:
becomes
further saves do not change the quotes
VladimirUmek commentedon Apr 8, 2025
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
which may be undesired as it is harder to read.
VladimirUmek commentedon Apr 8, 2025
@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?
brondani commentedon Apr 8, 2025
@VladimirUmek Yes the hexadecimal value is converted to decimal by
cbuild2cmake. Please raise a new issue in CMSIS-Toolbox or in cbuild2cmake repo.edriouk commentedon Apr 8, 2025
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: