-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rtt control block into YAML config #1418
base: main
Are you sure you want to change the base?
Conversation
This follows the way in the `jlink_probe` module of getting configs
This pull request introduces 2 alerts when merging 4518c1d into a29d167 - view on LGTM.com new alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from the options.py
additions, would you mind adding your copyright to the top of the file below the others? Thanks!!
Note: `elftools` version requirement may be too strict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the changes! If you remove the change to setup.cfg
it should be ready to go!
@@ -63,6 +63,7 @@ install_requires = | |||
pyyaml>=6.0,<7.0 | |||
six>=1.15.0,<2.0 | |||
typing-extensions>=4.0,<5.0 | |||
elftools>=0.28 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package doesn't exist. The package on PyPI is actually called pyelftools
, and is already a pyocd dependency. 😄
elf = ELFFile(open(self._args.elf, "rb")) | ||
symtab = elf.get_section_by_name(".symtab") | ||
if symtab: | ||
rtt_entry = symtab.get_symbol_by_name("_SEGGER_RTT") | ||
if len(rtt_entry) > 0: | ||
rtt_cb_addr = rtt_entry[0].entry["st_value"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fyi, pyocd has some built-in support for ELF symbol extraction (and other things) in the pyocd.debug.elf
sub-package. It's based on pyelftools, so for cases like this, where there is not much advantage, it's fine to directly use pyelftools. So no need to rewrite this.
For reference, this is what this code would look like using pyocd's ELF tools:
sym_info = ELFBinaryFile(self._args.elf).symbol_decoder.get_symbol_by_name('_SEGGER_RTT')
if sym_info:
rtt_cb_addr = sym_info.value
This follows the way in the
jlink_probe
module of getting configs.Fixes the first 2 requirements in #1417