3 # WSL2 Installation instructions
5 This provides instructions on how to install, build, and use Proxmark3
6 on Windows 11, using WSL2 (and Ubuntu Linux).
9 - [WSL2 Installation instructions](#wsl2-installation-instructions)
10 - [Table of Contents](#table-of-contents)
11 - [Requirements](#requirements)
12 - [Install the Linux distribution](#install-the-linux-distribution)
13 - [One-time configuration of Windows 11 host](#one-time-configuration-of-windows-11-host)
14 - [Install Git with Credential manager](#install-git-with-credential-manager)
15 - [Install USBIPD](#install-usbipd)
16 - [USBIPD hints](#usbipd-hints)
17 - [Get a list of attached devices.](#get-a-list-of-attached-devices)
18 - [Bind the device via USBIPD (configure for sharing)](#bind-the-device-via-usbipd-configure-for-sharing)
19 - [Attach the shared device to the WSL2 distribution](#attach-the-shared-device-to-the-wsl2-distribution)
20 - [One-time configuration of the WSL2 distribution](#one-time-configuration-of-the-wsl2-distribution)
21 - [Update / upgrade the distribution](#update--upgrade-the-distribution)
22 - [Install stuff needed to build proxmark3 binaries](#install-stuff-needed-to-build-proxmark3-binaries)
23 - [Configure source files and first build](#configure-source-files-and-first-build)
24 - [Configure git to use credential helper, etc.](#configure-git-to-use-credential-helper-etc)
25 - [Clone the Iceman repository](#clone-the-iceman-repository)
26 - [Start with a release tag ("known good" version)](#start-with-a-release-tag-known-good-version)
27 - [IMPORTANT! -- Setup configuration for your device](#important----setup-configuration-for-your-device)
28 - [Compile the project](#compile-the-project)
29 - [One-time configuration to fix permissions](#one-time-configuration-to-fix-permissions)
30 - [Install the udev rules](#install-the-udev-rules)
31 - [Install the udev rules](#install-the-udev-rules-1)
32 - [77-pm3-usb-device-blacklist.rules](#77-pm3-usb-device-blacklistrules)
33 - [WORKAROUND - Kick udev into action](#workaround---kick-udev-into-action)
34 - [Verify Device Exists](#verify-device-exists)
35 - [Using the client...](#using-the-client)
36 - [Summary of repeated commands](#summary-of-repeated-commands)
42 This WSL 2 method requires Windows 11 (Build 22000 or later),
43 with WSL installed and [set to WSL2](https://learn.microsoft.com/en-us/windows/wsl/basic-commands#set-wsl-version-to-1-or-2).
45 While WSL 2 does not itself support passing through USB or
46 serial devices, it can work by using the USB/IP open-source
47 project, [`usbipd-win`](https://github.com/dorssel/usbipd-win).
50 ## Install the Linux distribution
53 Open the Windows App Store, and install Ubuntu Linux. I used Ubuntu 20.04 when
54 verifying these instructions.
56 For general WSL configuration information, see [Manage and configure Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/wsl-config).
58 Start the Linux distribution at least once, to ensure it's fully installed.
60 ## One-time configuration of Windows 11 host
63 ### Install Git with Credential manager
66 This is ***not*** required, but is ***highly*** recommended.
67 It will allow you to use the credential manager to store
68 your Git credentials more securely, and allow you to avoid
69 entering your git passwords into the WSL2 distribution.
71 Details are outside the scope of this file.
72 See the [Credential Manager docs](https://microsoft.github.io/Git-Credential-Manager-for-Windows/Docs/CredentialManager.html) for more information,
73 or checkout its [Github page](https://github.com/Microsoft/Git-Credential-Manager-for-Windows).
78 On the Windows (host) machine, use the Windows Package Manager:
84 Or alternatively, install the
85 [latest release](https://github.com/dorssel/usbipd-win/releases)
86 of `usbpid-win` (typically an `.MSI` file).
92 This is *NOT* intended to be a full description of how to use USBIPD.
93 Rather, this is intended only to give a starting point, as ***the values
94 shown here are extremely likely to differ per machine***.
96 It's presumed that you've already installed USBIPD, plugged the Proxmark
97 device into a USB port, and that it appears in Windows as a COM port.
100 > **Breaking changes in USBIPD 4.0.0 (released 2023-12-06)**
102 > * You have to share the device using `usbipd bind --busid <busid>` first.
103 > * You no longer have to install any client-side tooling.
104 > * You no longer have to specify a specific distribution.
105 > * The syntax for the command to attach has changed slightly.
107 #### Get a list of attached devices.
110 Note that this command does ***not*** require administrative privileges.
113 C:\qwert> usbipd list
116 BUSID VID:PID DEVICE STATE
117 1-2 xxxx:xxxx USB Input Device Not shared
118 2-3 xxxx:xxxx USB Mass Storage Device Not shared
119 7-4 9ac4:4b8f USB Serial Device (COM60) Not shared
125 Take note of the `BUSID` for the proxmark device, which should show
126 as a USB Serial Device. In the above example, the `BUSID` is `7-4`.
127 The VID:PID of the proxmark device is going to be one of `9ac4:4b8f`,
128 `502d:502d`, or `2d2d:504d`.
130 #### Bind the device via USBIPD (configure for sharing)
133 This is the ***only*** command that ***does*** require
134 administrative privileges with USBIPD v4.0.0. This
135 must be done once per boot of the host (Windows) machine,
136 as it configures the device to be shared via USBIPD.
138 In this example, it is configuring the device attached at
139 `BUSID` of `7-4`, as that was the proxmark device. As can
140 be seen, at least as of v4.0.0, no output is shown on success.
143 C:\qwert>usbipd bind -b 7-4
146 #### Attach the shared device to the WSL2 distribution
149 Continuing the example, this will attach (and re-attach) the
150 device with `BUSID` of `7-4` to the WSL2 distributions.
153 C:\qwert> usbipd attach --auto-attach --busid 7-4 --wsl
154 usbipd: info: Using WSL distribution 'Ubuntu-20.04' to attach; the device will be available in all WSL 2 distributions.
155 usbipd: info: Using IP address 172.xxx.xxx.1 to reach the host.
156 usbipd: info: Starting endless attach loop; press Ctrl+C to quit.
159 WSL usbip: error: Attach Request for 7-4 failed - Device not found
162 WSL usbip: error: Attach Request for 7-4 failed - Device not found
166 NOTE: This example used the `--auto-attach` option to reconnect
167 the device automatically when it's reset, uplugged/replugged, etc.
168 While this requires leaving the terminal that run the command
169 running in the background, it does make updating firmware from
172 ## One-time configuration of the WSL2 distribution
176 ### Update / upgrade the distribution
179 Start the Linux distribution you installed. First, make sure
180 the distribution is up-to-date. For example, on Ubuntu:
184 sudo apt-get upgrade -y
185 sudo apt-get auto-remove -y
188 ### Install stuff needed to build proxmark3 binaries
191 For example, on Ubuntu:
194 sudo apt-get install --no-install-recommends \
195 git ca-certificates build-essential pkg-config \
196 libreadline-dev gcc-arm-none-eabi libnewlib-dev \
197 libbz2-dev liblz4-dev libpython3-dev qtbase5-dev \
202 > * If you don't need the graphical components of the
203 > Proxmark3 client, you can skip the installation of `qtbase5-dev`.
204 > * If you don't need support for Python3 scripts in the
205 > Proxmark3 client, you can skip the installation of `libpython3-dev`.
206 > * If you don't need support for NFC ePaper devices in the
207 > PM3 device, you can skip the installation of `libgd-dev`.
209 ### Configure source files and first build
213 #### Configure git to use credential helper, etc.
217 # While optional, reduces new use of 'master' as default branch name.
218 git config --global init.defaultbranch main
219 # For example, my two commands would be:
220 # ... config --global user.name "Henry Gabryjelski"
221 # ... config --global user.email "henrygab@users.noreply.github.com"
222 git config --global user.name "Your Name"
223 git config --global user.email "yourAlias@users.noreply.github.com"
226 If you've installed and setup the Git Credential Manager
227 in the host Windows 11 machine, configure git to use it,
228 so you don't have to enter your password into the WSL2
232 git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe"
235 #### Clone the Iceman repository
240 # For example, my command would be:
241 # ... clone https://github.com/henrygab/proxmark3.git
242 # If you are using only (will not contribute changes),
243 # then you could just clone Iceman's repository directly:
244 # ... clone https://github.com/RfidResearchGroup/proxmark3.git
245 git clone https://github.com/YourUsernameHere/proxmark3.git
247 git remote add upstream https://github.com/RfidResearchGroup/proxmark3.git
250 #### Start with a release tag ("known good" version)
252 The following starts you at the release named "Steamboat Willie".
253 This reduces variables in case your first build doesn't work.
257 git checkout v4.17768
260 #### IMPORTANT! -- Setup configuration for your device
263 This can be skipped for RDV4 devices.
264 For PM3 Easy, it helps to know if your device has the external
265 flash memory chip. Most do, but some do not.
267 As an example, all my PM3 Easy devices have external flash,
268 and by default, and if I wanted to use the `HF_UNISNIFF`
269 standalone mode, my final `Makefile.platform` would be:
273 PLATFORM_EXTRAS=FLASH
274 STANDALONE=HF_UNISNIFF
275 # always ensure final line ends in line feed, or comment line
278 Without flash memory (or if not sure it's there), only the
279 first line of `PLATFORM=PM3GENERIC` is needed for a PM3Easy.
281 Here are the commands I would use to edit the file using
286 cp Makefile.platform.sample Makefile.platform
287 nano Makefile.platform
288 REM In nano editor: Ctrl-S to save; Ctrl-X to exit
291 #### Compile the project
294 Now that the project is configured for your device, it's time
295 to build the binaries.
303 Once completed, you should have a number of executable
304 files in the `~/proxmark3/` directory:
307 $ ls -lFA ~/proxmark3/pm3*
308 -rwxr-xr-x 1 q q 17849 Jan 28 11:17 /home/q/proxmark3/pm3*
309 -rwxr-xr-x 1 q q 62 Jan 28 11:17 /home/q/proxmark3/pm3-flash*
310 -rwxr-xr-x 1 q q 62 Jan 28 11:17 /home/q/proxmark3/pm3-flash-all*
311 -rwxr-xr-x 1 q q 62 Jan 28 11:17 /home/q/proxmark3/pm3-flash-bootrom*
312 -rwxr-xr-x 1 q q 62 Jan 28 11:17 /home/q/proxmark3/pm3-flash-fullimage*
315 However, ***they won't work yet***, as you have to configure
316 permissions for the device first.
320 ### One-time configuration to fix permissions
323 #### Install the udev rules
326 Verify the proxmark device is appearing as a TTY device:
330 crw------- 1 root root 166, 0 Jan 28 12:07 /dev/ttyACM0
333 Note that the permissions above only allow the `root`
334 user to access the device. These next steps adjust the
335 configuration so that the current user is added to the
336 `dialout` group, and that when the device appears, it
337 is automatically configured to permit RWX access by
340 #### Install the udev rules
344 sudo make accessrights
348 On Ubuntu, the above does two things:
349 1. Ensures the user is a member of the `dialout` group
350 2. Copies the `./driver/77-pm3-usb-device-blacklist.rules` file to the `/etc/udev/rules.d/` directory
352 The file is used when a new device arrives. Walking through some lines
355 ##### 77-pm3-usb-device-blacklist.rules
358 * `ACTION!="add|change", GOTO="pm3_usb_device_blacklist_end"`
359 Having this line first means that the rest of the file is only processed
360 when a new device is added or changed. Any other events are ignored.
361 * `SUBSYSTEM!="tty", GOTO="pm3_ignore"`
362 Having this line as the second ensures that, unless the subsystem is
363 `tty` (e.g., COM port), the lines that grant the additional permissions
365 * Multiple VID/PID lines, ending with `SYMLINK+="pm3-%n" MODE="660" GROUP="dialout"`
366 * The `SYMLINK` portion instructs to creates a symbolic link named `/dev/pm3-0` (or `/dev/pm3-1`, etc.).
367 * The `GROUP="dialout"` portion instructs to change the group ownership to the `dialout` group.
368 * The `MODE=660` portion instructs to set the permissions to `rw` for the owner (root) and the group (`dialout` per above).
370 #### WORKAROUND - Kick udev into action
374 > As of December 2024, the following still needs to be done
375 > anytime the WSL2 subsystem has been restarted (e.g., host
376 > machine reboot, first WSL2 console window, first-time config,
377 > etc.). Otherwise, it appears that `udev` service will *not*
378 > see the arrival of devices, and therefore won't modify
379 > the permissions or group ownership on the `/dev/ttyACM*`.
381 > The following commands cause `udev` to work correctly...
382 > at least until the host machine reboots, or the last WSL
383 > console window is closed for a while, or the WSL2 subsystem
384 > is updated, or ....
386 > If you keep at least one WSL2 console open, that appears
387 > to prevent the WSL subsystem from being shutdown / restarted,
388 > and thus prevents needing to rerun this command more than
392 sudo service udev restart
393 sudo udevadm trigger --action=change
396 ## Verify Device Exists
399 Verify the device exists, and has a symbolic link created:
402 $ ls -lFA /dev/ttyACM* /dev/pm3*
403 lrwxrwxrwx 1 root root 7 Jan 28 15:54 /dev/pm3-0 -> ttyACM0
404 crw-rw---- 1 root dialout 166, 0 Jan 28 15:54 /dev/ttyACM0
407 Specifically, check that each `/dev/ttyACM*` device has
408 its group set to `dialout`, and that the permissions
409 show `rw-` for both the owner and the group.
410 Also verify that each `/dev/pm3*` device is a symbolic link,
411 and points to the corresponding `/dev/ttyACM*` device.
415 ## Using the client...
418 Build and flash the client (does not update bootloader):
428 ## Summary of repeated commands
430 Each time Windows restarts:
433 C:\qwert> REM ADMINISTRATOR PRIVILEGES REQUIRED FOR THIS COMMAND
434 C:\qwert> usbipd bind --busid 7-4
437 Each time WSL2 restarts:
440 C:\qwert> usbipd attach --auto-attach --busid 7-4 --wsl
446 sudo service udev restart
447 sudo udevadm trigger --action=change
450 And for building and updating:
459 ## Script to automate environment setup
461 Use this script if you don't want to enter the above commands every single time you reboot.
463 You must have Windows Terminal installed to use this script.
465 1. Save the following script as a batch file (**pm3_quick_startup_wsl2.bat**).
466 2. Use `usbipd list` to get your Proxmark3 hardware ID and replace in the script, as using BUSID is not very reliable since it might change between reboots.
467 3. Make sure your Proxmark3 is plugged in, and it is detected in the Device Manager as a COM port.
468 4. Run **pm3_quick_startup_wsl2.bat** and accept the UAC prompt. The script auto detects and asks for admin privileges, so you don't have to right-click and select Run As Administrator.
469 5. It will open up 2 windows. The first one is Command Prompt where initializing commands will run, and you need to keep this window open. The second one is Windows Terminal, where your pm3 client will run.
474 REM -- Minimize the initial command prompt window
475 if not "%Minimized%"=="" goto :Minimized
477 start /min cmd /C "%~dpnx0"
481 REM -- Check for permissions
482 IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
483 >nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
485 >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
488 REM -- If error flag set, we do not have admin.
489 if '%errorlevel%' NEQ '0' (
490 echo Requesting administrative privileges...
492 ) else ( goto gotAdmin )
495 echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
497 echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"
499 "%temp%\getadmin.vbs"
500 del "%temp%\getadmin.vbs"
507 REM -- Start Ubuntu in a new Terminal window, change working directory to /home/proxmark3 and run Proxmark3 Client. Adjust your path accordingly.
508 start "" wt wsl.exe -d Ubuntu --cd ~/proxmark3 ./pm3
510 REM -- A trick to make this script sleep for 2 seconds, waiting for the Ubuntu session to fully initialize.
511 ping 127.0.0.1 -n 3 > nul
513 REM -- Replace the following hardware IDs with your actual Proxmark3 ID. You can find it by using "usbipd list"
514 usbipd bind --hardware-id 9ac4:4b8f
515 usbipd attach --auto-attach --hardware-id 9ac4:4b8f --wsl
517 wsl -u root "service udev restart"
518 wsl -u root "udevadm trigger --action=change"
526 Full [compilation instructions](/doc/md/Use_of_Proxmark/0_Compilation-Instructions.md) may be helpful.