Conversation
When pyterm is used on boards that use CDC-ACM stdio (ie. provide their own USB device), that device is not available immediately after flashing, and a `make flash term` is likely to fail. This adds a --device-timeout option to pyterm that will repeat pyterm's device opening step until the timeout is exceeded (in which case it will fail as it had before), or the device can be opened. Boards that use such a configuration will want to set PYTERMFLAGS += --device-timeout=5 or another suitable value depending on the board's expected time to go from bootloader to operational.
Does this also apply to resetting? If yes, this might become a problem with the RIOT/dist/pythonlibs/testrunner/spawn.py Lines 42 to 43 in 7a818f0
Given these problems, and the one I pointed out, I think I prefer the alternative you proposed. What does @cladmi think? |
|
Question, with #11085, does not the terminal disappear after the But it will need some migration to do an interactive synchronization (or any synchronization) with the test before dumping the output as for example: f193ffd Handling of the term not being readyI would be somehow more for a Which would make that when you do And in test, it could call This way, no issue with breaking the test due to the reconnect time not taken into account or giving a wrong failure reason: |
Whether OK, I'll shut this down then and try again with a |
That is what I expected.
Agreed. That is why I wanted to change the testing environment to not do reset anymore (or at least, not after term), but did not manage to find the time to carry the migration. |
Contribution description
When pyterm is used on boards that use CDC-ACM stdio (ie. provide their own USB device), that device is not available immediately after flashing, and a
make flash termis likely to fail.This adds a --device-timeout option to pyterm that will repeat pyterm's device opening step until the timeout is exceeded (in which case it will fail as it had before), or the device can be opened.
Boards that use such a configuration will want to set PYTERMFLAGS += --device-timeout=5 or another suitable value depending on the board's expected time to go from bootloader to operational.
Testing procedure
On a board that uses the the stdio_cdc_acm module, set PYTERMFLAGS=--device-timeout=5 and
make flash termand see that the terminal opens after a few seconds rather than failing with a "device not found" message.On other boards the test can be emulated by running
make termwith the serial connection unplugged, plugging it in a second after the command has started.Issues/PRs references
The issue will become more widespread when #11085 is available and boards like the nrf52840-dongle (#12189) become more easily usable with RIOT.
Alternatives
This solves the problem only for pyterm. Worse yet, it may still be racy if the bootloader used is occupying the same file name as the serial target. (That is the case on my board, but the race always went well, presumably because the USB reset caused by the flashing tool is immediate).
An alternative solution would be to have a
term-readytarget thattermwould always depend on, and boards could set aTERM_READY_TOOL(defaulting totrue?) that would be active in that stage. A simple tool that does not handle the racing case could be shipped as a shell script. The variable would also provide an entry point for a more sophisticated solution that can tell boot loaders apart from real terminal ttys.I could implement that as well (come to think of it writing this last line I'm leaning more and more towards that rather than this PR), but would need some guidance in the complex Makefile ecosystem.