espressif / svd

SVD files for Espressif devices
Apache License 2.0
55 stars 2 forks source link

ESP32 SVD contains 360 errors according to the SVD Consistency Checker #27

Open littleboot opened 1 year ago

littleboot commented 1 year ago

I tried loading the latest esp32.svd inside vscode (platformio, also esp-idf plugin) for debugging. Copied the svd file to the project dir and added the svd path to platformio.ini -> debug_svd_path = ./esp32.svd

Sadly I was greeted with this error while debugging: Unable to parse SVD file: TypeError: Cannot read properties of undefined (reading 'map')

I checked the XML for formatting errors and got a warning which I think can be ignored (online check tool): Found XSD reference 'CMSIS-SVD_Schema_1_1.xsd' but unable to load it as it is not an absolute URL. Only checking for well-formedness

Next I checked the svd file using the SVDConv utility tool: This resulted in a lot of errors and warnings: Found 360 Error(s) and 1829 Warning(s). I believe this might cause the loading problem in platformio.

I attached the error log to this post. log.txt

littleboot commented 1 year ago

I did some more testing and found out that the errors are indicated by the SVDConv utility tool are valid and cause the parser to fail.

I started to correct the errors indicated manually using the technical reference manual but this took to much time, so instead of correcting the errors I started removing all registers containing errors until no errors are left. The resulting in this svd file: esp32_noerr.zip

This svd file can be loaded in vscode and used for debugging with platformio: image

I removed lots of registers to get rid off all the errors and make it work, but it can be used for debugging.

I don't have time to correct all the errors manually I hope their is a way to automate this process and get a CMSIS-compliant svd file for the ESP32.

arkanoid87 commented 1 year ago

These esp32 files are not valid according to svdconv tool

Found 360 Error(s) and 1829 Warning(s).

please find attached the output log (very verbose) for bd48e03a621d226c2f5cce1c39bf965b esp32.svd: svdconv_esp32_stdout.txt

littleboot commented 1 year ago

I'm currently using a external program as workaround, its not perfect but it works with the original svd files, maybe usefull for someone else. https://github.com/esynr3z/openocd-svd

arkanoid87 commented 1 year ago

@littleboot thanks for the link, but the point here is not about exploring the svd in a more ergonomic way than xml, but using it as machine-to-machine format to export API from it, as stated in this project readme

This format was intended for use with ARM microcontrollers, however it is still applicable to other architectures. SVD files can be used by some tools (such as [svd2rust](https://github.com/rust-embedded/svd2rust)) to generate libraries for low-level hardware access.

arkanoid87 commented 1 year ago

the provided SVDs does not comply with the official CMSIS-SVD XML schema

$ for svd in *.svd; echo \n; xmllint --noout --schema CMSIS-SVD_Schema_1_1.xsd $svd; end

esp32.svd:25: element name: Schemas validity error : Element 'name': [facet 'enumeration'] The value 'Xtensa LX6' is not an element of the set {'CM0', 'CM0PLUS', 'CM0+', 'CM1', 'CM3', 'CM4', 'CM7', 'CM23', 'CM33
', 'CM35P', 'CM55', 'CM85', 'SC000', 'SC300', 'ARMV8MML', 'ARMV8MBL', 'ARMV81MML', 'CA5', 'CA7', 'CA8', 'CA9', 'CA15', 'CA17', 'CA53', 'CA57', 'CA72', 'SMC1', 'other'}.                                           
esp32.svd:40561: element enumeratedValues: Schemas validity error : Element 'enumeratedValues': Missing child element(s). Expected is one of ( name, headerEnumName, usage, enumeratedValue ).                     
esp32.svd:40569: element enumeratedValues: Schemas validity error : Element 'enumeratedValues': Missing child element(s). Expected is one of ( name, headerEnumName, usage, enumeratedValue ).                     
esp32.svd:40577: element enumeratedValues: Schemas validity error : Element 'enumeratedValues': Missing child element(s). Expected is one of ( name, headerEnumName, usage, enumeratedValue ).                     
esp32.svd fails to validate                                                                                                                                                                                        

esp32c2.svd:5: element name: Schemas validity error : Element 'name': [facet 'pattern'] The value 'ESP32-C2' is not accepted by the pattern '[_A-Za-z0-9]*'.                                                       
esp32c2.svd:25: element name: Schemas validity error : Element 'name': [facet 'enumeration'] The value 'RV32IMC' is not an element of the set {'CM0', 'CM0PLUS', 'CM0+', 'CM1', 'CM3', 'CM4', 'CM7', 'CM23', 'CM33'
, 'CM35P', 'CM55', 'CM85', 'SC000', 'SC300', 'ARMV8MML', 'ARMV8MBL', 'ARMV81MML', 'CA5', 'CA7', 'CA8', 'CA9', 'CA15', 'CA17', 'CA53', 'CA57', 'CA72', 'SMC1', 'other'}.                                            
esp32c2.svd fails to validate                                                                                                                                                                                      

esp32c3.svd:5: element name: Schemas validity error : Element 'name': [facet 'pattern'] The value 'ESP32-C3' is not accepted by the pattern '[_A-Za-z0-9]*'.                                                       
esp32c3.svd:25: element name: Schemas validity error : Element 'name': [facet 'enumeration'] The value 'RV32IMC' is not an element of the set {'CM0', 'CM0PLUS', 'CM0+', 'CM1', 'CM3', 'CM4', 'CM7', 'CM23', 'CM33'
, 'CM35P', 'CM55', 'CM85', 'SC000', 'SC300', 'ARMV8MML', 'ARMV8MBL', 'ARMV81MML', 'CA5', 'CA7', 'CA8', 'CA9', 'CA15', 'CA17', 'CA53', 'CA57', 'CA72', 'SMC1', 'other'}.                                            
esp32c3.svd fails to validate                                                                                                                                                                                      

esp32c6.svd:5: element name: Schemas validity error : Element 'name': [facet 'pattern'] The value 'ESP32-C6' is not accepted by the pattern '[_A-Za-z0-9]*'.                                                       
esp32c6.svd:25: element name: Schemas validity error : Element 'name': [facet 'enumeration'] The value 'RV32IMAC' is not an element of the set {'CM0', 'CM0PLUS', 'CM0+', 'CM1', 'CM3', 'CM4', 'CM7', 'CM23', 'CM33
', 'CM35P', 'CM55', 'CM85', 'SC000', 'SC300', 'ARMV8MML', 'ARMV8MBL', 'ARMV81MML', 'CA5', 'CA7', 'CA8', 'CA9', 'CA15', 'CA17', 'CA53', 'CA57', 'CA72', 'SMC1', 'other'}.                                           
esp32c6.svd fails to validate                                                                                                                                                                                      

esp32h2.svd:5: element name: Schemas validity error : Element 'name': [facet 'pattern'] The value 'ESP32-H2' is not accepted by the pattern '[_A-Za-z0-9]*'.                                                       
esp32h2.svd:25: element name: Schemas validity error : Element 'name': [facet 'enumeration'] The value 'RV32IMAC' is not an element of the set {'CM0', 'CM0PLUS', 'CM0+', 'CM1', 'CM3', 'CM4', 'CM7', 'CM23', 'CM33
', 'CM35P', 'CM55', 'CM85', 'SC000', 'SC300', 'ARMV8MML', 'ARMV8MBL', 'ARMV81MML', 'CA5', 'CA7', 'CA8', 'CA9', 'CA15', 'CA17', 'CA53', 'CA57', 'CA72', 'SMC1', 'other'}.                                           
esp32h2.svd fails to validate                                                                                                                                                                                      

esp32s2.svd:5: element name: Schemas validity error : Element 'name': [facet 'pattern'] The value 'ESP32-S2' is not accepted by the pattern '[_A-Za-z0-9]*'.                                                       
esp32s2.svd:25: element name: Schemas validity error : Element 'name': [facet 'enumeration'] The value 'Xtensa LX7' is not an element of the set {'CM0', 'CM0PLUS', 'CM0+', 'CM1', 'CM3', 'CM4', 'CM7', 'CM23', 'CM
33', 'CM35P', 'CM55', 'CM85', 'SC000', 'SC300', 'ARMV8MML', 'ARMV8MBL', 'ARMV81MML', 'CA5', 'CA7', 'CA8', 'CA9', 'CA15', 'CA17', 'CA53', 'CA57', 'CA72', 'SMC1', 'other'}.                                         
esp32s2.svd fails to validate                                                                                                                                                                                      

esp32s3.svd:5: element name: Schemas validity error : Element 'name': [facet 'pattern'] The value 'ESP32-S3' is not accepted by the pattern '[_A-Za-z0-9]*'.                                                       
esp32s3.svd:25: element name: Schemas validity error : Element 'name': [facet 'enumeration'] The value 'Xtensa LX7' is not an element of the set {'CM0', 'CM0PLUS', 'CM0+', 'CM1', 'CM3', 'CM4', 'CM7', 'CM23', 'CM
33', 'CM35P', 'CM55', 'CM85', 'SC000', 'SC300', 'ARMV8MML', 'ARMV8MBL', 'ARMV81MML', 'CA5', 'CA7', 'CA8', 'CA9', 'CA15', 'CA17', 'CA53', 'CA57', 'CA72', 'SMC1', 'other'}.                                         
esp32s3.svd fails to validate
littleboot commented 1 year ago

@arkanoid87 to come back to your reply, "exploring the svd in a more ergonomic way than xml" our goals may differ. My purpose and the main reason why I would like to have a compliant svd file is that I hope that this will fix the problem with the peripheral viewer (vscode idf plugin and platformio) not working while debugging with the available svd files. I would like to have this working to be able to properly debug my custom low level peripheral drivers. The vscode idf plugin launches openocd with the telnet server enabled when debugging, this allows the "openocd-svd" program to connect to it and function as a external peripheral viewer / editor when using vscode as IDE for development