platformio-vscode-ide
platformio-vscode-ide copied to clipboard
SVD Parser fails for ATMega files with "TypeError: Cannot read property '0' of undefined"
See https://github.com/platformio/platform-atmelavr/pull/238 for the SVD files that this occurrs with. Tested with the Arduino Uno json file as described. platformio.ini and code as per this. If this is resolved, we would have a peripheral views for the Atmel chips, and therefore getting closer to what Atmel Studio offers.

On a sidenote, when loading the SVD files in CLion (in the "Peripherals" tab for a "PlatformIO Debug" target), it doesn't complain

And can read out some registers / addresses (but the wrong value?! They don't make sense as 32-bit values), but fails to read out the I/O registers. Probably becauase AVR memory spaces are weird and it's using the wrong commands to read them from the SRAM space (and not the Flash space) or avr-gdb has a bug or avr-stub has a bug.

It was obvious it is missing some element when parsing the XML of the SVD. By trial-and-error in comparison with a working SVD I've found that the error disappears when something like
<addressBlock>
<offset>0xNN</offset>
<size>0xNN</size>
<usage>registers</usage>
</addressBlock>
Is included under <peripherial>, which seems missing from the generated files (or at least the one I've been playing with).
This is also presents a problem debugging on RP2040 hardware: https://github.com/platformio/platform-raspberrypi/issues/21.
If it helps, I have been hacking on that minified extension.js and narrowed the problem to strange indexing in loadSVD and parse* in PeripheralTreeProvider. It looks to be taking the first character of the input strings rather than the strings themselves. Is it expecting an array? Also, the function that parses integers depending on prefix needs validation on the input.
I vote for #2587...