pyocd / pyocd/pyOCD

ELFSymbolProvider get_symbol_value return the symbol value +1

Open
#724 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
560
Avg merge
1h 41m
Merged PRs (30d)
3

Description

Hi,
I run my 1/2 year old script today for flashing and testing my fw. The script should flash a fw and then set a breakpoint to main and do some memory manipulation... To my surprise the breakpoint was never reached. After debugging a little bit I figured out the problem. I read the .elf file to get the address of the main function like that:
provider = ELFSymbolProvider(target.elf)
addr = provider.get_symbol_value("main")

After inspecting the addr, I figured out the address is 0x31da1. This is running on the cortex m4 (nrf52832) so this is a valid address for the cpu. The problem is that setting the breakpoint to this address wont work. The breakpoint should be 0x31da0, otherwise the debugger will never stop...

I dont know if this is intended, when I wrote my scripts the get_symbol_value was returning the even address. I dont know the pyOCD version I was using at that time. Anyway you should correct the documentation here, subtracting 1 from the address before setting the brakpoint:
https://github.com/mbedmicro/pyOCD/blob/master/docs/api_examples.md

My current version of the pyOCD is 0.22.0 and the target was nrf52832 with stlink v2 (chinese usb stick clone)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open docs/api_examples.md at the linked example and review how ELFSymbolProvider.get_symbol_value("main") is used for the breakpoint. Update the documentation to account for the returned odd address before setting the breakpoint, then confirm the example matches the reported nrf52832 behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools, documentation, embedded-iot
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.