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

Embedded testing with Flash and HW break points #21

Open
Spudmn opened this issue May 18, 2022 · 3 comments
Open

Embedded testing with Flash and HW break points #21

Spudmn opened this issue May 18, 2022 · 3 comments

Comments

@Spudmn
Copy link
Contributor

Spudmn commented May 18, 2022

I am making some changes to get pyrsp to work with my embedded test setup.

I found that pyrsp as it is now, seems to run it’s applications from RAM, (also noticed it is using SW break points). I am adding the ability to use flash and add HW breakpoints.

Soon I will offer you a pull request for these changes. But I would like to discuss how you would like to select the option to use flash and HW Break points.

I don’t want to break any existing code so how would you like to set this option in your code?

FYI I am use a Black magic probe.

@stef
Copy link
Owner

stef commented May 18, 2022

actually i believe pyrsp runs your code from wherever the elf file maps your code section, this is even true if you run the code on an external mcu using a swd debugger.

also run has a param where to set pc to (in case there is no elf file for example) to start the running:

def run(self, start=None, setpc=True):
    """ sets pc to start if given or to entry address from elf header,
        passes control to the device and handles breakpoints
    """

btw you can do hw breakpoints "manually" by running:

tmp = self.fetch(b'Z1,%s,2' % addr)
if tmp!= b'OK': print('failed to set breakpoint')

if you want to add hw breakpoints, i think it makes most sense to change

    def set_br(self, sym, cb, quiet=False):

into

    SWBR=0;HWBR=1;WWATCH=2;RWATCH=3
    def set_br(self, sym, cb, type=SWBR, quiet=False):

and also set_br_a() accordingly

and then this line

                tmp = self.fetch(b'Z0,%s,2' % addr)

into this:

                tmp = self.fetch(b'Z%s,%s,2' % (type,addr))

@Spudmn
Copy link
Contributor Author

Spudmn commented May 19, 2022

When doing a load, pyrsp uses the “M” command.

The Black magic probe treats this as a memory write, and because it is into flash memory it has no effect (I am using a STM32F4).

I have codded up a fix for this and it writes to flash using vFlashWrite. You need to vFlashErase before and vFlashDone after you write to flash also.

Re the hw breakpoints, I will do a separate pull request for this

def set_br(self, sym, cb, type=SWBR, quiet=False):

@stef
Copy link
Owner

stef commented May 19, 2022

aaah. so it's not about running code it's about uploading code.

it would be nice if the decision between M / flash would be automatic in cortex arch.

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

No branches or pull requests

2 participants