Botspot / wor-flasher

Legal utility that runs on RPiOS to flash another SD card with Windows 10/11
625 stars 76 forks source link
flasher imager linux raspberry raspberry-pi raspberry-pi-3 raspberrypi raspbian windows-10 windows-11

app icon WoR-flasher

Use a Linux machine to install Windows 10 or Windows 11 on a Raspberry Pi SD card.

In 2020, this was flat-out impossible.
In 2021, this required following a complicated tutorial.
Now, using the new WoR-flasher, it's a piece of cake.

Useful information

WoR-flasher walkthrough

Install WoR-flasher

The fastest way to get WoR-flasher running on a RPi is by using the Pi-Apps app store for Raspberry Pi:
badge
Installing WoR-flasher from Pi-Apps has several advantages: it creates a convenient button in the Start menu, uninstalling takes one click, and updates are handled seamlessly.

To manually download WoR-flasher

git clone https://github.com/Botspot/wor-flasher

This will download the scripts to a new directory named wor-flasher.
Dependencies: No need to install packages manually. Running the script will automatically install these: yad aria2 cabextract wimtools chntpw genisoimage exfat-fuse exfat-utils wget

To run WoR-flasher using the graphical interface

~/wor-flasher/install-wor-gui.sh
$ ~/wor-flasher/install-wor.sh
Choose Windows version:
1) Windows 11
2) Windows 10
3) Custom...
Enter 1, 2 or 3: 1

Choose language: en-us

Choose Raspberry Pi model to deploy Windows on:
1) Raspberry Pi 4 / 400
2) Raspberry Pi 2 rev 1.2 / 3 / CM3
Enter 1 or 2: 1

Available devices:
/dev/sdb - 59.5GB - USB Storage
Choose a device to flash the Windows setup files to: /dev/sdb

1) Create an installation drive (minimum 25 GB) capable of installing Windows to itself
2) Create a recovery drive (minimum 7 GB) to install Windows on other >16 GB drives
Choose the installation mode (1 or 2): 1

Input configuration:
DL_DIR: /home/pi/wor-flasher-files
RUN_MODE: cli
RPI_MODEL: 4
DEVICE: /dev/sdb
CAN_INSTALL_ON_SAME_DRIVE: 1
UUID: 6f7de912-4143-431b-b605-924c22ab9b1f
WIN_LANG: en-us

Formatting /dev/sdb
Generating partitions
Generating filesystems
# script output continues... It generates a Windows image legally, downloads all necessary drivers, the BIOS, the bootloader, and the modified kernel. Once done it ejects the drive.

This script is actually what does the flashing: The gui script is just a front-end that launches dialog windows and finally runs install-wor.sh in a terminal.

Environment variable options

The install-wor.sh script is designed to be used within other, larger bash scripts. For automation and customization, install-wor.sh will detect and obey certain environment variables:

Example usage:

DL_DIR=/media/pi/my-big-flash-drive DEVICE=/dev/sdg DRY_RUN=1 UUID=db8ec987-d136-4421-afb8-2ef109396b00 RPI_MODEL=4 WIN_LANG=en-us ~/wor-flasher/install-wor-gui.sh

Functions

The install-wor.sh script is designed to be used within other, larger bash scripts. For improved integration, install-wor.sh is equipped with a variety of useful functions that frontend scripts like install-wor-gui.sh can use.
To source the script so the functions are available:

source ~/wor-flasher/install-wor.sh source

Question: why does that command say "source" twice? Answer: The first "source" is a command, and the second "source" is a command-line flag that is passed to the script to let it know you are sourcing it. Once the script is sourced, these new commands (also known as functions) become available:

get_partition /dev/mmcblk0 2

Assuming partition 2 exists, the above command returns "/dev/mmcblk0p2"

get_partition /dev/mmcblk0 all

Returns every partition within the drive, each one on a line

- `get_name` - Determine a human-readable name for the given storage drive.  
Input: block device of drive  
Usage:  

get_name /dev/sda

- `get_size_raw` - Determines the size of a drive in bytes.  
Input: block device of drive  
Usage:  

get_size_raw /dev/sda

- `list_devs` - list available storage drives in a human-readable, colored format.  
Usage:  

list_devs

- `get_bid` - Get the latest Windows build ID for either Windows 10 or Windows 11  
Input: "`10`" or "`11`"
Usage:  

get_bid 11

- `get_space_free` - Get the available disk space of a folder  
Input: path to folder to check  
Usage:  

get_space_free ~/wor-flasher-files

- `get_os_name` - Get human-readable name of operating system.  
Input: valid Windows build ID  
Usage:

get_os_name 22631.2861


### Example function and variable usage
This code will non-interactively flash Windows 11 to `/dev/sda` and add overclock settings. You can copy and paste the code into a terminal, or save this as a shell script.
```bash
#make all variables we set to be visible to the script (only necessary if you run this in a terminal)
set -a

#First, source the script so its functions are available
source ~/wor-flasher/install-wor.sh source

#Determine the latest Windows 11 update ID using a function
BID="$(get_bid 11)"

#set destination RPi model
RPI_MODEL=4

#choose language
WIN_LANG=en-us

#set the device to flash
DEVICE=/dev/sda

#set a custom config.txt
CONFIG_TXT="over_voltage=6
arm_freq=2147
gpu_freq=750

# don't change anything below this point #
arm_64bit=1
enable_uart=1
uart_2ndstage=1
enable_gic=1
armstub=RPI_EFI.fd
disable_commandline_tags=1
disable_overscan=1
device_tree_address=0x1f0000
device_tree_end=0x200000
dtoverlay=miniuart-bt"

#indicate that drive is large enough to install Windows to itself
CAN_INSTALL_ON_SAME_DRIVE=1

~/wor-flasher/install-wor.sh