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

Add libusbK-based contrib driver package #56

Merged
merged 4 commits into from
Dec 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ OSX users can download `twib_osx64` and `twibd_osx64` from the [latest release](

## Windows

Windows support is experimental and is being improved. Windows users may download `twib_win64.exe` and `twibd_win64.exe` from the [latest release](https://github.com/misson20000/twili/releases/latest). Boot your switch with Twili installed, then run Zadig and set both of the `TransistorUSB` interfaces to `libusbK`. Run `twibd_win64.exe`, and leave it running in the background. `twib_win64.exe` should be run from the command prompt.
Windows support is experimental and is being improved. Windows users may download `twib_win64.exe` and `twibd_win64.exe` from the [latest release](https://github.com/misson20000/twili/releases/latest). Boot your switch with Twili installed, then install the libusbK-based [driver package](https://github.com/misson20000/twili/tree/master/contrib/windows/driver). Run `twibd_win64.exe`, and leave it running in the background. `twib_win64.exe` should be run from the command prompt.

# Building From Source

Expand Down
47 changes: 47 additions & 0 deletions contrib/windows/driver/Bootstrap.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Twili Driver Bootstrap Script
#
# This script downloads support tooling and libusbK, to set up the
# on-disk hierarchy to support driver installation via twili.inf
#

$LibusbkUrl = "https://sourceforge.net/projects/libusbk/files/libusbK-release/3.0.7.0/libusbK-3.0.7.0-bin.7z/download"
$LibusbkPrefix = "libusbK-3.0.7.0"
$7zipUrl = "https://www.7-zip.org/a/7z1805.msi"

New-Item -ItemType Directory tools -ErrorAction Stop | Out-Null
$env:Path += ";.\tools"

# # #
Write-Output "• Staging 7-Zip"

$WorkingFilename = [IO.Path]::GetRandomFileName()
$WorkingDirectory = [IO.Path]::GetRandomFileName()
Invoke-WebRequest $7zipUrl -OutFile $WorkingFilename
Start-Process msiexec.exe -Wait -NoNewWindow -ArgumentList @(
"/q","/a",$WorkingFilename,"TARGETDIR=$((Get-Item -Path '.\' -Verbose).FullName)\$WorkingDirectory")
Move-Item .\$WorkingDirectory\Files\7-Zip\7z.??? .\tools
Remove-Item .\$WorkingFilename
Remove-Item .\$WorkingDirectory -Recurse

# # #
Write-Output "• Staging libusbk"

New-Item -ItemType Directory @("amd64", "x86") -ErrorAction Stop | Out-Null
$WorkingFilename = [IO.Path]::GetRandomFileName()
$WorkingDirectory = [IO.Path]::GetRandomFileName()
Invoke-WebRequest $LibusbkUrl -OutFile $WorkingFilename -MaximumRedirection 3 -UserAgent "PowerShell/Windows"
Start-Process 7z.exe -Wait -ArgumentList @("x", $WorkingFilename, "-i!*\bin\dll", "-i!*\bin\sys", "-o$WorkingDirectory")

# # #
Write-Output "• Creating driver directory hierarchy"
Move-Item .\$WorkingDirectory\$LibusbkPrefix-bin\bin\*\x86\* .\x86
Move-Item .\$WorkingDirectory\$LibusbkPrefix-bin\bin\*\amd64\* .\amd64

# # #
Write-Output "• Cleaning up"
Remove-Item .\$WorkingFilename
Remove-Item .\$WorkingDirectory -Recurse

# # #
Write-Output "✓ Done"
32 changes: 32 additions & 0 deletions contrib/windows/driver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Twili USB Driver Package

This driver package associates the libtransistor USB device, and its interfaces, with libusbK for use with Twili.

## Usage

Before the driver package can be installed, you must download libusbk, create a catalog of its files, and digitally sign the catalog.

You have two options here:

1. Use the provided self-signed driver package.
2. Catalog and sign the driver package yourself.

Pick only one of these options. Temporary internet access is required during bootstrap.

### Using the provided self-signed driver package

1. Right-click `Bootstrap.ps1` and click Run with PowerShell.
2. Double-click `twili.cer` and click the Install Certificate button.
3. Follow the Certificate Import Wizard steps to install the certificate into the Local Machine `Trusted Root Certification Authorities` store.
4. Open Device Manager and double-click any of the `TransistorUSB` devices listed under the `Other devices` heading.
5. Click the Update Driver button and browse to the folder containing the provided driver package.
6. Follow on-screen instructions to complete the install.
7. Repeat steps 3-5 for any remaining `TransistorUSB` devices.

### Catalog and sign the driver package yourself

1. Right-click `Bootstrap.ps1` and click Run with PowerShell.
2. Download the [Enterprise Windows Driver Kit (EWDK)](https://docs.microsoft.com/en-us/windows-hardware/drivers/develop/using-the-enterprise-wdk) (13GB)
3. Mount the Enterprise WDK image and start a new **elevated** build environment (`LaunchBuildEnv.cmd`).
4. In that environment, navigate to the driver package location in the source tree and execute the signing script (`SignDrivers.cmd`).
5. Follow self-signed driver package installation steps 4-6.
4 changes: 4 additions & 0 deletions contrib/windows/driver/SignDrivers.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
inf2cat /os:7_X86,7_X64,8_X86,8_X64,10_X64,10_X86 /driver:.
makecert -r -pe -ss My -n "CN=ReSwitched (self-signed)" -eku 1.3.6.1.5.5.7.3.3 twili.cer
certmgr.exe /add twili.cer /s /r localMachine root
signtool sign /n ReSwitched twili.cat
Binary file added contrib/windows/driver/twili.cat
Binary file not shown.
Binary file added contrib/windows/driver/twili.cer
Binary file not shown.
Binary file added contrib/windows/driver/twili.inf
Binary file not shown.