This commit is contained in:
qiusongxiao
2023-12-06 19:35:36 +08:00
commit afe953ac4e
36 changed files with 2324 additions and 0 deletions

1
.build/_iflag.rsp Normal file
View File

@@ -0,0 +1 @@
-I"../."

1
.build/_obj.rsp Normal file
View File

@@ -0,0 +1 @@
..\.build\xburn.xc.o

1
.build/_pca.rsp Normal file
View File

@@ -0,0 +1 @@
.build/xburn.xc.pca.xml

0
.build/pca.d Normal file
View File

26
.build/pca.xml Normal file
View File

@@ -0,0 +1,26 @@
<preCompilationAnalysis>
<fInfo name="delay_microseconds" global="true" specialize="false" noreturn="false" doNotSpecialize="true" numParams="1">
<arg num="0" specialize="false">
<values>
</values>
</arg>
</fInfo>
<fInfo name="delay_milliseconds" global="true" specialize="false" noreturn="false" doNotSpecialize="true" numParams="1">
<arg num="0" specialize="false">
<values>
</values>
</arg>
</fInfo>
<fInfo name="delay_seconds" global="true" specialize="false" noreturn="false" doNotSpecialize="true" numParams="1">
<arg num="0" specialize="false">
<values>
</values>
</arg>
</fInfo>
<fInfo name="main" global="true" specialize="false" noreturn="false" doNotSpecialize="false" numParams="0">
</fInfo>
<fInfo name="program_0_0" global="true" specialize="false" noreturn="false" doNotSpecialize="false" numParams="0">
</fInfo>
<fInfo name="program_0_1" global="true" specialize="false" noreturn="false" doNotSpecialize="false" numParams="0">
</fInfo>
</preCompilationAnalysis>

4
.build/xburn.d Normal file
View File

@@ -0,0 +1,4 @@
xburn.o: \
../xburn.xc \
C:/Users/qiu/Desktop/<EFBFBD>½<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>/otp.h

5
.build/xburn.xc.d Normal file
View File

@@ -0,0 +1,5 @@
.build/xburn.xc.d .build/xburn.xc.o .build/xburn.xc.pca.xml: \
././xburn.xc \
C:/Users/qiu/Desktop/<EFBFBD>½<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>/otp.h

BIN
.build/xburn.xc.o Normal file

Binary file not shown.

98
.build/xburn.xc.pca.xml Normal file
View File

@@ -0,0 +1,98 @@
<preCompilationAnalysis file="../xburn.xc">
<fDef name="delay_microseconds" global="true" noreturn="false" doNotSpecialize="true" numParams="1"/>
<fDef name="delay_milliseconds" global="true" noreturn="false" doNotSpecialize="true" numParams="1"/>
<fDef name="delay_seconds" global="true" noreturn="false" doNotSpecialize="true" numParams="1"/>
<fDef name="main" global="true" noreturn="false" doNotSpecialize="false" numParams="0"/>
<fDef name="program_0_0" global="true" noreturn="false" doNotSpecialize="false" numParams="0"/>
<fDef name="program_0_1" global="true" noreturn="false" doNotSpecialize="false" numParams="0"/>
<fCall name="delay_ticks_longlong" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="delay_ticks_longlong" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="delay_ticks_longlong" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="otp_program" global="true" numArgs="4">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
<arg num="1">
<values>
<value type="intval"><intval isSigned="true" val="2044"/></value>
</values>
</arg>
<arg num="2">
<values>
<value type="unknown"/>
</values>
</arg>
<arg num="3">
<values>
<value type="intval"><intval isSigned="true" val="4"/></value>
</values>
</arg>
</fCall>
<fCall name="otp_program" global="true" numArgs="4">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
<arg num="1">
<values>
<value type="intval"><intval isSigned="true" val="2044"/></value>
</values>
</arg>
<arg num="2">
<values>
<value type="unknown"/>
</values>
</arg>
<arg num="3">
<values>
<value type="intval"><intval isSigned="true" val="4"/></value>
</values>
</arg>
</fCall>
<fCall name="program_0_0" global="true" numArgs="0">
</fCall>
<fCall name="program_0_1" global="true" numArgs="0">
</fCall>
<fCall name="printstr" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="printstr" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="exit" global="true" numArgs="1">
<arg num="0">
<values>
<value type="intval"><intval isSigned="true" val="1"/></value>
</values>
</arg>
</fCall>
</preCompilationAnalysis>

32
Makefile Normal file
View File

@@ -0,0 +1,32 @@
# The TARGET variable determines what target system the application is
# compiled for. It either refers to an XN file in the source directories
# or a valid argument for the --target option when compiling
TARGET = SLICEKIT-L16
# The APP_NAME variable determines the name of the final .xe file. It should
# not include the .xe postfix. If left blank the name will default to
# the project name
APP_NAME =otp_write
# The USED_MODULES variable lists other module used by the application.
USED_lib = libotp
# The flags passed to xcc when building the application
# You can also set the following to override flags for a particular language:
# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
# xcc for the final link (mapping) stage.
XCC_FLAGS = -g -O2
# The VERBOSE variable, if set to 1, enables verbose output from the make
# system.
VERBOSE = 0
XCC_FLAGS = $(XCC_FLAGS_Release)
#=============================================================================
# The following part of the Makefile includes the common build infrastructure
# for compiling XMOS applications. You should not need to edit below here.
XMOS_MAKE_PATH ?= ../..
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common

View File

@@ -0,0 +1 @@
-I"../." -I".././lib" -I".././src" -I".././src/core" -I".././src/extensions"

View File

@@ -0,0 +1 @@
..\.build\src\xburn.xc.o

View File

@@ -0,0 +1 @@
.build/src/xburn.xc.pca.xml

View File

View File

@@ -0,0 +1,26 @@
<preCompilationAnalysis>
<fInfo name="delay_microseconds" global="true" specialize="false" noreturn="false" doNotSpecialize="true" numParams="1">
<arg num="0" specialize="false">
<values>
</values>
</arg>
</fInfo>
<fInfo name="delay_milliseconds" global="true" specialize="false" noreturn="false" doNotSpecialize="true" numParams="1">
<arg num="0" specialize="false">
<values>
</values>
</arg>
</fInfo>
<fInfo name="delay_seconds" global="true" specialize="false" noreturn="false" doNotSpecialize="true" numParams="1">
<arg num="0" specialize="false">
<values>
</values>
</arg>
</fInfo>
<fInfo name="main" global="true" specialize="false" noreturn="false" doNotSpecialize="false" numParams="0">
</fInfo>
<fInfo name="program_0_0" global="true" specialize="false" noreturn="false" doNotSpecialize="false" numParams="0">
</fInfo>
<fInfo name="program_0_1" global="true" specialize="false" noreturn="false" doNotSpecialize="false" numParams="0">
</fInfo>
</preCompilationAnalysis>

View File

@@ -0,0 +1,5 @@
.build/src/xburn.xc.d .build/src/xburn.xc.o .build/src/xburn.xc.pca.xml: \
././src/xburn.xc \
C:/Users/qiu/Desktop/<EFBFBD>½<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>/OTP_Cache_backUp/src/extensions/otp.h

Binary file not shown.

View File

@@ -0,0 +1,98 @@
<preCompilationAnalysis file="../src/xburn.xc">
<fDef name="delay_microseconds" global="true" noreturn="false" doNotSpecialize="true" numParams="1"/>
<fDef name="delay_milliseconds" global="true" noreturn="false" doNotSpecialize="true" numParams="1"/>
<fDef name="delay_seconds" global="true" noreturn="false" doNotSpecialize="true" numParams="1"/>
<fDef name="main" global="true" noreturn="false" doNotSpecialize="false" numParams="0"/>
<fDef name="program_0_0" global="true" noreturn="false" doNotSpecialize="false" numParams="0"/>
<fDef name="program_0_1" global="true" noreturn="false" doNotSpecialize="false" numParams="0"/>
<fCall name="delay_ticks_longlong" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="delay_ticks_longlong" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="delay_ticks_longlong" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="otp_program" global="true" numArgs="4">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
<arg num="1">
<values>
<value type="intval"><intval isSigned="true" val="2044"/></value>
</values>
</arg>
<arg num="2">
<values>
<value type="unknown"/>
</values>
</arg>
<arg num="3">
<values>
<value type="intval"><intval isSigned="true" val="4"/></value>
</values>
</arg>
</fCall>
<fCall name="otp_program" global="true" numArgs="4">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
<arg num="1">
<values>
<value type="intval"><intval isSigned="true" val="2044"/></value>
</values>
</arg>
<arg num="2">
<values>
<value type="unknown"/>
</values>
</arg>
<arg num="3">
<values>
<value type="intval"><intval isSigned="true" val="4"/></value>
</values>
</arg>
</fCall>
<fCall name="program_0_0" global="true" numArgs="0">
</fCall>
<fCall name="program_0_1" global="true" numArgs="0">
</fCall>
<fCall name="printstr" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="printstr" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="exit" global="true" numArgs="1">
<arg num="0">
<values>
<value type="intval"><intval isSigned="true" val="1"/></value>
</values>
</arg>
</fCall>
</preCompilationAnalysis>

View File

@@ -0,0 +1,98 @@
<preCompilationAnalysis file="../src/xburn.xc">
<fDef name="delay_microseconds" global="true" noreturn="false" doNotSpecialize="true" numParams="1"/>
<fDef name="delay_milliseconds" global="true" noreturn="false" doNotSpecialize="true" numParams="1"/>
<fDef name="delay_seconds" global="true" noreturn="false" doNotSpecialize="true" numParams="1"/>
<fDef name="main" global="true" noreturn="false" doNotSpecialize="false" numParams="0"/>
<fDef name="program_0_0" global="true" noreturn="false" doNotSpecialize="false" numParams="0"/>
<fDef name="program_0_1" global="true" noreturn="false" doNotSpecialize="false" numParams="0"/>
<fCall name="delay_ticks_longlong" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="delay_ticks_longlong" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="delay_ticks_longlong" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="otp_program" global="true" numArgs="4">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
<arg num="1">
<values>
<value type="intval"><intval isSigned="true" val="2044"/></value>
</values>
</arg>
<arg num="2">
<values>
<value type="unknown"/>
</values>
</arg>
<arg num="3">
<values>
<value type="intval"><intval isSigned="true" val="4"/></value>
</values>
</arg>
</fCall>
<fCall name="otp_program" global="true" numArgs="4">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
<arg num="1">
<values>
<value type="intval"><intval isSigned="true" val="2044"/></value>
</values>
</arg>
<arg num="2">
<values>
<value type="unknown"/>
</values>
</arg>
<arg num="3">
<values>
<value type="intval"><intval isSigned="true" val="4"/></value>
</values>
</arg>
</fCall>
<fCall name="program_0_0" global="true" numArgs="0">
</fCall>
<fCall name="program_0_1" global="true" numArgs="0">
</fCall>
<fCall name="printstr" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="printstr" global="true" numArgs="1">
<arg num="0">
<values>
<value type="unknown"/>
</values>
</arg>
</fCall>
<fCall name="exit" global="true" numArgs="1">
<arg num="0">
<values>
<value type="intval"><intval isSigned="true" val="1"/></value>
</values>
</arg>
</fCall>
</preCompilationAnalysis>

View File

@@ -0,0 +1,4 @@
xburn.o: \
../src/xburn.xc \
C:/Users/qiu/Desktop/<EFBFBD>½<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>/OTP_Cache_backUp/src/extensions/otp.h

32
OTP_Cache_backUp/Makefile Normal file
View File

@@ -0,0 +1,32 @@
# The TARGET variable determines what target system the application is
# compiled for. It either refers to an XN file in the source directories
# or a valid argument for the --target option when compiling
TARGET = SLICEKIT-L16
# The APP_NAME variable determines the name of the final .xe file. It should
# not include the .xe postfix. If left blank the name will default to
# the project name
APP_NAME =otp_write
# The USED_MODULES variable lists other module used by the application.
# USED_lib = libotp
# The flags passed to xcc when building the application
# You can also set the following to override flags for a particular language:
# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
# xcc for the final link (mapping) stage.
XCC_FLAGS = -g -O2 -L../lib -lotp -I../lib
# The VERBOSE variable, if set to 1, enables verbose output from the make
# system.
VERBOSE = 0
XCC_FLAGS = $(XCC_FLAGS_Release)
#=============================================================================
# The following part of the Makefile includes the common build infrastructure
# for compiling XMOS applications. You should not need to edit below here.
XMOS_MAKE_PATH ?= ../..
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
<Type>Device</Type>
<Name>XU216-512-TQ128-C20 Device</Name>
<Declarations>
<Declaration>tileref tile[2]</Declaration>
<Declaration>tileref usb_tile</Declaration>
</Declarations>
<Packages>
<Package id="0" Type="XS2-UnA-512-TQ128">
<Nodes>
<Node Id="0" InPackageId="0" Type="XS2-L16A-512" SystemFrequency="500MHz" OscillatorSrc="1">
<Tile Number="0" Reference="tile[0]"/>
<Tile Number="1" Reference="tile[1]"/>
</Node>
<Node Id="1" InPackageId="1" Type="periph:XS1-SU" Reference="usb_tile">
</Node>
</Nodes>
<Links>
<Link Encoding="5wire">
<LinkEndpoint NodeId="0" Link="8" Delays="52clk,52clk"/>
<LinkEndpoint NodeId="1" Link="XL0" Delays="1clk,1clk"/>
</Link>
</Links>
</Package>
</Packages>
<JTAGChain>
<JTAGDevice NodeId="0"/>
</JTAGChain>
</Network>

View File

@@ -0,0 +1,277 @@
/**
* \file otp.h
*
* This API provides functions to program and read the OTP (One Time
* Programmable) memory of an xCORE. Functions are provided to program and read
* the OTP memory using both single-ended and differential modes. Functions are
* also provided that allow automatic repair of failed programming locations
* using the OTP redundancy registers. Access is also provided to program and
* read the OTP special registers.
*/
#ifndef _OTP_H_
#define _OTP_H_
#include <xccompat.h>
#ifdef __otp_conf_h_exists__
#include "otp_conf.h"
#endif
////////////////////////////////////////////////////////////////////////////////
/**
* OTP Statistics gathering is disabled by default. #define OTP_STATS 1 in
* user defined otp_conf.h to enable
*/
#ifndef OTP_STATS
#define OTP_STATS 0
#endif //OTP_STATS
/**
* Maximum size of OTP memory
*/
#define OTP_SIZE 0x800
/**
* Standard initializer for an otp_ports_t structure. Use as follows:
* on stdcore[0]: OTPPorts otp_ports = OTP_PORTS_INITIALIZER;
*/
#define OTP_PORTS_INITIALIZER \
{ \
XS1_PORT_32B, \
XS1_PORT_16C, \
XS1_PORT_16D \
}
////////////////////////////////////////////////////////////////////////////////
/**
* Structure contains ports used to access OTP memory.
*/
typedef struct OTPPorts
{
port data;
#if (__XC__)
out port addr;
out port ctrl;
#else
port addr;
port ctrl;
#endif
} OTPPorts;
/**
* 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_GetStats.
*/
#if (OTP_STATS)
typedef struct OTPStats
{
unsigned programmed_words; ///< Number of words that were successfully programmed
unsigned programmed_bits; ///< Number of bits that were successfully programmed using the short programming pulse
unsigned soaked_bits; ///< Number of bits that were successfully programmed using the long programming pulse
unsigned leaky_bits; ///< Number of bits that are already in the programmed state before programming commenced but should not be programmed
unsigned failed_to_program_words; ///< Number of words that failed to program
unsigned redundant_sectors_used; ///< Number of redundant sectors used (L1 family only)
} OTPStats;
#endif //OTP_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 on the L1 family of processors.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : unsigned - the amount of data to be written.
* \returns 1 if successful; 0 if failed.
*/
int otp_program(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 on the L1 family of processors.
* Differential mode programming is not available on the G4 family of
* processors and will simply return 0 (failed).
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : 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 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.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : unsigned - the amount of data to be written.
* \param[out] failmap : unsigned [] - location of bits that failed to program
* successfully.
* \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 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.
* Differential mode programming is not available on the G4 family of
* processors and will simply return 0 (failed).
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : unsigned - the amount of data to be written.
* \param[out] failmap : 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[]);
/**
* OTP_ProgramSpecialRegister programs a word to the OTP special register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] t : timer - a timer handle.
* \param[in] data : unsigned - the data to be written.
* \returns 1 if successful; 0 if failed.
*/
int otp_program_special_register(REFERENCE_PARAM(OTPPorts, ports), unsigned data);
/**
* otp_program_secure_config_register programs a word to the OTP secure config
* register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] t : timer - a timer handle.
* \param[in] data : 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);
//Program a single word without repairing any errors
int otpprogram_writeword_norepair(REFERENCE_PARAM(OTPPorts, ports),
unsigned address,
unsigned data);
/**
* OTP_Read reads a block of OTP data of defined size from address using
* default single_ended mode.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to read from.
* \param[out] data : unsigned[] - an array of words that the data being
* read can be stored in.
* \param[in] size : unsigned - the amount of data to be read.
*/
void otp_read(REFERENCE_PARAM(OTPPorts, ports),
unsigned address,
unsigned data[],
unsigned size);
/**
* OTP_ReadDifferential reads a block of OTP data of defined size from address
* using enhanced differential mode.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to read from.
* \param[out] data : unsigned[] - an array of words that the data being read
* can be stored in.
* \param[in] size : unsigned - the amount of data to be read.
*/
void otp_read_differential(REFERENCE_PARAM(OTPPorts, ports),
unsigned address,
unsigned data[],
unsigned size);
/**
* OTP_ReadSpecialRegister reads a word from the OTP special register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[out] data : unsigned - the word read from the special register.
*/
void otp_read_special_register(REFERENCE_PARAM(OTPPorts, ports), REFERENCE_PARAM(unsigned, data));
/**
* otp_read_secure_config_register reads a word from the OTP secure config
* register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[out] data : unsigned - the word read from the special register.
*/
void otp_read_secure_config_register(REFERENCE_PARAM(OTPPorts, ports), REFERENCE_PARAM(unsigned, data));
////////////////////////////////////////////////////////////////////////////////
#if (OTP_STATS)
/**
* This function retrieves the statistics from the last programming event.
* Requires the #define OTP_STATS to be set to 1 in user defined otp_conf.h
* to activate statistic gathering.
*
* \param[out] stats : OTPStats - structure that will contain the statitic
* information
*/
void otpstats_get_stats(REFERENCE_PARAM(OTPStats, stats));
/**
* This function allows two OTPStats structs to be merged together.
* Requires the #define OTP_STATS to be set to 1 in user defined otp_conf.h
* to activate statistic gathering.
*
* \param[in, out] a : OTPStats - structure contains the original stats and
* param b will be merged with them
* \param[in] b : OTPStats - structure contains the stats that are to be merged
* with param a
*/
void otpstats_merge_stats(REFERENCE_PARAM(OTPStats, a),
REFERENCE_PARAM(const OTPStats, b));
/**
* This function outputs the statistics from the given OTPStats struct.
* Requires the #define OTP_STATS to be set to 1 in user defined otp_conf.h
* to activate statistic gathering.
*
* \param[in] stats : OTPStats - structure containing the stats to be printed.
*
*/
void otpstats_print_stats(REFERENCE_PARAM(const OTPStats, stats));
#endif //OTP_STATS
////////////////////////////////////////////////////////////////////////////////
#endif //_OTP_H_
////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,270 @@
/**
* \file otp.h
*
* This API provides functions to program and read the OTP (One Time
* Programmable) memory of an xCORE. Functions are provided to program and read
* the OTP memory using both single-ended and differential modes. Functions are
* also provided that allow automatic repair of failed programming locations
* using the OTP redundancy registers. Access is also provided to program and
* read the OTP special registers.
*/
#ifndef _OTP3_H_
#define _OTP3_H_
#include <xccompat.h>
#ifdef __otp_conf_h_exists__
#include "otp_conf.h"
#endif
////////////////////////////////////////////////////////////////////////////////
/**
* OTP Statistics gathering is disabled by default. #define OTP_STATS 1 in
* user defined otp_conf.h to enable
*/
#ifndef OTP_STATS
#define OTP_STATS 0
#endif //OTP_STATS
/**
* Maximum size of OTP memory per tile in words. The 8kB OTP is split into two halves, each allocated to a tile.
*/
#define OTP_SIZE (0x800 / 2)
/**
* Standard initializer for an otp_ports_t structure. Use as follows:
* on stdcore[0]: OTPPorts otp_ports = OTP_PORTS_INITIALIZER;
*/
#define OTP_PORTS_INITIALIZER \
{ \
0, \
XS1_PORT_32B \
}
////////////////////////////////////////////////////////////////////////////////
/**
* Structure contains ports used to access OTP memory.
*/
typedef struct OTPPorts
{
unsigned otp_shadow_g;
port otp_data_g;
} OTPPorts;
/**
* 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_GetStats.
*/
#if (OTP_STATS)
typedef struct OTPStats
{
unsigned programmed_words; ///< Number of words that were successfully programmed
unsigned programmed_bits; ///< Number of bits that were successfully programmed using the short programming pulse
unsigned soaked_bits; ///< Number of bits that were successfully programmed using the long programming pulse
unsigned leaky_bits; ///< Number of bits that are already in the programmed state before programming commenced but should not be programmed
unsigned failed_to_program_words; ///< Number of words that failed to program
unsigned redundant_sectors_used; ///< Number of redundant sectors used (L1 family only)
} OTPStats;
#endif //OTP_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 on the L1 family of processors.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : unsigned - the amount of data to be written.
* \returns 1 if successful; 0 if failed.
*/
int otp_program(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 on the L1 family of processors.
* Differential mode programming is not available on the G4 family of
* processors and will simply return 0 (failed).
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : 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 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.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : unsigned - the amount of data to be written.
* \param[out] failmap : unsigned [] - location of bits that failed to program
* successfully.
* \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 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.
* Differential mode programming is not available on the G4 family of
* processors and will simply return 0 (failed).
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : unsigned - the amount of data to be written.
* \param[out] failmap : 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[]);
/**
* OTP_ProgramSpecialRegister programs a word to the OTP special register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] t : timer - a timer handle.
* \param[in] data : unsigned - the data to be written.
* \returns 1 if successful; 0 if failed.
*/
int otp_program_special_register(REFERENCE_PARAM(OTPPorts, ports), unsigned data);
/**
* otp_program_secure_config_register programs a word to the OTP secure config
* register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] t : timer - a timer handle.
* \param[in] data : 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);
//Program a single word without repairing any errors
int otpprogram_writeword_norepair(REFERENCE_PARAM(OTPPorts, ports),
unsigned address,
unsigned data);
/**
* OTP_Read reads a block of OTP data of defined size from address using
* default single_ended mode.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to read from.
* \param[out] data : unsigned[] - an array of words that the data being
* read can be stored in.
* \param[in] size : unsigned - the amount of data to be read.
*/
void otp_read(REFERENCE_PARAM(OTPPorts, ports),
unsigned address,
unsigned data[],
unsigned size);
/**
* OTP_ReadDifferential reads a block of OTP data of defined size from address
* using enhanced differential mode.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to read from.
* \param[out] data : unsigned[] - an array of words that the data being read
* can be stored in.
* \param[in] size : unsigned - the amount of data to be read.
*/
void otp_read_differential(REFERENCE_PARAM(OTPPorts, ports),
unsigned address,
unsigned data[],
unsigned size);
/**
* OTP_ReadSpecialRegister reads a word from the OTP special register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[out] data : unsigned - the word read from the special register.
*/
void otp_read_special_register(REFERENCE_PARAM(OTPPorts, ports), REFERENCE_PARAM(unsigned, data));
/**
* otp_read_secure_config_register reads a word from the OTP secure config
* register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[out] data : unsigned - the word read from the special register.
*/
void otp_read_secure_config_register(REFERENCE_PARAM(OTPPorts, ports), REFERENCE_PARAM(unsigned, data));
////////////////////////////////////////////////////////////////////////////////
#if (OTP_STATS)
/**
* This function retrieves the statistics from the last programming event.
* Requires the #define OTP_STATS to be set to 1 in user defined otp_conf.h
* to activate statistic gathering.
*
* \param[out] stats : OTPStats - structure that will contain the statitic
* information
*/
void otpstats_get_stats(REFERENCE_PARAM(OTPStats, stats));
/**
* This function allows two OTPStats structs to be merged together.
* Requires the #define OTP_STATS to be set to 1 in user defined otp_conf.h
* to activate statistic gathering.
*
* \param[in, out] a : OTPStats - structure contains the original stats and
* param b will be merged with them
* \param[in] b : OTPStats - structure contains the stats that are to be merged
* with param a
*/
void otpstats_merge_stats(REFERENCE_PARAM(OTPStats, a),
REFERENCE_PARAM(const OTPStats, b));
/**
* This function outputs the statistics from the given OTPStats struct.
* Requires the #define OTP_STATS to be set to 1 in user defined otp_conf.h
* to activate statistic gathering.
*
* \param[in] stats : OTPStats - structure containing the stats to be printed.
*
*/
void otpstats_print_stats(REFERENCE_PARAM(const OTPStats, stats));
#endif //OTP_STATS
////////////////////////////////////////////////////////////////////////////////
#endif //_OTP3_H_
////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,362 @@
#undef _XSCOPE_PROBES_INCLUDE_FILE
#define __XC__ 1
#define __llvm__ 1
#define __ATOMIC_RELAXED 0
#define __ATOMIC_CONSUME 1
#define __ATOMIC_ACQUIRE 2
#define __ATOMIC_RELEASE 3
#define __ATOMIC_ACQ_REL 4
#define __ATOMIC_SEQ_CST 5
#define __PRAGMA_REDEFINE_EXTNAME 1
#define __VERSION__ "4.2.1 Compatible XMOS-235-acbb966-Dec-01-2019 Clang 3.6.0 "
#define __CONSTANT_CFSTRINGS__ 1
#define __ORDER_LITTLE_ENDIAN__ 1234
#define __ORDER_BIG_ENDIAN__ 4321
#define __ORDER_PDP_ENDIAN__ 3412
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
#define __LITTLE_ENDIAN__ 1
#define _ILP32 1
#define __ILP32__ 1
#define __CHAR_BIT__ 8
#define __SCHAR_MAX__ 127
#define __SHRT_MAX__ 32767
#define __INT_MAX__ 2147483647
#define __LONG_MAX__ 2147483647L
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __WCHAR_MAX__ 255
#define __INTMAX_MAX__ 9223372036854775807LL
#define __SIZE_MAX__ 4294967295U
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_INT__ 4
#define __SIZEOF_LONG__ 4
#define __SIZEOF_LONG_DOUBLE__ 8
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_POINTER__ 4
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_PTRDIFF_T__ 4
#define __SIZEOF_SIZE_T__ 4
#define __SIZEOF_WCHAR_T__ 1
#define __SIZEOF_WINT_T__ 4
#define __INTMAX_TYPE__ long long int
#define __INTMAX_FMTd__ "lld"
#define __INTMAX_FMTi__ "lli"
#define __INTMAX_C_SUFFIX__ LL
#define __UINTMAX_TYPE__ long long unsigned int
#define __UINTMAX_FMTo__ "llo"
#define __UINTMAX_FMTu__ "llu"
#define __UINTMAX_FMTx__ "llx"
#define __UINTMAX_FMTX__ "llX"
#define __UINTMAX_C_SUFFIX__ ULL
#define __INTMAX_WIDTH__ 64
#define __PTRDIFF_TYPE__ int
#define __PTRDIFF_FMTd__ "d"
#define __PTRDIFF_FMTi__ "i"
#define __PTRDIFF_WIDTH__ 32
#define __INTPTR_TYPE__ int
#define __INTPTR_FMTd__ "d"
#define __INTPTR_FMTi__ "i"
#define __INTPTR_WIDTH__ 32
#define __SIZE_TYPE__ unsigned int
#define __SIZE_FMTo__ "o"
#define __SIZE_FMTu__ "u"
#define __SIZE_FMTx__ "x"
#define __SIZE_FMTX__ "X"
#define __SIZE_WIDTH__ 32
#define __WCHAR_TYPE__ unsigned char
#define __WCHAR_WIDTH__ 8
#define __WINT_TYPE__ unsigned int
#define __WINT_WIDTH__ 32
#define __SIG_ATOMIC_WIDTH__ 32
#define __SIG_ATOMIC_MAX__ 2147483647
#define __CHAR16_TYPE__ unsigned short
#define __CHAR32_TYPE__ unsigned int
#define __FLT_DENORM_MIN__ 1.40129846e-45F
#define __FLT_HAS_DENORM__ 1
#define __FLT_DIG__ 6
#define __FLT_EPSILON__ 1.19209290e-7F
#define __FLT_HAS_INFINITY__ 1
#define __FLT_HAS_QUIET_NAN__ 1
#define __FLT_MANT_DIG__ 24
#define __FLT_MAX_10_EXP__ 38
#define __FLT_MAX_EXP__ 128
#define __FLT_MAX__ 3.40282347e+38F
#define __FLT_MIN_10_EXP__ (-37)
#define __FLT_MIN_EXP__ (-125)
#define __FLT_MIN__ 1.17549435e-38F
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __DBL_HAS_DENORM__ 1
#define __DBL_DIG__ 15
#define __DBL_EPSILON__ 2.2204460492503131e-16
#define __DBL_HAS_INFINITY__ 1
#define __DBL_HAS_QUIET_NAN__ 1
#define __DBL_MANT_DIG__ 53
#define __DBL_MAX_10_EXP__ 308
#define __DBL_MAX_EXP__ 1024
#define __DBL_MAX__ 1.7976931348623157e+308
#define __DBL_MIN_10_EXP__ (-307)
#define __DBL_MIN_EXP__ (-1021)
#define __DBL_MIN__ 2.2250738585072014e-308
#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
#define __LDBL_HAS_DENORM__ 1
#define __LDBL_DIG__ 15
#define __LDBL_EPSILON__ 2.2204460492503131e-16L
#define __LDBL_HAS_INFINITY__ 1
#define __LDBL_HAS_QUIET_NAN__ 1
#define __LDBL_MANT_DIG__ 53
#define __LDBL_MAX_10_EXP__ 308
#define __LDBL_MAX_EXP__ 1024
#define __LDBL_MAX__ 1.7976931348623157e+308L
#define __LDBL_MIN_10_EXP__ (-307)
#define __LDBL_MIN_EXP__ (-1021)
#define __LDBL_MIN__ 2.2250738585072014e-308L
#define __POINTER_WIDTH__ 32
#define __CHAR_UNSIGNED__ 1
#define __WCHAR_UNSIGNED__ 1
#define __WINT_UNSIGNED__ 1
#define __INT8_TYPE__ signed char
#define __INT8_FMTd__ "hhd"
#define __INT8_FMTi__ "hhi"
#define __INT8_C_SUFFIX__
#define __INT16_TYPE__ short
#define __INT16_FMTd__ "hd"
#define __INT16_FMTi__ "hi"
#define __INT16_C_SUFFIX__
#define __INT32_TYPE__ int
#define __INT32_FMTd__ "d"
#define __INT32_FMTi__ "i"
#define __INT32_C_SUFFIX__
#define __INT64_TYPE__ long long int
#define __INT64_FMTd__ "lld"
#define __INT64_FMTi__ "lli"
#define __INT64_C_SUFFIX__ LL
#define __USER_LABEL_PREFIX__ _
#define __FINITE_MATH_ONLY__ 0
#define __FLT_EVAL_METHOD__ 0
#define __FLT_RADIX__ 2
#define __DECIMAL_DIG__ 17
#define __xcore__ 1
#define __XS1B__ 1
#define __STDC_HOSTED__ 1
#define __STDC_UTF_16__ 1
#define __STDC_UTF_32__ 1
#define OTP_STATS 1
#define __xcore__ 1
#define __XS1B__ 1
#define XCC_VERSION_YEAR 14
#define XCC_VERSION_MONTH 4
#define XCC_VERSION_MAJOR 1404
#define XCC_VERSION_MINOR 1
#define __XCC_HAVE_FLOAT__ 1
#define _XSCOPE_PROBES_INCLUDE_FILE "c:\\Users\\swnb\\Temp\\ccQPcbaa.h"
#define _xburn_h_
#define _OTP_H_
#define _xccompat_h_
#define REFERENCE_PARAM(type,name) type &name
#define NULLABLE_REFERENCE_PARAM(type,name) type &?name
#define NULLABLE_RESOURCE(type,name) type ?name
#define NULLABLE_ARRAY_OF(type,name) type (&?name)[]
#define ARRAY_OF_SIZE(type,name,size) type name[size]
#define NULLABLE_ARRAY_OF_SIZE(type,name,size) type (&?name)[size]
#define CLIENT_INTERFACE(tag,name) client interface tag name
#define SERVER_INTERFACE(tag,name) server interface tag name
typedef streaming chanend streaming_chanend_t;
typedef in buffered port:1 in_buffered_port_1_t;
typedef in buffered port:4 in_buffered_port_4_t;
typedef in buffered port:8 in_buffered_port_8_t;
typedef in buffered port:16 in_buffered_port_16_t;
typedef in buffered port:32 in_buffered_port_32_t;
typedef out buffered port:1 out_buffered_port_1_t;
typedef out buffered port:4 out_buffered_port_4_t;
typedef out buffered port:8 out_buffered_port_8_t;
typedef out buffered port:16 out_buffered_port_16_t;
typedef out buffered port:32 out_buffered_port_32_t;
#define OTP_SIZE 0x800
#define OTP_PORTS_INITIALIZER { XS1_PORT_32B, XS1_PORT_16C, XS1_PORT_16D }
typedef struct OTPPorts
{
port data;
out port addr;
out port ctrl;
} OTPPorts;
typedef struct OTPStats
{
unsigned programmed_words;
unsigned programmed_bits;
unsigned soaked_bits;
unsigned leaky_bits;
unsigned failed_to_program_words;
unsigned redundant_sectors_used;
} OTPStats;
int otp_program(OTPPorts &ports,
unsigned address,
const unsigned data[],
unsigned size);
int otp_program_differential(OTPPorts &ports,
unsigned address,
const unsigned data[],
unsigned size);
int otp_program_no_repair(OTPPorts &ports,
unsigned address,
const unsigned data[],
unsigned size,
char failmap[]);
int otp_program_differential_no_repair(OTPPorts &ports,
unsigned address,
const unsigned data[],
unsigned size,
char failmap[]);
int otp_program_special_register(OTPPorts &ports, unsigned data);
int otp_program_secure_config_register(OTPPorts &ports, unsigned data);
int otpprogram_writeword_norepair(OTPPorts &ports,
unsigned address,
unsigned data);
void otp_read(OTPPorts &ports,
unsigned address,
unsigned data[],
unsigned size);
void otp_read_differential(OTPPorts &ports,
unsigned address,
unsigned data[],
unsigned size);
void otp_read_special_register(OTPPorts &ports, unsigned &data);
void otp_read_secure_config_register(OTPPorts &ports, unsigned &data);
void otpstats_get_stats(OTPStats &stats);
void otpstats_merge_stats(OTPStats &a,
const OTPStats &b);
void otpstats_print_stats(const OTPStats &stats);
int ProgramSRMasked(OTPPorts &ports, unsigned sr, unsigned sr_mask);
int ProgramSecurityConfigMasked(OTPPorts &ports, unsigned sec, unsigned sec_mask);
void PrintArray(OTPPorts &ports, chanend prev, chanend next, int differential);
void CollectStats(chanend c, OTPStats &stats);
int ProgramSoftRedundancyForBoot(OTPPorts &ports,
int differential, unsigned address,
const unsigned (&?prefix)[], unsigned prefixSize,
const unsigned payload[], unsigned payloadSize,
unsigned maxSize, int writeDisableCrc);
int CheckStats(const OTPStats &stats, unsigned allowed);
#define _otp_soft_redundancy_h_
int otpsoftredundancy_program(OTPPorts &ports,
unsigned address,
const unsigned payload[],
unsigned payloadSize,
unsigned maxSize,
unsigned &size);
int otpsoftredundancy_program_differential(OTPPorts &ports,
unsigned address,
const unsigned payload[],
unsigned payloadSize,
unsigned maxSize,
unsigned &size);
int otpsoftredundancy_read(OTPPorts &ports,
unsigned address,
unsigned data[],
unsigned size);
int otpsoftredundancy_read_differential(OTPPorts &ports,
unsigned address,
unsigned data[],
unsigned size);
#include <platform.h>
#include <stdlib.h>
#include <print.h>
#include<otp.h>
enum BurnStatus {
STATUS_SUCCESS,
STATUS_FAIL_MARGINAL,
STATUS_FAIL_SOAKED,
STATUS_FAIL_WRITE
};
on tile[0]: OTPPorts ports_0_0 = OTP_PORTS_INITIALIZER;
on tile[1]: OTPPorts ports_0_1 = OTP_PORTS_INITIALIZER;
unsigned mem_0_0_0[] = {
0x00000000,
0x04060709,
0x00000102,
0x4847ffff
};
unsigned mem_0_1_0[] = {
0x00000000,
0x04060709,
0x00000102,
0x4847ffff
};
int program_0_0() {
if(!otp_program(ports_0_0, 2044, mem_0_0_0, 4)) {
return 0;
}
return 1;
}
int program_0_1() {
if(!otp_program(ports_0_1, 2044, mem_0_1_0, 4)) {
return 0;
}
return 1;
}
int main() {
chan c[2];
par {
on tile[0]: {
c[0] <: program_0_0();
}
on tile[1]: {
c[1] <: program_0_1();
}
on tile[0]: {
enum BurnStatus status = STATUS_SUCCESS;
for (unsigned i = 0; i < 2; i++) {
int coreSuccess;
c[i] :> coreSuccess;
if (!coreSuccess) {
status = STATUS_FAIL_WRITE;
}
}
switch (status) {
case STATUS_SUCCESS:
printstr("Device successfully burnt\n");
break;
case STATUS_FAIL_WRITE:
printstr("Burning device failed\n");
break;
}
if (status != STATUS_SUCCESS) {
exit(1);
}
}
}
return 0;
}

Binary file not shown.

36
XU216-512-TQ128-C20.xn Normal file
View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
<Type>Device</Type>
<Name>XU216-512-TQ128-C20 Device</Name>
<Declarations>
<Declaration>tileref tile[2]</Declaration>
<Declaration>tileref usb_tile</Declaration>
</Declarations>
<Packages>
<Package id="0" Type="XS2-UnA-512-TQ128">
<Nodes>
<Node Id="0" InPackageId="0" Type="XS2-L16A-512" SystemFrequency="500MHz" OscillatorSrc="1">
<Tile Number="0" Reference="tile[0]"/>
<Tile Number="1" Reference="tile[1]"/>
</Node>
<Node Id="1" InPackageId="1" Type="periph:XS1-SU" Reference="usb_tile">
</Node>
</Nodes>
<Links>
<Link Encoding="5wire">
<LinkEndpoint NodeId="0" Link="8" Delays="52clk,52clk"/>
<LinkEndpoint NodeId="1" Link="XL0" Delays="1clk,1clk"/>
</Link>
</Links>
</Package>
</Packages>
<JTAGChain>
<JTAGDevice NodeId="0"/>
</JTAGChain>
</Network>

BIN
libotp.a Normal file

Binary file not shown.

BIN
libotp3.a Normal file

Binary file not shown.

277
otp.h Normal file
View File

@@ -0,0 +1,277 @@
/**
* \file otp.h
*
* This API provides functions to program and read the OTP (One Time
* Programmable) memory of an xCORE. Functions are provided to program and read
* the OTP memory using both single-ended and differential modes. Functions are
* also provided that allow automatic repair of failed programming locations
* using the OTP redundancy registers. Access is also provided to program and
* read the OTP special registers.
*/
#ifndef _OTP_H_
#define _OTP_H_
#include <xccompat.h>
#ifdef __otp_conf_h_exists__
#include "otp_conf.h"
#endif
////////////////////////////////////////////////////////////////////////////////
/**
* OTP Statistics gathering is disabled by default. #define OTP_STATS 1 in
* user defined otp_conf.h to enable
*/
#ifndef OTP_STATS
#define OTP_STATS 0
#endif //OTP_STATS
/**
* Maximum size of OTP memory
*/
#define OTP_SIZE 0x800
/**
* Standard initializer for an otp_ports_t structure. Use as follows:
* on stdcore[0]: OTPPorts otp_ports = OTP_PORTS_INITIALIZER;
*/
#define OTP_PORTS_INITIALIZER \
{ \
XS1_PORT_32B, \
XS1_PORT_16C, \
XS1_PORT_16D \
}
////////////////////////////////////////////////////////////////////////////////
/**
* Structure contains ports used to access OTP memory.
*/
typedef struct OTPPorts
{
port data;
#if (__XC__)
out port addr;
out port ctrl;
#else
port addr;
port ctrl;
#endif
} OTPPorts;
/**
* 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_GetStats.
*/
#if (OTP_STATS)
typedef struct OTPStats
{
unsigned programmed_words; ///< Number of words that were successfully programmed
unsigned programmed_bits; ///< Number of bits that were successfully programmed using the short programming pulse
unsigned soaked_bits; ///< Number of bits that were successfully programmed using the long programming pulse
unsigned leaky_bits; ///< Number of bits that are already in the programmed state before programming commenced but should not be programmed
unsigned failed_to_program_words; ///< Number of words that failed to program
unsigned redundant_sectors_used; ///< Number of redundant sectors used (L1 family only)
} OTPStats;
#endif //OTP_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 on the L1 family of processors.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : unsigned - the amount of data to be written.
* \returns 1 if successful; 0 if failed.
*/
int otp_program(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 on the L1 family of processors.
* Differential mode programming is not available on the G4 family of
* processors and will simply return 0 (failed).
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : 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 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.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : unsigned - the amount of data to be written.
* \param[out] failmap : unsigned [] - location of bits that failed to program
* successfully.
* \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 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.
* Differential mode programming is not available on the G4 family of
* processors and will simply return 0 (failed).
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : unsigned - the amount of data to be written.
* \param[out] failmap : 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[]);
/**
* OTP_ProgramSpecialRegister programs a word to the OTP special register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] t : timer - a timer handle.
* \param[in] data : unsigned - the data to be written.
* \returns 1 if successful; 0 if failed.
*/
int otp_program_special_register(REFERENCE_PARAM(OTPPorts, ports), unsigned data);
/**
* otp_program_secure_config_register programs a word to the OTP secure config
* register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] t : timer - a timer handle.
* \param[in] data : 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);
//Program a single word without repairing any errors
int otpprogram_writeword_norepair(REFERENCE_PARAM(OTPPorts, ports),
unsigned address,
unsigned data);
/**
* OTP_Read reads a block of OTP data of defined size from address using
* default single_ended mode.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to read from.
* \param[out] data : unsigned[] - an array of words that the data being
* read can be stored in.
* \param[in] size : unsigned - the amount of data to be read.
*/
void otp_read(REFERENCE_PARAM(OTPPorts, ports),
unsigned address,
unsigned data[],
unsigned size);
/**
* OTP_ReadDifferential reads a block of OTP data of defined size from address
* using enhanced differential mode.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to read from.
* \param[out] data : unsigned[] - an array of words that the data being read
* can be stored in.
* \param[in] size : unsigned - the amount of data to be read.
*/
void otp_read_differential(REFERENCE_PARAM(OTPPorts, ports),
unsigned address,
unsigned data[],
unsigned size);
/**
* OTP_ReadSpecialRegister reads a word from the OTP special register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[out] data : unsigned - the word read from the special register.
*/
void otp_read_special_register(REFERENCE_PARAM(OTPPorts, ports), REFERENCE_PARAM(unsigned, data));
/**
* otp_read_secure_config_register reads a word from the OTP secure config
* register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[out] data : unsigned - the word read from the special register.
*/
void otp_read_secure_config_register(REFERENCE_PARAM(OTPPorts, ports), REFERENCE_PARAM(unsigned, data));
////////////////////////////////////////////////////////////////////////////////
#if (OTP_STATS)
/**
* This function retrieves the statistics from the last programming event.
* Requires the #define OTP_STATS to be set to 1 in user defined otp_conf.h
* to activate statistic gathering.
*
* \param[out] stats : OTPStats - structure that will contain the statitic
* information
*/
void otpstats_get_stats(REFERENCE_PARAM(OTPStats, stats));
/**
* This function allows two OTPStats structs to be merged together.
* Requires the #define OTP_STATS to be set to 1 in user defined otp_conf.h
* to activate statistic gathering.
*
* \param[in, out] a : OTPStats - structure contains the original stats and
* param b will be merged with them
* \param[in] b : OTPStats - structure contains the stats that are to be merged
* with param a
*/
void otpstats_merge_stats(REFERENCE_PARAM(OTPStats, a),
REFERENCE_PARAM(const OTPStats, b));
/**
* This function outputs the statistics from the given OTPStats struct.
* Requires the #define OTP_STATS to be set to 1 in user defined otp_conf.h
* to activate statistic gathering.
*
* \param[in] stats : OTPStats - structure containing the stats to be printed.
*
*/
void otpstats_print_stats(REFERENCE_PARAM(const OTPStats, stats));
#endif //OTP_STATS
////////////////////////////////////////////////////////////////////////////////
#endif //_OTP_H_
////////////////////////////////////////////////////////////////////////////////

270
otp3.h Normal file
View File

@@ -0,0 +1,270 @@
/**
* \file otp.h
*
* This API provides functions to program and read the OTP (One Time
* Programmable) memory of an xCORE. Functions are provided to program and read
* the OTP memory using both single-ended and differential modes. Functions are
* also provided that allow automatic repair of failed programming locations
* using the OTP redundancy registers. Access is also provided to program and
* read the OTP special registers.
*/
#ifndef _OTP3_H_
#define _OTP3_H_
#include <xccompat.h>
#ifdef __otp_conf_h_exists__
#include "otp_conf.h"
#endif
////////////////////////////////////////////////////////////////////////////////
/**
* OTP Statistics gathering is disabled by default. #define OTP_STATS 1 in
* user defined otp_conf.h to enable
*/
#ifndef OTP_STATS
#define OTP_STATS 0
#endif //OTP_STATS
/**
* Maximum size of OTP memory per tile in words. The 8kB OTP is split into two halves, each allocated to a tile.
*/
#define OTP_SIZE (0x800 / 2)
/**
* Standard initializer for an otp_ports_t structure. Use as follows:
* on stdcore[0]: OTPPorts otp_ports = OTP_PORTS_INITIALIZER;
*/
#define OTP_PORTS_INITIALIZER \
{ \
0, \
XS1_PORT_32B \
}
////////////////////////////////////////////////////////////////////////////////
/**
* Structure contains ports used to access OTP memory.
*/
typedef struct OTPPorts
{
unsigned otp_shadow_g;
port otp_data_g;
} OTPPorts;
/**
* 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_GetStats.
*/
#if (OTP_STATS)
typedef struct OTPStats
{
unsigned programmed_words; ///< Number of words that were successfully programmed
unsigned programmed_bits; ///< Number of bits that were successfully programmed using the short programming pulse
unsigned soaked_bits; ///< Number of bits that were successfully programmed using the long programming pulse
unsigned leaky_bits; ///< Number of bits that are already in the programmed state before programming commenced but should not be programmed
unsigned failed_to_program_words; ///< Number of words that failed to program
unsigned redundant_sectors_used; ///< Number of redundant sectors used (L1 family only)
} OTPStats;
#endif //OTP_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 on the L1 family of processors.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : unsigned - the amount of data to be written.
* \returns 1 if successful; 0 if failed.
*/
int otp_program(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 on the L1 family of processors.
* Differential mode programming is not available on the G4 family of
* processors and will simply return 0 (failed).
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : 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 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.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : unsigned - the amount of data to be written.
* \param[out] failmap : unsigned [] - location of bits that failed to program
* successfully.
* \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 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.
* Differential mode programming is not available on the G4 family of
* processors and will simply return 0 (failed).
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to write to.
* \param[in] data : const unsigned[] - an array of data to be written.
* \param[in] size : unsigned - the amount of data to be written.
* \param[out] failmap : 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[]);
/**
* OTP_ProgramSpecialRegister programs a word to the OTP special register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] t : timer - a timer handle.
* \param[in] data : unsigned - the data to be written.
* \returns 1 if successful; 0 if failed.
*/
int otp_program_special_register(REFERENCE_PARAM(OTPPorts, ports), unsigned data);
/**
* otp_program_secure_config_register programs a word to the OTP secure config
* register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] t : timer - a timer handle.
* \param[in] data : 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);
//Program a single word without repairing any errors
int otpprogram_writeword_norepair(REFERENCE_PARAM(OTPPorts, ports),
unsigned address,
unsigned data);
/**
* OTP_Read reads a block of OTP data of defined size from address using
* default single_ended mode.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to read from.
* \param[out] data : unsigned[] - an array of words that the data being
* read can be stored in.
* \param[in] size : unsigned - the amount of data to be read.
*/
void otp_read(REFERENCE_PARAM(OTPPorts, ports),
unsigned address,
unsigned data[],
unsigned size);
/**
* OTP_ReadDifferential reads a block of OTP data of defined size from address
* using enhanced differential mode.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[in] address : unsigned - the location in OTP memory to read from.
* \param[out] data : unsigned[] - an array of words that the data being read
* can be stored in.
* \param[in] size : unsigned - the amount of data to be read.
*/
void otp_read_differential(REFERENCE_PARAM(OTPPorts, ports),
unsigned address,
unsigned data[],
unsigned size);
/**
* OTP_ReadSpecialRegister reads a word from the OTP special register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[out] data : unsigned - the word read from the special register.
*/
void otp_read_special_register(REFERENCE_PARAM(OTPPorts, ports), REFERENCE_PARAM(unsigned, data));
/**
* otp_read_secure_config_register reads a word from the OTP secure config
* register.
*
* \param[in] ports : OTPPorts - the OTPPorts structure.
* \param[out] data : unsigned - the word read from the special register.
*/
void otp_read_secure_config_register(REFERENCE_PARAM(OTPPorts, ports), REFERENCE_PARAM(unsigned, data));
////////////////////////////////////////////////////////////////////////////////
#if (OTP_STATS)
/**
* This function retrieves the statistics from the last programming event.
* Requires the #define OTP_STATS to be set to 1 in user defined otp_conf.h
* to activate statistic gathering.
*
* \param[out] stats : OTPStats - structure that will contain the statitic
* information
*/
void otpstats_get_stats(REFERENCE_PARAM(OTPStats, stats));
/**
* This function allows two OTPStats structs to be merged together.
* Requires the #define OTP_STATS to be set to 1 in user defined otp_conf.h
* to activate statistic gathering.
*
* \param[in, out] a : OTPStats - structure contains the original stats and
* param b will be merged with them
* \param[in] b : OTPStats - structure contains the stats that are to be merged
* with param a
*/
void otpstats_merge_stats(REFERENCE_PARAM(OTPStats, a),
REFERENCE_PARAM(const OTPStats, b));
/**
* This function outputs the statistics from the given OTPStats struct.
* Requires the #define OTP_STATS to be set to 1 in user defined otp_conf.h
* to activate statistic gathering.
*
* \param[in] stats : OTPStats - structure containing the stats to be printed.
*
*/
void otpstats_print_stats(REFERENCE_PARAM(const OTPStats, stats));
#endif //OTP_STATS
////////////////////////////////////////////////////////////////////////////////
#endif //_OTP3_H_
////////////////////////////////////////////////////////////////////////////////

BIN
xburn-28017de4 Normal file

Binary file not shown.

BIN
xburn-e90e989d Normal file

Binary file not shown.

362
xburn.xc Normal file
View File

@@ -0,0 +1,362 @@
#undef _XSCOPE_PROBES_INCLUDE_FILE
#define __XC__ 1
#define __llvm__ 1
#define __ATOMIC_RELAXED 0
#define __ATOMIC_CONSUME 1
#define __ATOMIC_ACQUIRE 2
#define __ATOMIC_RELEASE 3
#define __ATOMIC_ACQ_REL 4
#define __ATOMIC_SEQ_CST 5
#define __PRAGMA_REDEFINE_EXTNAME 1
#define __VERSION__ "4.2.1 Compatible XMOS-235-acbb966-Dec-01-2019 Clang 3.6.0 "
#define __CONSTANT_CFSTRINGS__ 1
#define __ORDER_LITTLE_ENDIAN__ 1234
#define __ORDER_BIG_ENDIAN__ 4321
#define __ORDER_PDP_ENDIAN__ 3412
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
#define __LITTLE_ENDIAN__ 1
#define _ILP32 1
#define __ILP32__ 1
#define __CHAR_BIT__ 8
#define __SCHAR_MAX__ 127
#define __SHRT_MAX__ 32767
#define __INT_MAX__ 2147483647
#define __LONG_MAX__ 2147483647L
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __WCHAR_MAX__ 255
#define __INTMAX_MAX__ 9223372036854775807LL
#define __SIZE_MAX__ 4294967295U
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_INT__ 4
#define __SIZEOF_LONG__ 4
#define __SIZEOF_LONG_DOUBLE__ 8
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_POINTER__ 4
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_PTRDIFF_T__ 4
#define __SIZEOF_SIZE_T__ 4
#define __SIZEOF_WCHAR_T__ 1
#define __SIZEOF_WINT_T__ 4
#define __INTMAX_TYPE__ long long int
#define __INTMAX_FMTd__ "lld"
#define __INTMAX_FMTi__ "lli"
#define __INTMAX_C_SUFFIX__ LL
#define __UINTMAX_TYPE__ long long unsigned int
#define __UINTMAX_FMTo__ "llo"
#define __UINTMAX_FMTu__ "llu"
#define __UINTMAX_FMTx__ "llx"
#define __UINTMAX_FMTX__ "llX"
#define __UINTMAX_C_SUFFIX__ ULL
#define __INTMAX_WIDTH__ 64
#define __PTRDIFF_TYPE__ int
#define __PTRDIFF_FMTd__ "d"
#define __PTRDIFF_FMTi__ "i"
#define __PTRDIFF_WIDTH__ 32
#define __INTPTR_TYPE__ int
#define __INTPTR_FMTd__ "d"
#define __INTPTR_FMTi__ "i"
#define __INTPTR_WIDTH__ 32
#define __SIZE_TYPE__ unsigned int
#define __SIZE_FMTo__ "o"
#define __SIZE_FMTu__ "u"
#define __SIZE_FMTx__ "x"
#define __SIZE_FMTX__ "X"
#define __SIZE_WIDTH__ 32
#define __WCHAR_TYPE__ unsigned char
#define __WCHAR_WIDTH__ 8
#define __WINT_TYPE__ unsigned int
#define __WINT_WIDTH__ 32
#define __SIG_ATOMIC_WIDTH__ 32
#define __SIG_ATOMIC_MAX__ 2147483647
#define __CHAR16_TYPE__ unsigned short
#define __CHAR32_TYPE__ unsigned int
#define __FLT_DENORM_MIN__ 1.40129846e-45F
#define __FLT_HAS_DENORM__ 1
#define __FLT_DIG__ 6
#define __FLT_EPSILON__ 1.19209290e-7F
#define __FLT_HAS_INFINITY__ 1
#define __FLT_HAS_QUIET_NAN__ 1
#define __FLT_MANT_DIG__ 24
#define __FLT_MAX_10_EXP__ 38
#define __FLT_MAX_EXP__ 128
#define __FLT_MAX__ 3.40282347e+38F
#define __FLT_MIN_10_EXP__ (-37)
#define __FLT_MIN_EXP__ (-125)
#define __FLT_MIN__ 1.17549435e-38F
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __DBL_HAS_DENORM__ 1
#define __DBL_DIG__ 15
#define __DBL_EPSILON__ 2.2204460492503131e-16
#define __DBL_HAS_INFINITY__ 1
#define __DBL_HAS_QUIET_NAN__ 1
#define __DBL_MANT_DIG__ 53
#define __DBL_MAX_10_EXP__ 308
#define __DBL_MAX_EXP__ 1024
#define __DBL_MAX__ 1.7976931348623157e+308
#define __DBL_MIN_10_EXP__ (-307)
#define __DBL_MIN_EXP__ (-1021)
#define __DBL_MIN__ 2.2250738585072014e-308
#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
#define __LDBL_HAS_DENORM__ 1
#define __LDBL_DIG__ 15
#define __LDBL_EPSILON__ 2.2204460492503131e-16L
#define __LDBL_HAS_INFINITY__ 1
#define __LDBL_HAS_QUIET_NAN__ 1
#define __LDBL_MANT_DIG__ 53
#define __LDBL_MAX_10_EXP__ 308
#define __LDBL_MAX_EXP__ 1024
#define __LDBL_MAX__ 1.7976931348623157e+308L
#define __LDBL_MIN_10_EXP__ (-307)
#define __LDBL_MIN_EXP__ (-1021)
#define __LDBL_MIN__ 2.2250738585072014e-308L
#define __POINTER_WIDTH__ 32
#define __CHAR_UNSIGNED__ 1
#define __WCHAR_UNSIGNED__ 1
#define __WINT_UNSIGNED__ 1
#define __INT8_TYPE__ signed char
#define __INT8_FMTd__ "hhd"
#define __INT8_FMTi__ "hhi"
#define __INT8_C_SUFFIX__
#define __INT16_TYPE__ short
#define __INT16_FMTd__ "hd"
#define __INT16_FMTi__ "hi"
#define __INT16_C_SUFFIX__
#define __INT32_TYPE__ int
#define __INT32_FMTd__ "d"
#define __INT32_FMTi__ "i"
#define __INT32_C_SUFFIX__
#define __INT64_TYPE__ long long int
#define __INT64_FMTd__ "lld"
#define __INT64_FMTi__ "lli"
#define __INT64_C_SUFFIX__ LL
#define __USER_LABEL_PREFIX__ _
#define __FINITE_MATH_ONLY__ 0
#define __FLT_EVAL_METHOD__ 0
#define __FLT_RADIX__ 2
#define __DECIMAL_DIG__ 17
#define __xcore__ 1
#define __XS1B__ 1
#define __STDC_HOSTED__ 1
#define __STDC_UTF_16__ 1
#define __STDC_UTF_32__ 1
#define OTP_STATS 1
#define __xcore__ 1
#define __XS1B__ 1
#define XCC_VERSION_YEAR 14
#define XCC_VERSION_MONTH 4
#define XCC_VERSION_MAJOR 1404
#define XCC_VERSION_MINOR 1
#define __XCC_HAVE_FLOAT__ 1
#define _XSCOPE_PROBES_INCLUDE_FILE "c:\\Users\\swnb\\Temp\\ccQPcbaa.h"
#define _xburn_h_
#define _OTP_H_
#define _xccompat_h_
#define REFERENCE_PARAM(type,name) type &name
#define NULLABLE_REFERENCE_PARAM(type,name) type &?name
#define NULLABLE_RESOURCE(type,name) type ?name
#define NULLABLE_ARRAY_OF(type,name) type (&?name)[]
#define ARRAY_OF_SIZE(type,name,size) type name[size]
#define NULLABLE_ARRAY_OF_SIZE(type,name,size) type (&?name)[size]
#define CLIENT_INTERFACE(tag,name) client interface tag name
#define SERVER_INTERFACE(tag,name) server interface tag name
typedef streaming chanend streaming_chanend_t;
typedef in buffered port:1 in_buffered_port_1_t;
typedef in buffered port:4 in_buffered_port_4_t;
typedef in buffered port:8 in_buffered_port_8_t;
typedef in buffered port:16 in_buffered_port_16_t;
typedef in buffered port:32 in_buffered_port_32_t;
typedef out buffered port:1 out_buffered_port_1_t;
typedef out buffered port:4 out_buffered_port_4_t;
typedef out buffered port:8 out_buffered_port_8_t;
typedef out buffered port:16 out_buffered_port_16_t;
typedef out buffered port:32 out_buffered_port_32_t;
#define OTP_SIZE 0x800
#define OTP_PORTS_INITIALIZER { XS1_PORT_32B, XS1_PORT_16C, XS1_PORT_16D }
typedef struct OTPPorts
{
port data;
out port addr;
out port ctrl;
} OTPPorts;
typedef struct OTPStats
{
unsigned programmed_words;
unsigned programmed_bits;
unsigned soaked_bits;
unsigned leaky_bits;
unsigned failed_to_program_words;
unsigned redundant_sectors_used;
} OTPStats;
int otp_program(OTPPorts &ports,
unsigned address,
const unsigned data[],
unsigned size);
int otp_program_differential(OTPPorts &ports,
unsigned address,
const unsigned data[],
unsigned size);
int otp_program_no_repair(OTPPorts &ports,
unsigned address,
const unsigned data[],
unsigned size,
char failmap[]);
int otp_program_differential_no_repair(OTPPorts &ports,
unsigned address,
const unsigned data[],
unsigned size,
char failmap[]);
int otp_program_special_register(OTPPorts &ports, unsigned data);
int otp_program_secure_config_register(OTPPorts &ports, unsigned data);
int otpprogram_writeword_norepair(OTPPorts &ports,
unsigned address,
unsigned data);
void otp_read(OTPPorts &ports,
unsigned address,
unsigned data[],
unsigned size);
void otp_read_differential(OTPPorts &ports,
unsigned address,
unsigned data[],
unsigned size);
void otp_read_special_register(OTPPorts &ports, unsigned &data);
void otp_read_secure_config_register(OTPPorts &ports, unsigned &data);
void otpstats_get_stats(OTPStats &stats);
void otpstats_merge_stats(OTPStats &a,
const OTPStats &b);
void otpstats_print_stats(const OTPStats &stats);
int ProgramSRMasked(OTPPorts &ports, unsigned sr, unsigned sr_mask);
int ProgramSecurityConfigMasked(OTPPorts &ports, unsigned sec, unsigned sec_mask);
void PrintArray(OTPPorts &ports, chanend prev, chanend next, int differential);
void CollectStats(chanend c, OTPStats &stats);
int ProgramSoftRedundancyForBoot(OTPPorts &ports,
int differential, unsigned address,
const unsigned (&?prefix)[], unsigned prefixSize,
const unsigned payload[], unsigned payloadSize,
unsigned maxSize, int writeDisableCrc);
int CheckStats(const OTPStats &stats, unsigned allowed);
#define _otp_soft_redundancy_h_
int otpsoftredundancy_program(OTPPorts &ports,
unsigned address,
const unsigned payload[],
unsigned payloadSize,
unsigned maxSize,
unsigned &size);
int otpsoftredundancy_program_differential(OTPPorts &ports,
unsigned address,
const unsigned payload[],
unsigned payloadSize,
unsigned maxSize,
unsigned &size);
int otpsoftredundancy_read(OTPPorts &ports,
unsigned address,
unsigned data[],
unsigned size);
int otpsoftredundancy_read_differential(OTPPorts &ports,
unsigned address,
unsigned data[],
unsigned size);
#include <platform.h>
#include <stdlib.h>
#include <print.h>
#include<otp.h>
enum BurnStatus {
STATUS_SUCCESS,
STATUS_FAIL_MARGINAL,
STATUS_FAIL_SOAKED,
STATUS_FAIL_WRITE
};
on tile[0]: OTPPorts ports_0_0 = OTP_PORTS_INITIALIZER;
on tile[1]: OTPPorts ports_0_1 = OTP_PORTS_INITIALIZER;
unsigned mem_0_0_0[] = {
0x00000000,
0x04060709,
0x00000102,
0x4847ffff
};
unsigned mem_0_1_0[] = {
0x00000000,
0x04060709,
0x00000102,
0x4847ffff
};
int program_0_0() {
if(!otp_program(ports_0_0, 2044, mem_0_0_0, 4)) {
return 0;
}
return 1;
}
int program_0_1() {
if(!otp_program(ports_0_1, 2044, mem_0_1_0, 4)) {
return 0;
}
return 1;
}
int main() {
chan c[2];
par {
on tile[0]: {
c[0] <: program_0_0();
}
on tile[1]: {
c[1] <: program_0_1();
}
on tile[0]: {
enum BurnStatus status = STATUS_SUCCESS;
for (unsigned i = 0; i < 2; i++) {
int coreSuccess;
c[i] :> coreSuccess;
if (!coreSuccess) {
status = STATUS_FAIL_WRITE;
}
}
switch (status) {
case STATUS_SUCCESS:
printstr("Device successfully burnt\n");
break;
case STATUS_FAIL_WRITE:
printstr("Burning device failed\n");
break;
}
if (status != STATUS_SUCCESS) {
exit(1);
}
}
}
return 0;
}