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

buid system: improve serial port selection #18167

Merged
merged 8 commits into from
Jun 7, 2022

Conversation

maribu
Copy link
Member

@maribu maribu commented Jun 3, 2022

Contribution description

  • extend dist/tools/usb-serial/ttys.py with a --ifcae-num parameter
    • the CC2650-Launchpad exposes two USB serials, but only one is the UART bridge. The USB iface number is the only stable difference between the two
  • introduce TTY_BOARD_FILTER to let boards provide flags for dist/tools/usb-serial/ttys.py to filter only matching USB serials
    • if port selection via MOST_RECENT_PORT=1 is enabled, this will fist apply the filter and select the most recent port of the matching USB serials (if more than one)
  • provide TTY_BOARD_FILTER for a couple of boards
    • This will allow having a same54-xpro, nrf52840dk, nucleo-f767zi, and a cc2650-launchpad plugged in and make BOARD=<foo> MOST_RECENT_PORT=1 term will always pick the right USB serial
    • Beware: It cannot tell apart two Atmel/Microchip Xpro boards or two Nulceos or two boards with an embedded J-Link debugger though. So no panacea, but still can avoid manual lookup in many cases

Testing procedure

Plug in a Nucleo, a samr21-xpro (or same54-xpro), a random Nucleo, a cc2650-launchpad, and a nRF52840DK. make BOARD=<foo> MOST_RECENT_PORT=1 term should always pick the right board, no matter which order the boards were plugged in.

(I tested this successfully :))

Issues/PRs references

None

@maribu maribu added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: tools Area: Supplementary tools CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs labels Jun 3, 2022
@maribu maribu requested review from chrysn and benpicco June 3, 2022 17:54
@github-actions github-actions bot added Area: boards Area: Board ports Area: build system Area: Build system labels Jun 3, 2022
@maribu maribu force-pushed the dist/tools/usb-serial/ttys.py branch from c6948ea to 6f35842 Compare June 3, 2022 17:57
maribu added 8 commits June 3, 2022 19:59
The shorten() function was previously used to fit in overlong entries
into the table. But since it is no longer used, it can be dropped.
This is useful when a debugger provides multiple serial interfaces, e.g.
one to control the debugger and one as UART bridge.
When `MOST_RECENT_PORT` is set to `1`, the most recently added USB
serial is selected. This is a crude but surprisingly effective filter.
However, for the CC2560-Launchpad this doesn't work, as it provides
two USB serials. The first USB serial interface is the targeted UART
bridge and the second controls the debugger. Since the second is added
a tiny fraction after the first, this reliably selects the wrong
interface. Allowing the board to filter USB serials first can avoid
this issue.

This is also useful as e.g. an STM Nucleo board can easily be told
apart from an `samr21-xpro` or an nRF52840dk using such filters.
@maribu maribu force-pushed the dist/tools/usb-serial/ttys.py branch from 6f35842 to 2235874 Compare June 3, 2022 17:59
@benpicco benpicco requested a review from jeandudey June 6, 2022 23:06
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty neat - and since this only affects runs with MOST_RECENT_PORT=1 set it will barely be noticed 😉

@maribu maribu merged commit a34a4c7 into RIOT-OS:master Jun 7, 2022
@maribu
Copy link
Member Author

maribu commented Jun 7, 2022

Thx!

@maribu maribu deleted the dist/tools/usb-serial/ttys.py branch June 7, 2022 05:20
@chrysn chrysn added this to the Release 2022.07 milestone Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: build system Area: Build system Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants