platformio-vscode-ide icon indicating copy to clipboard operation
platformio-vscode-ide copied to clipboard

SVD Parser fails for ATMega files with "TypeError: Cannot read property '0' of undefined"

Open maxgerhardt opened this issue 4 years ago • 2 comments
trafficstars

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.

grafik

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

grafik

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.

grafik

maxgerhardt avatar Feb 10 '21 19:02 maxgerhardt

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).

evilmav avatar Jun 07 '21 18:06 evilmav

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...

devilman3d avatar Jan 04 '22 06:01 devilman3d