Commit e639352a authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

doc: updated documentation for the bootloader & golden bitstreams

parent 09abd1ca
......@@ -6,7 +6,7 @@
#################
# There is not basenames here, all *.in are considered input
INPUT = svec-golden.in
INPUT = svec-firmware-manual.in
TEXI = $(INPUT:.in=.texi)
INFO = $(INPUT:.in=.info)
......
......@@ -25,8 +25,8 @@
@comment %**start of header
@documentlanguage en
@documentencoding UTF-8
@setfilename fine-delay.info
@settitle svec-golden
@setfilename svec-firmware-manual.info
@settitle svec-firmware-manual
@iftex
@afourpaper
@end iftex
......@@ -35,12 +35,12 @@
@setchapternewpage off
@set update-month October 2012
@set update-month January 2013
@finalout
@titlepage
@title @i{Golden} bitstream for the SVEC card
@title Default firmware for the SVEC card
@subtitle Programmer's manual
@author CERN BE-CO-HT / Tomasz Włostowski
......@@ -55,16 +55,95 @@
@node Top
@chapter Introduction
This document describes the default bitstreams that come preloaded with every SVEC card. As there are two FPGAs on the SVEC, there are two default bitstreams:
@itemize
@item @b{Bootloader bitstream}, residing in the System FPGA whose role is to start up the Application FPGA
@item @b{Golden bitstream}, residing in the Application FPGA, which allows the device driver to enumerate the mezzanines.
@end itemize
@chapter The Bootloader
The System FPGA bootloader allows to boot the Application FPGA from the VME bus or from the onboard Flash memory and reprogram both the System and Application bitstreams in the flash via VME. The boot process goes as follows:
@itemize
@item Power up.
@item SFPGA checks for presence of a valid bitstream file for the Application FPGA in the Flash memory.
@item If a valid bitstream has been found, the AFPGA is initialized with it,
@item if not, the Bootloader enters passive mode. Upon reception of a boot sequence, if gives access to the Flash for the host or lets it program the AFPGA directly.
@end itemize
@section VME Interface
The bootloader core supports only 32-bit data CR/CSR accesses from/to address range @code{0x70000} - @code{0x70020}, allowing for plug&play reprogramming of the cards only knowing their physical slot locations. All other transfers are ignored. The base address is @code{0x70000}, and corresponds to the @code{CSR} register. When the card is powered up, the VME interface stays in passive mode, monitoring VME accesses without ACKing them. This is to prevent conflicts with the CR/CSR space of the VME core in the Application FPGA.
@section Entering bootloader mode
In order to enter the bootloader, one needs to write a magic sequence of 8 following transfers: @code{0xde}, @code{0xad}, @code{0xad}, @code{0xbe}, @code{0xca}, @code{0xfe}, @code{0xba}, @code{0xbe} to @code{BTRIGR} register. Afterwards, read the @code{IDR} register. It should be equal to @code{SVEC} ASCII string encoded in HEX. Any other value indicates that the boot trigger sequence was not correctly recognized.
@b{Note 1:} Triggering bootloader mode causes automatic reset (un-programming) of the Application FPGA.
@b{Note 2:} Write operations to @code{BTRIGR} register while the core is still in passie mode will not be acknowledged on the VME bus and will most likely cause bus errors. Please ignore them.
@section Programming the AFPGA
Programming the Application FPGA directly via VME involves following steps:
@itemize
@item Reset the Xilinx Passive Serial boot interface by writing @code{CSR.SWRST} bit,
@item Set download speed by writing @code{CSR.CLKDIV} field. Default value is @code{1}.
@item Write @code{CSR.START} bit and set endianess via @code{CSR.MSBF} bit,
@item Write the bitstream to the FIFO registers, observing FIFO full/empty status. Last transfer should have @code{FIFO_R1.XLAST} bit set to 1.
@item Wait for assertion of @code{CSR.DONE}. @code{CSR.ERROR} bit indicates a problem during configuration (most likely, an invalid bitstream)
@item Exit bootloader mode by writing 1 to @code{CSR.EXIT} bit.
@end itemize
Successful firmware download to the Application FPGA is indicated by turning on the ``AFPGA DONE'' LED.
@section Programming the Flash
SFPGA also allows raw access to the Flash memory (M25P128) via @code{FAR} register. The code below shows how to execute a single SPI transaction (command + N data bytes).
@example
uint8 spi_transfer(int cs, uint8 data) {
while (! FAR.READY);
FAR.CS = cs;
FAR.XFER = 1;
FAR.DATA = data;
while (! FAR.READY);
return FAR.DATA;
}
void flash_command(uint8 command, uint8 data[]) {
spi_transfer(0, 0);
spi_transfer(1, cmd);
for(i=0;i<length(data);i++)
data[i] = spi_transfer(1, data[i]);
spi_transfer(0, 0);
}
@end example
Low-level details about programming M25Pxxx series Flash memories can be found in their datasheets.
@b{Note 1:} It is advised to protect the System FPGA bitstream from being accidentally overwritten, as this will result in bricking the card and will require re-programming the flash via JTAG.
@b{Note 2:} The freshly-programmed bitstreams will be loaded into the FPGAs after power-cycling the card.
@section Flash memory organization
The flash memory of the SVEC contains 16 Megabytes of memory, that is 64k pages of 256 bytes. First 6 MBs are used for bitstream storage, the rest is available for the user application. The flash format is compatible with the SDB filesystem, with the SDB descriptor table located at offset @code{0x500000}. Locations of the bitstreams are fixed to:
@itemize
@item @code{0}: Raw bitstream for the System FPGA (up to 1 MB)
@item @code{0x100000}: Bitstream for the Application FPGA (up to 4 MB)
@end itemize
An example script for building the default flash filesystem (containg the bootloader and golden bitstreams) is located in the @code{software/sdb-flash} subdirectory. The presence of SDB descriptor table at @code{0x500000}, as the SDB signature is checked by the bootloader to prevent booting up from a corrupted flash.
@b{Note:} Both bitstreams must be in raw (@code{.bin} file extension) format. @code{.bit}, @code{.mcs}, @code{.xsvf} and other formats will not work. This also applies to direct VME boot mode.
@chapter The Golden Bitstream
The SVEC Application FPGA golden bitstream allows the SVEC device driver to:
@itemize
@item Query the board's serial number,
@item Check the presence of the FMC mezzanines,
@item Read out their @math{I^2C} identification EEPROMs.
@end itemize
The bitstream does not drive any of the mezzanine user/clock pins to protect from electrical damage resulting from mismatched
I/O standards.
@chapter Using the bitstream
The bitstream does not drive any of the mezzanine user/clock pins to protect from electrical damage resulting from mismatched I/O standards.
@section Block diagram
......@@ -91,5 +170,7 @@ Only A32/A24/D32/CSR address modifiers are supported.
@item @code{xwb_onewire_master} @tab @code{0x12000} @tab @code{general-cores} @tab OneWire Master for accessing temperature sensor/serial ID.
@item @code{xwb_gpio_port} @tab @code{0x13000} @tab @code{general-cores} @tab GPIO port for accessing FMC1/2 presence lines.
@end multitable
@appendix System FPGA register map
@include svec_xloader.in
@bye
@subsubsection Memory map summary
@multitable @columnfractions .10 .15 .15 .55
@headitem Address @tab Type @tab Prefix @tab Name
@item @code{0x0} @tab
REG @tab
@code{CSR} @tab
Control/status register
@item @code{0x4} @tab
REG @tab
@code{BTRIGR} @tab
Bootloader Trigger Register
@item @code{0x8} @tab
REG @tab
@code{FAR} @tab
Flash Access Register
@item @code{0xc} @tab
REG @tab
@code{IDR} @tab
ID Register
@item @code{0x10} @tab
FIFOREG @tab
@code{FIFO_R0} @tab
FIFO 'Bitstream FIFO' data input register 0
@item @code{0x14} @tab
FIFOREG @tab
@code{FIFO_R1} @tab
FIFO 'Bitstream FIFO' data input register 1
@item @code{0x18} @tab
REG @tab
@code{FIFO_CSR} @tab
FIFO 'Bitstream FIFO' control/status register
@end multitable
@subsubsection @code{CSR} - Control/status register
@multitable @columnfractions .10 .10 .15 .10 .55
@headitem Bits @tab Access @tab Prefix @tab Default @tab Name
@item @code{0}
@tab W/O @tab
@code{START}
@tab @code{X} @tab
Start configuration
@item @code{1}
@tab R/O @tab
@code{DONE}
@tab @code{X} @tab
Configuration done
@item @code{2}
@tab R/O @tab
@code{ERROR}
@tab @code{X} @tab
Configuration error
@item @code{3}
@tab R/O @tab
@code{BUSY}
@tab @code{X} @tab
Loader busy
@item @code{4}
@tab R/W @tab
@code{MSBF}
@tab @code{X} @tab
Byte order select
@item @code{5}
@tab W/O @tab
@code{SWRST}
@tab @code{X} @tab
Software resest
@item @code{6}
@tab W/O @tab
@code{EXIT}
@tab @code{X} @tab
Exit bootloader mode
@item @code{13...8}
@tab R/W @tab
@code{CLKDIV}
@tab @code{X} @tab
Serial clock divider
@end multitable
@multitable @columnfractions 0.15 0.85
@headitem Field @tab Description
@item @code{START} @tab write 1: starts the configuration process.@* write 0: no effect
@item @code{DONE} @tab read 1: the bitstream has been loaded@* read 0: configuration still in progress
@item @code{ERROR} @tab read 1: an error occured during the configuration (DONE/INIT_B timeout)@* read 0: configuration was successful
@item @code{BUSY} @tab read 1: the loader is busy (can't start configuration yet)@* read 0: the loader is ready to re-configure the FPGA
@item @code{MSBF} @tab write 1: MSB first (big endian host)@* write 0: LSB first (little endian host)
@item @code{SWRST} @tab write 1: resets the loader core@* write 0: no effect
@item @code{EXIT} @tab write 1: terminate bootloader mode and go passive (VME only)
@item @code{CLKDIV} @tab CCLK division ratio. CCLK frequency = F_sysclk / 2 / (CLKDIV + 1)
@end multitable
@subsubsection @code{BTRIGR} - Bootloader Trigger Register
@multitable @columnfractions .10 .10 .15 .10 .55
@headitem Bits @tab Access @tab Prefix @tab Default @tab Name
@item @code{7...0}
@tab W/O @tab
@code{BTRIGR}
@tab @code{X} @tab
Trigger Sequence Input
@end multitable
@multitable @columnfractions 0.15 0.85
@headitem Field @tab Description
@item @code{BTRIGR} @tab Write a sequence of 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0xba, 0xbe to enter bootloader mode (VME only)
@end multitable
@subsubsection @code{FAR} - Flash Access Register
Provides direct access to the SPI flash memory containing the bitstream.
@multitable @columnfractions .10 .10 .15 .10 .55
@headitem Bits @tab Access @tab Prefix @tab Default @tab Name
@item @code{7...0}
@tab R/W @tab
@code{DATA}
@tab @code{X} @tab
SPI Data
@item @code{8}
@tab R/W @tab
@code{XFER}
@tab @code{X} @tab
SPI Start Transfer
@item @code{9}
@tab R/O @tab
@code{READY}
@tab @code{X} @tab
SPI Ready
@item @code{10}
@tab R/W @tab
@code{CS}
@tab @code{X} @tab
SPI Chip Select
@end multitable
@multitable @columnfractions 0.15 0.85
@headitem Field @tab Description
@item @code{DATA} @tab Data to be written / read to/from the flash SPI controller.
@item @code{XFER} @tab write 1: initiate an SPI transfer with an 8-bit data word taken from the @code{DATA}field@* write 0: no effect
@item @code{READY} @tab read 1: Core is ready to initiate another transfer. DATA field contains the data read during previous transaction.@*read 0: core is busy
@item @code{CS} @tab write 1: Enable target SPI controller@*write 0: Disable target SPI controller
@end multitable
@subsubsection @code{IDR} - ID Register
@multitable @columnfractions .10 .10 .15 .10 .55
@headitem Bits @tab Access @tab Prefix @tab Default @tab Name
@item @code{31...0}
@tab R/O @tab
@code{IDR}
@tab @code{X} @tab
Identification code
@end multitable
@multitable @columnfractions 0.15 0.85
@headitem Field @tab Description
@item @code{IDR} @tab User-defined identification code (g_idr_value generic)
@end multitable
@subsubsection @code{FIFO_R0} - FIFO 'Bitstream FIFO' data input register 0
@multitable @columnfractions .10 .10 .15 .10 .55
@headitem Bits @tab Access @tab Prefix @tab Default @tab Name
@item @code{1...0}
@tab W/O @tab
@code{XSIZE}
@tab @code{X} @tab
Entry size
@item @code{2}
@tab W/O @tab
@code{XLAST}
@tab @code{X} @tab
Last xfer
@end multitable
@multitable @columnfractions 0.15 0.85
@headitem Field @tab Description
@item @code{XSIZE} @tab Number of bytes to send (0 = 1 byte .. 3 = full 32-bit word)
@item @code{XLAST} @tab write 1: indicates the last word to be written to the FPGA
@end multitable
@subsubsection @code{FIFO_R1} - FIFO 'Bitstream FIFO' data input register 1
@multitable @columnfractions .10 .10 .15 .10 .55
@headitem Bits @tab Access @tab Prefix @tab Default @tab Name
@item @code{31...0}
@tab W/O @tab
@code{XDATA}
@tab @code{X} @tab
Data
@end multitable
@multitable @columnfractions 0.15 0.85
@headitem Field @tab Description
@item @code{XDATA} @tab Subsequent words of the bitstream
@end multitable
@subsubsection @code{FIFO_CSR} - FIFO 'Bitstream FIFO' control/status register
@multitable @columnfractions .10 .10 .15 .10 .55
@headitem Bits @tab Access @tab Prefix @tab Default @tab Name
@item @code{16}
@tab R/O @tab
@code{FULL}
@tab @code{X} @tab
FIFO full flag
@item @code{17}
@tab R/O @tab
@code{EMPTY}
@tab @code{X} @tab
FIFO empty flag
@item @code{18}
@tab W/O @tab
@code{CLEAR_BUS}
@tab @code{X} @tab
FIFO clear
@item @code{7...0}
@tab R/O @tab
@code{USEDW}
@tab @code{X} @tab
FIFO counter
@end multitable
@multitable @columnfractions 0.15 0.85
@headitem Field @tab Description
@item @code{full} @tab 1: FIFO 'Bitstream FIFO' is full@*0: FIFO is not full
@item @code{empty} @tab 1: FIFO 'Bitstream FIFO' is empty@*0: FIFO is not empty
@item @code{clear_bus} @tab write 1: clears FIFO 'Bitstream FIFO@*write 0: no effect
@item @code{usedw} @tab Number of data records currently being stored in FIFO 'Bitstream FIFO'
@end multitable
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment