As a continuation of series of experiments with Basys2 board and FT232H-based JTAG adapter, I provide an easy way to generate SVF files for their further use in OpenOCD to program the board. No GUI interaction is needed, so it is saves a lot of time.
Programming the FPGA Chip
Suppose that you have generated a *.bit file for the xc3s100e chip. Converting it to SVF can be done in iMPACT's batch mode with the following script:
|
1
2
3
4
5
6
7
|
# Content of the Impact_FPGA.cmd file
setMode -bs
setCable -port svf -file "Project_FPGA.svf"
addDevice -p 1 -file "Project.bit"
addDevice -p 2 -part xcf02s
Program -p 1
exit
|
Actual generation of the SVF file is done in BASH with two lines:
|
1
2
|
[johndoe@ArchLinux]% source /opt/Xilinx/14.7/ISE_DS/settings64.sh
[johndoe@ArchLinux]% impact -batch Impact_FPGA.cmd
|
Generated Project_FPGA.svf file can be used in OpenOCD to program the FPGA chip.
Programming the PROM
For the xcf02s flash PROM, firstly we need to generate a PROM image:
|
1
|
promgen -w -s 128 -p mcs -o Project.mcs -u 0 Project.bit
|
The size of the *.bit file for the xc3s100e 72.8 kB, so the smallest size which is power of two should be 128 kB. The iMPACT script for generation of SVF, capable of programming xcf02s PROM chip:
|
1
2
3
4
5
6
7
8
|
# Content of the Impact_PROM.cmd file
setMode -bs
setCable -port svf -file "Project_PROM.svf"
addDevice -p 1 -part xc3s100e
addDevice -p 2 -part xcf02s
assignFile -p 2 -file "Project_LED.mcs"
Program -p 2 -e
exit
|
Actual generation of the SVF file is done in BASH with two lines:
|
1
2
|
[johndoe@ArchLinux]% source /opt/Xilinx/14.7/ISE_DS/settings64.sh
[johndoe@ArchLinux]% impact -batch Impact_PROM.cmd
|
Now let's program both of the chips. Start OpenOCD server:
|
1
2
3
4
5
6
7
8
9
10
11
|
[johndoe@ArchLinux]% openocd -f OpenOCD/FT232H.cfg -f OpenOCD/Basys2.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 6000 kHz
xc3s_get_dna
Info : clock speed 6000 kHz
Info : JTAG tap: prom.tap tap/device found: 0xf5045093 (mfg: 0x049 (Xilinx), part: 0x5045, ver: 0xf)
Info : JTAG tap: spartan3e.tap tap/device found: 0x11c10093 (mfg: 0x049 (Xilinx), part: 0x1c10, ver: 0x1)
Warn : gdb services need one or more targets defined
|
Login as a client and run SVF files:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
[johndoe@ArchLinux]% telnet localhost 4444
Trying ::1...
Connection failed: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> scan_chain
TapName Enabled IdCode Expected IrLen IrCap IrMask
-- ------------------- -------- ---------- ---------- ----- ----- ------
0 prom.tap Y 0xf5045093 0xf5045093 8 0x01 0x03
1 spartan3e.tap Y 0x11c10093 0x11c10093 6 0x01 0x03
> svf Project_FPGA.svf
Time used: 0m0s655ms
svf file programmed successfully for 58 commands with 0 errors
> svf Project_PROM.svf
Time used: 0m18s718ms
svf file programmed successfully for 1936 commands with 0 errors
|
Looks good but dealing with two iMPACT scripts clutters the directory with unnecessary files. Let's automate the building process and the iMPACT file generation. Here is a Makefile which does all of the work:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# Makefile
# This make file was written for Basys2 development board
Project = Sliding_LED
SVF_FPGA = $(Project)_FPGA.svf
SVF_PROM = $(Project)_PROM.svf
FlashSize = 128 # Size in kilobytes, power of two
ISE_DIR ?= /opt/Xilinx/14.7/ISE_DS
XIL_ENV ?= . $(ISE_DIR)/settings64.sh
all: Impact_FPGA.cmd Impact_PROM.cmd
$(XIL_ENV); \
for i in $^; do impact -batch $$i; done
Impact_FPGA.cmd: $(Project).bit
rm -f $@
echo "setMode -bs" > $@
echo "setCable -port svf -file \"$(SVF_FPGA)\"" >> $@
echo "addDevice -p 1 -file \"$(Project).bit\"" >> $@
echo "addDevice -p 2 -part xcf02s" >> $@
echo "Program -p 1" >> $@
echo "exit" >> $@
Impact_PROM.cmd: $(Project).mcs $(Project).cfi
rm -f $@
echo "setMode -bs" > $@
echo "setCable -port svf -file \"$(SVF_PROM)\"" >> $@
echo "addDevice -p 1 -part xc3s100e" >> $@
echo "addDevice -p 2 -part xcf02s" >> $@
echo "assignFile -p 2 -file \"$(Project).mcs\"" >> $@
echo "Program -p 2 -e" >> $@
echo "exit" >> $@
$(Project).mcs: $(Project).bit
$(XIL_ENV); \
promgen -w -s $(FlashSize) -p mcs -o $@ -u 0 $<
clean:
rm -f $(Project).mcs $(Project).cfi $(SVF_FPGA) $(SVF_PROM)
|
Building SVFs is a one-line command now:
|
1
|
[johndoe@ArchLinux]% make
|