lib_otp#

The lib_otp library provides functions for reading from and programming data to the OTP (One Time Programmable) memory available on each tile.

Two implementations of the library are provided. The original lib_otp implements the API for the XCORE-200 family of devices and earlier, while lib_otp3 implements it for the xcore.ai family.

To use the library, include either the otp.h or otp3.h header file and link your project using either -lotp or -lotp3.

Danger

Incorrect use of this library can result in irreversible damage to the device. It is documented for completeness, and its usage is unnecessary in the vast majority of applications. The most common operations can be performed using XBURN instead, which internally drives this library.

struct OTPPorts
#include <otp.h>

Defines

OTP_STATS#

OTP Statistics gathering is disabled by default.

#define OTP_STATS 1 in user defined otp_conf.h to enable

OTP_SIZE#

Maximum size of OTP memory.

OTP_PORTS_INITIALIZER#

Standard initializer for an otp_ports_t structure.

Use as follows: on tile[0]: OTPPorts otp_ports = OTP_PORTS_INITIALIZER;

Functions

int otp_program(REFERENCE_PARAM(OTPPorts, ports), unsigned address, const unsigned data[], unsigned size)#

If OTP_STATS is set then the OTP library will record statistics during OTP memory programming.

These statistics can then be used to determine the success/failure status from the programming event. Stats can the be retrieved using function otpstats_get_stats. This function programs a block of OTP memory of defined size at address using default single_ended mode. This function will attempt to repair any failures using the redundancy registers.

Parameters:
  • ports[in] : OTPPorts - the OTPPorts structure.

  • address[in] : unsigned - the location in OTP memory to write to.

  • data[in] : const unsigned[] - an array of data to be written.

  • size[in] : unsigned - the amount of data to be written.

Returns:

1 if successful; 0 if failed.

int otp_program_differential(REFERENCE_PARAM(OTPPorts, ports), unsigned address, const unsigned data[], unsigned size)#

This function programs a block of OTP memory of defined size at address using enhanced differential mode.

This function will attempt to repair any failures using the redundancy registers.

Parameters:
  • ports[in] : OTPPorts - the OTPPorts structure.

  • address[in] : unsigned - the location in OTP memory to write to.

  • data[in] : const unsigned[] - an array of data to be written.

  • size[in] : unsigned - the amount of data to be written.

Returns:

1 if successful; 0 if failed.

int otp_program_no_repair(REFERENCE_PARAM(OTPPorts, ports), unsigned address, const unsigned data[], unsigned size, char failmap[])#

This function programs a block of OTP memory of defined size at address using default single_ended mode.

No attempt to repair unprogrammed/faulty bits will take place using this function however a failure map is returned providing an indication of OTP memory that was not successfully programmed.

Parameters:
  • ports[in] : OTPPorts - the OTPPorts structure.

  • address[in] : unsigned - the location in OTP memory to write to.

  • data[in] : const unsigned[] - an array of data to be written.

  • size[in] : unsigned - the amount of data to be written.

  • failmap[out] : unsigned [] - location of bits that failed to program successfully.

Returns:

1 if successful; 0 if failed.

int otp_program_differential_no_repair(REFERENCE_PARAM(OTPPorts, ports), unsigned address, const unsigned data[], unsigned size, char failmap[])#

This function programs a block of OTP memory of defined size at address using enhanced differential mode.

No attempt to repair unprogrammed/faulty bits will take place using this function however a failure map is returned providing an indication of OTP memory that was not successfully programmed.

Parameters:
  • ports[in] : OTPPorts - the OTPPorts structure.

  • address[in] : unsigned - the location in OTP memory to write to.

  • data[in] : const unsigned[] - an array of data to be written.

  • size[in] : unsigned - the amount of data to be written.

  • failmap[out] : unsigned [] - location of bits that failed to program successfully.

Returns:

1 if successful; 0 if failed.

int otp_program_special_register(REFERENCE_PARAM(OTPPorts, ports), unsigned data)#

otp_program_special_register programs a word to the OTP special register.

Parameters:
  • ports[in] : OTPPorts - the OTPPorts structure.

  • data[in] : unsigned - the data to be written.

Returns:

1 if successful; 0 if failed.

int otp_program_secure_config_register(REFERENCE_PARAM(OTPPorts, ports), unsigned data)#

otp_program_secure_config_register programs a word to the OTP secure config register.

Parameters:
  • ports[in] : OTPPorts - the OTPPorts structure.

  • data[in] : unsigned - the data to be written.

Returns:

1 if successful; 0 if failed.

int otpprogram_writeword_norepair(REFERENCE_PARAM(OTPPorts, ports), unsigned address, unsigned data)#
void otp_read(REFERENCE_PARAM(OTPPorts, ports), unsigned address, unsigned data[], unsigned size)#

otp_read reads a block of OTP data of defined size from address using default single_ended mode.

Parameters:
  • ports[in] : OTPPorts - the OTPPorts structure.

  • address[in] : unsigned - the location in OTP memory to read from.

  • data[out] : unsigned[] - an array of words that the data being read can be stored in.

  • size[in] : unsigned - the amount of data to be read.

void otp_read_differential(REFERENCE_PARAM(OTPPorts, ports), unsigned address, unsigned data[], unsigned size)#

otp_read_differential reads a block of OTP data of defined size from address using enhanced differential mode.

Parameters:
  • ports[in] : OTPPorts - the OTPPorts structure.

  • address[in] : unsigned - the location in OTP memory to read from.

  • data[out] : unsigned[] - an array of words that the data being read can be stored in.

  • size[in] : unsigned - the amount of data to be read.

void otp_read_special_register(REFERENCE_PARAM(OTPPorts, ports), REFERENCE_PARAM(unsigned, data))#

otp_read_special_register reads a word from the OTP special register.

Parameters:
  • ports[in] : OTPPorts - the OTPPorts structure.

  • data[out] : unsigned - the word read from the special register.

void otp_read_secure_config_register(REFERENCE_PARAM(OTPPorts, ports), REFERENCE_PARAM(unsigned, data))#

otp_read_secure_config_register reads a word from the OTP secure config register.

Parameters:
  • ports[in] : OTPPorts - the OTPPorts structure.

  • data[out] : unsigned - the word read from the special register.

Typedefs

typedef struct OTPPorts OTPPorts#

Structure contains ports used to access OTP memory.

Note

xcore.ai does not have a “special register”, and so lib_otp3 will trap if either otp_read_special_register or otp_program_special_register are called.