Hello everyone,
I’m an engineering student at Polytech Montpellier. I’ve been working with an OpenFlexure microscope (v3.0.0-beta1 image, Raspberry Pi OS Trixie, Pi 4 + Sangaboard v5), and I built an OpenFlexure image that runs in USB peripheral mode. I’d like to present it to you and ask for your feedback and approval.
Why USB peripheral mode
The idea came from looking at what it would take to use the microscope at a hospital (Montpellier University Hospital). Networks like that make the usual setup impossible:
- Wi-Fi is WPA2-Enterprise (802.1X): every connection uses a staff member’s personal username and password. To connect the microscope, you would have to store a real person’s credentials on the Pi, and they would be stored in plain text on the SD card (in /etc/NetworkManager/system-connections/, the equivalent of wpa_supplicant.conf). That isn’t acceptable from a security standpoint: anyone with access to the SD card, or root access to the Pi, could recover that person’s account password. The microscope’s connection would also depend on one individual’s account (password changes, the person leaving, etc.).
- The wired network uses NAC: any unregistered device is cut off after about one minute.
- Getting a Raspberry Pi registered with the IT department is slow and the outcome is uncertain, and setting up your own access point or hotspot is usually not allowed.
Hospitals, universities, companies and many other institutions have similar restrictions. The idea is to keep the microscope off the network entirely: it plugs straight into the PC with a USB cable.
The image
It’s a ready-to-flash image for a blank SD card, built from the official OpenFlexure image. Once the card is flashed, the microscope boots straight into USB peripheral mode, with no configuration needed. The user plugs in the cable, opens http://10.55.0.1 in a browser and lands on the usual OpenFlexure interface. No network access is needed, no network credentials are stored on the Pi, and the microscope never appears on the local network.
What the image adds to the official image:
- dwc2 in peripheral mode on the Pi 4’s USB-C port, with a configfs gadget exposing two configurations: RNDIS (for Windows, no driver needed) and NCM (for Linux and macOS);
- a NetworkManager profile ofm-usb that gives the Pi the fixed address 10.55.0.1/24 and hands the PC an address over DHCP. It pushes no default route and no DNS, so the PC keeps its normal network connection and no traffic is routed through the microscope;
- a udev rule so NetworkManager manages usb0/usb1, which it ignored by default;
- a small service on port 80 that sets the Pi’s clock from the browser’s time (the Pi has no RTC and no internet access), then redirects to the OpenFlexure web app on :5000. Time updates are only accepted from the USB network (10.55.0.0/24);
- Wi-Fi disabled, so the USB cable is the only way to reach the microscope;
- SSH host keys and machine-id regenerated on first boot, so each flashed card gets its own identity instead of being a clone of the original card;
- the pi account currently has a login shell (/bin/bash instead of /usr/sbin/nologin in the official image), so SSH maintenance is possible over the USB cable. Before any distribution, I plan to make it closed by default, with SSH access enabled only by placing a file on the boot partition.
I didn’t modify the OpenFlexure server, and the UART link to the Sangaboard is untouched.
Power
The intended setup is this: the Sangaboard is powered by an external source (power bank or wall adapter) and powers the Pi through the GPIO header. The Pi’s USB-C port connects to the PC through a VBUS blocker, which cuts the 5 V line between them in both directions, so only the data passes. The cable between the Pi and the PC therefore carries communication only, and the Pi is never powered from two sources at once.
Test status
- Image flashed onto a new SD card: validated (first boot, partition resize, key regeneration, USB connection).
- Linux: tested and working.
- Windows: tested and working (RNDIS, no driver needed).
- macOS: not tested yet.
- Power: so far, all tests were done with the Pi powered directly by the PC through its USB-C port (data and power over the same cable, Sangaboard disconnected). The intended setup (Sangaboard powered by an external source, with a VBUS blocker between the Pi’s USB-C port and the PC so that only data passes) hasn’t been tested yet.
My questions
- Do you agree to me distributing this image? It’s based on the official OpenFlexure image. How should I name or label it so it isn’t mistaken for an official release?
- Do you see any problems with the 3.x server, for example assumptions about network interfaces or the management port :5001, or with future updates?
- Would you be interested in this as an option in the official image or documentation?
- Since the official image disables login for pi, what would you recommend for maintenance access? Is an opt-in switch on the boot partition acceptable to you?
I’d really appreciate your feedback and approval.
Thank you for all the work on OpenFlexure!
Best regards,
Tom Penfornis
Polytech Montpellier
PSL3D