xilskey
Vitis Drivers API Documentation
xilskey_jscmd.c File Reference

Overview

Contains jtag, efuse and bbram related API's.

Note
MODIFICATION HISTORY:

Ver Who Date Changes


1.00a rpoolla 04/26/13 First release 1.01a hk 09/18/13 Added BBRAM functionality. Following API's added: int JtagServerInitBbram(XilSKey_Bbram *InstancePtr) int Bbram_Init(XilSKey_Bbram *InstancePtr) int Bbram_ProgramKey(XilSKey_Bbram *InstancePtr) int Bbram_VerifyKey(XilSKey_Bbram *InstancePtr) void Bbram_DeInit(void) 2.1 kvn 04/01/15 Fixed warnings. CR#716453.

3.00  vns     31/07/15 Added efuse functionality for Ultrascale.
4.00  vns     09/10/15 Modified JtagWrite API as per IEEE 1149.1 standard
                       added TCK toggle after RTI state change where programming
                       will start and toggled TCK again at exit of RTI state to
                       stop programming. CR#885421.
5.0   vns     01/07/16 Modified JtagWrite_Ultrascale API as per IEEE 1149.1
                       standard added TCK toggle after RTI state change where
                       programming will start and ends programming at
                       TCK toggle after DR_SELECT state. CR #924262
                       Modified JtagServerInitBbram to support Ultrascale
                       BBRAM programming, added Bbram_Init_Ultra,
                       Bbram_ProgramKey_Ultra, Bbram_VerifyKey_Ultra
                       and Bbram_DeInit_Ultra APIs
6.0   vns     07/07/16 Initialized hardware module connections
                       Modified JtagWrite_Ultrascale API, to handover
                       programming sequence to hardware module to take care
                       of eFUSE programming.
                       Once Hardware module is triggered, JTAG state will be
                       entering to IDLE state and will wait for 5us and
                       toggles TCK pin at 1Mhz frequency. Finally it exists
                       when jtag state is navigated to DR SELECT by making
                       END pin to High state.
                       Modified return type of JtagWrite_Ultrascale API to int
                       for returning FAILURE on timeout.
      vns     07/28/16 Modified Bbram_ProgramKey_Ultra API to program control
                       word based on user inputs.
6.4   vns     02/27/18 Added support for virtex and virtex ultrascale plus
6.7   psl     03/18/19 Modified code to mask most significant nibble which
                       represents production version for ultrascale plus.
              03/20/19 Added eFuse/BBRAM key write support for SSIT devices.
      psl     03/29/19 Added Support for user configurable GPIO for jtag
                       control.
      arc     04/04/19 Fixed CPP warnings.
      psl     04/15/19 Corrected zynq Dap ID.
6.8   psl     06/26/19 Added support for user to add IDCODE, IR_length, SLR Nos,
                       device series for different devices.
      psl     08/23/19 Added Debug define to avoid writing of eFuse.
6.9   vns     03/18/20 Fixed Armcc compilation errors
7.0     am      10/04/20 Resolved MISRA C violations
7.1   am      11/29/20 Resolved MISRA C violations
7.1   kpt     04/08/21 Ignored product version of user defined IDCODE when comparing
                       with the tap code read from Jtag
7.2   am      07/13/21 Fixed doxygen warnings
7.5   ng      07/13/23 added SDT support
 

Macros

#define js_printf   dummy_printf
 Dummy PRINTF. More...
 
#define DEFAULT_FREQUENCY   10000000
 Default frequency. More...
 
#define MAX_FREQUENCY   30000000
 Maximum frequency. More...
 
#define ZYNQ_DAP_ID   0x0ba00477
 DAP Id. More...
 
#define KINTEX_ULTRA_MB_DAP_ID   0x03822093
 Kintex Ultrascale microblaze TAP ID. More...
 
#define KINTEX_ULTRAPLUS_DAP_ID   0x04A62093
 Kintex Ultrascale plus microblaze TAP ID. More...
 
#define VIRTEX110_ULTRA_MB_DAP_ID   0x03931093
 VIRTEX 110 Ultrascale microblaze TAP id. More...
 
#define VIRTEX108_ULTRA_MB_DAP_ID   0x03842093
 VIRTEX 108 Ultrascale microblaze TAP id. More...
 
#define VIRTEX_ULTRAPLUS_DAP_ID   0x04b31093
 VIRTEX Ultrascale plus microblaze TAP id. More...
 
#define VIRTEX_ULTRAPLUS_VC13P_DAP_ID   0x04B51093
 XCVU13P VIRTEX Ultrascale Plus microblaze TAP id. More...
 
#define ZYNQ_ULTRAPLUS_PL_DAP_ID   0x0484A093
 Zynq Ultrascale plus TAP ID. More...
 
#define set_last_error(JS,...)   js_set_last_error(&(JS)->js.base, __VA_ARGS__)
 Set last error. More...
 

Functions

void dummy_printf (const char *ctrl1,...)
 function prototype of dummy_printf More...
 
void GpioConfig (unsigned long addr, unsigned long mask, unsigned long val)
 This function performs Gpio Configuration. More...
 
void JtagInitGpio (XilSKey_ModuleSelection Module)
 This function performs Gpio Jtag initialization. More...
 
int getByteCountFromBitCount (int bitCount)
 This function calculates ByteCount From BitCount. More...
 
u32 calcInstr (u8 Instr, u8 cmd)
 This function calculates instructions. More...
 
unsigned int getNavigateTAPValue (unsigned char startState, unsigned char endState)
 This function calculates Navigate TAPValue. More...
 
void navigateTAP (unsigned char startState, unsigned char endState)
 This function performs NavigateTAP. More...
 
void jtagShiftTDI (unsigned char tdiData, unsigned char *tdoData, int clkCount, int exitState)
 This function performs Jtag shift TDI operation. More...
 
int jtagShiftTDIBits (unsigned char *tdiBuf, unsigned char *tdoBuf, int bitCount, js_state_t endState, unsigned int flags)
 This function will be used to shift long bits. More...
 
int jtag_setPreAndPostPads (js_port_t *port_arg, int irPrePadBits, int irPostPadBits, int drPrePadBits, int drPostPadBits)
 This function sets Jtag Pre and Post Pads. More...
 
int jtag_navigate (js_port_t *port, js_state_t state)
 This function performs Jtag navigate operation. More...
 
int jtag_shift (js_port_t *port_arg, unsigned char mode, int bits, unsigned char *wrBuffer, unsigned char *rdBuffer, js_state_t state)
 This function takes care of padding Must be set up with pre/post ir/dr info. More...
 
int open_port (js_lib_server_t *server, js_port_descr_t *port_descr, js_lib_port_t **result)
 This function performs open port operation. More...
 
js_server_tjs_init_zynq ()
 < Prototype declarations for Xilskey jscmd APIs More...
 
void JtagWrite (unsigned char row, unsigned char bit)
 JTAG Server Write routine. More...
 
void JtagRead (unsigned char row, unsigned int *row_data, unsigned char marginOption)
 JTAG Server Read routine. More...
 
int JtagValidateMioPins (XilSKey_ModuleSelection Module)
 This function validates MIO pins. More...
 
int JtagServerInit (XilSKey_EPl *InstancePtr)
 JTAG Server Initialization routine. More...
 
int JtagServerInitBbram (XilSKey_Bbram *InstancePtr)
 This function initializes JTAG server for use in BBRAM algorithm. More...
 
int Bbram_Init (void)
 This function implements the BBRAM algorithm initialization. More...
 
int Bbram_ProgramKey (XilSKey_Bbram *InstancePtr)
 This function implements the BBRAM program key. More...
 
int Bbram_VerifyKey (XilSKey_Bbram *InstancePtr)
 This function implements the BBRAM verify key. More...
 
void Bbram_DeInit (void)
 This function does de-initialization. More...
 
void Jtag_Read_Sysmon (u8 Row, u32 *Row_Data)
 This function reads temperature and voltage of Ultrascale. More...
 
int JtagWrite_Ultrascale (u8 Row, u8 Bit, u8 Page, u8 Redundant)
 This function blows the fuse of Ultrascale with provided parameters. More...
 
void JtagRead_Ultrascale (u8 Row, u32 *RowData, u8 MarginOption, u8 Page, u8 Redundant)
 This function reads entire row of Ultrascale's EFUSE. More...
 
void JtagRead_Status_Ultrascale (u32 *Rowdata)
 This function reads the status row of Ultrascale's EFUSE and updates the pointer. More...
 
u32 JtagAES_Check_Ultrascale (u32 *Crc, u8 MarginOption)
 This function verifies the AES key of Ultrascale's EFUSE with provided CRC value. More...
 
void Bbram_Close_Ultra (void)
 This function close UltraScale. More...
 
Xilskey jscmd API declarations

 

int setPin (int pin, int value)
 < Prototype declarations for Xilskey jscmd APIs More...
 
int readPin (int pin)
 

Variables

XilSKey_JtagSlr XilSKeyJtag
 JTAG Tap Instance. More...
 
XSKEfusePl_Fpga PlFpgaFlag
 For Storing Fpga series. More...
 
const unsigned int JTAGNavigateTable [256]
 File generated by JTAG.EXE. More...
 

Macro Definition Documentation

#define DEFAULT_FREQUENCY   10000000

Default frequency.

#define js_printf   dummy_printf
#define KINTEX_ULTRA_MB_DAP_ID   0x03822093

Kintex Ultrascale microblaze TAP ID.

#define KINTEX_ULTRAPLUS_DAP_ID   0x04A62093

Kintex Ultrascale plus microblaze TAP ID.

#define MAX_FREQUENCY   30000000

Maximum frequency.

#define set_last_error (   JS,
  ... 
)    js_set_last_error(&(JS)->js.base, __VA_ARGS__)

Set last error.

Referenced by open_port().

#define VIRTEX108_ULTRA_MB_DAP_ID   0x03842093

VIRTEX 108 Ultrascale microblaze TAP id.

#define VIRTEX110_ULTRA_MB_DAP_ID   0x03931093

VIRTEX 110 Ultrascale microblaze TAP id.

#define VIRTEX_ULTRAPLUS_DAP_ID   0x04b31093

VIRTEX Ultrascale plus microblaze TAP id.

#define VIRTEX_ULTRAPLUS_VC13P_DAP_ID   0x04B51093

XCVU13P VIRTEX Ultrascale Plus microblaze TAP id.

#define ZYNQ_DAP_ID   0x0ba00477

DAP Id.

#define ZYNQ_ULTRAPLUS_PL_DAP_ID   0x0484A093

Zynq Ultrascale plus TAP ID.

Function Documentation

void Bbram_Close_Ultra ( void  )

This function close UltraScale.

Returns
none
Note
none

References calcInstr(), jtag_navigate(), jtag_shift(), setPin(), and XilSKeyJtag.

Referenced by main().

void Bbram_DeInit ( void  )

This function does de-initialization.

De-initialization.

Returns
none
Note

References calcInstr(), jtag_navigate(), jtag_setPreAndPostPads(), jtag_shift(), and XilSKeyJtag.

int Bbram_Init ( void  )

This function implements the BBRAM algorithm initialization.

BBRAM Algorithm - Initialization.

Returns
  - XST_FAILURE - In case of failure
  - XST_SUCCESS - In case of Success
Note

References calcInstr(), jtag_navigate(), jtag_setPreAndPostPads(), jtag_shift(), XilSKey_Efuse_IsTimerExpired(), XilSKey_Efuse_SetTimeOut(), and XilSKeyJtag.

int Bbram_ProgramKey ( XilSKey_Bbram *  InstancePtr)

This function implements the BBRAM program key.

BBRAM Algorithm - Program key.

Parameters
InstancePtr- instance pointer
Returns
  - XST_FAILURE - In case of failure
  - XST_SUCCESS - In case of Success
Note

References calcInstr(), jtag_navigate(), jtag_setPreAndPostPads(), jtag_shift(), setPin(), and XilSKeyJtag.

int Bbram_VerifyKey ( XilSKey_Bbram *  InstancePtr)

This function implements the BBRAM verify key.

BBRAM Algorithm - Verify key.

Program and verify key have to be done together; These API's cannot be used independently.

Parameters
InstancePtr- instance pointer
Returns
  - XST_FAILURE - In case of failure
  - XST_SUCCESS - In case of Success
Note

References calcInstr(), jtag_navigate(), jtag_setPreAndPostPads(), jtag_shift(), setPin(), and XilSKeyJtag.

u32 calcInstr ( u8  Instr,
u8  cmd 
)
void dummy_printf ( const char *  ctrl1,
  ... 
)

function prototype of dummy_printf

int getByteCountFromBitCount ( int  bitCount)

This function calculates ByteCount From BitCount.

Returns
ByteCount

Referenced by jtag_shift(), and jtagShiftTDIBits().

unsigned int getNavigateTAPValue ( unsigned char  startState,
unsigned char  endState 
)

This function calculates Navigate TAPValue.

Returns
int tableValue

References JTAGNavigateTable.

Referenced by navigateTAP().

void GpioConfig ( unsigned long  addr,
unsigned long  mask,
unsigned long  val 
)

This function performs Gpio Configuration.

Referenced by JtagInitGpio().

js_server_t* js_init_zynq ( void  )

< Prototype declarations for Xilskey jscmd APIs

References open_port().

Referenced by JtagServerInit(), and JtagServerInitBbram().

int jtag_navigate ( js_port_t port,
js_state_t  state 
)
void Jtag_Read_Sysmon ( u8  Row,
u32 *  Row_Data 
)

This function reads temperature and voltage of Ultrascale.

Parameters
Rowspecifies the row number to read.
Row_Datais a pointer to a variable, to store the read value of given row.
Returns
None.
Note
None.

References calcInstr(), jtag_navigate(), jtag_shift(), setPin(), and XilSKeyJtag.

Referenced by XilSKey_EfusePs_XAdcReadTemperatureAndVoltage().

int jtag_setPreAndPostPads ( js_port_t port_arg,
int  irPrePadBits,
int  irPostPadBits,
int  drPrePadBits,
int  drPostPadBits 
)

This function sets Jtag Pre and Post Pads.

Returns
status value

Referenced by Bbram_DeInit(), Bbram_Init(), Bbram_ProgramKey(), Bbram_VerifyKey(), JtagRead(), and JtagWrite().

int jtag_shift ( js_port_t port_arg,
unsigned char  mode,
int  bits,
unsigned char *  wrBuffer,
unsigned char *  rdBuffer,
js_state_t  state 
)
u32 JtagAES_Check_Ultrascale ( u32 *  Crc,
u8  MarginOption 
)

This function verifies the AES key of Ultrascale's EFUSE with provided CRC value.

Parameters
Crcis a pointer to a 32 bit variable which holds the expected AES key's CRC.
MarginOptionis a variable which tells the margin option in which read operation to be performed.
Returns
Returns XST_FAILURE/XST_SUCCESS
  • XST_SUCCESS - If CRC is correct
  • XST_FAILURE - If CRC is wrong
Note
To verify AES key with provided CRC 256 bits need to be written with all ZEROS and last 32 bits with CRC. And then CTS word should be framed and read 9 rows. The keys are stored in 8 rows (20 to 27) but in UltraScale the device will read all 1s. On the 9th read (row 28), the CRC computation takes place. An extra read after the 9th read is required to read the computed CRC out (can use last row addr of 28 or row 0). The FPGA internally compares the computed CRC with the expected CRC loaded through the FUSE_KEY operation. If they match, then the expected CRC is read. If not, the FPGA will return all 1s.

References calcInstr(), jtag_navigate(), jtag_shift(), PlFpgaFlag, and XilSKeyJtag.

void JtagInitGpio ( XilSKey_ModuleSelection  Module)

This function performs Gpio Jtag initialization.

References GpioConfig(), and js_printf.

Referenced by JtagServerInit(), and JtagServerInitBbram().

void JtagRead ( unsigned char  row,
unsigned int *  row_data,
unsigned char  marginOption 
)

JTAG Server Read routine.

References calcInstr(), jtag_navigate(), jtag_setPreAndPostPads(), jtag_shift(), and XilSKeyJtag.

void JtagRead_Status_Ultrascale ( u32 *  Rowdata)

This function reads the status row of Ultrascale's EFUSE and updates the pointer.

Parameters
Rowdatais a pointer to a 32 bit variable which stores the status register value read from EFUSE status register.
Returns
None.
Note
Method to read FUSE register in Direct Macro Access way. For reading the status values we need send the bitstream in shift DR state. Shift in MAGIC_CTS_WRITE "FEED28AC" for ultrascale Read 64 bit data in IR read state.

References calcInstr(), jtag_navigate(), jtag_shift(), XilSKey_Efuse_ReverseHex(), and XilSKeyJtag.

void JtagRead_Ultrascale ( u8  Row,
u32 *  RowData,
u8  MarginOption,
u8  Page,
u8  Redundant 
)

This function reads entire row of Ultrascale's EFUSE.

Parameters
Rowspecifies the row number of EFUSE.
MarginOptionis a variable which tells the margin option in which read operation to be performed.
Pagetell the page of EFUSE in which the given row is located.
Redundantis a flag to specify the bit to be programmed is Normal bit or Redundant bit.
  • Redundant - XSK_EFUSEPL_REDUNDANT_ULTRA
  • Normal - XSK_EFUSEPL_NORMAL_ULTRA This variable is not valid for Ultrascale plus as each row contains both redundant and normal bits upper 16 are redundant.
Returns
None.
Note
Method to read FUSE register in Direct Macro Access way. Go to TLR to clear FUSE_CTS Load FUSE_CTS instruction on IR Step to CDR/SDR to shift in 32-bits FUSE_CTS command word Shift in MAGIC_CTS_WRITE "FEED28AC" for ultrascale Read 64 bit data in IR read state.

References calcInstr(), jtag_navigate(), jtag_shift(), PlFpgaFlag, and XilSKeyJtag.

int JtagServerInitBbram ( XilSKey_Bbram *  InstancePtr)

This function initializes JTAG server for use in BBRAM algorithm.

JTAG Server Initialization routine for Bbram.

Parameters
InstancePtr- instance pointer
Returns
  - XST_FAILURE - In case of failure
  - XST_SUCCESS - In case of Success
Note

References js_init_zynq(), js_printf, JtagInitGpio(), JtagValidateMioPins(), and XilSKeyJtag.

void jtagShiftTDI ( unsigned char  tdiData,
unsigned char *  tdoData,
int  clkCount,
int  exitState 
)

This function performs Jtag shift TDI operation.

References setPin().

Referenced by jtagShiftTDIBits().

int jtagShiftTDIBits ( unsigned char *  tdiBuf,
unsigned char *  tdoBuf,
int  bitCount,
js_state_t  endState,
unsigned int  flags 
)

This function will be used to shift long bits.

Returns
1 if shift state is to be exited.
Note
If tdoBuf != NULL, data will be read from device.

References getByteCountFromBitCount(), js_printf, and jtagShiftTDI().

int JtagValidateMioPins ( XilSKey_ModuleSelection  Module)

This function validates MIO pins.

Returns
0 value
Note
none

Referenced by JtagServerInit(), and JtagServerInitBbram().

void JtagWrite ( unsigned char  row,
unsigned char  bit 
)
int JtagWrite_Ultrascale ( u8  Row,
u8  Bit,
u8  Page,
u8  Redundant 
)

This function blows the fuse of Ultrascale with provided parameters.

Parameters
Rowspecifies the row number of EFUSE to blow.
BitSpecifies the bit location in the given row.
Pagetell the page of EFUSE in which the given row is located.
Redundantis a flag to specify the bit to be programmed is Normal bit or Redundant bit.
  • Redundant - XSK_EFUSEPL_REDUNDANT_ULTRA
  • Normal - XSK_EFUSEPL_NORMAL_ULTRA
Returns
None.
Note
None.

References calcInstr(), jtag_navigate(), jtag_shift(), PlFpgaFlag, setPin(), TimerTicksfor1000ns, XilSKey_Efuse_IsTimerExpired(), XilSKey_Efuse_StartTimer(), and XilSKeyJtag.

void navigateTAP ( unsigned char  startState,
unsigned char  endState 
)

This function performs NavigateTAP.

References getNavigateTAPValue(), js_printf, and setPin().

int open_port ( js_lib_server_t server,
js_port_descr_t port_descr,
js_lib_port_t **  result 
)
int setPin ( int  pin,
int  value 
)

Variable Documentation

const unsigned int JTAGNavigateTable[256]

File generated by JTAG.EXE.

This are the tms values and the corresponding bit counts to navigate quickly from any state to any state.

Referenced by getNavigateTAPValue().

XSKEfusePl_Fpga PlFpgaFlag

For Storing Fpga series.

Referenced by JtagAES_Check_Ultrascale(), JtagRead_Ultrascale(), and JtagWrite_Ultrascale().