Wednesday 2 June 2010

ERROR: Programming Cable Locked

In case you get this error message when using the Xilinx Platform cable, he cable can be unlocked using impact with the command:

echo -e 'cleancablelock\nexit' | impact -batch

Xilinx Debugger XMD - MicroBlaze & External RAM

Just a quick recipe on how to download and run an application from externally connected memory on the MicroBlaze processor.

1.) Create a project in Xilinx EDK (start with xps from the command line), including MicroBlaze with debugging enabled.

2.) If you want speed then also enable cache and select the external memory to be cached later in the setup procedure. Enabling cache makes a huge difference in speed!

3.) In EDK's Applications tab, select 'Default: microblaze_0_bootloop' to initialise the block RAMs (BRAMs). This basically creates an infinite loop one the processor comes out of reset, preventing the system to crash, enabling the Xilinx debugger (XMD) to connect to the processor.

4.) Use impact to download the bit-file. Note that after this the processor is up and running and carrying out an infinite loop.

5.) Go to the command line and start XMD:

xmd
connect mb mdm
dow myapplication.elf
run
stop

These commands are quite straight forward (once you know them ;-)). They connect to the MicroBlaze (mb) memory debugger (mdm). With that kind of control over the memory, you can then download the binary (elf) of the application and tell the processor to run it.

Note that the elf file can be compiled either from EDK Applications tab or using mb-gcc, which is the microblaze C compiler.

Nexys2 - Configure Via USB

The Nexys2 is a low-cost FPGA development board from Digilent. It features a Xilinx Spartan-3E FPGA (500K or 1200K gate version), 16 MByte Flash/SDRAM, USB and an RS232.

The board can be powered via USB, which makes it quite convenient to use. The board can be configured in two different ways:

1.) Using a Xilinx Platform Cable

- attach cable (separade leads) to J5.
- pins 1 to 6: TMS, TDI, TDO, TCK, GND, VREF

Using the platform cable provides convenient access to the FPGA + attached SPI flash as well as the platform flash (PROM) using the impact tool from the Xilinx suite.

2.) Configuring via USB

... which does not require the expensive platform cable!

In case you run Windows, just download the Digilent Adept tool from the digilent website.

In case you run Linux you are fine thanks to the guy who wrote a nice tool called nexys2prog. It is fairly straight forward to set it up and works like a charm (example for Ubuntu / Debian):

apt-get install fxload
apt-get install libftdi
download UrJTAG and install it via:
./configure
make
make install

Now you should be ready to run the nexys2prog configuration script

nexys2prog myfile.bit

It will detect and configure the Nexys2 board when it is connected to the USB port. In order to do so, custom firmware is loaded into the board's USB controller. Unplug and replug the board in order to restore the original configuration, which is required to use Digilent Adept.