Permalink
Browse files

Removing standalone mode; adding slave serial and slave parallel prog…

…ramming
  • Loading branch information...
1 parent f628291 commit a117078bd364dd8bc5e098bb3485b665cb9c1a8e makestuff committed Mar 16, 2013
Showing with 1,595 additions and 793 deletions.
  1. +8 −21 Makefile
  2. +15 −15 csvfplay.c
  3. +3 −3 csvfplay.h
  4. +7 −12 examples/python/fpgalink2.py
  5. +0 −19 firmware.h
  6. +24 −14 firmware/fx2/Makefile
  7. +146 −81 firmware/fx2/app.c
  8. +14 −4 firmware/fx2/descriptors.a51
  9. +35 −27 firmware/fx2/jtag.c
  10. +8 −20 firmware/fx2/jtag.h
  11. +77 −0 firmware/fx2/livePatch.c
  12. +55 −0 firmware/fx2/lstParse.pl
  13. +2 −1 firmware/fx2/prom.c
  14. +128 −65 firmware/fx2/selectmap.c
  15. +12 −195 fx2.c
  16. +339 −26 jtag.c
  17. +38 −0 libfpgalink.c
  18. +24 −8 libfpgalink.h
  19. +28 −277 mkfw/main.c
  20. +535 −0 nero.c
  21. +82 −0 nero.h
  22. +13 −4 private.h
  23. +2 −1 vendorCommands.h
View
@@ -15,12 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
ROOT := $(realpath ../..)
-DEPS := error usbwrap fx2loader nero buffer
+DEPS := error usbwrap fx2loader buffer
TYPE := dll
#SUBDIRS := tests-unit
PRE_BUILD := $(ROOT)/3rd/fx2lib/lib/fx2.lib gen_fw
POST_BUILD := tools
-EXTRA_CC_SRCS := gen_fw/ramFirmware.c gen_fw/eepromWithBootFirmware.c gen_fw/eepromNoBootFirmware.c
+EXTRA_CC_SRCS := gen_fw/ramFirmware.c gen_fw/eepromNoBootFirmware.c
EXTRA_CLEAN := gen_fw #gen_svf gen_xsvf gen_csvf
EXTRA_CLEAN_DIRS := mkfw firmware/fx2 xsvf2csvf dump
@@ -39,27 +39,14 @@ tools:
gen_fw: $(MKFW)
mkdir -p gen_fw
make -C firmware/fx2 clean
- make -C firmware/fx2 FLAGS="-DJTAG_PORT=3 -DTDO_BIT=0 -DTDI_BIT=1 -DTMS_BIT=2 -DTCK_BIT=3"
- cp firmware/fx2/firmware.hex gen_fw/ramFirmware1.hex
+ make -C firmware/fx2
+ cp firmware/fx2/firmware.hex gen_fw/ramFirmware.hex
make -C firmware/fx2 clean
- make -C firmware/fx2 FLAGS="-DJTAG_PORT=2 -DTDO_BIT=7 -DTDI_BIT=6 -DTMS_BIT=5 -DTCK_BIT=4"
- cp firmware/fx2/firmware.hex gen_fw/ramFirmware2.hex
+ make -C firmware/fx2 FLAGS="-DEEPROM"
+ cp firmware/fx2/firmware.hex gen_fw/eepromNoBootFirmware.hex
make -C firmware/fx2 clean
- make -C firmware/fx2 FLAGS="-DJTAG_PORT=3 -DTDO_BIT=0 -DTDI_BIT=1 -DTMS_BIT=2 -DTCK_BIT=3 -DEEPROM -DBOOT"
- cp firmware/fx2/firmware.hex gen_fw/eepromWithBootFirmware1.hex
- make -C firmware/fx2 clean
- make -C firmware/fx2 FLAGS="-DJTAG_PORT=2 -DTDO_BIT=7 -DTDI_BIT=6 -DTMS_BIT=5 -DTCK_BIT=4 -DEEPROM -DBOOT"
- cp firmware/fx2/firmware.hex gen_fw/eepromWithBootFirmware2.hex
- make -C firmware/fx2 clean
- make -C firmware/fx2 FLAGS="-DJTAG_PORT=3 -DTDO_BIT=0 -DTDI_BIT=1 -DTMS_BIT=2 -DTCK_BIT=3 -DEEPROM"
- cp firmware/fx2/firmware.hex gen_fw/eepromNoBootFirmware1.hex
- make -C firmware/fx2 clean
- make -C firmware/fx2 FLAGS="-DJTAG_PORT=2 -DTDO_BIT=7 -DTDI_BIT=6 -DTMS_BIT=5 -DTCK_BIT=4 -DEEPROM"
- cp firmware/fx2/firmware.hex gen_fw/eepromNoBootFirmware2.hex
- make -C firmware/fx2 clean
- $(MKFW) gen_fw/ramFirmware1.hex gen_fw/ramFirmware2.hex ram bix > gen_fw/ramFirmware.c
- $(MKFW) gen_fw/eepromWithBootFirmware1.hex gen_fw/eepromWithBootFirmware2.hex eepromWithBoot iic > gen_fw/eepromWithBootFirmware.c
- $(MKFW) gen_fw/eepromNoBootFirmware1.hex gen_fw/eepromNoBootFirmware2.hex eepromNoBoot iic > gen_fw/eepromNoBootFirmware.c
+ $(MKFW) gen_fw/ramFirmware.hex ram bix > gen_fw/ramFirmware.c
+ $(MKFW) gen_fw/eepromNoBootFirmware.hex eepromNoBoot iic > gen_fw/eepromNoBootFirmware.c
hdl:
./hdlbuild.sh $(X2C)
View
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <makestuff.h>
#include <liberror.h>
-#include <libnero.h>
+#include "nero.h"
#include "vendorCommands.h"
#include "xsvf.h"
#include "csvfplay.h"
@@ -43,7 +43,7 @@ static bool tdoMatchFailed(
// Play the uncompressed CSVF stream into the JTAG port.
//
-int csvfPlay(const uint8 *csvfData, bool isCompressed, struct NeroHandle *nero, const char **error) {
+int csvfPlay(struct FLContext *handle, const uint8 *csvfData, bool isCompressed, const char **error) {
int returnCode;
NeroStatus nStatus;
uint8 thisByte, numBits;
@@ -64,7 +64,7 @@ int csvfPlay(const uint8 *csvfData, bool isCompressed, struct NeroHandle *nero,
uint8 *tdiAll;
struct Context cp;
- nStatus = neroClockFSM(nero, 0x0000001F, 6, error); // Reset TAP, goto Run-Test/Idle
+ nStatus = neroClockFSM(handle, 0x0000001F, 6, error); // Reset TAP, goto Run-Test/Idle
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
if ( csvfInitReader(&cp, csvfData, isCompressed) ) {
@@ -102,7 +102,7 @@ int csvfPlay(const uint8 *csvfData, bool isCompressed, struct NeroHandle *nero,
break;
case XSIR:
- nStatus = neroClockFSM(nero, 0x00000003, 4, error); // -> Shift-IR
+ nStatus = neroClockFSM(handle, 0x00000003, 4, error); // -> Shift-IR
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
numBits = csvfGetByte(&cp);
#ifdef DEBUG
@@ -120,12 +120,12 @@ int csvfPlay(const uint8 *csvfData, bool isCompressed, struct NeroHandle *nero,
#ifdef DEBUG
printf(")\n");
#endif
- nStatus = neroShift(nero, numBits, tdiData, NULL, true, error); // -> Exit1-DR
+ nStatus = neroShift(handle, numBits, tdiData, NULL, true, error); // -> Exit1-DR
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
- nStatus = neroClockFSM(nero, 0x00000001, 2, error); // -> Run-Test/Idle
+ nStatus = neroClockFSM(handle, 0x00000001, 2, error); // -> Run-Test/Idle
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
if ( xruntest ) {
- nStatus = neroClocks(nero, xruntest, error);
+ nStatus = neroClocks(handle, xruntest, error);
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
}
break;
@@ -148,14 +148,14 @@ int csvfPlay(const uint8 *csvfData, bool isCompressed, struct NeroHandle *nero,
numBytes = bitsToBytes(xsdrSize);
i = 0;
do {
- nStatus = neroClockFSM(nero, 0x00000001, 3, error); // -> Shift-DR
+ nStatus = neroClockFSM(handle, 0x00000001, 3, error); // -> Shift-DR
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
- nStatus = neroShift(nero, xsdrSize, tdiData, tdoData, true, error); // -> Exit1-DR
+ nStatus = neroShift(handle, xsdrSize, tdiData, tdoData, true, error); // -> Exit1-DR
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
- nStatus = neroClockFSM(nero, 0x0000001A, 6, error); // -> Run-Test/Idle
+ nStatus = neroClockFSM(handle, 0x0000001A, 6, error); // -> Run-Test/Idle
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
if ( xruntest ) {
- nStatus = neroClocks(nero, xruntest, error);
+ nStatus = neroClocks(handle, xruntest, error);
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
}
i++;
@@ -184,21 +184,21 @@ int csvfPlay(const uint8 *csvfData, bool isCompressed, struct NeroHandle *nero,
// TODO: Need to print actual TDO data too
printf("XSDR(%08X)\n", xsdrSize);
#endif
- nStatus = neroClockFSM(nero, 0x00000001, 3, error); // -> Shift-DR
+ nStatus = neroClockFSM(handle, 0x00000001, 3, error); // -> Shift-DR
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
numBytes = bitsToBytes(xsdrSize);
tdiAll = malloc(numBytes);
tdiPtr = tdiAll;
while ( numBytes-- ) {
*tdiPtr++ = csvfGetByte(&cp);
}
- nStatus = neroShift(nero, xsdrSize, tdiAll, NULL, true, error); // -> Exit1-DR
+ nStatus = neroShift(handle, xsdrSize, tdiAll, NULL, true, error); // -> Exit1-DR
free(tdiAll);
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
- nStatus = neroClockFSM(nero, 0x00000001, 2, error); // -> Run-Test/Idle
+ nStatus = neroClockFSM(handle, 0x00000001, 2, error); // -> Run-Test/Idle
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
if ( xruntest ) {
- nStatus = neroClocks(nero, xruntest, error);
+ nStatus = neroClocks(handle, xruntest, error);
CHECK_STATUS(nStatus, "csvfPlay()", nStatus);
}
break;
View
@@ -23,8 +23,8 @@
extern "C" {
#endif
- // Forward declaration of NeroHandle struct
- struct NeroHandle;
+ // Forward declaration of NeroContext struct
+ struct FLContext;
// csvfPlay() may return any NeroStatus code, plus these
#define CPLAY_COMPARE_ERR 100
@@ -33,7 +33,7 @@ extern "C" {
// Play the uncompressed CSVF stream into the JTAG port.
int csvfPlay(
- const uint8 *csvfData, bool isCompressed, struct NeroHandle *nero, const char **error
+ struct FLContext *handle, const uint8 *csvfData, bool isCompressed, const char **error
) WARN_UNUSED_RESULT;
#ifdef __cplusplus
@@ -88,9 +88,9 @@ class FLException(Exception):
fpgalink.flPlayXSVF.restype = FLStatus
# FX2LP Firmware Operations
-fpgalink.flLoadStandardFirmware.argtypes = [c_char_p, c_char_p, c_char_p, POINTER(ErrorString)]
+fpgalink.flLoadStandardFirmware.argtypes = [c_char_p, c_char_p, POINTER(ErrorString)]
fpgalink.flLoadStandardFirmware.restype = FLStatus
-fpgalink.flFlashStandardFirmware.argtypes = [FLHandle, c_char_p, c_char_p, uint32, c_char_p, POINTER(ErrorString)]
+fpgalink.flFlashStandardFirmware.argtypes = [FLHandle, c_char_p, POINTER(ErrorString)]
fpgalink.flFlashStandardFirmware.restype = FLStatus
fpgalink.flSaveFirmware.argtypes = [FLHandle, uint32, c_char_p, POINTER(ErrorString)]
fpgalink.flSaveFirmware.restype = FLStatus
@@ -247,9 +247,9 @@ def flPlayXSVF(handle, xsvfFile):
raise FLException(s)
# Load standard firmware into the FX2LP chip
-def flLoadStandardFirmware(curVidPid, newVidPid, jtagPort):
+def flLoadStandardFirmware(curVidPid, newVidPid):
error = ErrorString()
- status = fpgalink.flLoadStandardFirmware(curVidPid.encode('ascii'), newVidPid.encode('ascii'), jtagPort.encode('ascii'), byref(error))
+ status = fpgalink.flLoadStandardFirmware(curVidPid.encode('ascii'), newVidPid.encode('ascii'), byref(error))
if ( status != FL_SUCCESS ):
s = str(error.value)
fpgalink.flFreeError(error)
@@ -285,10 +285,9 @@ def flAppendWriteChannelCommand(handle, chan, values):
raise FLException(s)
# Flash standard firmware into the FX2LP's EEPROM
-def flFlashStandardFirmware(handle, newVidPid, jtagPort, eepromSize, xsvfFile = None):
+def flFlashStandardFirmware(handle, newVidPid):
error = ErrorString()
- xsvfFile = None if ( xsvfFile == None ) else xsvfFile.encode('ascii')
- status = fpgalink.flFlashStandardFirmware(handle, newVidPid.encode('ascii'), jtagPort.encode('ascii'), eepromSize, xsvfFile, byref(error))
+ status = fpgalink.flFlashStandardFirmware(handle, newVidPid.encode('ascii'), byref(error))
if ( status != FL_SUCCESS ):
s = str(error.value)
fpgalink.flFreeError(error)
@@ -313,7 +312,6 @@ def flInitialise(debugLevel):
parser.add_argument('-s', action="store_true", default=False, help="scan the JTAG chain")
parser.add_argument('-v', action="store", nargs=1, required=True, metavar="<VID:PID>", help="renumerated vendor and product ID of the FPGALink device")
parser.add_argument('-i', action="store", nargs=1, metavar="<VID:PID>", help="initial vendor and product ID of the (FX2LP-based) FPGALink device")
- parser.add_argument('-j', action="store", nargs=1, metavar="<jtagPort>", help="JTAG port specification for the (FX2LP-based) FPGALink device")
parser.add_argument('-x', action="store", nargs=1, metavar="<xsvfFile>", help="SVF, XSVF or CSVF file to play into the JTAG chain")
parser.add_argument('-f', action="store", nargs=1, metavar="<dataFile>", help="binary data to write to channel 0")
argList = parser.parse_args()
@@ -328,12 +326,9 @@ def flInitialise(debugLevel):
handle = flOpen(vp)
except FLException, ex:
if ( argList.i ):
- jtagPort = "D0234"
- if ( argList.j ):
- jtagPort = argList.j[0]
ivp = argList.i[0]
print "Loading firmware into %s..." % ivp
- flLoadStandardFirmware(ivp, vp, jtagPort);
+ flLoadStandardFirmware(ivp, vp);
print "Awaiting renumeration..."
if ( not flAwaitDevice(vp, 600) ):
View
@@ -27,30 +27,11 @@ extern "C" {
const uint8 *const data;
const uint16 length;
const uint16 vp;
- const uint16 d0E; // 0x08 when on A, 0x0C when on C, 0x0E when on D
- const uint16 d0F; // 0x09 when on A, 0x0D when on C, 0x0F when on D
- const uint16 outBits;
- const uint16 outBitsComp;
- const uint16 *oeRegs;
- const uint16 *allBits;
- const uint16 *allBitsComp;
- const uint16 *tdoBit;
- const uint16 *tdiBit;
- const uint16 *tmsBit;
- const uint16 *tckBit;
};
extern const struct FirmwareInfo ramFirmware;
extern const struct FirmwareInfo eepromNoBootFirmware;
- extern const struct FirmwareInfo eepromWithBootFirmware;
- #define NUM_OE_BITS 2
- #define NUM_ALL_BITS 6
- #define NUM_TDO_BIT 11
- #define NUM_TDI_BIT 30
- #define NUM_TMS_BIT 7
- #define NUM_TCK_BIT 66
-
#ifdef __cplusplus
}
#endif
View
@@ -26,34 +26,44 @@
# make FLAGS="-DEEPROM -DBOOT"
# sudo make eeprom
#
-TARGET = firmware
-FX2LIBDIR=../../../../3rd/fx2lib
-LIBS = -L$(FX2LIBDIR)/lib fx2.lib
-INCS = -I sdcc -I$(FX2LIBDIR)/include -I../../../../common
+TARGET := firmware
+FX2LIBDIR := ../../../../3rd/fx2lib
+LIBS := -L$(FX2LIBDIR)/lib fx2.lib
+INCS := -I sdcc -I$(FX2LIBDIR)/include -I../../../../common
+MAKESTUFF_TODAY_DATE := $(shell date +%Y%m%d)
-CC_SRCS = $(shell ls *.c)
-AS_SRCS = $(shell ls *.a51)
-CC_OBJS = $(CC_SRCS:%.c=%.rel)
-AS_OBJS = $(AS_SRCS:%.a51=%.rel)
-CC = sdcc
-AS = asx8051
-CCFLAGS = -mmcs51 --code-size 0x3c00 --xram-size 0x0200 --xram-loc 0x3c00 -Wl"-b DSCR_AREA=0x3e00" -Wl"-b INT2JT=0x3f00" $(FLAGS)
+CC_SRCS := $(shell ls *.c)
+AS_SRCS := $(shell ls *.a51)
+CC_OBJS := $(CC_SRCS:%.c=%.rel)
+AS_OBJS := $(AS_SRCS:%.a51=%.rel)
+CC := sdcc
+AS := asx8051
+CCFLAGS := -mmcs51 --code-size 0x2e00 --xram-loc 0xe000 --xram-size 0x0200 -Wl"-b DSCR_AREA=0x2e00" -Wl"-b INT2JT=0x2f00" $(FLAGS)
-all: $(TARGET).hex
+all: date.inc jtagOffsets.h $(TARGET).hex
+
+foo: FORCE
+ @echo $(AS_OBJS)
$(TARGET).hex: $(CC_OBJS) $(AS_OBJS) $(TARGET).rel
- $(CC) $(CCFLAGS) -o $@ $(CC_OBJS) $(AS_OBJS) $(LIBS)
+ $(CC) $(CCFLAGS) -o $@ $+ $(LIBS)
%.rel: %.c
$(CC) $(CCFLAGS) -c --disable-warning 85 $(INCS) $?
%.rel: %.a51
$(AS) -logs $?
+jtagOffsets.h: jtag.rel
+ cat jtag.lst | ./lstParse.pl > jtagOffsets.h
+
+date.inc:
+ echo DATE=0x$(MAKESTUFF_TODAY_DATE) > $@
+
firmware.c: $(FX2LIBDIR)/fw/fw.c
cp $(FX2LIBDIR)/fw/fw.c firmware.c
clean: FORCE
- rm -f *.iic *.asm *.hex *.lnk *.lst *.map *.mem *.rel *.rst *.sym firmware.c
+ rm -f *.iic *.asm *.hex *.lnk *.lst *.map *.mem *.rel *.rst *.sym firmware.c jtagOffsets.h date.inc
FORCE:
Oops, something went wrong.

0 comments on commit a117078

Please sign in to comment.