Created
June 15, 2023 12:03
-
-
Save eduardoaugustojulio/7528035e5e23b3e1dd1bf3e0f2a29301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyocd.core.helpers import ConnectHelper | |
from pyocd.flash.loader import FlashLoader | |
from pyocd.flash.eraser import FlashEraser | |
from pyocd.flash.file_programmer import FileProgrammer | |
class ClientOCD(): | |
board = None | |
target = None | |
session = None | |
def __init__(self): | |
self.session = ConnectHelper.session_with_chosen_probe(blocking=False) | |
if None != self.session: | |
self.session.open() | |
def __del__(self): | |
if None != self.session: | |
self.session.close() | |
def connect(self): | |
status = False | |
if None != self.session: | |
status = True | |
self.board = self.session.board | |
self.target = self.board.target | |
return status | |
def write_target(self, file, address, format): | |
programmer = FileProgrammer(self.session) | |
programmer.program(file, file_format=format, base_address=address) | |
def erase_target(self): | |
eraser = FlashEraser(self.session, FlashEraser.Mode.CHIP) | |
eraser.erase() | |
def reset(self): | |
self.target.reset_and_halt() | |
def resume(self): | |
self.target.resume() | |
def reset_resume(self): | |
self.reset() | |
self.resume() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment