Cygwin is a Linux-like environment in Windows. This is useful for several functions including building host apps and running python scripts. What is the particular recommended Cygwin configuration for use with ZNet and Thread projects?


Cygwin Installation and Options


  • You'll need to install Cygwin 32-Bit (NOT 64-Bit) from
  • Do NOT download the 64-bit version!! This will encounter all kinds of problems.
  • Make sure whatever shell you run cygwin in runs as Admin. Some of the executables we produce have the name "update" or "patch" in them, and Windows 7 requires Admin access to run programs with those strings in their names. If you forget to do this you'll get "permission denied" errors when running things like "make test".
  • If you want a "Run Cygwin here" in the right-click folder context menu, download the attached "run_cygwin_here.reg" file and open it (requires "chere" package)

At a minimum, make sure the following packages are installed. Pay special attention to the following instructions for some specific packages.

  • Base
    • All
  • Devel
    • Binutils
    • gcc-core, gcc-g++, gccmakedep
    • git, git-completion, git-gui
    • libgcc
    • make
    • doxygen
    • mingw
      • NOTE: The Mingw package should be mingw64-i686-***
      • DO NOT INSTALL THE BASE “mingw” PACKAGES (eg. mingw-gcc-core). Make sure to install the mingw64 packages (eg. mingw64-i686-gcc).
      • Probably easiest to just install all of the mingw64-i686-* packages.
      • Again, do not install the mingw-* packages, or the mingw64-x86_64-* packages!
  • Editors
    • Favorite editor (VIM, emacs, etc)
  • Perl
    • Perl
  • Python
    • Python
  • Net
    • inetutils
  • Shells
    • Bash, bash-completion
  • Utilities
    • ncurses
    • which
    • chere
Cygwin Setup

Edit ~/.bashrc (usually in C:\cygwin\home\{YOUR_USERNAME}\.bashrc)

Add the following to the end of the ~/.bashrc file to build znet projects on a 64-bit architecture. (Note, the ~/.bashrc file should already exist if Cygwin was installed correctly. If it does not exist, check the Cygwin installation.)

  • export E_CC="gcc -m32"
  • export E_CPP="g++ -m32"
  • export E_LD="ld -m elf_i386"
  • export CYGWIN=1
  • export NO_REAL_ECC=1

Also add the following (modifying if necessary to use the correct paths on your system)

  • export ARM_IAR6_DIR="C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0"
  • export CLASSPATH=./build::$CLASSPATH

To handle carriage returns:

  • export SHELLOPTS
  • set -o igncr

Lots of webpages out there suggest running dos2unix to convert files. This is ultimately silly because it is like trying to hold back the tide. Windows files should have CRLFs in them and tools should just ignore them.

Fortunately the Cygwin maintainers agreed with this approach and circa 2006 added a change to bash 3.2.9-10 to fix this.

You can now set the following in your .bashrc or .bash_profile

set -o igncr

This will cause bash to ignore '\r' in files.


OPTIONAL – A couple useful aliases to change directories quickly: (Change directory path if necessary)

  • Figure out where you will install the znet and ember-desktop projects, or come back to this step later, after you have installed them. Then, create the following aliases:
    • alias cdz='cd /cygdrive/c/Development/znet'
    • alias cde='cd /cygdrive/c/Development/ember-desktop'
    • alias cdp='cd /cygdrive/c/Development/znet/app/framework/plugin'

OPTIONAL – And a final alias to quickly reload .bashrc changes

  • alias reload='source ~/.bashrc'


Cygwin Cheat Sheet

(We don't maintain this page, so we can't vouch for all of the information, but it's definitely useful)


  • ZigBee and Thread
  • Thread SDK
  • Knowledge Base Articles