Skip to content

Commit 6079974

Browse files
authored
Merge pull request #8 from macmpi/dev
add systemd service (beta)
2 parents 03ce383 + cd01605 commit 6079974

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ It is **a shell script** to run on device in order to enable features, rather th
1212
- mass-storage
1313

1414
## Benefits:
15+
- simple: one single command/service to run (no kernel parameters-list & drivers fiddling)
1516
- Interoperates with most host OS computers (Linux/macOS/Windows) without additional host-side drivers or configuration required.
1617
- Supports any linux device with OTG-peripheral capability (including Raspberry Pis).
1718
- Performs initial OTG ports sanity-checks and returns diagnostics if not properly set.
1819

1920
## Setup procedure:
2021
Make sure `dwc2` (or `dwc3`) driver is previously loaded on capable device, and configuration is set to **OTG peripheral** mode: this may be driven by hardware (including cable) and/or software.\
21-
(on supporting Pi devices, just add `dtoverlay=dwc2,dr_mode=peripheral` in `config.txt` to force both by software)
22+
(on supporting Pi devices[^2], just add `dtoverlay=dwc2,dr_mode=peripheral` in `config.txt` to force both by software)
2223

2324
Then connect device to host via USB cable, and run `xg_multi` on device as follows:
2425
```
@@ -37,7 +38,9 @@ Options: -D|--Device <MAC address> Specify MAC address for device
3738
```
3839
Main execution steps are logged: `cat /var/log/messages | grep xg_multi`.
3940

40-
OpenRC files are available to run `xg_multi` as a boot service; a complete Alpine Linux [package](https://pkgs.alpinelinux.org/packages?name=xg_multi&branch=edge&repo=&arch=&origin=&flagged=&maintainer=) is also available (check [wiki](https://github.com/macmpi/xg_multi/wiki/Install) for details).
41+
Services files are provided to run `xg_multi` as a boot service; a complete Alpine Linux [package](https://pkgs.alpinelinux.org/packages?name=xg_multi&branch=edge&repo=&arch=&origin=&flagged=&maintainer=) is also available (check [wiki](https://github.com/macmpi/xg_multi/wiki/Install) for details).
42+
43+
[![Packaging status](https://repology.org/badge/vertical-allrepos/xg-multi.svg)](https://repology.org/project/xg-multi/versions)
4144

4245
*Note:*
4346
- application-specific ports setup (i.e. serial options, console bring-up, networking configuration, ...) are not in the scope of this project: user shall take care of this after gadget ports are created.\
@@ -47,9 +50,11 @@ OpenRC files are available to run `xg_multi` as a boot service; a complete Alpin
4750
cat /etc/udev/rules.d/99-ttyacms-gadget.rules
4851
ATTRS{idVendor}=="0x1d6b" ATTRS{idProduct}=="0x0104", ENV{ID_MM_DEVICE_IGNORE}="1"
4952
```
50-
- `xg_multi` is intended to run on `ash` shell within `busybox`. It may work within other environments (`bash`,...), but has not been tested (yet).
53+
- `xg_multi` is initially intended to run on `ash` shell within `busybox`, and works within other environments.
5154

5255
## Credits
5356
Kudos for info & snippets from @geekman, @Leo-PL and many others to understand/work-around various MS-Windows particularites...
5457

5558
[^1]: Windows does NOT support dual configurations (ECM/RNDIS) with composite gadget.
59+
60+
[^2]: OTG capable Pi devices include Zero serie/A/A+/3A+/4B/400/5/500/Compute-Modules
File renamed without changes.
File renamed without changes.

services/systemd/xg_multi.default

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# check available options at https://github.com/macmpi/xg_multi
2+
3+
XG_MULTI_OPTS=""
4+

services/systemd/xg_multi.service

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SPDX-FileCopyrightText: Copyright 2025, macmpi
2+
# SPDX-License-Identifier: MIT
3+
4+
# This systemd service manages xg_multi usb-gadget setup
5+
6+
[Unit]
7+
Description=Extended Multifunction Composite USB-gadget
8+
Requires=sys-kernel-config.mount
9+
After=sysinit.target sys-kernel-config.mount local-fs.target syslog.service
10+
Before=NetworkManager.service [email protected]
11+
12+
[Service]
13+
EnvironmentFile=/etc/default/xg_multi
14+
Type=oneshot
15+
RemainAfterExit=yes
16+
ExecStart=/usr/bin/xg_multi $XG_MULTI_OPTS
17+
ExecStop=/usr/bin/xg_multi -r
18+
19+
[Install]
20+
WantedBy=multi-user.target
21+

0 commit comments

Comments
 (0)