Marus / cortex-debug

Visual Studio Code extension for enhancing debug capabilities for Cortex-M Microcontrollers
MIT License
1.02k stars 240 forks source link

Allow string for cpuFrequency and swoFrequency #1060

Open mm-mm-bb opened 1 week ago

mm-mm-bb commented 1 week ago

I need to support different chip with clock speed. The setup is:

Unfortunately, while this work for stuff like the swoPort, on the cpuFrequency field i get error "Expected "number"."

Describe the solution you'd like Allow cpuFrequency and swoFrequency (but really any numeric field) to be a string. Something similar was implemented here: https://github.com/microsoft/vscode-js-debug/pull/1880/files

Describe alternatives you've considered CMake would have to edit the launch.json and not only the setting.json. (launch.json using cacheVariables directly would NOT fix, as seems ${} must be in quotes to work)

haneefdm commented 1 week ago

Show me what your launch.json line for swoConfig.cpuFrequency looks like now and after the change. I am not understanding

mm-mm-bb commented 1 week ago

this works

  "swoConfig":{
      [...]
      "swoFrequency": 2250000,
      [...]
   }

this does not work (not a number error)

  "swoConfig":{
      [...]
      "swoFrequency": "${config:target_core_clock}",
      [...]
   }

this does not work (unrecognized syntax)

  "swoConfig":{
      [...]
      "swoFrequency": ${config:target_core_clock},
      [...]
   }

target_core_clock is defined in .vscode/settings.json. Im using other variables set there, for example "svdFile": "${config:TARGET_SVD}", and that is fine

mm-mm-bb commented 6 days ago

ok, took a little look at the code unfortunately is my first time looking at .ts. seems like some of the field are string, some are numerics: https://github.com/Marus/cortex-debug/blob/8210ae481352e00955fb60265d29378f0a5855c5/src/common.ts#L199

not sure if the fix is as easy as changing to string, as that may break existing setups; maybe string|number is possible?

@haneefdm if you give me a hint on what is the best solution, i may give a try this weekend :)