Adding Xc3sprog ported to SAKC

Adding FPGA sram hdl code and user space code
Fixing some errors:
LCD's pinout connector is swapped
FPGA TDI SIGNAL must be routed to another pin (C14), right now is DQMH
Remove R11
Check JZ4725 symbol's component (PORTD is wrong)
Adding PB2 and PB3
wiring ADC's vref to external connector
Adding power LED
Adding CPU Led
This commit is contained in:
Carlos Camargo 2010-03-17 15:42:11 -05:00
parent 307c5f471b
commit a7c692d3f0
55 changed files with 3219 additions and 0 deletions

View File

@ -0,0 +1,74 @@
DESIGN = sram_bus
PINS = sram_bus.ucf
DEVICE = xc3s250e-VQ100-4
BGFLAGS = -g TdoPin:PULLNONE -g DonePin:PULLUP \
-g CRC:enable -g StartUpClk:CCLK
SIM_CMD = /opt/cad/modeltech/bin/vsim
SIM_COMP_SCRIPT = simulation/$(DESIGN)_TB.do
#SIM_INIT_SCRIPT = simulation/$(DESIGN)_init.do
SIMGEN_OPTIONS = -p $(FPGA_ARCH) -lang $(LANGUAGE)
SAKC_IP = 192.168.254.101
SRC = sram_bus.v
all: bits
remake: clean-build all
clean:
rm -f *~ */*~ a.out *.log *.key *.edf *.ps trace.dat
rm *.bit
clean-build: clean
rm -rf build
cleanall: clean
rm -rf build $(DESIGN).bit
bits: $(DESIGN).bit
#
# Synthesis
#
build/project.src:
@[ -d build ] || mkdir build
@rm -f $@
for i in $(SRC); do echo verilog work ../$$i >> $@; done
for i in $(SRC_HDL); do echo VHDL work ../$$i >> $@; done
build/project.xst: build/project.src
echo "run" > $@
echo "-top $(DESIGN) " >> $@
echo "-p $(DEVICE)" >> $@
echo "-opt_mode Area" >> $@
echo "-opt_level 1" >> $@
echo "-ifn project.src" >> $@
echo "-ifmt mixed" >> $@
echo "-ofn project.ngc" >> $@
echo "-ofmt NGC" >> $@
echo "-rtlview yes" >> $@
build/project.ngc: build/project.xst $(SRC)
cd build && xst -ifn project.xst -ofn project.log
build/project.ngd: build/project.ngc $(PINS)
cd build && ngdbuild -p $(DEVICE) project.ngc -uc ../$(PINS)
build/project.ncd: build/project.ngd
cd build && map -pr b -p $(DEVICE) project
build/project_r.ncd: build/project.ncd
cd build && par -w project project_r.ncd
build/project_r.twr: build/project_r.ncd
cd build && trce -v 25 project_r.ncd project.pcf
$(DESIGN).bit: build/project_r.ncd build/project_r.twr
cd build && bitgen project_r.ncd -l -w $(BGFLAGS)
@mv -f build/project_r.bit $@
sim:
cd simulation; $(SIM_CMD) -do $(DESIGN)_TB.do
upload: $(DESIGN).bit
scp $(DESIGN).bit root@$(SAKC_IP):

View File

@ -0,0 +1,43 @@
NET clk LOC = "P38";
NET reset LOC = "P71";
NET led LOC = "P44";
#ADDRESS BUS
NET "addr<12>" LOC = "P90";
NET "addr<11>" LOC = "P91";
NET "addr<10>" LOC = "P85";
NET "addr<9>" LOC = "P92";
NET "addr<8>" LOC = "P94";
NET "addr<7>" LOC = "P95";
NET "addr<6>" LOC = "P98";
NET "addr<5>" LOC = "P3";
NET "addr<4>" LOC = "P2";
NET "addr<3>" LOC = "P78";
NET "addr<2>" LOC = "P79";
NET "addr<1>" LOC = "P83";
NET "addr<0>" LOC = "P84";
#DATA BUS
NET "sram_data<7>" LOC = "P4";
NET "sram_data<6>" LOC = "P5";
NET "sram_data<5>" LOC = "P9";
NET "sram_data<4>" LOC = "P10";
NET "sram_data<3>" LOC = "P11";
NET "sram_data<2>" LOC = "P12";
NET "sram_data<1>" LOC = "P15";
NET "sram_data<0>" LOC = "P16";
#CONTROL BUS
NET "nwe" LOC = "P88";
NET "noe" LOC = "P86";
NET "ncs" LOC = "P69";
#ADC
#NET "ADC_EOC" LOC = "P17";
#NET "ADC_SCLK" LOC = "P18";
#NET "ADC_SDIN" LOC = "P22";
#NET "ADC_SDOUT" LOC = "P23";
#NET "ADC_CS" LOC = "P24";
#NET "ADC_CSTART" LOC = "P26";

View File

@ -0,0 +1,75 @@
`timescale 1ns / 1ps
module sram_bus(clk, sram_data, addr, nwe, ncs, noe, reset, led);
parameter B = (7);
input clk, addr, nwe, ncs, noe, reset;
inout [B:0] sram_data;
output led;
// Internal conection
wire led;
// synchronize signals
reg sncs, snwe;
reg [12:0] buffer_addr;
reg [B:0] buffer_data;
// interfaz fpga signals
wire [12:0] addr;
// bram interfaz signals
reg we;
reg w_st;
reg [B:0] wdBus;
wire [B:0] rdBus;
// interefaz signals assignments
wire T = ~noe | ncs;
assign sram_data = T?8'bZ:rdBus;
//--------------------------------------------------------------------------
// synchronize assignment
always @(negedge clk)
begin
sncs <= ncs;
snwe <= nwe;
buffer_data <= sram_data;
buffer_addr <= addr;
end
// write access cpu to bram
always @(posedge clk)
if(reset) {w_st, we, wdBus} <= 0;
else begin
wdBus <= buffer_data;
case (w_st)
0: begin
we <= 0;
if(sncs | snwe) w_st <= 1;
end
1: begin
if(~(sncs | snwe)) begin
we <= 1;
w_st <= 0;
end
else we <= 0;
end
endcase
end
RAMB16_S18 ba0( .CLK(~clk), .EN(1'b1), .SSR(1'b0), .ADDR(buffer_addr),
.WE(we), .DIP(2'b00), .DI(wdBus), .DO(rdBus) );
reg [32:0] counter;
always @(posedge clk) begin
if (reset)
counter <= {32{1'b0}};
else
counter <= counter + 1;
end
assign led = counter[24];
endmodule

Binary file not shown.

View File

@ -0,0 +1,39 @@
CC = mipsel-openwrt-linux-gcc
all: jz_init_sram jz_test_gpio
DEBUG = -O3 -g0
COMMON_SOURCES = jz47xx_gpio.c jz47xx_mmap.c
H_SOURCES = jz47xx_gpio.h jz47xx_mmap.h
INCLUDE = -I.
WARNINGS= -Wcast-align -Wpacked -Wpadded -Wall
CCFLAGS = ${INCLUDE} ${DEBUG} ${WARNINGS}
LDFLAGS =
COMMON_OBJECTS = $(COMMON_SOURCES:.c=.o)
NANO_IP = 192.168.254.101
jz_init_sram: $(COMMON_OBJECTS)
$(CC) $(LDFLAGS) $(COMMON_OBJECTS) jz_init_sram.c -o jz_init_sram
jz_test_gpio: $(COMMON_OBJECTS)
$(CC) $(LDFLAGS) $(COMMON_OBJECTS) jz_test_gpio.c -o jz_test_gpio
.c.o:
$(CC) -c $(CCFLAGS) $< -o $@
upload: jz_init_sram jz_test_gpio
scp jz_test_gpio jz_init_sram root@$(NANO_IP):
clean:
rm -f *.o jz_init_sram jz_test_gpio ${EXEC} *~
indent:
indent -bad -bap -nbc -bl -nce -i2 --no-tabs --line-length120 $(COMMON_SOURCES) $(H_SOURCES)

View File

@ -0,0 +1,108 @@
/*
JZ47xx GPIO at userspace
Copyright (C) 2010 Andres Calderon andres.calderon@emqbit.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <jz47xx_gpio.h>
#include <jz47xx_mmap.h>
#define JZ_GPIO_BASE 0x10010000
void
jz_gpio_as_output (JZ_PIO * pio, unsigned int o)
{
pio->PXFUNC = (1 << (o));
pio->PXSELC = (1 << (o));
pio->PXDIRS = (1 << (o));
}
void
jz_gpio_as_input (JZ_PIO * pio, unsigned int o)
{
pio->PXFUNC = (1 << (o));
pio->PXSELC = (1 << (o));
pio->PXDIRC = (1 << (o));
}
void
jz_gpio_set_pin (JZ_PIO * pio, unsigned int o)
{
pio->PXDATS = (1 << (o));
}
void
jz_gpio_clear_pin (JZ_PIO * pio, unsigned int o)
{
pio->PXDATC = (1 << (o));
}
void
jz_gpio_out (JZ_PIO * pio, unsigned int o, unsigned int val)
{
if (val == 0)
pio->PXDATC = (1 << (o));
else
pio->PXDATS = (1 << (o));
}
unsigned int
jz_gpio_get_pin (JZ_PIO * pio, unsigned int o)
{
return (pio->PXPIN & (1 << o)) ? 1 : 0;
}
int
jz_gpio_as_func (JZ_PIO * pio, unsigned int o, int func)
{
switch (func)
{
case 0:
pio->PXFUNS = (1 << o);
pio->PXTRGC = (1 << o);
pio->PXSELC = (1 << o);
return 1;
case 1:
pio->PXFUNS = (1 << o);
pio->PXTRGC = (1 << o);
pio->PXSELS = (1 << o);
return 1;
case 2:
pio->PXFUNS = (1 << o);
pio->PXTRGS = (1 << o);
pio->PXSELC = (1 << o);
return 1;
}
return 0;
}
JZ_PIO *
jz_gpio_map (int port)
{
JZ_PIO *pio;
pio = (JZ_PIO *) jz_mmap (JZ_GPIO_BASE);
pio = (JZ_PIO *) ((unsigned int) pio + port * 0x100);
return pio;
}

View File

@ -0,0 +1,84 @@
/*
JZ47xx GPIO at userspace
Copyright (C) 2010 Andres Calderon andres.calderon@emqbit.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef __jz47xx_gpio_h__
#define __jz47xx_gpio_h__
#define JZ_GPIO_PORT_A 0
#define JZ_GPIO_PORT_B 1
#define JZ_GPIO_PORT_C 2
#define JZ_GPIO_PORT_D 3
typedef volatile unsigned int JZ_REG; /* Hardware register definition */
typedef struct _JZ_PIO
{
JZ_REG PXPIN; /* PIN Level Register */
JZ_REG Reserved0;
JZ_REG Reserved1;
JZ_REG Reserved2;
JZ_REG PXDAT; /* Port Data Register */
JZ_REG PXDATS; /* Port Data Set Register */
JZ_REG PXDATC; /* Port Data Clear Register */
JZ_REG Reserved3;
JZ_REG PXIM; /* Interrupt Mask Register */
JZ_REG PXIMS; /* Interrupt Mask Set Reg */
JZ_REG PXIMC; /* Interrupt Mask Clear Reg */
JZ_REG Reserved4;
JZ_REG PXPE; /* Pull Enable Register */
JZ_REG PXPES; /* Pull Enable Set Reg. */
JZ_REG PXPEC; /* Pull Enable Clear Reg. */
JZ_REG Reserved5;
JZ_REG PXFUN; /* Function Register */
JZ_REG PXFUNS; /* Function Set Register */
JZ_REG PXFUNC; /* Function Clear Register */
JZ_REG Reserved6;
JZ_REG PXSEL; /* Select Register */
JZ_REG PXSELS; /* Select Set Register */
JZ_REG PXSELC; /* Select Clear Register */
JZ_REG Reserved7;
JZ_REG PXDIR; /* Direction Register */
JZ_REG PXDIRS; /* Direction Set Register */
JZ_REG PXDIRC; /* Direction Clear Register */
JZ_REG Reserved8;
JZ_REG PXTRG; /* Trigger Register */
JZ_REG PXTRGS; /* Trigger Set Register */
JZ_REG PXTRGC; /* Trigger Set Register */
JZ_REG Reserved9;
JZ_REG PXFLG; /* Port Flag Register */
JZ_REG PXFLGC; /* Port Flag clear Register */
} JZ_PIO, *PJZ_PIO;
void jz_gpio_as_output (JZ_PIO * pio, unsigned int o);
void jz_gpio_as_input (JZ_PIO * pio, unsigned int o);
void jz_gpio_set_pin (JZ_PIO * pio, unsigned int o);
void jz_gpio_clear_pin (JZ_PIO * pio, unsigned int o);
void jz_gpio_out (JZ_PIO * pio, unsigned int o, unsigned int val);
unsigned int jz_gpio_get_pin (JZ_PIO * pio, unsigned int o);
int jz_gpio_as_func (JZ_PIO * pio, unsigned int o, int func);
JZ_PIO *jz_gpio_map (int port);
#endif

View File

@ -0,0 +1,39 @@
/*
* JZ47xx GPIO lines
*
* Written 2010 by Andres Calderon andres.calderon@emqbit.com
*/
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <jz47xx_mmap.h>
void *
jz_mmap (off_t address)
{
int fd;
void *pio;
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC)) == -1)
{
fprintf (stderr, "Cannot open /dev/mem.\n");
return 0;
}
pio = (void *) mmap (0, getpagesize (), PROT_READ | PROT_WRITE, MAP_SHARED, fd, address);
if (pio == (void *) -1)
{
fprintf (stderr, "Cannot mmap.\n");
return 0;
}
return pio;
}

View File

@ -0,0 +1,14 @@
/*
* JZ47xx GPIO lines
*
* Written 2010 by Andres Calderon andres.calderon@emqbit.com
*/
#ifndef __jz47xx_mmap_h__
#define __jz47xx_mmap_h__
#include <sys/mman.h>
void *jz_mmap (off_t address);
#endif

View File

@ -0,0 +1,65 @@
/* SAKC FPGA/SRAM interface test
Copyright (C) 2010 Carlos Camargo cicamargoba@unal.edu.co
Andres Calderon andres.calderon@emqbit.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <stdio.h>
#include <unistd.h>
#include "jz47xx_gpio.h"
#include "jz47xx_mmap.h"
#define TEST_PORT JZ_GPIO_PORT_B
#define TEST_PIN 26
int
main ()
{
int i,j;
JZ_PIO *pio;
JZ_REG *virt_addr;
pio = jz_gpio_map (TEST_PORT);
jz_gpio_as_func (pio, TEST_PIN, 0);
virt_addr = (JZ_REG *) jz_mmap (0x13010000) + 0x18;
if (*virt_addr != 0xFFF7700)
{ // 0 WS, 8 bits
*virt_addr = 0xFFF7700;
printf ("Configuring CS3 16 bits and 1 WS\n");
}
else
printf ("CS3, already configured\n");
virt_addr = (JZ_REG *) jz_mmap (0x15000000);
for (i = 0; i < 255; i++)
{
virt_addr[i] = i;
}
printf ("Reading Memory..\n");
for (i = 0; i < 255; i++)
{
j = virt_addr[i];
printf ("%X = %X\n", i, j);
}
return 0;
}

View File

@ -0,0 +1,50 @@
/*
JZ47xx test gpio
Copyright (C) 2010 Andres Calderon andres.calderon@emqbit.com
Carlos Camargo cicamargoba@unal.edu.co
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <stdio.h>
#include <unistd.h>
#include "jz47xx_gpio.h"
#define TEST_PORT JZ_GPIO_PORT_D
#define TEST_PIN 23
int
main ()
{
JZ_PIO *pio = jz_gpio_map (TEST_PORT);
if (!pio)
return -1;
jz_gpio_as_output (pio, TEST_PIN);
int tg = 1;
while (1)
{
jz_gpio_out (pio, TEST_PIN, tg);
printf ("[%d]", jz_gpio_get_pin (pio, TEST_PIN));
fflush (stdout);
usleep (500 * 1000);
tg = !tg;
}
return 0;
}

340
Software/xc3sprog/COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

81
Software/xc3sprog/Makefile Executable file
View File

@ -0,0 +1,81 @@
# Spartan3 JTAG programmer and other utilities
# Copyright (C) 2004 Andrew Rogers
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
GXX=mipsel-openwrt-linux-g++
GCC=mipsel-openwrt-linux-gcc
LIBS=-lstdc++
all: xc3sprog
#debug bitparse detectchain xc3sprog
debug: debug.o iobase.o sakcXCProgrammer.o iodebug.o
${GXX} -Wall ${LIBS} $^ -o $@
bitparse: bitparse.o bitfile.o
${GXX} -Wall ${LIBS} $^ -o $@
detectchain: detectchain.o jtag.o iobase.o sakcXCProgrammer.o iodebug.o devicedb.o
${GXX} -Wall ${LIBS} $^ -o $@
xc3sprog: xc3sprog.o jtag.o iobase.o sakcXCProgrammer.o iodebug.o bitfile.o devicedb.o progalgxcf.o progalgxc3s.o jz47xx_gpio.o
${GXX} -Wall ${LIBS} $^ -o $@
debug.o: debug.cpp iobase.h sakcXCProgrammer.h iodebug.h
${GXX} -Wall -c $< -o $@
bitparse.o: bitparse.cpp bitfile.h
${GXX} -Wall -c $< -o $@
detectchain.o: detectchain.cpp iobase.h sakcXCProgrammer.h jtag.h iodebug.h devicedb.h
${GXX} -Wall -c $< -o $@
xc3sprog.o: xc3sprog.cpp iobase.h sakcXCProgrammer.h jtag.h iodebug.h bitfile.h devicedb.h progalgxcf.h progalgxc3s.h
${GXX} -Wall -c $< -o $@
iobase.o: iobase.cpp iobase.h
${GXX} -c $< -o $@
iodebug.o: iodebug.cpp iodebug.h iobase.h
${GXX} -c $< -o $@
sakcXCProgrammer.o: sakcXCProgrammer.cpp sakcXCProgrammer.h iobase.h
${GXX} -c $< -o $@
bitfile.o: bitfile.cpp bitfile.h
${GXX} -c $< -o $@
jtag.o: jtag.cpp jtag.h
${GXX} -c $< -o $@
devicedb.o: devicedb.cpp devicedb.h
${GXX} -c $< -o $@
progalgxcf.o: progalgxcf.cpp progalgxcf.h iobase.h jtag.h bitfile.h
${GXX} -c $< -o $@
progalgxc3s.o: progalgxc3s.cpp progalgxc3s.h iobase.h jtag.h bitfile.h
${GXX} -c $< -o $@
jz47xx_gpio.o: jz47xx_gpio.c jz47xx_gpio.h
${GCC} -c $< -o $@
clean:
rm -f debug.o iobase.o sakcXCProgrammer.o iodebug.o bitfile.o jtag.o xc3sprog.o
rm -f devicedb.o bitparse.o detectchain.o progalgxcf.o progalgxc3s.o
rm -f debug bitparse detectchain xc3sprog jz47xx_gpio.o *~

45
Software/xc3sprog/README Normal file
View File

@ -0,0 +1,45 @@
Spartan3 JTAG programmer and other utilities
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Please also read the file "COPYING" which is a copy of the GNU General Public License
This program should run without installation as root.
To compile:
$ make
A simple example is included that copies the switches to the LEDs on the Xilinx Spartan3 Starter Kit.
$ ./xc3sprog echo_out.bit
The Platform Flash PROM of the Xilinx Spartan3 Starter Kit can be programmed by specifying it's location in the JTAG chain. Example command line below.
$ ./xc3sprog echo_out.bit 1
There is also a utility program included that parses and prints the header of a Xilinx .bit file.
$ ./bitparse echo_out.bit

View File

@ -0,0 +1,143 @@
/* Xilinx .bit file parser
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "bitfile.h"
using namespace std;
BitFile::BitFile()
{
Error=false;
logfile=stderr;
initFlip();
buffer=0;
length=0;
}
unsigned long BitFile::load(const char *fname)
{
FILE *fp=fopen(fname,"rb");
if(fp==0){
string err="Cannot open file '";
err+=fname;
err+="'";
error(err);
return 0;
}
filename=fname;
// Parse the header
char hdr[13];
fread(hdr,1,13,fp); // 13 byte header
char key;
do{
fread(&key,1,1,fp);
if(key=='a')readField(ncdFilename,fp);
if(key=='b')readField(partName,fp);
if(key=='c')readField(date,fp);
if(key=='d')readField(time,fp);
}while(key!='e'&&!feof(fp));
if(key=='e')processData(fp); // This is the data
else{
error("Unexpected end of file");
fclose(fp);
return 0;
}
fclose(fp);
return getLength();
}
void BitFile::processData(FILE *fp)
{
byte t[4];
fread(t,1,4,fp);
length=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3];
if(buffer) delete [] buffer;
buffer=new byte[length];
for(int i=0; i<length&&!feof(fp); i++){
byte b;
fread(&b,1,1,fp);
buffer[i]=bitRevTable[b]; // Reverse the bit order.
}
if(feof(fp)){
error("Unexpected end of file");
length=0;
}
fread(t,1,1,fp);
if(!feof(fp))error("Ignoring extra data at end of file");
}
unsigned long BitFile::saveAsBin(const char *fname)
{
if(length<=0)return length;
FILE *fptr=fopen(fname,"wb");
if(fptr==0){
string err="Cannot open file'";
err+=fname;
err+="'";
error(err);
return 0;
}
for(int i=0; i<length; i++){
byte b=bitRevTable[buffer[i]]; // Reverse bit order
fwrite(&b,1,1,fptr);
}
fclose(fptr);
return length;
}
void BitFile::error(const string &str)
{
errorStr=str;
Error=true;
fprintf(logfile,"%s\n",str.c_str());
}
void BitFile::readField(string &field, FILE *fp)
{
byte t[2];
fread(t,1,2,fp);
unsigned short len=(t[0]<<8)+t[1];
for(int i=0; i<len; i++){
byte b;
fread(&b,1,1,fp);
field+=(char)b;
}
}
void BitFile::initFlip()
{
for(int i=0; i<256; i++){
int num=i;
int fnum=0;
for(int k=0; k<8; k++){
int bit=num&1;
num=num>>1;
fnum=(fnum<<1)+bit;
}
bitRevTable[i]=fnum;
}
}
BitFile::~BitFile()
{
if(buffer) delete [] buffer;
}

114
Software/xc3sprog/bitfile.h Normal file
View File

@ -0,0 +1,114 @@
/* Xilinx .bit file parser
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef BITFILE_H
#define BITFILE_H
#include <stdio.h>
#include <string>
// ----------------------Xilinx .bit file format---------------------------
// 00000000: 00 09 0f f0 0f f0 0f f0 0f f0 00 00 01 61 00 0a *.............a..*
// 00000010: 78 66 6f 72 6d 2e 6e 63 64 00 62 00 0c 76 31 30 *xform.ncd.b..v10*
// 00000020: 30 30 65 66 67 38 36 30 00 63 00 0b 32 30 30 31 *00efg860.c..2001*
// 00000030: 2f 30 38 2f 31 30 00 64 00 09 30 36 3a 35 35 3a */08/10.d..06:55:*
// 00000040: 30 34 00 65 00 0c 28 18 ff ff ff ff aa 99 55 66 *04.e..(.......Uf*
/*
Field 1
2 bytes length 0x0009 (big endian)
9 bytes some sort of header
2 bytes length 0x0001
Field 2
1 byte key 0x61 (The letter "a")
2 bytes length 0x000a (value depends on file name length)
10 bytes string design name "xform.ncd" (including a trailing 0x00)
Field 3
1 byte key 0x62 (The letter "b")
2 bytes length 0x000c (value depends on part name length)
12 bytes string part name "v1000efg860" (including a trailing 0x00)
Field 4
1 byte key 0x63 (The letter "c")
2 bytes length 0x000b
11 bytes string date "2001/08/10" (including a trailing 0x00)
Field 5
1 byte key 0x64 (The letter "d")
2 bytes length 0x0009
9 bytes string time "06:55:04" (including a trailing 0x00)
Field 6
1 byte key 0x65 (The letter "e")
4 bytes length 0x000c9090 (value depends on device type,
and maybe design details)
8233440 bytes raw bit stream starting with 0xffffffff aa995566 sync
word. */
// Modified to reflect parsing - Andrew Rogers
// Reference: http://www.fpga-faq.com/FAQ_Pages/0026_Tell_me_about_bit_files.htm
//--------------------------------------------------------------------------------
typedef unsigned char byte;
class BitFile
{
private:
std::string ncdFilename; // key 'a'
std::string partName; // key 'b'
std::string date; // key 'c'
std::string time; // key 'd'
unsigned long length; // The length of the byte data that follows, multiply by 8 to get bitstream length.
byte *buffer; // Each byte is reversed, Xilinx does things MSB first and JTAG does things LSB first!
std::string filename;
byte bitRevTable[256]; // Bit reverse lookup table
bool Error;
std::string errorStr;
FILE *logfile;
private:
void initFlip();
void error(const std::string &str);
void readField(std::string &field, FILE *fp);
void processData(FILE *fp);
public:
BitFile();
~BitFile();
unsigned long load(const char *fname);
inline byte *getData(){return buffer;}
inline unsigned long getLength(){return length*8;} // Returns length of bitstream
inline const char *getError(){
if(!Error)return("");
Error=false;
return errorStr.c_str();
}
inline const char *getNCDFilename(){return ncdFilename.c_str();}
inline const char *getPartName(){return partName.c_str();}
inline const char *getDate(){return date.c_str();}
inline const char *getTime(){return time.c_str();}
unsigned long saveAsBin(const char *fname);
};
#endif //BITFILE_H

BIN
Software/xc3sprog/bitfile.o Normal file

Binary file not shown.

View File

@ -0,0 +1,41 @@
/* Xilinx .bit file parser
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "bitfile.h"
int main(int argc, char**args)
{
BitFile file;
if(argc>1){
int length=file.load(args[1]);
byte *data=file.getData();
if(length>0){
printf("Created from NCD file: %s\n",file.getNCDFilename());
printf("Target device: %s\n",file.getPartName());
printf("Created: %s %s\n",file.getDate(),file.getTime());
printf("Bitstream length: %d bits\n",length);
}
else return 1;
}
if(argc>2)if(file.saveAsBin(args[2])>0)printf("Bitstream saved in binary format in file: %s\n",args[2]);
if(argc<2){
fprintf(stderr,"Usage: %s infile.bit [outfile.bin]\n",args[0]);
}
}

View File

@ -0,0 +1,29 @@
The IO routines that shift data out to the JTAG port start with the first byte of the buffer given. Each byte is is output LSB first. If the byte order was the same as the SVF file then the entire buffer would have to be stored and then reversed, causing problems for embedded JTAG servers with limited memory.
The table below shows an example of the byte order reversal required for playing an SVF file.
SVF IO buffer
.. ff
.. aa
.. 33
.. 00
00 ..
33 ..
aa ..
ff ..
For a Xilinx bit file, which is MSB first, each byte is bit-reversed as shown below.
BIT IO buffer
ff ff
55 aa
cc 33
00 00
.. ..
.. ..
.. ..
.. ..

119
Software/xc3sprog/debug.cpp Normal file
View File

@ -0,0 +1,119 @@
/* JTAG debugging code
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <asm/arch/pxa-regs.h>
#include <stdio.h>
#include "iobase.h"
#include "at91XCProgramer.h"
#include "iodebug.h"
#define MEMDEV "/dev/mem"
#define CPLD_PHY_BASE PXA_CS2_PHYS
using namespace std;
void testPP();
void testDebug();
void printBit(unsigned char *data, int bit);
void getSwitches(IOBase *io);
void getID(IOBase *io);
int main(int argc, char**args)
{
testPP();
return 0;
}
void testDebug()
{
IOBase *io;
io=new IODebug();
unsigned char tdi[]={0x3a,0xa3};
unsigned char tdo[10];
io->setTapState(IOBase::SHIFT_DR);
io->shiftTDITDO(tdi,tdo,16,false);
for(int i=0; i<2; i++)printf("TDO %02x\n",tdo[i]);
delete io;
}
void testPP()
{
IOBase *io;
io=new JTAGBus(MEMDEV,CPLD_PHY_BASE);
unsigned char tdi[]={0,0,0,0,0,0,0,0};
unsigned char tdo[100];
io->setTapState(IOBase::SHIFT_DR);
io->shiftTDITDO(tdi,tdo,64);
for(int i=0; i<8; i++)printf("TDO %02x\n",tdo[i]);
printf("\n");
getSwitches(io);
getID(io);
delete io;
}
void printBit1(bool val)
{
if(val)printf("|=| ");
else printf("| | ");
}
void getID(IOBase *io)
{
unsigned char tdo[100];
unsigned char tdi[]={0xfe,0x09};
io->setTapState(IOBase::SHIFT_IR);
io->shiftTDI(tdi,14);
io->setTapState(IOBase::RUN_TEST_IDLE);
io->setTapState(IOBase::SHIFT_DR);
io->shiftTDO(tdo,64);
for(int i=0; i<8; i++)printf("TDO %02x\n",tdo[i]);
printf("\n");
}
void getSwitches(IOBase *io)
{
unsigned char tdo[100];
unsigned char tdi[]={0xff,0x01};
io->setTapState(IOBase::SHIFT_IR);
io->shiftTDI(tdi,14);
io->setTapState(IOBase::SHIFT_DR);
io->shiftTDO(tdo,600);
int swi[]={506,509,518,521,539,536,557,569};
for(int i=0; i<8; i++){
int bit=swi[i];
bool val=(tdo[bit/8]>>(bit%8))&1;
printBit1(val);
}
printf("\n");
for(int i=0; i<8; i++){
int bit=swi[i];
bool val=(tdo[bit/8]>>(bit%8))&1;
printBit1(!val);
}
printf("\n\n");
}
void printBit(unsigned char *data, int bit)
{
printf("bit %d = %d\n",bit,(data[bit/8]>>(bit%8))&1);
}

View File

@ -0,0 +1,59 @@
/* JTAG chain detection
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <asm/arch/pxa-regs.h>
#include "iodebug.h"
#include "jtag.h"
#include "devicedb.h"
#include "jtag_bus.h"
#define MEMDEV "/dev/mem"
#define CPLD_PHY_BASE PXA_CS2_PHYS
#define DEVICEDB "devlist.txt"
int main(int argc, char **args)
{
JTAGBus io(MEMDEV,CPLD_PHY_BASE);
if(io.checkError()){
fprintf(stderr,"Can map physical address into virtual space! or can not open '%s'.\n",MEMDEV);
return 1;
}
Jtag jtag(&io);
int num=jtag.getChain();
DeviceDB db(DEVICEDB);
int dblast=0;
for(int i=0; i<num; i++){
unsigned long id=jtag.getDeviceID(i);
int length=db.loadDevice(id);
printf("IDCODE: 0x%08x\t",id);
if(length>0){
jtag.setDeviceIRLength(i,length);
printf("Desc: %s\tIR length: %d\n",db.getDeviceDescription(dblast),length);
dblast++;
}
else{
printf("not found in '%s'.\n",DEVICEDB);
}
}
return 0;
}

View File

@ -0,0 +1,71 @@
/* JTAG chain device database
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "devicedb.h"
using namespace std;
DeviceDB::DeviceDB(const char *fname)
{
filename=fname;
FILE *fp=fopen(fname,"rt");
if(fp==0)fprintf(stderr,"Cannot open device database file '%s'\n",fname);
else fclose(fp);
}
int DeviceDB::loadDevice(const unsigned long id)
{
FILE *fp=fopen(filename.c_str(),"rt");
if(fp==0){
fprintf(stderr,"Cannot open device database file '%s'\n",filename.c_str());
return 0;
}
int irlen;
while(!feof(fp)){
unsigned long idr;
char text[256];
char buffer[256];
fgets(buffer,256,fp); // Get next line from file
sscanf(buffer,"%08x %d %s",&idr,&irlen,text);
if(id==idr){
device_t dev;
dev.text=text;
dev.idcode=idr;
dev.irlen=irlen;
devices.push_back(dev);
fclose(fp);
return irlen;
}
}
fclose(fp);
return 0;
}
int DeviceDB::getIRLength(int i)
{
if(i>=devices.size())return 0;
return devices[i].irlen;
}
const char *DeviceDB::getDeviceDescription(int i)
{
if(i>=devices.size())return 0;
return devices[i].text.c_str();
}

View File

@ -0,0 +1,47 @@
/* JTAG chain device database
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef DEVICEDB_H
#define DEVICEDB_H
#include <vector>
#include <string>
typedef unsigned char byte;
class DeviceDB
{
private:
struct device_t
{
unsigned long idcode; // Store IDCODE
int irlen; // instruction register length.
std::string text;
};
std::vector<device_t> devices;
std::string filename;
public:
DeviceDB(const char *fname);
int loadDevice(const unsigned long id);
int getIRLength(int i);
const char *getDeviceDescription(int i);
};
#endif

Binary file not shown.

View File

@ -0,0 +1,16 @@
# IDCODE IR Length Text
0140d093 6 XC3S50
01414093 6 XC3S200
0141c093 6 XC3S400
01428093 6 XC3S1000
01434093 6 XC3S1500
01440093 6 XC3S2000
01448093 6 XC3S4000
01450093 6 XC3S5000
05045093 8 XCF02S
00608093 5 XC2S15
0060c093 5 XC2S30
00610093 5 XC2S50
00614093 5 XC2S100
00618093 5 XC2S150
0061c093 5 XC2S200

View File

@ -0,0 +1,352 @@
/* JTAG low level functions and base class for cables
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "iobase.h"
#include <stdio.h>
using namespace std;
IOBase::IOBase()
{
current_state=UNKNOWN;
}
int IOBase::shiftTDITDO(const unsigned char *tdi, unsigned char *tdo, int length, bool last)
{
if(length==0)return 0;
int i=0;
int j=0;
unsigned char tdo_byte=0;
unsigned char tdi_byte=tdi[j];
while(i<length-1){
tdo_byte=tdo_byte+(txrx(false, (tdi_byte&1)==1)<<(i%8));
tdi_byte=tdi_byte>>1;
i++;
if((i%8)==0){ // Next byte
tdo[j]=tdo_byte; // Save the TDO byte
tdo_byte=0;
j++;
tdi_byte=tdi[j]; // Get the next TDI byte
}
};
tdo_byte=tdo_byte+(txrx(last, (tdi_byte&1)==1)<<(i%8)); // TMS set if last=true
tdo[j]=tdo_byte;
nextTapState(last); // If TMS is set the the state of the tap changes
}
int IOBase::shiftTDI(const unsigned char *tdi, int length, bool last)
{
if(length==0)return 0;
int i=0;
int j=0;
unsigned char tdi_byte=tdi[j];
while(i<length-1){
tx(false, (tdi_byte&1)==1);
tdi_byte=tdi_byte>>1;
i++;
if((i%8)==0){ // Next byte
j++;
tdi_byte=tdi[j]; //Get the next TDI byte
}
};
tx(last, (tdi_byte&1)==1); // TMS set if last=true
nextTapState(last); // If TMS is set the the state of the tap changes
}
// TDI gets a load of zeros, we just record TDO.
int IOBase::shiftTDO(unsigned char *tdo, int length, bool last)
{
if(length==0)return 0;
int i=0;
int j=0;
unsigned char tdo_byte=0;
while(i<length-1){
tdo_byte=tdo_byte+(txrx(false, false)<<(i%8));
i++;
if((i%8)==0){ // Next byte
tdo[j]=tdo_byte; // Save the TDO byte
tdo_byte=0;
j++;
}
};
tdo_byte=tdo_byte+(txrx(last, false)<<(i%8)); // TMS set if last=true
tdo[j]=tdo_byte;
nextTapState(last); // If TMS is set the the state of the tap changes
}
// TDI gets a load of zeros or ones, and we ignore TDO
int IOBase::shift(bool tdi, int length, bool last)
{
if(length==0)return 0;
int i=0;
while(i<length-1){
tx(false, tdi);
i++;
};
tx(last, tdi); // TMS set if last=true
nextTapState(last); // If TMS is set the the state of the tap changes
}
int IOBase::setTapState(tapState_t state)
{
bool tms;
while(current_state!=state){
switch(current_state){
case TEST_LOGIC_RESET:
switch(state){
case TEST_LOGIC_RESET:
tms=true;
break;
default:
tms=false;
current_state=RUN_TEST_IDLE;
};
break;
case RUN_TEST_IDLE:
switch(state){
case RUN_TEST_IDLE:
tms=false;
break;
default:
tms=true;
current_state=SELECT_DR_SCAN;
};
break;
case SELECT_DR_SCAN:
switch(state){
case CAPTURE_DR:
case SHIFT_DR:
case EXIT1_DR:
case PAUSE_DR:
case EXIT2_DR:
case UPDATE_DR:
tms=false;
current_state=CAPTURE_DR;
break;
default:
tms=true;
current_state=SELECT_IR_SCAN;
};
break;
case CAPTURE_DR:
switch(state){
case SHIFT_DR:
tms=false;
current_state=SHIFT_DR;
break;
default:
tms=true;
current_state=EXIT1_DR;
};
break;
case SHIFT_DR:
switch(state){
case SHIFT_DR:
tms=false;
break;
default:
tms=true;
current_state=EXIT1_DR;
};
break;
case EXIT1_DR:
switch(state){
case PAUSE_DR:
case EXIT2_DR:
case SHIFT_DR:
case EXIT1_DR:
tms=false;
current_state=PAUSE_DR;
break;
default:
tms=true;
current_state=UPDATE_DR;
};
break;
case PAUSE_DR:
switch(state){
case PAUSE_DR:
tms=false;
break;
default:
tms=true;
current_state=EXIT2_DR;
};
break;
case EXIT2_DR:
switch(state){
case SHIFT_DR:
case EXIT1_DR:
case PAUSE_DR:
tms=false;
current_state=SHIFT_DR;
break;
default:
tms=true;
current_state=UPDATE_DR;
};
break;
case UPDATE_DR:
switch(state){
case RUN_TEST_IDLE:
tms=false;
current_state=RUN_TEST_IDLE;
break;
default:
tms=true;
current_state=SELECT_DR_SCAN;
};
break;
case SELECT_IR_SCAN:
switch(state){
case CAPTURE_IR:
case SHIFT_IR:
case EXIT1_IR:
case PAUSE_IR:
case EXIT2_IR:
case UPDATE_IR:
tms=false;
current_state=CAPTURE_IR;
break;
default:
tms=true;
current_state=TEST_LOGIC_RESET;
};
break;
case CAPTURE_IR:
switch(state){
case SHIFT_IR:
tms=false;
current_state=SHIFT_IR;
break;
default:
tms=true;
current_state=EXIT1_IR;
};
break;
case SHIFT_IR:
switch(state){
case SHIFT_IR:
tms=false;
break;
default:
tms=true;
current_state=EXIT1_IR;
};
break;
case EXIT1_IR:
switch(state){
case PAUSE_IR:
case EXIT2_IR:
case SHIFT_IR:
case EXIT1_IR:
tms=false;
current_state=PAUSE_IR;
break;
default:
tms=true;
current_state=UPDATE_IR;
};
break;
case PAUSE_IR:
switch(state){
case PAUSE_IR:
tms=false;
break;
default:
tms=true;
current_state=EXIT2_IR;
};
break;
case EXIT2_IR:
switch(state){
case SHIFT_IR:
case EXIT1_IR:
case PAUSE_IR:
tms=false;
current_state=SHIFT_IR;
break;
default:
tms=true;
current_state=UPDATE_IR;
};
break;
case UPDATE_IR:
switch(state){
case RUN_TEST_IDLE:
tms=false;
current_state=RUN_TEST_IDLE;
break;
default:
tms=true;
current_state=SELECT_DR_SCAN;
};
break;
default:
tapTestLogicReset();
tms=true;
};
tx(tms,false);
};
}
// After shift data into the DR or IR we goto the next state
// This function should only be called from the end of a shift function
int IOBase::nextTapState(bool tms)
{
if(current_state==SHIFT_DR){
if(tms)current_state=EXIT1_DR; // If TMS was set then goto next state
}
else if(current_state==SHIFT_IR){
if(tms)current_state=EXIT1_IR; // If TMS was set then goto next state
}
else tapTestLogicReset(); // We were in an unexpected state
}
void IOBase::tapTestLogicReset()
{
for(int i=0; i<5; i++)tx(true,false);
current_state=TEST_LOGIC_RESET;
}
void IOBase::cycleTCK(int n, bool tdi)
{
bool tms=false;
if(current_state==TEST_LOGIC_RESET)tms=true;
for(int i=0; i<n; i++)tx(tms,tdi);
}

View File

@ -0,0 +1,65 @@
/* JTAG low level functions and base class for cables
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef IOBASE_H
#define IOBASE_H
class IOBase
{
public:
enum tapState_t{
TEST_LOGIC_RESET=0,
RUN_TEST_IDLE=1,
SELECT_DR_SCAN=2,
CAPTURE_DR=3,
SHIFT_DR=4,
EXIT1_DR=5,
PAUSE_DR=6,
EXIT2_DR=7,
UPDATE_DR=8,
SELECT_IR_SCAN=9,
CAPTURE_IR=10,
SHIFT_IR=11,
EXIT1_IR=12,
PAUSE_IR=13,
EXIT2_IR=14,
UPDATE_IR=15,
UNKNOWN=999
};
protected:
tapState_t current_state;
virtual bool txrx(bool tms, bool tdi){}
virtual void tx(bool tms, bool tdi){}
int nextTapState(bool tms);
public:
IOBase();
virtual int shiftTDITDO(const unsigned char *tdi, unsigned char *tdo, int length, bool last=true);
virtual int shiftTDI(const unsigned char *tdi, int length, bool last=true);
virtual int shiftTDO(unsigned char *tdo, int length, bool last=true);
virtual int shift(bool tdi, int length, bool last=true);
virtual int setTapState(tapState_t state);
virtual void tapTestLogicReset();
virtual void cycleTCK(int n, bool tdi=1);
};
#endif // IOBASE_H

BIN
Software/xc3sprog/iobase.o Normal file

Binary file not shown.

View File

@ -0,0 +1,39 @@
/* Monitor JTAG signals instead of using physical cable
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <stdio.h>
#include "iodebug.h"
using namespace std;
bool IODebug::txrx(bool tms, bool tdi)
{
int tdo;
printf("txrx(%d,%d) enter tdo>",tms,tdi);
scanf("%d",&tdo);
return tdo!=0;
}
void IODebug::tx(bool tms, bool tdi)
{
printf("tx(%d,%d)\n",tms,tdi);
}

View File

@ -0,0 +1,37 @@
/* Monitor JTAG signals instead of using physical cable
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef IODEBUG_H
#define IODEBUG_H
#include "iobase.h"
class IODebug : public IOBase
{
protected:
virtual bool txrx(bool tms, bool tdi);
virtual void tx(bool tms, bool tdi);
public:
IODebug() : IOBase(){}
};
#endif // IODEBUG_H

BIN
Software/xc3sprog/iodebug.o Normal file

Binary file not shown.

View File

@ -0,0 +1,119 @@
/* JTAG GNU/Linux parport device io
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/parport.h>
#include <linux/ppdev.h>
#include <sys/time.h>
#include <unistd.h>
#include "ioparport.h"
using namespace std;
void IOParport::delay(int del)
{
struct timeval actualtime, endtime;
gettimeofday( &actualtime, NULL );
endtime.tv_usec=(actualtime.tv_usec+del)% 1000000;
endtime.tv_sec=actualtime.tv_sec+(actualtime.tv_usec+del)/1000000;
while(1){
gettimeofday( &actualtime, NULL );
if ( actualtime.tv_sec > endtime.tv_sec )
return;
if ( actualtime.tv_sec == endtime.tv_sec )
if ( actualtime.tv_usec > endtime.tv_usec )
return;
}
}
IOParport::IOParport(const char *device_name) : IOBase()
{
fd = open (device_name, O_RDWR);
if (fd == -1) {
//perror ("open");
error=true;
return;
}
if (ioctl (fd, PPCLAIM)) {
perror ("PPCLAIM");
close (fd);
error=true;
return;
}
// Switch to compatibility mode.
int mode = IEEE1284_MODE_COMPAT;
if (ioctl (fd, PPNEGOT, &mode)) {
perror ("PPNEGOT");
close (fd);
error=true;
return;
}
error=false;
}
bool IOParport::txrx(bool tms, bool tdi)
{
unsigned char ret;
unsigned char data=0x10; // D4 pin5 TDI enable
if(tdi)data|=1; // D0 pin2
if(tms)data|=4; // D2 pin4
ioctl(fd, PPWDATA, &data);
//delay(2);
data|=2; // clk high D1 pin3
ioctl(fd, PPWDATA, &data);
ioctl(fd, PPRSTATUS, &ret);
//delay(2);
//data=data^2; // clk low
//ioctl(fd, PPWDATA, &data);
//delay(2);
//ioctl(fd, PPRSTATUS, &ret);
return (ret&0x10)!=0; // TDO pin13
}
void IOParport::tx(bool tms, bool tdi)
{
unsigned char data=0x10; // D4 pin5 TDI enable
if(tdi)data|=1; // D0 pin2
if(tms)data|=4; // D2 pin4
ioctl(fd, PPWDATA, &data);
//delay(2);
data|=2; // clk high D1 pin3
ioctl(fd, PPWDATA, &data);
//delay(2);
//data=data^2; // clk low
//ioctl(fd, PPWDATA, &data);
//delay(2);
}
IOParport::~IOParport()
{
ioctl (fd, PPRELEASE);
close (fd);
}

View File

@ -0,0 +1,41 @@
/* JTAG GNU/Linux parport device io
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef IOPARPORT_H
#define IOPARPORT_H
#include "iobase.h"
class IOParport : public IOBase
{
protected:
int fd;
bool error;
public:
IOParport(const char *device_name);
~IOParport();
virtual bool txrx(bool tms, bool tdi);
virtual void tx(bool tms, bool tdi);
void delay(int del);
inline bool checkError(){return error;}
};
#endif // IOPARPORT_H

106
Software/xc3sprog/jtag.cpp Normal file
View File

@ -0,0 +1,106 @@
/* JTAG routines
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "jtag.h"
Jtag::Jtag(IOBase *iob)
{
io=iob;
postDRState=IOBase::RUN_TEST_IDLE;
postIRState=IOBase::RUN_TEST_IDLE;
deviceIndex=-1;
shiftDRincomplete=false;
}
int Jtag::getChain()
{
io->tapTestLogicReset();
io->setTapState(IOBase::SHIFT_DR);
byte idx[4];
byte zero[4];
numDevices=0;
for(int i=0; i<4; i++)zero[i]=0;
do{
io->shiftTDITDO(zero,idx,32,false);
unsigned long id=byteArrayToLong(idx);
if(id!=0){
numDevices++;
chainParam_t dev;
dev.idcode=id;
printf("Device with ID=%x found\n", id);
devices.insert(devices.begin(),dev);
}
else break;
}while(numDevices<MAXNUMDEVICES);
io->setTapState(IOBase::TEST_LOGIC_RESET);
return numDevices;
}
int Jtag::selectDevice(int dev)
{
if(dev>=numDevices)deviceIndex=-1;
else deviceIndex=dev;
return deviceIndex;
}
int Jtag::setDeviceIRLength(int dev, int len)
{
if(dev>=numDevices||dev<0)return -1;
devices[dev].irlen=len;
return dev;
}
void Jtag::shiftDR(const byte *tdi, byte *tdo, int length, int align, bool exit)
{
if(deviceIndex<0)return;
int post=deviceIndex;
if(!shiftDRincomplete){
io->setTapState(IOBase::SHIFT_DR);
int pre=numDevices-deviceIndex-1;
if(align){
pre=-post;
while(pre<=0)pre+=align;
}
io->shift(false,pre,false);
}
if(tdi!=0&&tdo!=0)io->shiftTDITDO(tdi,tdo,length,post==0&&exit);
else if(tdi!=0&&tdo==0)io->shiftTDI(tdi,length,post==0&&exit);
else if(tdi==0&&tdo!=0)io->shiftTDO(tdo,length,post==0&&exit);
else io->shift(false,length,post==0&&exit);
if(exit){
io->shift(false,post);
io->setTapState(postDRState);
shiftDRincomplete=false;
}
else shiftDRincomplete=true;
}
void Jtag::shiftIR(const byte *tdi, byte *tdo)
{
if(deviceIndex<0)return;
io->setTapState(IOBase::SHIFT_IR);
int pre=0;
for(int dev=deviceIndex+1; dev<numDevices; dev++)pre+=devices[dev].irlen; // Calculate number of pre BYPASS bits.
int post=0;
for(int dev=0; dev<deviceIndex; dev++)post+=devices[dev].irlen; // Calculate number of post BYPASS bits.
io->shift(true,pre,false);
if(tdo!=0)io->shiftTDITDO(tdi,tdo,devices[deviceIndex].irlen,post==0);
else if(tdo==0)io->shiftTDI(tdi,devices[deviceIndex].irlen,post==0);
io->shift(true,post);
io->setTapState(postIRState);
}

74
Software/xc3sprog/jtag.h Normal file
View File

@ -0,0 +1,74 @@
/* JTAG routines
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef JTAG_H
#define JTAG_H
#include <vector>
#include <stdio.h>
#include "iobase.h"
typedef unsigned char byte;
class Jtag
{
private:
static const int MAXNUMDEVICES=1000;
protected:
struct chainParam_t
{
unsigned long idcode; // Store IDCODE
//byte bypass[4]; // The bypass instruction. Most instruction register lengths are a lot less than 32 bits.
int irlen; // instruction register length.
};
std::vector<chainParam_t> devices;
IOBase *io;
int numDevices;
IOBase::tapState_t postDRState;
IOBase::tapState_t postIRState;
int deviceIndex;
FILE *logfile;
bool shiftDRincomplete;
public:
Jtag(IOBase *iob);
int getChain(); // Shift IDCODEs from devices
inline void setPostDRState(IOBase::tapState_t s){postDRState=s;}
inline void setPostIRState(IOBase::tapState_t s){postIRState=s;}
int setDeviceIRLength(int dev, int len);
unsigned long getDeviceID(int dev){
if(dev>=devices.size())return 0;
return devices[dev].idcode;
}
int selectDevice(int dev);
void shiftDR(const byte *tdi, byte *tdo, int length, int align=0, bool exit=true);// Some devices use TCK for aligning data, for example, Xilinx FPGAs for configuration data.
void shiftIR(const byte *tdi, byte *tdo=0); // No length argumant required as IR length specified in chainParam_t
inline void longToByteArray(unsigned long l, byte *b){
b[0]=(byte)(l&0xff);
b[1]=(byte)((l>>8)&0xff);
b[2]=(byte)((l>>16)&0xff);
b[3]=(byte)((l>>24)&0xff);
}
inline unsigned long byteArrayToLong(byte *b){
return (b[3]<<24)+(b[2]<<16)+(b[1]<<8)+b[0];
}
};
#endif //JTAG_H

BIN
Software/xc3sprog/jtag.o Normal file

Binary file not shown.

View File

@ -0,0 +1,91 @@
/*
* JZ47xx GPIO lines
*
* Written 2010 by Andres Calderon andres.calderon@emqbit.com
*/
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include "jz47xx_gpio.h"
#define JZ_GPIO_BASE 0x10010000
PJZ_PIO* pio;
void
jz_gpio_as_output (int port, unsigned int o)
{
pio[port]->PXFUNC = (1 << (o));
pio[port]->PXSELC = (1 << (o));
pio[port]->PXDIRS = (1 << (o));
}
void
jz_gpio_as_input (int port, unsigned int o)
{
pio[port]->PXFUNC = (1 << (o));
pio[port]->PXSELC = (1 << (o));
pio[port]->PXDIRC = (1 << (o));
}
void
jz_gpio_set_pin (int port, unsigned int o)
{
pio[port]->PXDATS = (1 << (o));
}
void
jz_gpio_clear_pin (int port, unsigned int o)
{
pio[port]->PXDATC = (1 << (o));
}
void
jz_gpio_out (int port, unsigned int o, unsigned int val)
{
if (val == 0)
pio[port]->PXDATC = (1 << (o));
else
pio[port]->PXDATS = (1 << (o));
}
unsigned int
jz_gpio_get_pin (int port, unsigned int o)
{
return (pio[port]->PXPIN & (1 << o)) ? 1 : 0;
}
JZ_PIO *
jz_gpio_map ()
{
int fd;
int port;
JZ_PIO *pio_base;
pio = (PJZ_PIO*)malloc(sizeof(PJZ_PIO)*4);
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC)) == -1)
{
fprintf (stderr, "Cannot open /dev/mem.\n");
return 0;
}
pio_base = (JZ_PIO *) mmap (0, getpagesize (), PROT_READ | PROT_WRITE, MAP_SHARED, fd, JZ_GPIO_BASE);
if (pio_base == (JZ_PIO *) - 1)
{
fprintf (stderr, "Cannot mmap.\n");
return 0;
}
for(port=0; port<4; port++)
pio[port] = (JZ_PIO *) ((unsigned int) pio_base + port * 0x100);
return pio_base;
}

View File

@ -0,0 +1,69 @@
/*
* JZ47xx GPIO lines
*
* Written 2010 by Andres Calderon andres.calderon@emqbit.com
*/
#ifndef __jz47xx_gpio_h__
#define __jz47xx_gpio_h__
#define JZ_GPIO_PORT_A 0
#define JZ_GPIO_PORT_B 1
#define JZ_GPIO_PORT_C 2
#define JZ_GPIO_PORT_D 3
typedef volatile unsigned int JZ_REG; /* Hardware register definition */
typedef struct _JZ_PIO
{
JZ_REG PXPIN; /* PIN Level Register */
JZ_REG Reserved0;
JZ_REG Reserved1;
JZ_REG Reserved2;
JZ_REG PXDAT; /* Port Data Register */
JZ_REG PXDATS; /* Port Data Set Register */
JZ_REG PXDATC; /* Port Data Clear Register */
JZ_REG Reserved3;
JZ_REG PXIM; /* Interrupt Mask Register */
JZ_REG PXIMS; /* Interrupt Mask Set Reg */
JZ_REG PXIMC; /* Interrupt Mask Clear Reg */
JZ_REG Reserved4;
JZ_REG PXPE; /* Pull Enable Register */
JZ_REG PXPES; /* Pull Enable Set Reg. */
JZ_REG PXPEC; /* Pull Enable Clear Reg. */
JZ_REG Reserved5;
JZ_REG PXFUN; /* Function Register */
JZ_REG PXFUNS; /* Function Set Register */
JZ_REG PXFUNC; /* Function Clear Register */
JZ_REG Reserved6;
JZ_REG PXSEL; /* Select Register */
JZ_REG PXSELS; /* Select Set Register */
JZ_REG PXSELC; /* Select Clear Register */
JZ_REG Reserved7;
JZ_REG PXDIR; /* Direction Register */
JZ_REG PXDIRS; /* Direction Set Register */
JZ_REG PXDIRC; /* Direction Clear Register */
JZ_REG Reserved8;
JZ_REG PXTRG; /* Trigger Register */
JZ_REG PXTRGS; /* Trigger Set Register */
JZ_REG PXTRGC; /* Trigger Set Register */
JZ_REG Reserved9;
JZ_REG PXFLG; /* Port Flag Register */
JZ_REG PXFLGC; /* Port Flag clear Register */
} JZ_PIO, *PJZ_PIO;
void jz_gpio_as_output (int port, unsigned int o);
void jz_gpio_as_input (int port, unsigned int o);
void jz_gpio_set_pin (int port, unsigned int o);
void jz_gpio_clear_pin (int port, unsigned int o);
void jz_gpio_out (int port, unsigned int o, unsigned int val);
unsigned int jz_gpio_get_pin (int port, unsigned int o);
JZ_PIO * jz_gpio_map ();
#endif

Binary file not shown.

View File

@ -0,0 +1,66 @@
/* Spartan3 JTAG programming algorithms
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "progalgxc3s.h"
const byte ProgAlgXC3S::JPROGRAM=0x0b;
const byte ProgAlgXC3S::CFG_IN=0x05;
const byte ProgAlgXC3S::JSHUTDOWN=0x0d;
const byte ProgAlgXC3S::JSTART=0x0c;
const byte ProgAlgXC3S::BYPASS=0x3f;
ProgAlgXC3S::ProgAlgXC3S(Jtag &j, IOBase &i)
{
jtag=&j;
io=&i;
}
int ProgAlgXC3S::program(BitFile &file)
{
jtag->shiftIR(&JPROGRAM);
jtag->shiftIR(&CFG_IN);
byte init[24];
jtag->longToByteArray(0xffffffff,&init[0]); // Sync
jtag->longToByteArray(0x66aa9955,&init[4]); // Sync
jtag->longToByteArray(0x8001000c,&init[8]); // CMD
jtag->longToByteArray(0xe0000000,&init[12]); // Clear CRC
jtag->longToByteArray(0x00000000,&init[16]); // Flush
jtag->longToByteArray(0x00000000,&init[20]); // Flush
jtag->shiftDR(init,0,192,32); // Align to 32 bits.
jtag->shiftIR(&JSHUTDOWN);
io->cycleTCK(12);
jtag->shiftIR(&CFG_IN);
byte hdr[12];
jtag->longToByteArray(0x8001000c,&hdr[0]); // CMD
jtag->longToByteArray(0x10000000,&hdr[4]); // Assert GHIGH
jtag->longToByteArray(0x00000000,&hdr[8]); // Flush
jtag->shiftDR(hdr,0,96,32,false); // Align to 32 bits and do not goto EXIT1-DR
jtag->shiftDR(file.getData(),0,file.getLength());
io->tapTestLogicReset();
io->setTapState(IOBase::RUN_TEST_IDLE);
jtag->shiftIR(&JSTART);
io->cycleTCK(12);
jtag->shiftIR(&BYPASS); // Don't know why, but without this the FPGA will not reconfigure from Flash when PROG is asserted.
printf("Done\n");
}

View File

@ -0,0 +1,44 @@
/* Spartan3 JTAG programming algorithms
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef PROGALGXC3S_H
#define PROGALGXC3S_H
#include "bitfile.h"
#include "jtag.h"
#include "iobase.h"
class ProgAlgXC3S
{
private:
static const byte JPROGRAM;
static const byte CFG_IN;
static const byte JSHUTDOWN;
static const byte JSTART;
static const byte BYPASS;
Jtag *jtag;
IOBase *io;
public:
ProgAlgXC3S(Jtag &j, IOBase &i);
int program(BitFile &file);
};
#endif

Binary file not shown.

View File

@ -0,0 +1,113 @@
/* XCF Flash PROM JTAG programming algorithms
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "progalgxcf.h"
const byte ProgAlgXCF::SERASE=0x0a;
const byte ProgAlgXCF::ISPEN=0xe8;
const byte ProgAlgXCF::FPGM=0xea;
const byte ProgAlgXCF::FADDR=0xeb;
const byte ProgAlgXCF::FERASE=0xec;
const byte ProgAlgXCF::FDATA0=0xed;
const byte ProgAlgXCF::FVFY0=0xef;
const byte ProgAlgXCF::NORMRST=0xf0;
const byte ProgAlgXCF::IDCODE=0xfe;
const byte ProgAlgXCF::BYPASS=0xff;
const byte ProgAlgXCF::BIT3=0x08;
const byte ProgAlgXCF::BIT4=0x10;
ProgAlgXCF::ProgAlgXCF(Jtag &j, IOBase &i)
{
jtag=&j;
io=&i;
}
int ProgAlgXCF::erase()
{
byte data[4];
jtag->shiftIR(&NORMRST);
io->cycleTCK(40000);
byte ircap[1];
jtag->shiftIR(&BYPASS,ircap);
if((ircap[0]&BIT3)==BIT3){
fprintf(stderr,"Device is write protected.\n",ircap[0]);
return 1;
}
jtag->shiftIR(&ISPEN);
jtag->shiftIR(&FADDR);
jtag->longToByteArray(1,data);
jtag->shiftDR(data,0,16);
io->cycleTCK(2);
printf("Erasing...."); fflush(stdout);
jtag->shiftIR(&FERASE);
io->cycleTCK(2400000);
printf("done.\n");
jtag->shiftIR(&BYPASS);
io->tapTestLogicReset();
return 0;
}
int ProgAlgXCF::program(BitFile &file)
{
jtag->shiftIR(&NORMRST);
io->cycleTCK(40000);
io->setTapState(IOBase::TEST_LOGIC_RESET);
byte data[4];
jtag->shiftIR(&ISPEN);
data[0]=0x34;
jtag->shiftDR(data,0,6);
for(int i=0; i<file.getLength(); i+=4096){
int frame=i/128;
printf("Programming frames 0x%04x to 0x%04x....",frame,frame+31); fflush(stdout);
jtag->shiftIR(&FDATA0);
if((i+4096)<=file.getLength()){
jtag->shiftDR(&(file.getData())[i/8],0,4096);
}
else{
int rem=(file.getLength()-i)/8; // Bytes remaining
int pad=512-rem;
byte paddata[pad]; for(int k=0; k<pad; k++)paddata[k]=0xff;
jtag->shiftDR(&(file.getData())[i/8],0,rem*8,0,false); // Do not goto EXIT1-DR
jtag->shiftDR(paddata,0,pad*8);
}
jtag->longToByteArray(frame,data);
jtag->shiftIR(&FADDR);
jtag->shiftDR(data,0,16);
io->cycleTCK(2);
jtag->shiftIR(&FPGM);
io->cycleTCK(5000);
printf("done.\n");
}
jtag->shiftIR(&BYPASS);
io->tapTestLogicReset();
return 0;
}
int ProgAlgXCF::verify(BitFile &file)
{
return 0;
}

View File

@ -0,0 +1,58 @@
/* XCF Flash PROM JTAG programming algorithms
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef PROGALGXCF_H
#define PROGALGXCF_H
#include "bitfile.h"
#include "jtag.h"
#include "iobase.h"
class ProgAlgXCF
{
private:
static const byte SERASE;
static const byte ISPEN;
static const byte FPGM;
static const byte FADDR;
static const byte FERASE;
static const byte FDATA0;
static const byte FVFY0;
static const byte NORMRST;
static const byte IDCODE;
static const byte BYPASS;
static const byte BIT3;
static const byte BIT4;
Jtag *jtag;
IOBase *io;
public:
ProgAlgXCF(Jtag &j, IOBase &i);
int erase();
int program(BitFile &file);
int verify(BitFile &file);
};
#endif //PROGALGXCF_H

Binary file not shown.

View File

@ -0,0 +1,51 @@
/* JTAG GNU/Linux parport device io
Copyright (C) 2005 Andres Calderon
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include "sakcXCProgrammer.h"
using namespace std;
/*
WE1 TDI PC24
SDA TMS PD23
SCK TDO PD24
TCK PD28
*/
sakcXCProgrammer::sakcXCProgrammer() : IOBase()
{
JZ_PIO * pio = jz_gpio_map ();
jz_gpio_as_input (JZ_GPIO_PORT_D, TDO);
jz_gpio_as_output (JZ_GPIO_PORT_D, TCK);
jz_gpio_as_output (JZ_GPIO_PORT_C, TDI);
jz_gpio_as_output (JZ_GPIO_PORT_D, TMS);
error = (pio) ? false : true;
}
sakcXCProgrammer::~sakcXCProgrammer()
{
}

View File

@ -0,0 +1,75 @@
/* at91 XC Programer
Copyright (C) 2006 Carlos Camargo, Andres Calderon
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef SAKC_XCP_H
#define SAKC_XCP_H
#include "iobase.h"
#include <unistd.h>
extern "C"
{
#include "jz47xx_gpio.h"
}
class sakcXCProgrammer: public IOBase
{
public:
sakcXCProgrammer();
virtual ~sakcXCProgrammer();
virtual bool txrx(bool tms, bool tdi);
virtual void tx(bool tms, bool tdi);
bool checkError(){return error;}
bool done(){return true; /*!error && (cpld_base[0]&DONE==DONE);*/}
protected:
bool error;
unsigned char data;
};
#define TDI 14 /*C*/
#define TMS 23 /*D*/
#define TDO 24 /*D*/
#define TCK 28 /*D*/
inline
bool
sakcXCProgrammer::txrx(bool tms, bool tdi)
{
tx(tms,tdi);
return jz_gpio_get_pin (JZ_GPIO_PORT_D, TDO);
}
inline
void
sakcXCProgrammer::tx(bool tms, bool tdi)
{
jz_gpio_out (JZ_GPIO_PORT_D, TCK, 0);
jz_gpio_out (JZ_GPIO_PORT_C, TDI, tdi);
jz_gpio_out (JZ_GPIO_PORT_D, TMS, tms);
jz_gpio_out (JZ_GPIO_PORT_D, TCK, 1);
}
#endif // JTAGBUS_H

Binary file not shown.

BIN
Software/xc3sprog/xc3sprog Executable file

Binary file not shown.

View File

@ -0,0 +1,123 @@
/* Spartan3 JTAG programmer
Copyright (C) 2004 Andrew Rogers
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sakcXCProgrammer.h"
#include "bitfile.h"
#include "jtag.h"
#include "devicedb.h"
#include "progalgxcf.h"
#include "progalgxc3s.h"
#define MEMDEV "/dev/mem"
#define DEVICEDB "devlist.txt"
void process(IOBase &io, BitFile &file, int chainpos);
void programXC3S(Jtag &jtag, IOBase &io, BitFile &file);
void programXCF(Jtag &jtag, IOBase &io, BitFile &file);
int main(int argc, char **args)
{
// Produce release info from CVS tags
char release[]={"$Name: Release-0-5 $"};
char *loc0=strchr(release,'-');
if(loc0>0){
loc0++;
char *loc=loc0;
do{
loc=strchr(loc,'-');
if(loc)*loc='.';
}while(loc);
release[strlen(release)-1]='\0'; // Strip off $
}
printf("Release %s\n",loc0);
sakcXCProgrammer io;
int chainpos=0;
if(io.checkError()){
fprintf(stderr,"Can map physical address into virtual space! or can not open '%s'.\n",MEMDEV);
}
if(argc<=1){
fprintf(stderr,"\nUsage: %s infile.bit [POS]\n\n",args[0]);
fprintf(stderr,"\tPOS position in JTAG chain, 0=closest to TDI (default)\n\n",args[0]);
return 1;
}
if(argc>2)chainpos=atoi(args[2]);
BitFile file;
if(file.load(args[1]))process(io,file,chainpos);
else return 1;
return 0;
}
void process(IOBase &io, BitFile &file, int chainpos)
{
Jtag jtag(&io);
int num=jtag.getChain();
// Synchronise database with chain of devices.
DeviceDB db(DEVICEDB);
for(int i=0; i<num; i++){
printf("ID=%x\n", jtag.getDeviceID(i));
int length=db.loadDevice(jtag.getDeviceID(i));
if(length>0)jtag.setDeviceIRLength(i,length);
else{
unsigned id=jtag.getDeviceID(i);
fprintf(stderr,"Cannot find device having IDCODE=%08x\n",id);
return;
}
}
if(jtag.selectDevice(chainpos)<0){
fprintf(stderr,"Invalid chain position %d, position must be less than %d (but not less than 0).\n",chainpos,num);
return;
}
// Find the programming algorithm required for device
const char *dd=db.getDeviceDescription(chainpos);
if(strncmp("XC3S",dd,4)==0) {
printf("Programming..\n");
programXC3S(jtag,io,file);
}
else if(strncmp("XCF",dd,3)==0) programXCF(jtag,io,file);
else{
fprintf(stderr,"Sorry, cannot program '%s', a later release may be able to.\n",dd);
return;
}
}
void programXC3S(Jtag &jtag, IOBase &io, BitFile &file)
{
ProgAlgXC3S alg(jtag,io);
alg.program(file);
return;
}
void programXCF(Jtag &jtag, IOBase &io, BitFile &file)
{
ProgAlgXCF alg(jtag,io);
alg.erase();
alg.program(file);
return;
}

Binary file not shown.

BIN
docs/SAKC_BOT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

BIN
docs/SAKC_SST.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
docs/SAKC_TOP.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.