2021-05-22 06:18:02 -07:00
# How to build the rusEFI firmware from the source files
2021-03-28 18:30:01 -07:00
2024-03-08 16:07:20 -08:00
## Step-by-step guide to creating the build environment in windows 10+ using Windows Shell for Linux
2021-03-28 18:30:01 -07:00
2023-01-02 11:22:23 -08:00
The best way to build the rusEFI firmware is using a set of tools that run best under linux,
2021-03-28 18:30:01 -07:00
2023-01-02 11:22:23 -08:00
1. Install WSL
2023-01-06 17:10:33 -08:00
Run the following in an elevated powershell
2024-03-08 16:07:20 -08:00
```shell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
```
2021-03-28 18:30:01 -07:00
2. Download linux
2023-01-06 17:10:33 -08:00
Download the appx for linux 2004 from here:
[WSL Install Manual ](https://docs.microsoft.com/en-us/windows/wsl/install-manual )
Or type the following into powershell:
2024-03-08 16:07:20 -08:00
```shell
cd ubuntu/
Invoke-WebRequest -Uri < https: / / aka . ms / wsl-ubuntu-2004 > -OutFile Ubuntu.appx -UseBasicParsing
```
2023-01-06 17:10:33 -08:00
This command will download the file to the currently active directory.
2021-03-28 18:30:01 -07:00
2023-01-02 11:22:23 -08:00
3. install linux
2023-01-06 17:10:33 -08:00
2024-03-08 16:07:20 -08:00
```shell
PS C:\Windows\system32> cd c:/Ubuntu
PS C:\Ubuntu> Add-AppxPackage Ubuntu_2004.2020.424.0_x64.appx
```
2023-01-06 17:10:33 -08:00
Open start menu and launch linux
Wait for it to complete install and ask for username and password
2021-03-28 18:30:01 -07:00
2023-01-02 11:22:23 -08:00
4. check WSL default install
2023-01-06 17:10:33 -08:00
In powershell type:
2024-03-08 16:07:20 -08:00
```shell
wslconfig /l
```
2023-01-06 17:10:33 -08:00
Make sure the ubuntu 2004 is marked as default.
2021-03-28 18:30:01 -07:00
5. get git
2023-01-06 17:10:33 -08:00
2024-03-08 16:07:20 -08:00
```shell
sudo apt-get install git
```
2021-03-28 18:30:01 -07:00
6. clone git
2023-01-06 17:10:33 -08:00
2024-03-08 16:07:20 -08:00
```shell
git clone < https: / / github . com / YOUR-REPOSITORY / rusefi . git >
```
2021-03-28 18:30:01 -07:00
7. Run setup script
2023-01-06 17:10:33 -08:00
2024-03-08 16:07:20 -08:00
```shell
cd /home/owner/rusefi/firmware
sh setup_linux_environment.sh
```
2021-03-28 18:30:01 -07:00
8. install VScode in windows
2023-01-06 17:10:33 -08:00
Download and install as normal, is should detect WSL and ask to install the extension for it, do this and close VScode
2021-03-28 18:30:01 -07:00
9. Install VScode in linux
2023-01-06 17:10:33 -08:00
2024-03-08 16:07:20 -08:00
```shell
cd /home/owner/rusefi
code .
```
2021-03-28 18:30:01 -07:00
2023-01-02 11:22:23 -08:00
10. Hit ctrl-b and run "build unit tests"
2023-01-06 17:10:33 -08:00
Allow to run and complete, it may exit with "multiple targets" error, if so just run it a second time.
2021-03-28 18:30:01 -07:00
11. exit both VScode and ubunu
2023-01-06 17:10:33 -08:00
Click the x in VScode and type exit in ubuntu
2021-03-28 18:30:01 -07:00
12. reboot ubuntu from the start menu and run make
2023-01-06 17:10:33 -08:00
2024-03-08 16:07:20 -08:00
```shell
cd /home/owner/rusefi/firmware
make -j$(nproc)
```
2023-01-06 17:10:33 -08:00
2024-03-08 16:07:20 -08:00
This should build the firmware for the F407 Discovery board
2021-03-28 18:30:01 -07:00
13. If successful then reopen VScode in ubuntu
2023-01-06 17:10:33 -08:00
2024-03-08 16:07:20 -08:00
```shell
cd /home/owner/rusefi
code .
```
2021-03-28 18:30:01 -07:00
14. Run the built tool for the specific board in VScode
2023-01-06 17:10:33 -08:00
Ctrl-Shift-B and select the chosen board, this should build the firmware.
2021-03-28 18:30:01 -07:00
- Note submodules are their own thing - the main repo just contains a pointer to where the submodule should be checked out
2023-01-02 11:22:23 -08:00
- Zach method:
2023-01-06 17:10:33 -08:00
2021-03-28 18:30:01 -07:00
install wsl (already have ubuntu 20.04 on wsl2)
2023-01-06 17:10:33 -08:00
```shell
2024-03-08 16:07:20 -08:00
sudo apt update
sudo apt install openjdk-8-jre-headless -y
curl -O < https: / / armkeil . blob . core . windows . net / developer / Files / downloads / gnu-rm / 9-2020q2 / gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux . tar . bz2 >
tar -xf gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2
2023-01-06 17:10:33 -08:00
```
2022-02-05 11:04:32 -08:00
2023-01-06 17:10:33 -08:00
## Without WSL
2023-01-02 11:22:23 -08:00
2024-03-08 16:07:20 -08:00
A less fancy toolchain without WSL works as well.
There is [a forum thread ](https://rusefi.com/forum/viewtopic.php?f=5&t=9 ) on building the firmware, but be aware that it contains some out-of-date information.
## Linux
See [Developing on Linux ](Developing-On-Linux )