UPGRADE YOUR BROWSER
We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!
07-07-2011 05:59 PM
We are using the XC3S400AN FGPA in our products. One of the feature of these products is to be field upgradeable of both the firmware and the FPGA image through processor control. In our previous design we were using the XC3S1000 FPGA with an external XCF04SV0G20C EEPROM and I have no problem in programming the EEPROM through CPU control, by implementing a JTAG interface. But this new FPGA has an internal SPI flash that I have some questions on re-programming it.
First of all, are my following assumptions correct?
1/ After reading several documents I am led to believe that I can access the flash only through the SPI logic inside the FPGA.
2/ The SPI logic inside the FPGA is not hardcoded in the FPGA, it needed to be downloaded into the FPGA from the programmed flash at power up, or through the JTAG interface on the fly.
3/ When using the IMPACT tool to program the FPGA’s internal flash, it first configure the FPGA with the SPI logic on the fly, then through this logic the flash is erased and programmed by issuing SPI commands.
Currently our FPGA image does not include the SPI logic, does that mean that in order for me to modify the flash I would have to simulate the IMPACT tool, by first downloading the FPGA with the SPI logic, then erase and program the flash through this SPI interface? Or, are there some easier methods. Thanks for your input.
Francis
07-07-2011 06:40 PM - edited 07-07-2011 06:41 PM
I am not a Spartan-3AN expert, so these may not be the final words on the matters at hand:
First of all, are my following assumptions correct?
1/ After reading several documents I am led to believe that I can access the flash only through the SPI logic inside the FPGA.
This might be a more accurate description:
I can access the flash only indirectly, through the SPI logic I design to run inside the FPGA
There is also the option for programming the internal SPI flash memory indirectly, through the FPGA JTAG interface, as IMPACT does.
2/ The SPI logic inside the FPGA is not hardcoded in the FPGA, it needed to be downloaded into the FPGA from the programmed flash at power up, or through the JTAG interface on the fly.
3/ When using the IMPACT tool to program the FPGA’s internal flash, it first configure the FPGA with the SPI logic on the fly, then through this logic the flash is erased and programmed by issuing SPI commands.
I cannot speak to this.
-- Bob Elkind
07-07-2011 07:39 PM
First of all, thank you very much for answering my post, but I still have a couple of questions un-answered.
"After FPGA configuration, access to the 'internal' SPI flash memory is via the SPI_ACCESS primitive. See UG333."
As far as I understand it, the SPI logic is not part of the FPGA's hardwired logic nor it is included in the FPGA image automatically if not specifically selected with the Xilinx tools. So I cannot expect to be able to access it via the SPI_ACCESS primitive, as indicated in the UG333. Am I correct?
"An FPGA configuration which provides access to the SPI flash can be provided from a number of different sources. For example, your onboard microprocessor can switch the FPGA's M0:1:2 pin settings to 'slave serial' mode, and can then provide configuration bitstream data directly to the FPGA. See UG332 for the various options."
Bus this means every time when the board is powered up, I would need to download the FPGA's bit stream through the CPU, that would take a lot longer then having the FPGA directly loads its bit stream from the flash. If possible, I would rather programming the flash once and let the FPGA gets its configuration from the flash every time at power up.
"JTAG is another configuration option, but not your only option -- far from it."
I am all ears to listen to other suggestions.
I have read plenty of PDFs on this Spartan-3AN FPGA and the forums for it. There are tons of info out there on the technical details of the FPGA, and programming it using the Xilinx tools, but still I cannot find any solid lead to how to program the internal flash using the microprocessor control, unless somehow I first make the FPGA to do the JTAG->SPI conversion for me, by either configure the FPGA on the fly, or include the SPI logic as part of its image.
What I am looking for, is a direct answer from Xilinx that "yes, I have to do either one of the two ways as I mentioned above", so that I will bite the bullet and do whatever is required, instead of still having my hope up on some easier methods.
07-07-2011 08:21 PM - edited 07-07-2011 08:26 PM
"After FPGA configuration, access to the 'internal' SPI flash memory is via the SPI_ACCESS primitive. See UG333."
As far as I understand it, the SPI logic is not part of the FPGA's hardwired logic nor it is included in the FPGA image automatically if not specifically selected with the Xilinx tools. So I cannot expect to be able to access it via the SPI_ACCESS primitive, as indicated in the UG333. Am I correct?
I don't know how to answer you. Do you understand how any logic makes it from your mind to the FPGA image? The SPI_ACCESS primitive is no different than registers, clocks, combinatorial logic, inputs and outputs. If you infer or instantiate it in your design code, it will be represented in the 'FPGA image'. Otherwise, it won't be represented in the FPGA image.
Have I misunderstood you? Perhaps I don't understand your specific meaning.
"An FPGA configuration which provides access to the SPI flash can be provided from a number of different sources. For example, your onboard microprocessor can switch the FPGA's M0:1:2 pin settings to 'slave serial' mode, and can then provide configuration bitstream data directly to the FPGA. See UG332 for the various options."
But this means every time when the board is powered up, I would need to download the FPGA's bit stream through the CPU, that would take a lot longer then having the FPGA directly loads its bit stream from the flash. If possible, I would rather programming the flash once and let the FPGA gets its configuration from the flash every time at power up.
I suspect that you are new to hardware design. If you configure the board to power up with a default setting of "configure the FPGA via internal SPI Flash memory", and provide means for the microprocessor to over-ride the default setting when you wish to install new firmware, you can accomplish what you desire. Or you can provide hardware jumpers on the board to switch the FPGA configuration mode.
"JTAG is another configuration option, but not your only option -- far from it."
I am all ears to listen to other suggestions.
Imagine all the various ways which a microprocessor on the circuit board can be connected to the FPGA, and program (configure) the FPGA. JTAG is one, slave serial is another, slave parallel is a third. At the risk of repeating myself, you should read UG332 to understand the hardware alternatives, keeping in mind that the microprocessor will need code written to support whichever alternative you select.
I suggest you solicit the services of someone experienced in FPGA and circuit board design to assist you and guide you, step by step, in this first effort. Once you have walked through the design steps once, it will become very simple in your mind.
If this was my design, the steps would be as follows:
-- Bob Elkind
07-07-2011 09:13 PM
07-07-2011 09:45 PM - edited 07-07-2011 10:56 PM
I sympathise with your predicament.
1. These details should have been in your very first post in this thread. The limits of your solution options would have saved me considerable time and words spent trying to help you with useless options.
2. If your circuit board design cannot be changed, and you are constrained to using the microprocessor, then you are left with only one option: JTAG. I do not have the expertise to be of further assistance to you in this area.
I wish you well.
-- Bob Elkind
07-07-2011 09:56 PM
07-07-2011 10:37 PM
Hi Francis,
I use Spartan 3ANs in several of my designs and support flash firmware upgrades in the field. All of them use a Picoblaze processor inside the Spartan hooked to the outside world through a simple serial interface (2 wires), and the Picoblaze is internally connected to the SPI_ACCESS bus. You might have your fellow engineers provide a similar interface to your microprocessor. I've found that implementing flash reprogrammability over the JTAG interface is comparatively slow and convoluted.
-Greg
07-07-2011 10:44 PM
07-07-2011 11:04 PM - edited 07-07-2011 11:05 PM
Followup to Greg's suggestion:
Greg's suggestion assumes there is an external, direct serial interface to the FPGA. This may not be the case with your circuit board.
If the microprocessor signals which drive the JTAG TDI and TMS pins can be jumpered (connected) to 2 unused FPGA pins, this would be enough to provide a 'serial' connection similar to the design described by Greg. It only takes 2 wires to implement this, and there may be a relatively easy way to modify the circuit board to achieve this solution. The circuit board designer might have some useful implementation suggestions.
This would allow your product (your existing board design) to use the existing interfaces to the microprocessor (e.g. USB, serial, ethernet, etc.) for uploading the new firmware.
-- Bob Elkind
07-07-2011 11:23 PM
07-08-2011 12:21 AM - edited 07-08-2011 12:51 AM
If you can find 4 GPIO pins to connect to FPGA I/O pins, you can directly control the SPI_ACCESS port from the microprocessor.
(NOTE: The signals from the microprocessor to the FPGA JTAG interface also consist of 3 outputs and 1 input)
This is how the SPI_ACCESS port looks, represented as a graphic symbol.
If you can only manage 2 GPIO connections to the FPGA, this is enough to use Greg's PicoBlaze design approach.
The 2 GPIO pins are used for serial transmit data and serial receive data, respectively, representing a duplex serial port between the microprocessor and the FPGA.
Inside the FPGA is a (soft IP core) primitive 8-bit processor -- PicoBlaze -- which interprets commands and data sent from the microprocessor to the FPGA. PicoBlaze executes these commands to perform read and write operations to the SPI flash memory via the SPI_ACCESS port. PicoBlaze returns read data and status to the microprocessor via the serial receive data signal. In other words, the 2-wire interface requires a simple command protocol for basic SPI functions, for example:
You would need to 'design' and implement the protocol, both in the microprocessor and in the PicoBlaze processor in the FPGA. The details would need to include specific format for addresses and data, and response format for 'command complete'.
So, two options:
Either can work. Greg has already proven that the 2-wire plus PicoBlaze solution can work.
-- Bob Elkind
07-08-2011 12:34 AM
07-08-2011 12:39 AM
If the 2-wire approach works for you, you and your FPGA designer colleague will each owe Greg a beer!
-- Bob Elkind
07-08-2011 12:42 AM