atbetaflight/docs/development/Building in Windows.md

4.0 KiB

Building in windows

Bash On Windows 10

A new feature in Windows 10 allows any developer to quickly and easily run an entire linux subsystem in windows and access it via a bash terminal. This gives developers full use of the entire linux OS and all of the great existing linux tools and programs. When Bash for Windows is up and running it feels like you sshed into a full linux box, except the linux distro is actually running alongside windows locally.

If you use Bash on Windows you can easily build betaflight exactly as you would for Ubuntu. (the linux distro running on Windows is Ubuntu Trusty)

Setup for Bash on Windows is very easy and takes less than 5 minutes. For instructions follow the official guide here.

Once you have Bash On Windows running you can follow the "Building in Ubuntu" instructions for building cleanfight.

##Setup Cygwin

download the Setup*.exe from https://www.cygwin.com/

Cygwin Installation

Execute the download Setup and step through the installation wizard (no need to customize the settings here). Stop at the "Select Packages" Screen and select the following Packages for Installation:

  • Devel/git
  • Devel/bash-completion (was git-completion, Optional)
  • Devel/make
  • Devel/binutils
  • Editors/vim
  • Editors/vim-common (Optional)
  • Shells/mintty (should be already selected)

Cygwin Installation

Cygwin Installation

Cygwin Installation

Cygwin Installation

Cygwin Installation

Continue with the Installation and accept all autodetected dependencies.

Cygwin Installation

##Setup GNU ARM Toolchain


versions do matter, 5.4 is known to work well. Download this version from https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-win32.zip

Extract the contents of this archive to any folder of your choice, for instance C:\dev\gcc-arm.

GNU ARM Toolchain Setup

add the "bin" subdirectory to the PATH Windows environment variable: %PATH%;C:\dev\gcc-arm\bin

GNU ARM Toolchain Setup

GNU ARM Toolchain Setup

Checkout and compile Betaflight

Head over to the Betaflight Github page and grab the URL of the GIT Repository: "https://github.com/betaflight/betaflight.git"

Open the Cygwin-Terminal, navigate to your development folder and use the git commandline to checkout the repository:

cd /cygdrive/c/dev
git clone https://github.com/betaflight/betaflight.git

GIT Checkout

GIT Checkout

To compile your Betaflight binaries, enter the Betaflight directory and build the project using the make command. You can append TARGET=[HARDWARE] if you want to build anything other than the default NAZE target:

cd betaflight
make TARGET=NAZE

GIT Checkout

within few moments you should have your binary ready:

(...)
arm-none-eabi-size ./obj/main/betaflight_NAZE.elf
   text    data     bss     dec     hex filename
  95388     308   10980  106676   1a0b4 ./obj/main/betaflight_NAZE.elf
arm-none-eabi-objcopy -O ihex --set-start 0x8000000 obj/main/betaflight_NAZE.elf obj/betaflight_NAZE.hex

You can use the Betaflight-Configurator to flash the obj/betaflight_NAZE.hex file.

Updating and rebuilding

Navigate to the local betaflight repository and use the following steps to pull the latest changes and rebuild your version of betaflight:

cd /cygdrive/c/dev/betaflight
git reset --hard
git pull
make clean TARGET=NAZE -j16 -l
make

You may want to remove -j16 -l if your having a hard time narrowing down errors. It does multithreaded make, however it makes it harder to know which warning or error comes from which file.