Skip to main content
Topic: Xilinx JTAG XC3S200A XSVF Overflow Error + Recompiling Github SVN Code (Read 691 times) previous topic - next topic

Xilinx JTAG XC3S200A XSVF Overflow Error + Recompiling Github SVN Code

Hi everyone,

I have been having a terrible time trying to get my Bus Pirate to program a Xilinx FPGA (XC3S200A) using JTAG and need some help.

When I use the last compiled/built XSVF firmware from the DP website I have noticed two things:
Number one: as described in a topic elsewhere on this forum the last official compiled code is not up to date with the SVN code (which was then ported to github). Hence the JTAG reset and boundary scan is not available on the XSVF firmware I have.
Number 2: When trying to use the BP to program the XC3S200A via JTAG it ends with a XSVF Error Overflow (corresponding to error 6 I think) always at the same point in the upload.

There are already two different posts on this forum with people who had this error (one was resolved by recreating their .xsvf file and the other never was. I would add links to all forum posts but my main computer with my research on it died a few days ago).

Digging into the code available on github I believe that the issue is that the XSVF firmware was built with the MAXLEN parameter in LENVAL.h set to 50 whereas for FPGAs Xilinx recommends a value of 128. I have tried using Xilinx iMPACT to reduce the required length when I create the .xsvf file from the .svf file to suit the MAXLEN as 50 but receive a TDO mismatch error instead (quite early on in the upload sequence).

I believe that the MAXLEN value needs to be increased (to Xilinx's recommended value of 128 for FPGAs) and the XSVF firmware recompiled in order to work with FPGAs and hence the XC3S200A. However the last time I did any programming was about 8 years ago and it was with really simple stuff on AVRs (nothing near the complexity of this code) and not with PICs and hence I am having some difficulty in building the XSVF firmware from the source on github.

Currently I have MPLAB X IDE v5.30 installed with the XC16 C Compiler and the XC16 C Compiler Part support. In the project view I have added all the header files under the headers section and all the .c files under the source section. I have set the project settings to the PIC24FJ64GA002 and set optimisation to level 2. There were numerous errors/warnings in the code on github which I have dealt with as follows:

In main.c: _config1 and _config2 seem to work but apparently #pragma is preferred. Hence I have translated the configs to pragmas.
In main.c: for the _config1 COE = Off apparently is not defined for the PIC24FJ64GA002 (I couldn't find coe in the header file thing for the PIC24FJ64GA002 in the Microchip install directories and other people on the internet have had this issue). I removed reference to COE to fix this. However based on my research the PIC24FJ64GA002 may have indeed supported this under previous IDEs.

In jtag.c: Functions jtagWriteByte and jtagReadByte declare variable a but do not initialise it. I have inserted a=0; below their declaration (it looked like it needed either a 0 or a 1 as the LSB or MSB).

Which finally leaves my pulling my hair out with UART.c which I can't fix. When I try to build I get the following errors:

UART.c: In function 'UART1RX':
UART.c:6:11: error: 'U1STAbits' undeclared (first use in this function)
UART.c:6:11: note: each undeclared identifier is reported only once for each function it appears in
UART.c:7:9: error: 'U1RXREG' undeclared (first use in this function)
UART.c: In function 'UART1TX':
UART.c:13:8: error: 'U1STAbits' undeclared (first use in this function)
UART.c:14:5: error: 'U1TXREG' undeclared (first use in this function)
UART.c: In function 'InitializeUART1':
UART.c:20:2: error: 'RPINR18bits' undeclared (first use in this function)
UART.c:21:2: error: 'RPOR1bits' undeclared (first use in this function)
UART.c:22:5: error: 'U1BRG' undeclared (first use in this function)
UART.c:23:5: error: 'U1MODE' undeclared (first use in this function)
UART.c:24:5: error: 'U1MODEbits' undeclared (first use in this function)
UART.c:25:5: error: 'U1STA' undeclared (first use in this function)
UART.c:27:5: error: 'U1STAbits' undeclared (first use in this function)
UART.c:28:5: error: 'IFS0bits' undeclared (first use in this function)
UART.c: In function 'UART1RX':
UART.c:8:1: warning: control reaches end of non-void function
nbproject/ recipe for target 'build/default/production/UART.o' failed

Now I believe the warning about the control reaching the end of non-void function will sort itself out once these variables are 'declared'. However with my limited understanding of PICs and UART these variables are mainly part of the UART definitions that apparently just work without needing to be declared.

So I have a few questions:
Do I need to download a UART add on to the IDE to make it understand most of these 'undeclared' variables?
There is also a few BP sepcific variables which should be picked up in the hardware header files but the compiler is saying that these are undeclared variables. Why? Do I need to add #include "hardwarev2a.h" to UART.c?

As I do not believe the XSVF firmware has been updated since the SVN/github code alternatively if someone could recompile the XSVF firmware on github with MAXLEN as 32, 128, 256, 1100 and 2500 then this would cover all the Xilinx situations noted in LENVAL.h and I could continue (to lose my sanity) from there.

I am using Windows 7 x64 as my OS and a Bus Pirate v3.6.

Thanks in advance.