Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

crides
Copy link

@crides crides commented Jun 12, 2022

This follows the way in the jlink_probe module of getting configs.

Fixes the first 2 requirements in #1417

This follows the way in the `jlink_probe` module of getting configs
@lgtm-com
Copy link

lgtm-com bot commented Jun 12, 2022

This pull request introduces 2 alerts when merging 4518c1d into a29d167 - view on LGTM.com

new alerts:

  • 2 for Variable defined multiple times

Copy link
Member

@flit flit left a 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!!

pyocd/subcommands/rtt_cmd.py Outdated Show resolved Hide resolved
pyocd/subcommands/rtt_cmd.py Outdated Show resolved Hide resolved
Copy link
Member

@flit flit left a 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
Copy link
Member

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

Comment on lines +138 to +143
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"]
Copy link
Member

@flit flit Jun 25, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants