commit afe953ac4ed8cb023233cc3b65ea9ee4ccbe5a28 Author: qiusongxiao Date: Wed Dec 6 19:35:36 2023 +0800 init diff --git a/.build/_iflag.rsp b/.build/_iflag.rsp new file mode 100644 index 0000000..8f34b8a --- /dev/null +++ b/.build/_iflag.rsp @@ -0,0 +1 @@ +-I"../." diff --git a/.build/_obj.rsp b/.build/_obj.rsp new file mode 100644 index 0000000..16605bd --- /dev/null +++ b/.build/_obj.rsp @@ -0,0 +1 @@ +..\.build\xburn.xc.o diff --git a/.build/_pca.rsp b/.build/_pca.rsp new file mode 100644 index 0000000..1d8210d --- /dev/null +++ b/.build/_pca.rsp @@ -0,0 +1 @@ + .build/xburn.xc.pca.xml diff --git a/.build/pca.d b/.build/pca.d new file mode 100644 index 0000000..e69de29 diff --git a/.build/pca.xml b/.build/pca.xml new file mode 100644 index 0000000..fce43b6 --- /dev/null +++ b/.build/pca.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.build/xburn.d b/.build/xburn.d new file mode 100644 index 0000000..e61f16e --- /dev/null +++ b/.build/xburn.d @@ -0,0 +1,4 @@ +xburn.o: \ + ../xburn.xc \ + C:/Users/qiu/Desktop/新建文件夹/otp.h + diff --git a/.build/xburn.xc.d b/.build/xburn.xc.d new file mode 100644 index 0000000..50638c8 --- /dev/null +++ b/.build/xburn.xc.d @@ -0,0 +1,5 @@ +.build/xburn.xc.d .build/xburn.xc.o .build/xburn.xc.pca.xml: \ + ././xburn.xc \ + C:/Users/qiu/Desktop/新建文件夹/otp.h + + diff --git a/.build/xburn.xc.o b/.build/xburn.xc.o new file mode 100644 index 0000000..7177b69 Binary files /dev/null and b/.build/xburn.xc.o differ diff --git a/.build/xburn.xc.pca.xml b/.build/xburn.xc.pca.xml new file mode 100644 index 0000000..c2c5813 --- /dev/null +++ b/.build/xburn.xc.pca.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e4a8a33 --- /dev/null +++ b/Makefile @@ -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 diff --git a/OTP_Cache_backUp/.build/_iflag.rsp b/OTP_Cache_backUp/.build/_iflag.rsp new file mode 100644 index 0000000..de6fbbc --- /dev/null +++ b/OTP_Cache_backUp/.build/_iflag.rsp @@ -0,0 +1 @@ +-I"../." -I".././lib" -I".././src" -I".././src/core" -I".././src/extensions" diff --git a/OTP_Cache_backUp/.build/_obj.rsp b/OTP_Cache_backUp/.build/_obj.rsp new file mode 100644 index 0000000..c0c7064 --- /dev/null +++ b/OTP_Cache_backUp/.build/_obj.rsp @@ -0,0 +1 @@ +..\.build\src\xburn.xc.o diff --git a/OTP_Cache_backUp/.build/_pca.rsp b/OTP_Cache_backUp/.build/_pca.rsp new file mode 100644 index 0000000..df8beef --- /dev/null +++ b/OTP_Cache_backUp/.build/_pca.rsp @@ -0,0 +1 @@ + .build/src/xburn.xc.pca.xml diff --git a/OTP_Cache_backUp/.build/pca.d b/OTP_Cache_backUp/.build/pca.d new file mode 100644 index 0000000..e69de29 diff --git a/OTP_Cache_backUp/.build/pca.xml b/OTP_Cache_backUp/.build/pca.xml new file mode 100644 index 0000000..fce43b6 --- /dev/null +++ b/OTP_Cache_backUp/.build/pca.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OTP_Cache_backUp/.build/src/xburn.xc.d b/OTP_Cache_backUp/.build/src/xburn.xc.d new file mode 100644 index 0000000..76ed9c3 --- /dev/null +++ b/OTP_Cache_backUp/.build/src/xburn.xc.d @@ -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/新建文件夹/OTP_Cache_backUp/src/extensions/otp.h + + diff --git a/OTP_Cache_backUp/.build/src/xburn.xc.o b/OTP_Cache_backUp/.build/src/xburn.xc.o new file mode 100644 index 0000000..18246fb Binary files /dev/null and b/OTP_Cache_backUp/.build/src/xburn.xc.o differ diff --git a/OTP_Cache_backUp/.build/src/xburn.xc.pca.xml b/OTP_Cache_backUp/.build/src/xburn.xc.pca.xml new file mode 100644 index 0000000..05e1568 --- /dev/null +++ b/OTP_Cache_backUp/.build/src/xburn.xc.pca.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OTP_Cache_backUp/.build/src/xburn.xc.pca.xml.decouple b/OTP_Cache_backUp/.build/src/xburn.xc.pca.xml.decouple new file mode 100644 index 0000000..05e1568 --- /dev/null +++ b/OTP_Cache_backUp/.build/src/xburn.xc.pca.xml.decouple @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OTP_Cache_backUp/.build/xburn.d b/OTP_Cache_backUp/.build/xburn.d new file mode 100644 index 0000000..f6e1844 --- /dev/null +++ b/OTP_Cache_backUp/.build/xburn.d @@ -0,0 +1,4 @@ +xburn.o: \ + ../src/xburn.xc \ + C:/Users/qiu/Desktop/新建文件夹/OTP_Cache_backUp/src/extensions/otp.h + diff --git a/OTP_Cache_backUp/Makefile b/OTP_Cache_backUp/Makefile new file mode 100644 index 0000000..0c98419 --- /dev/null +++ b/OTP_Cache_backUp/Makefile @@ -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 diff --git a/OTP_Cache_backUp/lib/libotp.a b/OTP_Cache_backUp/lib/libotp.a new file mode 100644 index 0000000..00573c0 Binary files /dev/null and b/OTP_Cache_backUp/lib/libotp.a differ diff --git a/OTP_Cache_backUp/lib/libotp3.a b/OTP_Cache_backUp/lib/libotp3.a new file mode 100644 index 0000000..6c5bb12 Binary files /dev/null and b/OTP_Cache_backUp/lib/libotp3.a differ diff --git a/OTP_Cache_backUp/src/core/XU216-512-TQ128-C20.xn b/OTP_Cache_backUp/src/core/XU216-512-TQ128-C20.xn new file mode 100644 index 0000000..23c455a --- /dev/null +++ b/OTP_Cache_backUp/src/core/XU216-512-TQ128-C20.xn @@ -0,0 +1,36 @@ + + + Device + XU216-512-TQ128-C20 Device + + + tileref tile[2] + tileref usb_tile + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OTP_Cache_backUp/src/extensions/otp.h b/OTP_Cache_backUp/src/extensions/otp.h new file mode 100644 index 0000000..3bada2a --- /dev/null +++ b/OTP_Cache_backUp/src/extensions/otp.h @@ -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 + +#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_ + +//////////////////////////////////////////////////////////////////////////////// diff --git a/OTP_Cache_backUp/src/extensions/otp3.h b/OTP_Cache_backUp/src/extensions/otp3.h new file mode 100644 index 0000000..39445fb --- /dev/null +++ b/OTP_Cache_backUp/src/extensions/otp3.h @@ -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 + +#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_ + +//////////////////////////////////////////////////////////////////////////////// diff --git a/OTP_Cache_backUp/src/xburn.xc b/OTP_Cache_backUp/src/xburn.xc new file mode 100644 index 0000000..26322f9 --- /dev/null +++ b/OTP_Cache_backUp/src/xburn.xc @@ -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 +#include +#include +#include +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; +} diff --git a/OTP_Cache_backUp/xburn-cf8579fe b/OTP_Cache_backUp/xburn-cf8579fe new file mode 100644 index 0000000..142db75 Binary files /dev/null and b/OTP_Cache_backUp/xburn-cf8579fe differ diff --git a/XU216-512-TQ128-C20.xn b/XU216-512-TQ128-C20.xn new file mode 100644 index 0000000..23c455a --- /dev/null +++ b/XU216-512-TQ128-C20.xn @@ -0,0 +1,36 @@ + + + Device + XU216-512-TQ128-C20 Device + + + tileref tile[2] + tileref usb_tile + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libotp.a b/libotp.a new file mode 100644 index 0000000..00573c0 Binary files /dev/null and b/libotp.a differ diff --git a/libotp3.a b/libotp3.a new file mode 100644 index 0000000..6c5bb12 Binary files /dev/null and b/libotp3.a differ diff --git a/otp.h b/otp.h new file mode 100644 index 0000000..3bada2a --- /dev/null +++ b/otp.h @@ -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 + +#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_ + +//////////////////////////////////////////////////////////////////////////////// diff --git a/otp3.h b/otp3.h new file mode 100644 index 0000000..39445fb --- /dev/null +++ b/otp3.h @@ -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 + +#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_ + +//////////////////////////////////////////////////////////////////////////////// diff --git a/xburn-28017de4 b/xburn-28017de4 new file mode 100644 index 0000000..3bfb913 Binary files /dev/null and b/xburn-28017de4 differ diff --git a/xburn-e90e989d b/xburn-e90e989d new file mode 100644 index 0000000..032caee Binary files /dev/null and b/xburn-e90e989d differ diff --git a/xburn.xc b/xburn.xc new file mode 100644 index 0000000..26322f9 --- /dev/null +++ b/xburn.xc @@ -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 +#include +#include +#include +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; +}