Can I restrict "nrfjprog -i" from showing all connected devices on Linux?

Background info

I have 10 nRF52840-dk boards connected to a single Ubuntu machine (via usb) and have set-up 10 user accounts. The intention is, each user account to be able to access and program only one of those 10 boards.

I have set-up udev rules so that based on the serial number of the connected board, it will add it to a different group (called nrf01, nrf02 ... nrf10) and set the mode to read/write for user and group only (mode=0660). Also, each user account is also added to one of those groups.

# for all nrf52840 boards
ATTRS{idVendor}=="1366", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_PORT_IGNORE}="1"

# per board
ATTRS{idVendor}=="1366", ATTRS{serial}=="000123456789", ACTION=="add", GROUP="nrf01", MODE="0660"
ATTRS{idVendor}=="1366", ATTRS{serial}=="000234567890", ACTION=="add", GROUP="nrf02", MODE="0660"
# etc

What works

With this set-up, I can indeed program only one device from each account, provided I give the correct SN to nrfjrpog, eg "nrfjprog -f nrf52 --program blah.hex -s xxxxxxxx", and if I try to program one of the other connected devices, I get a "can't connect" type of error. Which is exactly what I want

What doesn't work (and need your help)

If though, it seems that I can only program 1 device per user account, when I do "nrfjprog -i" or "nrfjprog --deviceversion" I get all 10 connected devices! And also if I try to program a device without providing a serial number, it fails. I'm assuming because it tries to program the first board it sees, and of course due to the udev rules it cannot write to it.

So my question is, how do I need to set-up my udev rules so that "nrfjprog -i" only shows one single board per user account?

Parents Reply Children
Related