Comments (6)
See the changes introduced in #180:
You need to provide a package_root
directory to SVDParser.for_packaged_svd
or SVDParser.for_mcu
. Have a look at the examples provided for this project.
from cmsis-svd.
Instead of iterating the directory of the pkg_resources
you will need to list the contents of a directory provided externally.
Assuming you had some function get_svd_path()
that read an environment variable (cf. example I linked), you'd fetch that directory and read the list of files with e.g. opendir
/readdir
/closedir
. Similar for the vendor subdirectories.
For this to work you will have to clone the cmsis-svd-data
repository and point your script to the data directory in there (e.g. with an environment variable or some other configuration.
If you cloned said repo to /usr/share/cmsis-svd-data
you'd configure the base path to be something like /usr/share/cmsis-svd-data/data
. For the two functions I mentioned above, you simple provide this path in the first argument. Most of the changes to your gist are related to listing vendors and MCUs as that's not part of the public API in cmsis-svd AFAICS rn; thus that part has to be done by hand.
from cmsis-svd.
@zkrx thank you for your feedback, more explicit information on how to use a data folder with the cmsis-svd library will be add.
I would also like to point out, the Archlinux User Repository (AUR) you point here is not up to date, the new git remote URL for this repository is https://github.com/cmsis-svd/cmsis-svd.git
and the version of the actual main
branch is 0.5
. However, the old remote url point to the following for the moment.
About the issue related to file-svd-dump-py
contains in the gist.
-
(1) The code is out dated, the
__init__
must be reimplemented. Since the data directory has been striped from this repository, it is no longer possible to usepkg_resources.resource_listdir
to iterate over the directory which was embedded in the python package. -
(2) The Python code you point here is bugged, it uses the data directory of the cmsis-svd project moved to cmsis-svd-data, since the code do not walk recursively over the vendor directory, it can potentially skip CMSIS-SVD files. Vendor can have a directory tree structure, see the SiliconLabs directory of the cmsis-svd-data repository.
First, retrieve CMSIS-SVD files, for example clone the data repository of the cmsis-svd project.
$ cd /tmp
$ git clone https://github.com/cmsis-svd/cmsis-svd-data.git
Next rewrite the __init__()
method of your class. The __init__()
must iterate over the data directory and collect CMSIS-SVD files by vendor, for example with the previous cloned data directory of the cmsis-svd project you can do the following in the __init__()
.
from pathlib import Path
import gdb
import struct
from cmsis_svd.parser import SVDParser
SVD_DATA_DIR='/tmp/cmsis-svd-data/data'
class SVDSelector(gdb.Command):
def __init__(self):
super(SVDSelector, self).__init__("svd_load", gdb.COMMAND_USER)
self.vendors = {}
vendor_directories = Path(SVD_DATA_DIR)
for vendor_path in list(vendor_directories.iterdir()):
self.vendors[vendor_path.name] = [svd_path.name for svd_path in Path(vendor_path).glob('**/*.svd')]
Next, rewrite the invoke()
method of the class to call SVDParser.for_packaged_svd with the new interface, use SVD_DATA_DIR
as parameter.
try:
parser = SVDParser.for_packaged_svd(SVD_DATA_DIR, vendor_name, filename)
_svd_printer.set_device(parser.get_device())
I have not tested this Python code, but I think that it should work.
from cmsis-svd.
Wow, this is really more help than I would have hoped for. Thanks a lot.
I was a bit surprised as I would have expected the cmsis-svd-data
repo to be a submodule, or to be pulled during setup.py.
the new git remote URL for this repository is
yes, somehow the old URL redirects to the current one. I agree it should be updated.
more explicit information on how to use a data folder with the cmsis-svd library will be add.
I think it would be nice to have a quick mention in the README.
Perhaps the best course of action regarding the AUR is to have a 2nd cmsis-svd-data package and mark it as an (optional?) dependency. But I understand this is out of your scope.
I might try to fix the script and improve the AUR if I get the opportunity (this gdb script has been very handy for debugging), although time is lacking as always.
Again, thank you both for your time.
from cmsis-svd.
Thanks for the help.
Sorry, I'm not sure I understand. I'm trying to have the following gist to work again:
https://gist.github.com/devanlai/644910b712361e7317ec2305884aea8d#file-svd-dump-py
In particular, this fails:
class SVDSelector(gdb.Command):
def __init__(self):
super(SVDSelector, self).__init__("svd_load", gdb.COMMAND_USER)
vendor_names = pkg_resources.resource_listdir("cmsis_svd", "data")
self.vendors = {}
for vendor in vendor_names:
fnames = pkg_resources.resource_listdir("cmsis_svd", "data/%s" % vendor)
self.vendors[vendor] = [fname for fname in fnames if fname.lower().endswith(".svd")]
Traceback (most recent call last):
File "/home/user/svd-dump.py", line 266, in <module>
SVDSelector()
File "/home/user/svd-dump.py", line 70, in __init__
vendor_names = pkg_resources.resource_listdir("cmsis_svd", "data")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 1231, in resource_listdir
return get_provider(package_or_requirement).resource_listdir(resource_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 1538, in resource_listdir
return self._listdir(self._fn(self.module_path, resource_name))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 1721, in _listdir
return os.listdir(path)
^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.11/site-packages/cmsis_svd/data'
I can't find the data/ folder any longer.
from cmsis-svd.
Sorry, I closed the ticket by mistake. I'll let you handle that.
from cmsis-svd.
Related Issues (20)
- Q: Are none ARM-Cortex PR's with svd's welcome? HOT 2
- SAM{E,V,S}7X SVDs are outdated HOT 2
- Is this repo abandoned? HOT 2
- parsing blob files, possible with this lib? HOT 3
- Deriving of peripheral attributes is not working correctly
- Please make a new release in PyPI. HOT 3
- STMicro Content.txt out of date
- Compile SVD to binary for packaging
- SVD data model inconsistency due to Python attribute dynamic lookup for SVD "derivedFrom" tags HOT 2
- (suggestion) Support importing SVD files from pack files HOT 1
- Incorrect DMA register bit definition of STM32L562.svd
- No iterable field element returned if a fields name contains the string 'reserved' HOT 2
- to_dict() raises "Object of type range is not JSON serializable" for some svd files
- Incorrect address for register providing the CRC initial value.
- Question: status of this project? HOT 15
- Incorrect TIM register bit definition of STM32F429.svd
- XMC7200 svd parsing problems
- Incomplete generation of register arrays in clusters.
- Usage / Wiki
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cmsis-svd.