Add support for PyOCD and labgrid-client reset subcommand - #1944
Add support for PyOCD and labgrid-client reset subcommand#1944gumulka wants to merge 10 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1944 +/- ##
========================================
+ Coverage 61.0% 62.5% +1.4%
========================================
Files 182 183 +1
Lines 14881 14995 +114
========================================
+ Hits 9086 9373 +287
+ Misses 5795 5622 -173
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
the SerialDriver does not support the ResetProtocol, so remove it from documentation. Signed-off-by: Fabian Pflug <fabian.pflug@gumulka.eu>
A CMSIS DAP cannot start a gdb server, but it can bootstrap a DUT. Signed-off-by: Fabian Pflug <fabian.pflug@gumulka.eu>
The PyOCD tool is used for example by the zephyr project to flash the devices. Add support for pyocd to bootstrap and reset a device under test. Signed-off-by: Fabian Pflug <fabian.pflug@gumulka.eu>
Add tests for pyocd and fix errors found during testing. Since the PyOCDDriver will call the pyocd binary, most tests mock away the call to pyocd, since it will only work with hardware attached. Signed-off-by: Fabian Pflug <fabian.pflug@gumulka.eu>
The PyOCDDriver does support the BootstrapProtocol and could be used to flash the device. Signed-off-by: Fabian Pflug <fabian.pflug@gumulka.eu>
Move the search for a power driver into a seperate function, which also respects the priority of power drivers. Not much of an improvement at the moment, as all have the same priority, but could maybe done later. This is in preparation for the reset command in client. Signed-off-by: Fabian Pflug <fabian.pflug@gumulka.eu>
Move the search for IO driver into a seperate function, that also handles priorities. This is in preparation of the reset command. Signed-off-by: Fabian Pflug <fabian.pflug@gumulka.eu>
Add reset subcommand to reset the board. With MCU development, the Debugger, Serial and Power can all be delivered through one USB-Port. In order to see the bootlog messages, a reset command needs to be send to the DUT without powercycling it, as this would also powercycle the USB->UART converter and defeat the point. Since the PyOCDDriver supports reset as a NetworkUSBDebugger it should be the prefered method, but do allow all other sources, that implement the ResetProtocol. Signed-off-by: Fabian Pflug <fabian.pflug@gumulka.eu>
Mock out the connection to the coordinator and ressource updates, because they are handled inside the testcase. Check that the right ressources get created and used during execution and that an error is raised, if no resources are available. Signed-off-by: Fabian Pflug <fabian.pflug@gumulka.eu>
ozan956
left a comment
There was a problem hiding this comment.
Thanks for implementing this! LGTM overall, I left only one comment regarding load_commands.
| if isinstance(self.load_commands, str): | ||
| commands = self.load_commands.split() | ||
| else: | ||
| commands = self.load_commands |
There was a problem hiding this comment.
I noticed this while testing two consecutive load() calls on the same PyOCDDriver instance with list-based load_commands.
For example:
load_commands: ["--frequency", "100"]
Then, in a custom test script:
driver.load("first.hex")
driver.load("second.hex")
The first call mutates the configured list to:
["--frequency", "100", "first.hex"]
As a result, the second call invokes:
pyocd load --frequency 100 first.hex second.hex
This does not occur across separate labgrid-client bootstrap invocations, since each CLI invocation creates a new process and driver instance. It can occur whenever the same driver object is reused programmatically.
There was a problem hiding this comment.
Hey, thanks for pointing that out! I just added a new commit, that has a pytest and a fix for it.
When calling load multiple times with load_commands as an array, the file to load was appended to the load_commands array, resulting in the second load command failing. Pointed out in labgrid-project#1944 (comment) Signed-off-by: Fabian Pflug <fabian.pflug@gumulka.eu>
Path-based matching is relatively important for labs with multiple places. Is there an upstream feature request for this? If not, please crate one and link to it here. |
Description
This PR adds support for the pyocd command line tool. A Python based tool for programming Arm Cortex microcontrollers.
The command line tool was used instead of the API, because its integration was easier and it does not add a dependency to the project.
OpenOCD is great, but working with the config files, can become quite convoluted. PyOCD on the other hand tries to figure most stuff out on its own, but does take Hints like
--targetto define which MCU is targeted. This makes it much easier to use for programming devices using labgrids bootstrap mechanism.labgrid-client bootstrap <file>has been extended to use pyocd, when a USBDebugging Interface is available on the exporter.A new subcommand
labgrid-client resethas been added to make use of theResetProtocolto reset a target.I'm currently using a single CMSIS DAP-Link controller for programming, power and serial. Since Serial and Power are done using the same USB-Port, the boot messages can only be read through a
resetcommand and not with a power-cycle.I did test some more complex commands like:
labgrid-client bootstrap build/zephyr/zephyr.signed.hex target_name=nrf52832 load_commands="-e sector -a 0x6000"and everything works fine.Checklist
Add a section on how to use the feature to doc/usage.rstAdd a section on how to use the feature to doc/development.rstPyOCD currently does not support distinguishing between adapters based on the USB-Path, but only based on serial. If there is no serial, a pseudo-serial is generated based on the path and some more data.
Maybe at some point it can be added, but not yet.