Skip to content
Sean Cross edited this page Jan 19, 2018 · 23 revisions

Using Windows to develop Litex

Linux runs pretty well on Windows. Well enough to build and use Litex.

Pre-work

You can build Litex on Windows, using the Linux subsystem. To start with, Install Linux on Windows.

You can use Chocolatey as a package manager to install additional software, or you can manually install packages.

To use Bash, you can simply run "bash" from a command prompt, however it is recommended to use ConEmu.

To install Xilinx, install an X server. The preferred server is MobaXTerm.

You will need a terminal client. We use Tera Term.

You will also need a tftp server. Chocolatey has tftpd64.exe.

openocd is not in Chocolatey, but is required. Download it from [http://gnutoolchains.com/arm-eabi/openocd/](GNU Toolchains) and manually extract it and set up your PATH variable to point to the bin directory. We will assume it has been installed to C:\Program Files\OpenOCD.

Finally, you will need a tool to modify the USB driver used. Download the Visual GDB USB Driver Tool.

Install Vivado

Litex uses Vivado. You can do a console-only install, but it's usually easier to use the GUI.

  1. Open MobaXTerm
  2. Open bash
  3. run "export DISPLAY=:0"
  4. Follow the Linux instructions. Your Windows files are stored in /mnt/c/ in case you decide to download Vivado under Windows.

The Linux instructions are at Xilinx-Vivado.

Install Litex

Download & setup the LiteX Build Environment

$ git clone https://github.com/timvideos/litex-buildenv.git
$ cd litex-buildenv
$ export CPU=or1k PLATFORM=arty TARGET=net
$ ./scripts/download-env.sh

Currently, you need to download newer versions of the compiler that do not statically link glibc, due to Microsoft not implementing the deprecated vsyscall.

$ bash
$ export PATH=$PWD/build/conda/bin:$PATH
$ conda install http://hopper.mithis.com/~tim/gcc-lm32-elf-nostdc-5.4.0-20180118_145621.tar.bz2
$ conda install ...or1k...

Now you can enter the environment:

$ source ./scripts/enter-env.sh
(LX P=arty C=or1k) $

You should have "(LX P=arty C=or1k)" in your bash prompt now. NOTE: if you see an error like “bash: lm32-elf-ld: command not found...” you probably forgot to do the exports above.

Resuming Development

So you walked away and now need to start a new session. Here’s how:

$ cd litex-buildenv
$ export CPU=or1k PLATFORM=arty TARGET=net
$ source ./scripts/enter-env.sh
(LX P=arty C=or1k) $

Setting up OpenOCD

We will replace the bundled copy of openocd with a Windows version, and create a shim. We will also copy the configuration scripts to our global install of openocd.

The Arty exposes two USB devices. The first is used for programming, and the second is used for serial communication.

Open up the VisualGDB USB Driver Tool. You should see two "Diligent USB Device" listings. One is listed as "Interface 00", and the other is "Interface 01".

Double-click on "Interface 00", and then double-click on "WinUSB". This will replace the default driver with the WinUSB libusb-compatible shim.

Double-click on "Interface 01", and then double-click on "FTDI". This will replace the default driver with the official FTDI driver.

Copy the scripts into the openocd directory:

$ sudo cp -a build/conda/share/openocd/scripts/* /mnt/c/Program\ Files/OpenOCD/share/openocd/scripts/

Create a shim for openocd to redirect it to the Windows version:

$ mv build/conda/bin/openocd build/conda/bin/openocd.orig
$ vi build/conda/bin/openocd

Create the following shell script:

#!/bin/bash
nargs=$#
args=
while [ $nargs -gt 0 ]
do
  args="\"\$$nargs\" $args"
  nargs=`expr \$nargs - 1`
done
eval exec openocd.exe $args

Mark it as executable:

chmod a+x build/conda/bin/openocd
Clone this wiki locally