update to Platform Library 00.06: header file updates
authorMing Wei <mwei@ti.com>
Tue, 31 Mar 2015 17:58:41 +0000 (12:58 -0500)
committerMing Wei <mwei@ti.com>
Tue, 31 Mar 2015 17:58:41 +0000 (12:58 -0500)
20 files changed:
program_evm/binaries/evmk2g/eepromwriter_evmk2g.out
program_evm/binaries/evmk2g/nandwriter_evmk2g.out
program_evm/binaries/evmk2g/norwriter_evmk2g.out
writer/eeprom/evmk2g/.cproject
writer/nand/evmk2g/.cproject
writer/nand/src/nandwriter.c
writer/nor/evmk2g/.cproject
writer/nor/src/norwriter.c
writer/qspi_flash/docs/README.txt [new file with mode: 0644]
writer/qspi_flash/evmk2g/.ccsproject [new file with mode: 0644]
writer/qspi_flash/evmk2g/.cproject [new file with mode: 0644]
writer/qspi_flash/evmk2g/.project [new file with mode: 0644]
writer/qspi_flash/evmk2g/.settings/org.eclipse.cdt.codan.core.prefs [new file with mode: 0644]
writer/qspi_flash/evmk2g/.settings/org.eclipse.cdt.debug.core.prefs [new file with mode: 0644]
writer/qspi_flash/evmk2g/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
writer/qspi_flash/evmk2g/bin/qspi_flash_writer_input.txt [new file with mode: 0644]
writer/qspi_flash/evmk2g/macros.ini_initial [new file with mode: 0644]
writer/qspi_flash/evmk2g/qspiflashwriter.cmd [new file with mode: 0644]
writer/qspi_flash/include/types.h [new file with mode: 0644]
writer/qspi_flash/src/qspiflashwriter.c [new file with mode: 0644]

index c0fde9fa57a39fe8be1ef112be569c6b28887187..278266b1d26aed338dccb6a325f5c59d51eea35e 100644 (file)
Binary files a/program_evm/binaries/evmk2g/eepromwriter_evmk2g.out and b/program_evm/binaries/evmk2g/eepromwriter_evmk2g.out differ
index d34f664362ed0c33aba861b2abb5fb5fa6e74caf..c04663a1cec17a99871da58ebbadf49510dd69d8 100644 (file)
Binary files a/program_evm/binaries/evmk2g/nandwriter_evmk2g.out and b/program_evm/binaries/evmk2g/nandwriter_evmk2g.out differ
index 3d291576dc9c4947d480b2b6474191597e626a66..3906bd2f4f483f7326af3601385776297d363fd0 100644 (file)
Binary files a/program_evm/binaries/evmk2g/norwriter_evmk2g.out and b/program_evm/binaries/evmk2g/norwriter_evmk2g.out differ
index 85f20319a809ccf3683650a8455d968ba8000bb1..86fa4347ad325263b70739746b0000c07f5782cc 100644 (file)
                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">\r
                                <configuration artifactExtension="out" artifactName="../bin/eepromwriter_evmk2g" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" errorParsers="com.ti.ccstudio.errorparser.LinkErrorParser;com.ti.ccstudio.errorparser.CoffErrorParser;com.ti.ccstudio.errorparser.AsmErrorParser" id="com.ti.ccstudio.buildDefinitions.C6000.Debug.1869204513.574484181" name="Debug" parent="com.ti.ccstudio.buildDefinitions.C6000.Debug">\r
                                        <folderInfo id="com.ti.ccstudio.buildDefinitions.C6000.Debug.1869204513.574484181." name="/" resourcePath="">\r
-                                               <toolChain id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain.633016266" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.1120346129">\r
-                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.596345792" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">\r
+                                               <toolChain id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain.665269276" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.1595058077">\r
+                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.257315044" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">\r
                                                                <listOptionValue builtIn="false" value="DEVICE_CONFIGURATION_ID=com.ti.ccstudio.deviceModel.C6000.CustomC6000Device"/>\r
                                                                <listOptionValue builtIn="false" value="DEVICE_ENDIANNESS=little"/>\r
                                                                <listOptionValue builtIn="false" value="OUTPUT_FORMAT=ELF"/>\r
                                                                <listOptionValue builtIn="false" value="CCS_MBS_VERSION=5.5.0"/>\r
                                                                <listOptionValue builtIn="false" value="LINKER_COMMAND_FILE=eepromwriter.cmd"/>\r
                                                                <listOptionValue builtIn="false" value="RUNTIME_SUPPORT_LIBRARY=libc.a"/>\r
-                                                               <listOptionValue builtIn="false" value="RTSC_PRODUCTS=ti.pdk:3.1.1.04;"/>\r
+                                                               <listOptionValue builtIn="false" value="RTSC_PRODUCTS=ti.pdk:3.2.0.00;"/>\r
                                                                <listOptionValue builtIn="false" value="OUTPUT_TYPE=rtscApplication:executable"/>\r
                                                        </option>\r
-                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.245499941" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="7.4.2" valueType="string"/>\r
-                                                       <targetPlatform id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug.193380857" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug"/>\r
-                                                       <builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug.1948718643" keepEnvironmentInBuildfile="false" name="GNU Make" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug"/>\r
-                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug.444333255" name="C6000 Compiler" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug">\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION.1726361057" name="Target processor version (--silicon_version, -mv)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION" value="6600" valueType="string"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.512602528" name="Debugging model" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH.637712012" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH" valueType="includePath">\r
+                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.139556053" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="7.4.4" valueType="string"/>\r
+                                                       <targetPlatform id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug.740501635" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug"/>\r
+                                                       <builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug.1972993440" keepEnvironmentInBuildfile="false" name="GNU Make" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug"/>\r
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug.1391189602" name="C6000 Compiler" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION.1235350521" name="Target processor version (--silicon_version, -mv)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION" value="6600" valueType="string"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.628964040" name="Application binary interface (coffabi, eabi) [See 'General' page to edit] (--abi)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.eabi" valueType="enumerated"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.2007544430" name="Debugging model" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH.1269380774" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH" valueType="includePath">\r
                                                                        <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${TI_PDK_INSTALL_DIR}/packages/ti/platform&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${TI_PDK_INSTALL_DIR}/packages&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${PROJECT_ROOT}/../include&quot;"/>\r
                                                                </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER.1870682215" name="Emit diagnostic identifier numbers (--display_error_number, -pden)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING.844801303" name="Treat diagnostic &lt;id&gt; as warning (--diag_warning, -pdsw)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING" valueType="stringList">\r
-                                                                       <listOptionValue builtIn="false" value="225"/>\r
-                                                               </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.1165302552" name="Application binary interface (coffabi, eabi) [See 'General' page to edit] (--abi)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.eabi" valueType="enumerated"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEFINE.31330608" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEFINE" valueType="definedSymbols">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEFINE.124982271" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEFINE" valueType="definedSymbols">\r
                                                                        <listOptionValue builtIn="false" value="DEVICE_K2G"/>\r
                                                                </option>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS.78737091" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS.736605371" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS.1230716097" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS.644836130" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER.2062651461" name="Emit diagnostic identifier numbers (--display_error_number, -pden)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING.91454299" name="Treat diagnostic &lt;id&gt; as warning (--diag_warning, -pdsw)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING" valueType="stringList">\r
+                                                                       <listOptionValue builtIn="false" value="225"/>\r
+                                                               </option>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS.1797633876" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS.1694442153" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS.1813802696" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS.1912020409" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS"/>\r
                                                        </tool>\r
-                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.1734344016" name="C6000 Linker" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug">\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE.2052112523" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE" value="&quot;../bin/eepromwriter_evmk2g.out&quot;" valueType="string"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE.1612478128" name="Input and output sections listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE" value="&quot;../bin/eepromwriter_evmk2g.map&quot;" valueType="string"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY.1321213661" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY" valueType="libs">\r
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.1595058077" name="C6000 Linker" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE.2124077948" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE" value="&quot;../bin/eepromwriter_evmk2g.out&quot;" valueType="string"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE.1790620058" name="Input and output sections listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE" value="&quot;../bin/eepromwriter_evmk2g.map&quot;" valueType="string"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY.5084580" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY" valueType="libs">\r
                                                                        <listOptionValue builtIn="false" value="&quot;libc.a&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;ti.platform.evmk2g.ae66&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;ti.csl.ae66&quot;"/>\r
                                                                </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH.2090958552" name="Add &lt;dir&gt; to library search path (--search_path, -i)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH" valueType="stringList">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH.2009145954" name="Add &lt;dir&gt; to library search path (--search_path, -i)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH" valueType="libPaths">\r
                                                                        <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/lib&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${TI_PDK_INSTALL_DIR}/packages/ti/platform/evmk2g/platform_lib/lib/debug&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${TI_PDK_INSTALL_DIR}/packages/ti/csl/lib/k2g/c66&quot;"/>\r
                                                                </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO.566568341" name="Detailed link information data-base into &lt;file&gt; (--xml_link_info, -xml_link_info)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO" value="&quot;../bin/eepromwriter_evmk2g_linkInfo.xml&quot;" valueType="string"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS.1105595573" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS.734672930" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS.672968248" name="Generated Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO.2144750757" name="Detailed link information data-base into &lt;file&gt; (--xml_link_info, -xml_link_info)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO" value="&quot;../bin/eepromwriter_evmk2g_linkInfo.xml&quot;" valueType="string"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS.1801421729" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS.1666875977" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS.1526777509" name="Generated Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS"/>\r
                                                        </tool>\r
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.hex.1200539174" name="C6000 Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.hex"/>\r
                                                </toolChain>\r
                                        </folderInfo>\r
                                </configuration>\r
index 70518e344189436c022c097d4bed85da3a8e7a66..7c64c8be627d964c95b4c2cbe91deb2955f87df5 100644 (file)
                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">\r
                                <configuration artifactExtension="out" artifactName="../bin/nandwriter_evmk2g" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" errorParsers="com.ti.ccstudio.errorparser.LinkErrorParser;com.ti.ccstudio.errorparser.CoffErrorParser;com.ti.ccstudio.errorparser.AsmErrorParser" id="com.ti.ccstudio.buildDefinitions.C6000.Debug.1869204513.1567123612" name="Debug" parent="com.ti.ccstudio.buildDefinitions.C6000.Debug">\r
                                        <folderInfo id="com.ti.ccstudio.buildDefinitions.C6000.Debug.1869204513.1567123612." name="/" resourcePath="">\r
-                                               <toolChain id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain.309610217" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.1695288410">\r
-                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.415559586" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">\r
+                                               <toolChain id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain.2047697621" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.71349552">\r
+                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.1106693103" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">\r
                                                                <listOptionValue builtIn="false" value="DEVICE_CONFIGURATION_ID=com.ti.ccstudio.deviceModel.C6000.CustomC6000Device"/>\r
                                                                <listOptionValue builtIn="false" value="DEVICE_ENDIANNESS=little"/>\r
                                                                <listOptionValue builtIn="false" value="OUTPUT_FORMAT=ELF"/>\r
                                                                <listOptionValue builtIn="false" value="CCS_MBS_VERSION=5.5.0"/>\r
                                                                <listOptionValue builtIn="false" value="LINKER_COMMAND_FILE=nandwriter.cmd"/>\r
                                                                <listOptionValue builtIn="false" value="RUNTIME_SUPPORT_LIBRARY=libc.a"/>\r
-                                                               <listOptionValue builtIn="false" value="RTSC_PRODUCTS=ti.pdk:3.1.1.04;"/>\r
+                                                               <listOptionValue builtIn="false" value="RTSC_PRODUCTS=ti.pdk:3.2.0.00;"/>\r
                                                                <listOptionValue builtIn="false" value="OUTPUT_TYPE=rtscApplication:executable"/>\r
                                                        </option>\r
-                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.1654370339" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="7.4.2" valueType="string"/>\r
-                                                       <targetPlatform id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug.737059449" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug"/>\r
-                                                       <builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug.1837653980" keepEnvironmentInBuildfile="false" name="GNU Make" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug"/>\r
-                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug.426532009" name="C6000 Compiler" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug">\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION.726744277" name="Target processor version (--silicon_version, -mv)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION" value="6600" valueType="string"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.185522910" name="Debugging model" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEFINE.795189217" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEFINE" valueType="definedSymbols">\r
-                                                                       <listOptionValue builtIn="false" value="DEVICE_K2G"/>\r
-                                                               </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH.549598401" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH" valueType="includePath">\r
+                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.183843241" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="7.4.4" valueType="string"/>\r
+                                                       <targetPlatform id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug.965573218" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug"/>\r
+                                                       <builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug.6825928" name="GNU Make.Debug" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug"/>\r
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug.515510045" name="C6000 Compiler" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION.1419284617" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION" value="6600" valueType="string"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.745317315" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.eabi" valueType="enumerated"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.1594060424" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH.939653500" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH" valueType="includePath">\r
                                                                        <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="${TI_PDK_INSTALL_DIR}/packages/ti/platform"/>\r
                                                                        <listOptionValue builtIn="false" value="${TI_PDK_INSTALL_DIR}/packages"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${PROJECT_ROOT}/../include&quot;"/>\r
                                                                </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER.1235819303" name="Emit diagnostic identifier numbers (--display_error_number, -pden)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING.1445405327" name="Treat diagnostic &lt;id&gt; as warning (--diag_warning, -pdsw)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING" valueType="stringList">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEFINE.1822702327" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEFINE" valueType="definedSymbols">\r
+                                                                       <listOptionValue builtIn="false" value="DEVICE_K2G"/>\r
+                                                               </option>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER.1810983668" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING.1098874891" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING" valueType="stringList">\r
                                                                        <listOptionValue builtIn="false" value="225"/>\r
                                                                </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.1433650012" name="Application binary interface (coffabi, eabi) [See 'General' page to edit] (--abi)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.eabi" valueType="enumerated"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS.765158743" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS.974308354" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS.1354120023" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS.1413788883" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS.842182870" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS.330031660" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS.268854630" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS.943763505" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS"/>\r
                                                        </tool>\r
-                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.1206826069" name="C6000 Linker" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug">\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE.1344929244" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE" value="&quot;../bin/nandwriter_evmk2g.out&quot;" valueType="string"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE.333280880" name="Input and output sections listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE" value="&quot;../bin/nandwriter_evmk2g.map&quot;" valueType="string"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY.1709188673" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY" valueType="libs">\r
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.71349552" name="C6000 Linker" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE.1260421918" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE" value="&quot;../bin/nandwriter_evmk2g.out&quot;" valueType="string"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE.1119387979" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE" value="&quot;../bin/nandwriter_evmk2g.map&quot;" valueType="string"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY.1022988475" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY" valueType="libs">\r
                                                                        <listOptionValue builtIn="false" value="&quot;libc.a&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;ti.platform.evmk2g.ae66&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;ti.csl.ae66&quot;"/>\r
                                                                </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH.282452847" name="Add &lt;dir&gt; to library search path (--search_path, -i)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH" valueType="stringList">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH.2020058160" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH" valueType="libPaths">\r
                                                                        <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/lib&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="${TI_PDK_INSTALL_DIR}/packages/ti/platform/evmk2g/platform_lib/lib/debug"/>\r
                                                                        <listOptionValue builtIn="false" value="${TI_PDK_INSTALL_DIR}/packages/ti/csl/lib/k2g/c66"/>\r
                                                                </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO.2018867685" name="Detailed link information data-base into &lt;file&gt; (--xml_link_info, -xml_link_info)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO" value="&quot;../bin/nandwriter_evmk2g_linkInfo.xml&quot;" valueType="string"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS.1646427199" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS.1704598513" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS.1240113538" name="Generated Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO.1295462709" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO" value="&quot;../bin/nandwriter_evmk2g_linkInfo.xml&quot;" valueType="string"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS.1127630097" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS.1011503766" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS.914249323" name="Generated Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS"/>\r
                                                        </tool>\r
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.hex.43762506" name="C6000 Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.hex"/>\r
                                                </toolChain>\r
                                        </folderInfo>\r
                                </configuration>\r
index 742be938994c1956a087abc4f96a488a909e4533..458796be306167549b6ef0ef762d399d86d35d6a 100755 (executable)
-/******************************************************************************
- * Copyright (c) 2013-2014 Texas Instruments Incorporated - http://www.ti.com
- * 
- *  Redistribution and use in source and binary forms, with or without 
- *  modification, are permitted provided that the following conditions 
- *  are met:
- *
- *    Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer.
- *
- *    Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the 
- *    documentation and/or other materials provided with the   
- *    distribution.
- *
- *    Neither the name of Texas Instruments Incorporated nor the names of
- *    its contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
- *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
- *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- *****************************************************************************/
-
-/**************************************************************************************
- * FILE PURPOSE: NAND writer utility
- **************************************************************************************
- * FILE NAME: nandwriter.c
- *
- * DESCRIPTION: A simple nand writer using platform lib APIs to program the NAND flash
- *              with an image that the ibl can read.
- *
- ***************************************************************************************/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "platform.h"
-#include "types.h"
-
-/* NAND writer utility version */
-char version[] = "01.00.00.05";
-
-/* The input file name is hard coded */
-char *input_file = "nand_writer_input.txt";
-
-uint32_t swap_byte = 0;
-volatile uint32_t nand_erase_flag = 0;
-
-/* Parameters defined in the input_file */
-#define FILE_NAME      "file_name"
-#define START_ADDR     "start_addr"
-#define RBL_ECC        "rbl_ecc"
-#define SKIP_BAD       "skip_bad"
-
-/* Memory address to store the write data */
-#define WRITE_DATA_ADDRESS     0x80000000
-
-/* NAND device specific definitions */
-#define BAD_BLOCK_MARKER_VALUE  0xA5
-
-/******************************************************************************
- * Structure:   NAND_WRITER_INFO_T
- *
- *              NAND writer control data. This structure should be filled in
- *              by the user before running
- ******************************************************************************/
-#define MAX_LINE_LENGTH 40
-typedef struct NAND_WRITER_INFO_tag
-{
-    char        file_name[MAX_LINE_LENGTH]; /* CCS format data file name */
-    uint32_t    blockSizeBytes;             /* The size of each sector */
-    uint32_t    deviceTotalBytes;           /* Total number of bytes available in the device */
-    uint32_t    startAddr;                  /* Start address to write */
-    uint32_t    writeBytes;                 /* Number of bytes to be written into the device */
-    uint8_t     flags;                      /* Flag used for EVMK2H for multiple ECC formats */
-    uint8_t     skip_bad_blks;              /* Flag used to skip bad blocks */
-    uint8_t     *writeData;                 /* Address to store the write data */
-    uint8_t     *readData;                  /* Address to store the read data */
-
-} NAND_WRITER_INFO_T;
-
-NAND_WRITER_INFO_T nandWriterInfo;
-
-/* OSAL functions for Platform Library */
-uint8_t *Osal_platformMalloc (uint32_t num_bytes, uint32_t alignment)
-{
-       return malloc(num_bytes);
-}
-
-void Osal_platformFree (uint8_t *dataPtr, uint32_t num_bytes)
-{
-    /* Free up the memory */
-    if (dataPtr)
-    {
-        free(dataPtr);
-    }
-}
-
-void Osal_platformSpiCsEnter(void)
-{
-    return;
-}
-
-void Osal_platformSpiCsExit (void)
-{
-    return;
-}
-
-/******************************************************************************
- * Function:    print_platform_errno
- ******************************************************************************/
-void
-print_platform_errno
-(
-    void
-)
-{
-    printf ("Returned platform error number is %d\n", platform_errno);
-}
-
-/******************************************************************************
- * Function:    checkBadBlockMark
- *
- *              Checks for the bad block mark. Returns TRUE if a block is marked bad.
- ******************************************************************************/
-Bool
-checkBadBlockMark 
-(
-    PLATFORM_DEVICE_info    *p_device,
-    uint32_t                  block
-)
-{
-    if (p_device->bblist[block] != 0xff)
-    {
-        return TRUE;
-    }
-    else
-    {
-        return FALSE;
-    }
-}
-
-/******************************************************************************
- * Function:    markBlockBad
- *
- *              Mark a block as bad. Byte 5 of the spare area data is
- *              written as 0xA5.
- ******************************************************************************/
-void 
-markBlockBad 
-(
-    PLATFORM_DEVICE_info        *p_device,
-    uint32_t                    block
-)
-{
-    uint8_t       *spare_data;
-
-    spare_data = malloc(p_device->spare_size);
-    if (spare_data == NULL)
-    {
-        printf ("Can not allocate spare_data memory!\n");
-        return;
-    }
-
-    platform_device_read_spare_data(p_device->handle, block, 0, spare_data);
-
-    /* Set all data bytes to 0xff, only set the user defined bad block mark value */
-    spare_data[p_device->bboffset] = BAD_BLOCK_MARKER_VALUE;
-
-    /* Write the data to page */
-    platform_device_write_spare_data(p_device->handle, block, 0, spare_data);
-
-    /* Save the user defined bad block mark in bblist */
-    p_device->bblist[block] = BAD_BLOCK_MARKER_VALUE;
-
-    free (spare_data);
-}
-
-/******************************************************************************
- * Function:    formBlock
- *
- *      Form a block of data to write to the NAND. The block is
- *      created as a byte stream from the 4 byte stream in which
- *      the MSB is always sent first.
- ******************************************************************************/
-void
-formBlock
-(
-    uint32_t      *data,
-    uint32_t      blockSize,
-    uint8_t       *scratch
-)
-{
-    uint32_t i, j;
-
-    /* Convert the data to a byte stream */
-    for (i = j = 0; j < blockSize; i++, j+=4)
-    {
-        scratch[j+0] = (data[i] >> 24) & 0xff;
-        scratch[j+1] = (data[i] >> 16) & 0xff;
-        scratch[j+2] = (data[i] >>  8) & 0xff;
-        scratch[j+3] = (data[i] >>  0) & 0xff;
-    }
-}
-
-/******************************************************************************
- * Function:    flash_nand
- *
- *              Write the image to flash.
- *              Returns TRUE if the image is written successfully
- *                      FALSE if the image write fails
- ******************************************************************************/
-Bool 
-flash_nand
-(
-    PLATFORM_DEVICE_info    *p_device
-)
-{
-    uint32_t      wPos, wLen;
-    uint32_t      block, start_block;
-    uint8_t       *scrach_block;
-    uint32_t      num_blks;
-    uint32_t      bad_block_found;
-
-    if (swap_byte)
-    {
-        scrach_block = malloc(nandWriterInfo.blockSizeBytes);
-        if (scrach_block == NULL)
-        {
-            printf ("Can not allocate scratch block memory!\n");
-            return (FALSE);
-        }
-    }
-
-    start_block = nandWriterInfo.startAddr / nandWriterInfo.blockSizeBytes;
-
-    /* skip the bad blocks if the flag is set */
-    if (nandWriterInfo.skip_bad_blks)
-    {
-       num_blks = nandWriterInfo.writeBytes / nandWriterInfo.blockSizeBytes;
-       if ((nandWriterInfo.writeBytes - nandWriterInfo.blockSizeBytes * num_blks) > 0)
-               num_blks++;
-
-       while (TRUE)
-       {
-               bad_block_found = FALSE;
-               for (block = start_block; block < start_block + num_blks; block++)
-               {
-                       if (checkBadBlockMark(p_device, block))
-                       {
-                               start_block = block + 1;
-                               bad_block_found = TRUE;
-                               break;
-                       }
-               }
-               if (bad_block_found == FALSE)
-                       break;
-       }
-    }
-
-    /* Program the NAND */
-    for (block = start_block, wPos = 0; wPos < nandWriterInfo.writeBytes; block++, wPos += nandWriterInfo.blockSizeBytes)
-    {
-        while(checkBadBlockMark(p_device, block))
-        {
-            printf ("Bad block # %d detected, skipping block ... \n", block);
-            if (++block == p_device->block_count)
-            {
-                printf ("Flash failed: End of device reached\n");
-                if (swap_byte) free (scrach_block);
-                return (FALSE);        
-            }
-        }
-
-        printf ("Flashing block %d (%d bytes of %d)\n", block, wPos, nandWriterInfo.writeBytes);
-
-       platform_device_erase_block(p_device->handle, block);
-
-        wLen = nandWriterInfo.blockSizeBytes;
-        if (nandWriterInfo.writeBytes - wPos < nandWriterInfo.blockSizeBytes)
-        {
-            wLen = nandWriterInfo.writeBytes - wPos;
-        }
-
-        if (swap_byte)
-        {
-            formBlock((uint32_t *)(&nandWriterInfo.writeData[wPos]), nandWriterInfo.blockSizeBytes, scrach_block);
-        }
-        else
-        {
-            scrach_block = &nandWriterInfo.writeData[wPos];
-        }
-        if (platform_device_write(p_device->handle, 
-                                  block*nandWriterInfo.blockSizeBytes, 
-                                  scrach_block, 
-                                  wLen) != Platform_EOK)
-        {
-            printf ("platform_device_write block # %d failed!\n", block);
-            print_platform_errno();
-            if (swap_byte) free (scrach_block);
-            return (FALSE);
-        }
-
-    }
-
-    if (swap_byte) free (scrach_block);
-    return (TRUE);
-}    
-
-/******************************************************************************
- * Function:    flash_verify
- *
- *              Read back the data file that was just flashed. On errors mark the block as bad.
- *              Returns TRUE if the image verified correctly.
- *                      FALSE if the image verification failed
- ******************************************************************************/
-Bool 
-flash_verify
-(
-    PLATFORM_DEVICE_info    *p_device
-)
-{
-    uint32_t      rPos, rLen;
-    uint32_t      i, j;
-    uint32_t      block, start_block;
-    uint8_t       *scrach_block;
-    uint32_t      *read_data_w;
-
-    if (swap_byte) 
-    {
-        scrach_block = malloc(nandWriterInfo.blockSizeBytes);
-        if (scrach_block == NULL)
-        {
-            printf ("Can not allocate scratch block memory!\n");
-            return (FALSE);
-        }
-    }
-
-    start_block = nandWriterInfo.startAddr / nandWriterInfo.blockSizeBytes;
-
-    for (block = start_block, rPos = 0; rPos < nandWriterInfo.writeBytes; block++, rPos += nandWriterInfo.blockSizeBytes)
-    {
-        while(checkBadBlockMark(p_device, block))
-        {
-            printf ("Bad block # %d detected, skipping block ... \n", block);
-            if (++block == p_device->block_count)
-            {
-                printf ("Flash failed: End of device reached\n");
-                if (swap_byte) free (scrach_block);
-                return (FALSE);        
-            }
-        }
-
-
-        printf ("Reading and verifying block %d (%d bytes of %d)\n", block, rPos, nandWriterInfo.writeBytes);
-
-        if (!swap_byte)
-        {
-            scrach_block = &nandWriterInfo.readData[rPos];
-
-        }
-
-        /* Read a block of data */
-        if(platform_device_read(p_device->handle, 
-                                block*nandWriterInfo.blockSizeBytes, 
-                                scrach_block,
-                                nandWriterInfo.blockSizeBytes) != Platform_EOK)
-        {
-            printf ("Failure in reading block %d\n", block);
-            print_platform_errno();
-            if (platform_errno == PLATFORM_ERRNO_ECC_FAIL)
-            {
-                printf ("marking block %d as bad, re-flash attempted\n", block);
-                markBlockBad (p_device, block);
-            }
-            if (swap_byte) free (scrach_block);
-            return (FALSE);
-        }
-
-        /* Convert the packed data */
-        if (swap_byte)
-        {
-            read_data_w = (uint32_t *)(&nandWriterInfo.readData[rPos]);
-            for  (i = 0, j = 0; i < nandWriterInfo.blockSizeBytes; i += 4)
-                read_data_w[j++] = (scrach_block[i+0] << 24) | (scrach_block[i+1] << 16) | (scrach_block[i+2] << 8) | scrach_block[i+3];
-        }
-
-        rLen = nandWriterInfo.blockSizeBytes;
-        if (nandWriterInfo.writeBytes - rPos < nandWriterInfo.blockSizeBytes)
-        {
-            rLen = nandWriterInfo.writeBytes - rPos;
-        }
-
-        /* Compare the data read with data programmed */
-        for (i = rPos; i < rLen; i++)
-        {
-            if (nandWriterInfo.readData[i] != nandWriterInfo.writeData[i])
-            {
-                printf ("Failure in block %d, at byte %d, (at byte %d in the data file) expected 0x%08x, read 0x%08x\n", 
-                        block, i, rPos, nandWriterInfo.writeData[i], nandWriterInfo.readData[i]);
-                if (swap_byte) free (scrach_block);
-                return (FALSE);
-            }
-        }
-
-    }
-
-    if (swap_byte) free (scrach_block);
-    return (TRUE);
-}
-
-/******************************************************************************
- * Function:    parse_input_file  
- ******************************************************************************/
-static Bool
-parse_input_file
-(
-    FILE*               fp
-)
-{
-    char line[MAX_LINE_LENGTH];
-    char tokens[] = " :=;\n\r";
-    char *key, *data;
-
-    memset(line, 0, MAX_LINE_LENGTH);
-
-    fgets(line, MAX_LINE_LENGTH, fp);
-    key  = (char *)strtok(line, tokens);
-    data = (char *)strtok(NULL, tokens);
-
-    if(strlen(data) == 0)
-    {
-       return FALSE;
-    }
-
-    if(strcmp(key, FILE_NAME) != 0)
-    {
-        return FALSE;
-    }
-
-    strcpy (nandWriterInfo.file_name, data);
-
-    fgets(line, MAX_LINE_LENGTH, fp);
-    key  = (char *)strtok(line, tokens);
-    data = (char *)strtok(NULL, tokens);
-
-    if(strlen(data) == 0)
-    {
-       return FALSE;
-    }
-
-    if(strcmp(key, START_ADDR) != 0)
-    {
-        return FALSE;
-    }
-
-    nandWriterInfo.startAddr = (uint32_t)atoi(data);
-    
-    fgets(line, MAX_LINE_LENGTH, fp);
-    key = (char *)strtok(line, tokens);
-    data = (char *)strtok(NULL, tokens);
-    
-    if(strlen(data) != 0 && (strcmp(key, RBL_ECC) == 0))
-    {
-        nandWriterInfo.flags = (uint8_t)atoi(data);
-    }
-    else
-    {
-        nandWriterInfo.flags = 0;
-    }
-
-    /* Scan skip bad block input parameter */
-    fgets(line, MAX_LINE_LENGTH, fp);
-    key = (char *)strtok(line, tokens);
-    data = (char *)strtok(NULL, tokens);
-
-    if(strlen(data) != 0 && (strcmp(key, SKIP_BAD) == 0))
-    {
-        nandWriterInfo.skip_bad_blks = (uint8_t)atoi(data);
-    }
-    else
-    {
-        nandWriterInfo.skip_bad_blks = 0;
-    }
-
-    return TRUE;
-}
-
-/******************************************************************************
- * Function:    find_file_length
- ******************************************************************************/
-static Bool
-find_file_length
-(
-    FILE*               fp
-)
-{
-    char        line[MAX_LINE_LENGTH];
-    char        *pEnd;
-    char        *ext;
-    uint32_t    data_len, write_addr;
-
-    memset(line, 0, MAX_LINE_LENGTH);
-
-    ext = strrchr(nandWriterInfo.file_name, '.');
-    if (ext && (strcmp(ext, ".dat") == 0))
-    {
-    fgets(line, MAX_LINE_LENGTH, fp);
-
-    /* Read the write address from the CCS header */
-    strtoul (line,&pEnd,16);
-    strtoul (pEnd,&pEnd,16);
-    write_addr = strtoul (pEnd,&pEnd,16);
-    strtoul (pEnd,&pEnd,16);
-
-    /* Read the data length */
-    data_len = (strtoul (pEnd,NULL,16)) * 4;
-    }
-    else
-    {
-        /* find the data length by seeking to the end and getting position */
-        fseek(fp, 0, SEEK_END);
-        data_len = ftell(fp);
-        fseek(fp, 0, SEEK_SET);
-    }
-
-    if (data_len > (nandWriterInfo.deviceTotalBytes - nandWriterInfo.startAddr))
-    {
-        printf ("The data file is too big to fit into the device.\n");
-        return FALSE;
-    }
-
-    nandWriterInfo.writeBytes = data_len;
-    if (write_addr != WRITE_DATA_ADDRESS)
-        write_addr = WRITE_DATA_ADDRESS;
-    nandWriterInfo.writeData  = (uint8_t *)write_addr;
-    nandWriterInfo.readData   = (uint8_t *)(write_addr + nandWriterInfo.deviceTotalBytes);
-
-    return TRUE;
-}
-
-static Bool 
-nand_erase_all_blks(PLATFORM_DEVICE_info *p_device)
-{
-  uint32_t block;
-  uint32_t max_blks;
-
-  max_blks = p_device->block_count;
-  
-  for (block=0; block<max_blks;block++)
-  {
-      printf (".");
-      if (platform_device_erase_block(p_device->handle, block) != Platform_EOK)
-        return FALSE;
-  }
-
-  printf ("\nFormatted %d nand blocks \n", block);
-  return (TRUE);
-}
-
-/******************************************************************************
- * Function:    main  
- ******************************************************************************/
-void main ()
-{
-    FILE                    *fp;
-    platform_init_flags     init_flags;
-    platform_init_config    init_config;
-    PLATFORM_DEVICE_info    *p_device;
-    Bool                    ret;
-    uint32_t                rCount;
-    printf("NAND Writer Utility Version %s\n\n", version);
-
-    fp = fopen(input_file, "r");
-    if (fp == NULL)
-    {
-        printf("Error in opening %s input file\n", input_file);
-        return;
-    }
-
-    ret = parse_input_file(fp);
-    fclose (fp);
-
-    if (ret == FALSE)
-    {
-        printf("Error in parsing %s input file\n", input_file);
-        return;
-    }
-
-    /* Initialize main Platform lib */
-    memset(&init_config, 0, sizeof(platform_init_config));
-    memset(&init_flags, 1, sizeof(platform_init_flags));
-    init_flags.pll = 0;
-    init_flags.ddr = 0;
-    init_flags.phy =0;
-    if (platform_init(&init_flags, &init_config) != Platform_EOK)
-    {
-        printf ("Platform init failed!\n");
-        print_platform_errno();
-        return;
-    }
-#if (defined(_EVMC6657L_) || defined(DEVICE_K2H))
-     p_device = platform_device_open(PLATFORM_DEVID_MT29F1G08ABCHC, nandWriterInfo.flags);
-#elif defined(DEVICE_K2E)
-     p_device = platform_device_open(PLATFORM_DEVID_MT29F4G08ABADA, nandWriterInfo.flags);
-#elif defined(DEVICE_K2L)
-     p_device = platform_device_open(PLATFORM_DEVID_MT29F16G08ADBCAH4C, nandWriterInfo.flags);
-#elif defined(DEVICE_K2G)
-     p_device = platform_device_open(PLATFORM_DEVID_MT29F2G16ABAFA, nandWriterInfo.flags);
-#else
-    p_device = platform_device_open(PLATFORM_DEVID_NAND512R3A2D, 0);
-#endif
-    if (p_device == NULL) 
-    {
-        printf ("NAND device open failed!\n");
-        print_platform_errno();
-        return;
-    }
-    nandWriterInfo.deviceTotalBytes = p_device->block_count * p_device->page_count * p_device->page_size;
-    nandWriterInfo.blockSizeBytes   = p_device->page_count * p_device->page_size;
-
-    if ((nandWriterInfo.startAddr % nandWriterInfo.blockSizeBytes) != 0)
-    {
-        printf ("The start programming address 0x%8x set in %s is not at the beginning of a block, block size = 0x%4x\n", 
-                nandWriterInfo.startAddr, 
-                nandWriterInfo.file_name,
-                nandWriterInfo.blockSizeBytes);
-        return;
-    }
-
-    /* Check if we need to erase the nand completely */
-     if (nand_erase_flag == 0x12345678)
-     {
-        if (nand_erase_all_blks(p_device) == FALSE)
-        {
-           printf ("Formatting all nand blocks - failed \n");
-        }
-        else
-        {
-           printf ("Formatting all nand blocks - Successful\n");
-        }
-        platform_device_close(p_device->handle);
-        /* Operation Complete */
-        return;
-     }
-
-    /* Open and find the length of the data file */
-    fp = fopen (nandWriterInfo.file_name, "rb");
-    if (fp == NULL)
-    {
-      printf ("Failed to open file %s\n", nandWriterInfo.file_name);
-      platform_device_close(p_device->handle);
-      return;
-    }
-
-    /* Parse the CCS format file */
-    ret = find_file_length(fp);
-    fclose (fp);
-    if (ret == FALSE)
-    {
-        printf("Error in parsing CCS file %s\n", nandWriterInfo.file_name);
-        platform_device_close(p_device->handle);
-        return;
-    }
-    
-    /* Write the flash, verify the results. On read back failure mark
-     * the block as bad and try rewriting again */
-    rCount = 0;
-
-    do  
-    {
-        if (flash_nand (p_device) == FALSE)
-        {
-            printf ("NAND write giving up\n");
-            return;
-        }
-
-        rCount += 1;
-
-    }  while ((flash_verify (p_device) == FALSE) && (rCount < 5));
-
-    
-    if (rCount >= 5) 
-    {
-        printf ("NAND write failed (maximum retries reached)\n");
-    }
-    else
-    {
-        printf ("NAND programming completed successfully\n");
-    }
-
-    platform_device_close(p_device->handle);
-    
-    return;
-}
-
-
-
-
+/*\r
+ * Copyright (c) 2011-2015, Texas Instruments Incorporated\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ * *  Redistributions of source code must retain the above copyright\r
+ *    notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * *  Redistributions in binary form must reproduce the above copyright\r
+ *    notice, this list of conditions and the following disclaimer in the\r
+ *    documentation and/or other materials provided with the distribution.\r
+ *\r
+ * *  Neither the name of Texas Instruments Incorporated nor the names of\r
+ *    its contributors may be used to endorse or promote products derived\r
+ *    from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ */\r
+\r
+/**************************************************************************************\r
+ * FILE PURPOSE: NAND writer utility\r
+ **************************************************************************************\r
+ * FILE NAME: nandwriter.c\r
+ *\r
+ * DESCRIPTION: A simple nand writer using platform lib APIs to program the NAND flash\r
+ *              with an image that the ibl can read.\r
+ *\r
+ ***************************************************************************************/\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include "platform.h"\r
+#include "types.h"\r
+\r
+/* NAND writer utility version */\r
+char version[] = "01.00.00.05";\r
+\r
+/* The input file name is hard coded */\r
+char *input_file = "nand_writer_input.txt";\r
+\r
+uint32_t swap_byte = 0;\r
+volatile uint32_t nand_erase_flag = 0;\r
+\r
+/* Parameters defined in the input_file */\r
+#define FILE_NAME      "file_name"\r
+#define START_ADDR     "start_addr"\r
+#define RBL_ECC        "rbl_ecc"\r
+#define SKIP_BAD       "skip_bad"\r
+\r
+/* Memory address to store the write data */\r
+#define WRITE_DATA_ADDRESS     0x80000000\r
+\r
+/* NAND device specific definitions */\r
+#define BAD_BLOCK_MARKER_VALUE  0xA5\r
+\r
+/******************************************************************************\r
+ * Structure:   NAND_WRITER_INFO_T\r
+ *\r
+ *              NAND writer control data. This structure should be filled in\r
+ *              by the user before running\r
+ ******************************************************************************/\r
+#define MAX_LINE_LENGTH 40\r
+typedef struct NAND_WRITER_INFO_tag\r
+{\r
+    char        file_name[MAX_LINE_LENGTH]; /* CCS format data file name */\r
+    uint32_t    blockSizeBytes;             /* The size of each sector */\r
+    uint32_t    deviceTotalBytes;           /* Total number of bytes available in the device */\r
+    uint32_t    startAddr;                  /* Start address to write */\r
+    uint32_t    writeBytes;                 /* Number of bytes to be written into the device */\r
+    uint8_t     flags;                      /* Flag used for EVMK2H for multiple ECC formats */\r
+    uint8_t     skip_bad_blks;              /* Flag used to skip bad blocks */\r
+    uint8_t     *writeData;                 /* Address to store the write data */\r
+    uint8_t     *readData;                  /* Address to store the read data */\r
+\r
+} NAND_WRITER_INFO_T;\r
+\r
+NAND_WRITER_INFO_T nandWriterInfo;\r
+\r
+/* OSAL functions for Platform Library */\r
+uint8_t *Osal_platformMalloc (uint32_t num_bytes, uint32_t alignment)\r
+{\r
+       return malloc(num_bytes);\r
+}\r
+\r
+void Osal_platformFree (uint8_t *dataPtr, uint32_t num_bytes)\r
+{\r
+    /* Free up the memory */\r
+    if (dataPtr)\r
+    {\r
+        free(dataPtr);\r
+    }\r
+}\r
+\r
+void Osal_platformSpiCsEnter(void)\r
+{\r
+    return;\r
+}\r
+\r
+void Osal_platformSpiCsExit (void)\r
+{\r
+    return;\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    print_platform_errno\r
+ ******************************************************************************/\r
+void\r
+print_platform_errno\r
+(\r
+    void\r
+)\r
+{\r
+    printf ("Returned platform error number is %d\n", platform_errno);\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    checkBadBlockMark\r
+ *\r
+ *              Checks for the bad block mark. Returns TRUE if a block is marked bad.\r
+ ******************************************************************************/\r
+Bool\r
+checkBadBlockMark \r
+(\r
+    PLATFORM_DEVICE_info    *p_device,\r
+    uint32_t                  block\r
+)\r
+{\r
+    if (p_device->bblist[block] != 0xff)\r
+    {\r
+        return TRUE;\r
+    }\r
+    else\r
+    {\r
+        return FALSE;\r
+    }\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    markBlockBad\r
+ *\r
+ *              Mark a block as bad. Byte 5 of the spare area data is\r
+ *              written as 0xA5.\r
+ ******************************************************************************/\r
+void \r
+markBlockBad \r
+(\r
+    PLATFORM_DEVICE_info        *p_device,\r
+    uint32_t                    block\r
+)\r
+{\r
+    uint8_t       *spare_data;\r
+\r
+    spare_data = malloc(p_device->spare_size);\r
+    if (spare_data == NULL)\r
+    {\r
+        printf ("Can not allocate spare_data memory!\n");\r
+        return;\r
+    }\r
+\r
+    platform_device_read_spare_data(p_device->handle, block, 0, spare_data);\r
+\r
+    /* Set all data bytes to 0xff, only set the user defined bad block mark value */\r
+    spare_data[p_device->bboffset] = BAD_BLOCK_MARKER_VALUE;\r
+\r
+    /* Write the data to page */\r
+    platform_device_write_spare_data(p_device->handle, block, 0, spare_data);\r
+\r
+    /* Save the user defined bad block mark in bblist */\r
+    p_device->bblist[block] = BAD_BLOCK_MARKER_VALUE;\r
+\r
+    free (spare_data);\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    formBlock\r
+ *\r
+ *      Form a block of data to write to the NAND. The block is\r
+ *      created as a byte stream from the 4 byte stream in which\r
+ *      the MSB is always sent first.\r
+ ******************************************************************************/\r
+void\r
+formBlock\r
+(\r
+    uint32_t      *data,\r
+    uint32_t      blockSize,\r
+    uint8_t       *scratch\r
+)\r
+{\r
+    uint32_t i, j;\r
+\r
+    /* Convert the data to a byte stream */\r
+    for (i = j = 0; j < blockSize; i++, j+=4)\r
+    {\r
+        scratch[j+0] = (data[i] >> 24) & 0xff;\r
+        scratch[j+1] = (data[i] >> 16) & 0xff;\r
+        scratch[j+2] = (data[i] >>  8) & 0xff;\r
+        scratch[j+3] = (data[i] >>  0) & 0xff;\r
+    }\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    flash_nand\r
+ *\r
+ *              Write the image to flash.\r
+ *              Returns TRUE if the image is written successfully\r
+ *                      FALSE if the image write fails\r
+ ******************************************************************************/\r
+Bool \r
+flash_nand\r
+(\r
+    PLATFORM_DEVICE_info    *p_device\r
+)\r
+{\r
+    uint32_t      wPos, wLen;\r
+    uint32_t      block, start_block;\r
+    uint8_t       *scrach_block;\r
+    uint32_t      num_blks;\r
+    uint32_t      bad_block_found;\r
+\r
+    if (swap_byte)\r
+    {\r
+        scrach_block = malloc(nandWriterInfo.blockSizeBytes);\r
+        if (scrach_block == NULL)\r
+        {\r
+            printf ("Can not allocate scratch block memory!\n");\r
+            return (FALSE);\r
+        }\r
+    }\r
+\r
+    start_block = nandWriterInfo.startAddr / nandWriterInfo.blockSizeBytes;\r
+\r
+    /* skip the bad blocks if the flag is set */\r
+    if (nandWriterInfo.skip_bad_blks)\r
+    {\r
+       num_blks = nandWriterInfo.writeBytes / nandWriterInfo.blockSizeBytes;\r
+       if ((nandWriterInfo.writeBytes - nandWriterInfo.blockSizeBytes * num_blks) > 0)\r
+               num_blks++;\r
+\r
+       while (TRUE)\r
+       {\r
+               bad_block_found = FALSE;\r
+               for (block = start_block; block < start_block + num_blks; block++)\r
+               {\r
+                       if (checkBadBlockMark(p_device, block))\r
+                       {\r
+                               start_block = block + 1;\r
+                               bad_block_found = TRUE;\r
+                               break;\r
+                       }\r
+               }\r
+               if (bad_block_found == FALSE)\r
+                       break;\r
+       }\r
+    }\r
+\r
+    /* Program the NAND */\r
+    for (block = start_block, wPos = 0; wPos < nandWriterInfo.writeBytes; block++, wPos += nandWriterInfo.blockSizeBytes)\r
+    {\r
+        while(checkBadBlockMark(p_device, block))\r
+        {\r
+            printf ("Bad block # %d detected, skipping block ... \n", block);\r
+            if (++block == p_device->block_count)\r
+            {\r
+                printf ("Flash failed: End of device reached\n");\r
+                if (swap_byte) free (scrach_block);\r
+                return (FALSE);        \r
+            }\r
+        }\r
+\r
+        printf ("Flashing block %d (%d bytes of %d)\n", block, wPos, nandWriterInfo.writeBytes);\r
+\r
+       platform_device_erase_block(p_device->handle, block);\r
+\r
+        wLen = nandWriterInfo.blockSizeBytes;\r
+        if (nandWriterInfo.writeBytes - wPos < nandWriterInfo.blockSizeBytes)\r
+        {\r
+            wLen = nandWriterInfo.writeBytes - wPos;\r
+        }\r
+\r
+        if (swap_byte)\r
+        {\r
+            formBlock((uint32_t *)(&nandWriterInfo.writeData[wPos]), nandWriterInfo.blockSizeBytes, scrach_block);\r
+        }\r
+        else\r
+        {\r
+            scrach_block = &nandWriterInfo.writeData[wPos];\r
+        }\r
+        if (platform_device_write(p_device->handle, \r
+                                  block*nandWriterInfo.blockSizeBytes, \r
+                                  scrach_block, \r
+                                  wLen) != Platform_EOK)\r
+        {\r
+            printf ("platform_device_write block # %d failed!\n", block);\r
+            print_platform_errno();\r
+            if (swap_byte) free (scrach_block);\r
+            return (FALSE);\r
+        }\r
+\r
+    }\r
+\r
+    if (swap_byte) free (scrach_block);\r
+    return (TRUE);\r
+}    \r
+\r
+/******************************************************************************\r
+ * Function:    flash_verify\r
+ *\r
+ *              Read back the data file that was just flashed. On errors mark the block as bad.\r
+ *              Returns TRUE if the image verified correctly.\r
+ *                      FALSE if the image verification failed\r
+ ******************************************************************************/\r
+Bool \r
+flash_verify\r
+(\r
+    PLATFORM_DEVICE_info    *p_device\r
+)\r
+{\r
+    uint32_t      rPos, rLen;\r
+    uint32_t      i, j;\r
+    uint32_t      block, start_block;\r
+    uint8_t       *scrach_block;\r
+    uint32_t      *read_data_w;\r
+\r
+    if (swap_byte) \r
+    {\r
+        scrach_block = malloc(nandWriterInfo.blockSizeBytes);\r
+        if (scrach_block == NULL)\r
+        {\r
+            printf ("Can not allocate scratch block memory!\n");\r
+            return (FALSE);\r
+        }\r
+    }\r
+\r
+    start_block = nandWriterInfo.startAddr / nandWriterInfo.blockSizeBytes;\r
+\r
+    for (block = start_block, rPos = 0; rPos < nandWriterInfo.writeBytes; block++, rPos += nandWriterInfo.blockSizeBytes)\r
+    {\r
+        while(checkBadBlockMark(p_device, block))\r
+        {\r
+            printf ("Bad block # %d detected, skipping block ... \n", block);\r
+            if (++block == p_device->block_count)\r
+            {\r
+                printf ("Flash failed: End of device reached\n");\r
+                if (swap_byte) free (scrach_block);\r
+                return (FALSE);        \r
+            }\r
+        }\r
+\r
+\r
+        printf ("Reading and verifying block %d (%d bytes of %d)\n", block, rPos, nandWriterInfo.writeBytes);\r
+\r
+        if (!swap_byte)\r
+        {\r
+            scrach_block = &nandWriterInfo.readData[rPos];\r
+\r
+        }\r
+\r
+        /* Read a block of data */\r
+        if(platform_device_read(p_device->handle, \r
+                                block*nandWriterInfo.blockSizeBytes, \r
+                                scrach_block,\r
+                                nandWriterInfo.blockSizeBytes) != Platform_EOK)\r
+        {\r
+            printf ("Failure in reading block %d\n", block);\r
+            print_platform_errno();\r
+            if (platform_errno == PLATFORM_ERRNO_ECC_FAIL)\r
+            {\r
+                printf ("marking block %d as bad, re-flash attempted\n", block);\r
+                markBlockBad (p_device, block);\r
+            }\r
+            if (swap_byte) free (scrach_block);\r
+            return (FALSE);\r
+        }\r
+\r
+        /* Convert the packed data */\r
+        if (swap_byte)\r
+        {\r
+            read_data_w = (uint32_t *)(&nandWriterInfo.readData[rPos]);\r
+            for  (i = 0, j = 0; i < nandWriterInfo.blockSizeBytes; i += 4)\r
+                read_data_w[j++] = (scrach_block[i+0] << 24) | (scrach_block[i+1] << 16) | (scrach_block[i+2] << 8) | scrach_block[i+3];\r
+        }\r
+\r
+        rLen = nandWriterInfo.blockSizeBytes;\r
+        if (nandWriterInfo.writeBytes - rPos < nandWriterInfo.blockSizeBytes)\r
+        {\r
+            rLen = nandWriterInfo.writeBytes - rPos;\r
+        }\r
+\r
+        /* Compare the data read with data programmed */\r
+        for (i = rPos; i < rLen; i++)\r
+        {\r
+            if (nandWriterInfo.readData[i] != nandWriterInfo.writeData[i])\r
+            {\r
+                printf ("Failure in block %d, at byte %d, (at byte %d in the data file) expected 0x%08x, read 0x%08x\n", \r
+                        block, i, rPos, nandWriterInfo.writeData[i], nandWriterInfo.readData[i]);\r
+                if (swap_byte) free (scrach_block);\r
+                return (FALSE);\r
+            }\r
+        }\r
+\r
+    }\r
+\r
+    if (swap_byte) free (scrach_block);\r
+    return (TRUE);\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    parse_input_file  \r
+ ******************************************************************************/\r
+static Bool\r
+parse_input_file\r
+(\r
+    FILE*               fp\r
+)\r
+{\r
+    char line[MAX_LINE_LENGTH];\r
+    char tokens[] = " :=;\n\r";\r
+    char *key, *data;\r
+\r
+    memset(line, 0, MAX_LINE_LENGTH);\r
+\r
+    fgets(line, MAX_LINE_LENGTH, fp);\r
+    key  = (char *)strtok(line, tokens);\r
+    data = (char *)strtok(NULL, tokens);\r
+\r
+    if(strlen(data) == 0)\r
+    {\r
+       return FALSE;\r
+    }\r
+\r
+    if(strcmp(key, FILE_NAME) != 0)\r
+    {\r
+        return FALSE;\r
+    }\r
+\r
+    strcpy (nandWriterInfo.file_name, data);\r
+\r
+    fgets(line, MAX_LINE_LENGTH, fp);\r
+    key  = (char *)strtok(line, tokens);\r
+    data = (char *)strtok(NULL, tokens);\r
+\r
+    if(strlen(data) == 0)\r
+    {\r
+       return FALSE;\r
+    }\r
+\r
+    if(strcmp(key, START_ADDR) != 0)\r
+    {\r
+        return FALSE;\r
+    }\r
+\r
+    nandWriterInfo.startAddr = (uint32_t)atoi(data);\r
+    \r
+    fgets(line, MAX_LINE_LENGTH, fp);\r
+    key = (char *)strtok(line, tokens);\r
+    data = (char *)strtok(NULL, tokens);\r
+    \r
+    if(strlen(data) != 0 && (strcmp(key, RBL_ECC) == 0))\r
+    {\r
+        nandWriterInfo.flags = (uint8_t)atoi(data);\r
+    }\r
+    else\r
+    {\r
+        nandWriterInfo.flags = 0;\r
+    }\r
+\r
+    /* Scan skip bad block input parameter */\r
+    fgets(line, MAX_LINE_LENGTH, fp);\r
+    key = (char *)strtok(line, tokens);\r
+    data = (char *)strtok(NULL, tokens);\r
+\r
+    if(strlen(data) != 0 && (strcmp(key, SKIP_BAD) == 0))\r
+    {\r
+        nandWriterInfo.skip_bad_blks = (uint8_t)atoi(data);\r
+    }\r
+    else\r
+    {\r
+        nandWriterInfo.skip_bad_blks = 0;\r
+    }\r
+\r
+    return TRUE;\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    find_file_length\r
+ ******************************************************************************/\r
+static Bool\r
+find_file_length\r
+(\r
+    FILE*               fp\r
+)\r
+{\r
+    char        line[MAX_LINE_LENGTH];\r
+    char        *pEnd;\r
+    char        *ext;\r
+    uint32_t    data_len, write_addr;\r
+\r
+    memset(line, 0, MAX_LINE_LENGTH);\r
+\r
+    ext = strrchr(nandWriterInfo.file_name, '.');\r
+    if (ext && (strcmp(ext, ".dat") == 0))\r
+    {\r
+    fgets(line, MAX_LINE_LENGTH, fp);\r
+\r
+    /* Read the write address from the CCS header */\r
+    strtoul (line,&pEnd,16);\r
+    strtoul (pEnd,&pEnd,16);\r
+    write_addr = strtoul (pEnd,&pEnd,16);\r
+    strtoul (pEnd,&pEnd,16);\r
+\r
+    /* Read the data length */\r
+    data_len = (strtoul (pEnd,NULL,16)) * 4;\r
+    }\r
+    else\r
+    {\r
+        /* find the data length by seeking to the end and getting position */\r
+        fseek(fp, 0, SEEK_END);\r
+        data_len = ftell(fp);\r
+        fseek(fp, 0, SEEK_SET);\r
+    }\r
+\r
+    if (data_len > (nandWriterInfo.deviceTotalBytes - nandWriterInfo.startAddr))\r
+    {\r
+        printf ("The data file is too big to fit into the device.\n");\r
+        return FALSE;\r
+    }\r
+\r
+    nandWriterInfo.writeBytes = data_len;\r
+    if (write_addr != WRITE_DATA_ADDRESS)\r
+        write_addr = WRITE_DATA_ADDRESS;\r
+    nandWriterInfo.writeData  = (uint8_t *)write_addr;\r
+    nandWriterInfo.readData   = (uint8_t *)(write_addr + nandWriterInfo.deviceTotalBytes);\r
+\r
+    return TRUE;\r
+}\r
+\r
+static Bool \r
+nand_erase_all_blks(PLATFORM_DEVICE_info *p_device)\r
+{\r
+  uint32_t block;\r
+  uint32_t max_blks;\r
+\r
+  max_blks = p_device->block_count;\r
+  \r
+  for (block=0; block<max_blks;block++)\r
+  {\r
+      printf (".");\r
+      if (platform_device_erase_block(p_device->handle, block) != Platform_EOK)\r
+        return FALSE;\r
+  }\r
+\r
+  printf ("\nFormatted %d nand blocks \n", block);\r
+  return (TRUE);\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    main  \r
+ ******************************************************************************/\r
+void main ()\r
+{\r
+    FILE                    *fp;\r
+    platform_init_flags     init_flags;\r
+    platform_init_config    init_config;\r
+    PLATFORM_DEVICE_info    *p_device;\r
+    Bool                    ret;\r
+    uint32_t                rCount;\r
+    printf("NAND Writer Utility Version %s\n\n", version);\r
+\r
+    fp = fopen(input_file, "r");\r
+    if (fp == NULL)\r
+    {\r
+        printf("Error in opening %s input file\n", input_file);\r
+        return;\r
+    }\r
+\r
+    ret = parse_input_file(fp);\r
+    fclose (fp);\r
+\r
+    if (ret == FALSE)\r
+    {\r
+        printf("Error in parsing %s input file\n", input_file);\r
+        return;\r
+    }\r
+\r
+    /* Initialize main Platform lib */\r
+    memset(&init_config, 0, sizeof(platform_init_config));\r
+    memset(&init_flags, 1, sizeof(platform_init_flags));\r
+    init_flags.pll = 0;\r
+    init_flags.ddr = 0;\r
+    init_flags.phy =0;\r
+    if (platform_init(&init_flags, &init_config) != Platform_EOK)\r
+    {\r
+        printf ("Platform init failed!\n");\r
+        print_platform_errno();\r
+        return;\r
+    }\r
+#if (defined(_EVMC6657L_) || defined(DEVICE_K2H))\r
+     p_device = platform_device_open(PLATFORM_DEVID_MT29F1G08ABCHC, nandWriterInfo.flags);\r
+#elif defined(DEVICE_K2E)\r
+     p_device = platform_device_open(PLATFORM_DEVID_MT29F4G08ABADA, nandWriterInfo.flags);\r
+#elif defined(DEVICE_K2L)\r
+     p_device = platform_device_open(PLATFORM_DEVID_MT29F16G08ADBCAH4C, nandWriterInfo.flags);\r
+#elif defined(DEVICE_K2G)\r
+     p_device = platform_device_open(PLATFORM_DEVID_MT29F2G16ABAFA, nandWriterInfo.flags);\r
+#else\r
+    p_device = platform_device_open(PLATFORM_DEVID_NAND512R3A2D, 0);\r
+#endif\r
+    if (p_device == NULL) \r
+    {\r
+        printf ("NAND device open failed!\n");\r
+        print_platform_errno();\r
+        return;\r
+    }\r
+    nandWriterInfo.deviceTotalBytes = p_device->block_count * p_device->page_count * p_device->page_size;\r
+    nandWriterInfo.blockSizeBytes   = p_device->page_count * p_device->page_size;\r
+\r
+    if ((nandWriterInfo.startAddr % nandWriterInfo.blockSizeBytes) != 0)\r
+    {\r
+        printf ("The start programming address 0x%8x set in %s is not at the beginning of a block, block size = 0x%4x\n", \r
+                nandWriterInfo.startAddr, \r
+                nandWriterInfo.file_name,\r
+                nandWriterInfo.blockSizeBytes);\r
+        return;\r
+    }\r
+\r
+    /* Check if we need to erase the nand completely */\r
+     if (nand_erase_flag == 0x12345678)\r
+     {\r
+        if (nand_erase_all_blks(p_device) == FALSE)\r
+        {\r
+           printf ("Formatting all nand blocks - failed \n");\r
+        }\r
+        else\r
+        {\r
+           printf ("Formatting all nand blocks - Successful\n");\r
+        }\r
+        platform_device_close(p_device->handle);\r
+        /* Operation Complete */\r
+        return;\r
+     }\r
+\r
+    /* Open and find the length of the data file */\r
+    fp = fopen (nandWriterInfo.file_name, "rb");\r
+    if (fp == NULL)\r
+    {\r
+      printf ("Failed to open file %s\n", nandWriterInfo.file_name);\r
+      platform_device_close(p_device->handle);\r
+      return;\r
+    }\r
+\r
+    /* Parse the CCS format file */\r
+    ret = find_file_length(fp);\r
+    fclose (fp);\r
+    if (ret == FALSE)\r
+    {\r
+        printf("Error in parsing CCS file %s\n", nandWriterInfo.file_name);\r
+        platform_device_close(p_device->handle);\r
+        return;\r
+    }\r
+    \r
+    /* Write the flash, verify the results. On read back failure mark\r
+     * the block as bad and try rewriting again */\r
+    rCount = 0;\r
+\r
+    do  \r
+    {\r
+        if (flash_nand (p_device) == FALSE)\r
+        {\r
+            printf ("NAND write giving up\n");\r
+            return;\r
+        }\r
+\r
+        rCount += 1;\r
+\r
+    }  while ((flash_verify (p_device) == FALSE) && (rCount < 5));\r
+\r
+    \r
+    if (rCount >= 5) \r
+    {\r
+        printf ("NAND write failed (maximum retries reached)\n");\r
+    }\r
+    else\r
+    {\r
+        printf ("NAND programming completed successfully\n");\r
+    }\r
+\r
+    platform_device_close(p_device->handle);\r
+    \r
+    return;\r
+}\r
+\r
+\r
+\r
+\r
index acbacd5b97fe45ea551651246a33d9cfde3fa5ef..52673aff5f2d95a9938186f51686b463346b0362 100644 (file)
                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">\r
                                <configuration artifactExtension="out" artifactName="../bin/norwriter_evmk2g" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" errorParsers="com.ti.ccstudio.errorparser.LinkErrorParser;com.ti.ccstudio.errorparser.CoffErrorParser;com.ti.ccstudio.errorparser.AsmErrorParser" id="com.ti.ccstudio.buildDefinitions.C6000.Debug.1869204513.1038725656" name="Debug" parent="com.ti.ccstudio.buildDefinitions.C6000.Debug">\r
                                        <folderInfo id="com.ti.ccstudio.buildDefinitions.C6000.Debug.1869204513.1038725656." name="/" resourcePath="">\r
-                                               <toolChain id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain.1715456997" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.887471279">\r
-                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.925227249" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">\r
+                                               <toolChain id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain.606039415" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.821528841">\r
+                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.234836940" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">\r
                                                                <listOptionValue builtIn="false" value="DEVICE_CONFIGURATION_ID=com.ti.ccstudio.deviceModel.C6000.CustomC6000Device"/>\r
                                                                <listOptionValue builtIn="false" value="DEVICE_ENDIANNESS=little"/>\r
                                                                <listOptionValue builtIn="false" value="OUTPUT_FORMAT=ELF"/>\r
                                                                <listOptionValue builtIn="false" value="CCS_MBS_VERSION=5.5.0"/>\r
                                                                <listOptionValue builtIn="false" value="LINKER_COMMAND_FILE=norwriter.cmd"/>\r
                                                                <listOptionValue builtIn="false" value="RUNTIME_SUPPORT_LIBRARY=libc.a"/>\r
-                                                               <listOptionValue builtIn="false" value="RTSC_PRODUCTS=ti.pdk:3.1.1.04;"/>\r
+                                                               <listOptionValue builtIn="false" value="RTSC_PRODUCTS=ti.pdk:3.2.0.00;"/>\r
                                                                <listOptionValue builtIn="false" value="OUTPUT_TYPE=rtscApplication:executable"/>\r
                                                        </option>\r
-                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.1256287207" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="7.4.2" valueType="string"/>\r
-                                                       <targetPlatform id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug.126999959" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug"/>\r
-                                                       <builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug.1214958731" keepEnvironmentInBuildfile="false" name="GNU Make" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug"/>\r
-                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug.1831004393" name="C6000 Compiler" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug">\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION.1961617285" name="Target processor version (--silicon_version, -mv)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION" value="6600" valueType="string"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.1541549737" name="Debugging model" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH.1452476872" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH" valueType="includePath">\r
+                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.1561689798" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="7.4.4" valueType="string"/>\r
+                                                       <targetPlatform id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug.1590632800" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug"/>\r
+                                                       <builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug.2056892774" name="GNU Make.Debug" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug"/>\r
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug.466446350" name="C6000 Compiler" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION.1435527510" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION" value="6600" valueType="string"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.1289396343" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.eabi" valueType="enumerated"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.1450947320" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH.1718319555" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH" valueType="includePath">\r
                                                                        <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${TI_PDK_INSTALL_DIR}/packages/ti/platform&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${TI_PDK_INSTALL_DIR}/packages&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${PROJECT_ROOT}/../include&quot;"/>\r
                                                                </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER.1401337456" name="Emit diagnostic identifier numbers (--display_error_number, -pden)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING.1261743708" name="Treat diagnostic &lt;id&gt; as warning (--diag_warning, -pdsw)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING" valueType="stringList">\r
-                                                                       <listOptionValue builtIn="false" value="225"/>\r
-                                                               </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.871932654" name="Application binary interface (coffabi, eabi) [See 'General' page to edit] (--abi)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.eabi" valueType="enumerated"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEFINE.1107274157" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEFINE" valueType="definedSymbols">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEFINE.1696076075" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEFINE" valueType="definedSymbols">\r
                                                                        <listOptionValue builtIn="false" value="DEVICE_K2G"/>\r
                                                                </option>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS.176625496" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS.965820505" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS.352604096" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS.970179599" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER.51903075" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING.1806087552" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING" valueType="stringList">\r
+                                                                       <listOptionValue builtIn="false" value="225"/>\r
+                                                               </option>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS.297336456" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS.989752520" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS.187909383" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS.1231947531" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS"/>\r
                                                        </tool>\r
-                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.85217902" name="C6000 Linker" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug">\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE.1656601823" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE" value="&quot;../bin/norwriter_evmk2g.out&quot;" valueType="string"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE.950207562" name="Input and output sections listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE" value="&quot;../bin/norwriter_evmk2g.map&quot;" valueType="string"/>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY.1077885696" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY" valueType="libs">\r
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.821528841" name="C6000 Linker" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE.617412837" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE" value="&quot;../bin/norwriter_evmk2g.out&quot;" valueType="string"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE.1268890407" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE" value="&quot;../bin/norwriter_evmk2g.map&quot;" valueType="string"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY.1200219258" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY" valueType="libs">\r
                                                                        <listOptionValue builtIn="false" value="&quot;libc.a&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;ti.platform.evmk2g.ae66&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;ti.csl.ae66&quot;"/>\r
                                                                </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH.1102677682" name="Add &lt;dir&gt; to library search path (--search_path, -i)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH" valueType="stringList">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH.506763466" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH" valueType="libPaths">\r
                                                                        <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/lib&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${TI_PDK_INSTALL_DIR}/packages/ti/platform/evmk2g/platform_lib/lib/debug&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${TI_PDK_INSTALL_DIR}/packages/ti/csl/lib/k2g/c66&quot;"/>\r
                                                                </option>\r
-                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO.1912462839" name="Detailed link information data-base into &lt;file&gt; (--xml_link_info, -xml_link_info)" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO" value="&quot;../bin/norwriter_evmk2g_linkInfo.xml&quot;" valueType="string"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS.1841612369" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS.670567142" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS"/>\r
-                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS.1104689498" name="Generated Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO.1491754488" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO" value="&quot;../bin/norwriter_evmk2g_linkInfo.xml&quot;" valueType="string"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS.1057132807" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS.48067898" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS.536780752" name="Generated Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS"/>\r
                                                        </tool>\r
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.hex.1575703568" name="C6000 Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.hex"/>\r
                                                </toolChain>\r
                                        </folderInfo>\r
                                </configuration>\r
index 054ba683fbbf4ae52e9e2ef067ee81d3f238fdef..c3835a9c6e212d76d33919f4c91e4d2223e4f137 100644 (file)
-/******************************************************************************
- * Copyright (c) 2013-2014 Texas Instruments Incorporated - http://www.ti.com
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions
- *  are met:
- *
- *    Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- *    Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the
- *    distribution.
- *
- *    Neither the name of Texas Instruments Incorporated nor the names of
- *    its contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *****************************************************************************/
-
-/**************************************************************************************
- * FILE PURPOSE: NOR writer utility
- **************************************************************************************
- * FILE NAME: norwriter.c
- *
- * DESCRIPTION: A simple nor writer using platform lib APIs to program the NOR flash
- *              with an image that the ibl can read.
- *
- ***************************************************************************************/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "platform.h"
-#include "types.h"
-
-/* NOR writer utility version */
-char version[] = "01.00.00.04";
-
-/* The input file name is hard coded */
-char *input_file = "nor_writer_input.txt";
-
-uint32_t swap_byte = 0;
-
-/* Parameters defined in the input_file */
-#define FILE_NAME      "file_name"
-#define START_ADDR     "start_addr"
-
-/* Memory address to store the write data */
-#define WRITE_DATA_ADDRESS     0x80000000
-
-/******************************************************************************
- * Structure:   NOR_WRITER_INFO_T
- *
- *              NOR writer control data. This structure should be filled in
- *              by the user before running
- ******************************************************************************/
-#define MAX_LINE_LENGTH 40
-typedef struct NOR_WRITER_INFO_tag
-{
-    char        file_name[MAX_LINE_LENGTH]; /* CCS format data file name */
-    uint32_t    blockSizeBytes;             /* The size of each sector */
-    uint32_t    deviceTotalBytes;           /* Total number of bytes available in the device */
-    uint32_t    startAddr;                  /* Start address to write */
-    uint32_t    writeBytes;                 /* Number of bytes to be written into the device */
-    uint8_t     *writeData;                 /* Address to store the write data */
-    uint8_t     *readData;                  /* Address to store the read data */
-
-} NOR_WRITER_INFO_T;
-
-NOR_WRITER_INFO_T norWriterInfo;
-
-/* OSAL functions for Platform Library */
-uint8_t *Osal_platformMalloc (uint32_t num_bytes, uint32_t alignment)
-{
-       return malloc(num_bytes);
-}
-
-void Osal_platformFree (uint8_t *dataPtr, uint32_t num_bytes)
-{
-    /* Free up the memory */
-    if (dataPtr)
-    {
-        free(dataPtr);
-    }
-}
-
-void Osal_platformSpiCsEnter(void)
-{
-    return;
-}
-
-void Osal_platformSpiCsExit (void)
-{
-    return;
-}
-
-/******************************************************************************
- * Function:    print_platform_errno
- ******************************************************************************/
-void
-print_platform_errno
-(
-    void
-)
-{
-    printf ("Returned platform error number is %d\n", platform_errno);
-}
-
-/******************************************************************************
- * Function:    formBlock
- *
- *      Form a block of data to write to the NOR. The block is
- *      created as a byte stream from the 4 byte stream in which
- *      the MSB is always sent first.
- ******************************************************************************/
-void
-formBlock
-(
-    uint32_t      *data,
-    uint32_t      blockSize,
-    uint8_t       *scratch
-)
-{
-    uint32_t i, j;
-    
-    /* Convert the data to a byte stream */
-    for (i = j = 0; j < blockSize; i++, j+=4)
-    {
-        scratch[j+0] = (data[i] >> 24) & 0xff;
-        scratch[j+1] = (data[i] >> 16) & 0xff;
-        scratch[j+2] = (data[i] >>  8) & 0xff;
-        scratch[j+3] = (data[i] >>  0) & 0xff;
-    }
-}
-
-/******************************************************************************
- * Function:    flash_nor
- *
- *              Write the image to flash.
- *              Returns TRUE if the image is written successfully
- *                      FALSE if the image write fails
- ******************************************************************************/
-Bool
-flash_nor
-(
-    PLATFORM_DEVICE_info    *p_device
-)
-{
-    uint32_t      wPos, wLen;
-    uint32_t      block, start_block;
-    uint8_t       *scrach_block;
-
-    if (swap_byte)
-    {
-        scrach_block = malloc(norWriterInfo.blockSizeBytes);
-        if (scrach_block == NULL)
-        {
-            printf ("Can not allocate scratch block memory!\n");
-            return (FALSE);
-        }
-    }
-
-    start_block = norWriterInfo.startAddr / norWriterInfo.blockSizeBytes;
-
-    /* Program the NOR */
-    for (block = start_block, wPos = 0; wPos < norWriterInfo.writeBytes; block++, wPos += norWriterInfo.blockSizeBytes)
-    {
-        printf ("Flashing sector %d (%d bytes of %d)\n", block, wPos, norWriterInfo.writeBytes);
-
-        wLen = norWriterInfo.blockSizeBytes;
-        if (norWriterInfo.writeBytes - wPos < norWriterInfo.blockSizeBytes)
-        {
-            wLen = norWriterInfo.writeBytes - wPos;
-        }
-
-        if (swap_byte)
-        {
-            formBlock((uint32_t *)(&norWriterInfo.writeData[wPos]), norWriterInfo.blockSizeBytes, scrach_block);
-        }
-        else
-        {
-            scrach_block = &norWriterInfo.writeData[wPos];
-        }
-        if (platform_device_write(p_device->handle,
-                                  block*norWriterInfo.blockSizeBytes,
-                                  scrach_block,
-                                  wLen) != Platform_EOK)
-        {
-            printf ("platform_nor_write sector # %d failed!\n", block);
-            print_platform_errno();
-            if (swap_byte) free (scrach_block);
-            return (FALSE);
-        }
-    }
-
-    if (swap_byte) free (scrach_block);
-    return (TRUE);
-}
-
-/******************************************************************************
- * Function:    flash_verify
- *
- *              Read back the data file that was just flashed. On errors mark the block as bad.
- *              Returns TRUE if the image verified correctly.
- *                      FALSE if the image verification failed
- ******************************************************************************/
-Bool
-flash_verify
-(
-    PLATFORM_DEVICE_info    *p_device
-)
-{
-    uint32_t      rPos, rLen;
-    uint32_t      i, j;
-    uint32_t      block, start_block;
-    uint8_t       *scrach_block;
-    uint32_t      *read_data_w;
-
-    if (swap_byte) 
-    {
-        scrach_block = malloc(norWriterInfo.blockSizeBytes);
-        if (scrach_block == NULL)
-        {
-            printf ("Can not allocate scratch block memory!\n");
-            return (FALSE);
-        }
-    }
-
-    start_block = norWriterInfo.startAddr / norWriterInfo.blockSizeBytes;
-
-    for (block = start_block, rPos = 0; rPos < norWriterInfo.writeBytes; block++, rPos += norWriterInfo.blockSizeBytes)
-    {
-        printf ("Reading and verifying sector %d (%d bytes of %d)\n", block, rPos, norWriterInfo.writeBytes);
-
-        if (!swap_byte)
-        {
-            scrach_block = &norWriterInfo.readData[rPos];
-
-        }
-        /* Read a sector of data */
-        if(platform_device_read(p_device->handle,
-                                block*norWriterInfo.blockSizeBytes,
-                                scrach_block,
-                                norWriterInfo.blockSizeBytes) != Platform_EOK)
-        {
-            printf ("Failure in sector %d\n", block);
-            print_platform_errno();
-            if (swap_byte) free (scrach_block);
-            return (FALSE);
-        }
-
-        /* Convert the packed data */
-        if (swap_byte)
-        {
-            read_data_w = (uint32_t *)(&norWriterInfo.readData[rPos]);
-            for  (i = 0, j = 0; i < norWriterInfo.blockSizeBytes; i += 4)
-                read_data_w[j++] = (scrach_block[i+0] << 24) | (scrach_block[i+1] << 16) | (scrach_block[i+2] << 8) | scrach_block[i+3];
-        }
-
-        /* Read the data from the file */
-        rLen = norWriterInfo.blockSizeBytes;
-        if (norWriterInfo.writeBytes - rPos < norWriterInfo.blockSizeBytes)
-        {
-            rLen = norWriterInfo.writeBytes - rPos;
-        }
-
-        for (i = rPos; i < rLen; i++)
-        {
-            if (norWriterInfo.readData[i] != norWriterInfo.writeData[i])
-            {
-                printf ("Failure in sector %d, at byte %d, (at byte %d in the data file) expected 0x%08x, read 0x%08x\n",
-                        block, i, rPos, norWriterInfo.writeData[i], norWriterInfo.readData[i]);
-                if (swap_byte) free (scrach_block);
-                return (FALSE);
-            }
-        }
-
-    }
-
-    if (swap_byte) free (scrach_block);
-    return (TRUE);
-}
-
-/******************************************************************************
- * Function:    parse_input_file
- ******************************************************************************/
-static Bool
-parse_input_file
-(
-    FILE*               fp
-)
-{
-    char line[MAX_LINE_LENGTH];
-    char tokens[] = " :=;\n\r";
-    char *key, *data;
-
-    memset(line, 0, MAX_LINE_LENGTH);
-
-    fgets(line, MAX_LINE_LENGTH, fp);
-    key  = (char *)strtok(line, tokens);
-    data = (char *)strtok(NULL, tokens);
-
-    if(strlen(data) == 0)
-    {
-       return FALSE;
-    }
-
-    if(strcmp(key, FILE_NAME) != 0)
-    {
-        return FALSE;
-    }
-
-    strcpy (norWriterInfo.file_name, data);
-
-    fgets(line, MAX_LINE_LENGTH, fp);
-    key  = (char *)strtok(line, tokens);
-    data = (char *)strtok(NULL, tokens);
-
-    if(strlen(data) == 0)
-    {
-       return FALSE;
-    }
-
-    if(strcmp(key, START_ADDR) != 0)
-    {
-        return FALSE;
-    }
-
-    norWriterInfo.startAddr = (uint32_t)atoi(data);
-
-    return TRUE;
-}
-
-/******************************************************************************
- * Function:    find_file_length
- ******************************************************************************/
-static Bool
-find_file_length
-(
-    FILE*               fp
-)
-{
-    char        line[MAX_LINE_LENGTH];
-    char        *pEnd;
-    char        *ext;
-    uint32_t    data_len, write_addr;
-
-    memset(line, 0, MAX_LINE_LENGTH);
-
-    ext = strrchr(norWriterInfo.file_name, '.');
-
-
-    if (ext && (strcmp(ext, ".dat") == 0))
-    {
-    fgets(line, MAX_LINE_LENGTH, fp);
-
-    /* Read the write address from the CCS header */
-    strtoul (line,&pEnd,16);
-    strtoul (pEnd,&pEnd,16);
-    write_addr = strtoul (pEnd,&pEnd,16);
-    strtoul (pEnd,&pEnd,16);
-
-    /* Read the data length */
-    data_len = (strtoul (pEnd,NULL,16)) * 4;
-    }
-    else
-    {
-        /* find the data length by seeking to the end and getting position */
-        fseek(fp, 0, SEEK_END);
-        data_len = ftell(fp);
-        fseek(fp, 0, SEEK_SET);
-    }
-
-    if (data_len > (norWriterInfo.deviceTotalBytes - norWriterInfo.startAddr))
-    {
-        printf ("The data file is too big to fit into the device.\n");
-        return FALSE;
-    }
-
-    norWriterInfo.writeBytes = data_len;
-    if (write_addr != WRITE_DATA_ADDRESS)
-        write_addr = WRITE_DATA_ADDRESS;
-    norWriterInfo.writeData  = (uint8_t *)write_addr;
-    norWriterInfo.readData   = (uint8_t *)(write_addr + norWriterInfo.deviceTotalBytes);
-
-    return TRUE;
-}
-
-/******************************************************************************
- * Function:    main
- ******************************************************************************/
-void main ()
-{
-    FILE                    *fp;
-    platform_init_flags     init_flags;
-    platform_init_config    init_config;
-    PLATFORM_DEVICE_info    *p_device;
-    Bool                    ret;
-
-    printf("NOR Writer Utility Version %s\n\n", version);
-
-    fp = fopen(input_file, "r");
-    if (fp == NULL)
-    {
-        printf("Error in opening %s input file\n", input_file);
-        return;
-    }
-
-    ret = parse_input_file(fp);
-    fclose (fp);
-
-    if (ret == FALSE)
-    {
-        printf("Error in parsing %s input file\n", input_file);
-        return;
-    }
-
-    /* Initialize main Platform lib */
-    memset(&init_config, 0, sizeof(platform_init_config));
-    memset(&init_flags, 1, sizeof(platform_init_flags));
-    init_flags.pll = 0;
-    init_flags.ddr = 0;
-    init_flags.phy = 0;
-    if (platform_init(&init_flags, &init_config) != Platform_EOK)
-    {
-        printf ("Platform init failed!\n");
-        print_platform_errno();
-        return;
-    }
-#if !(defined(_EVMC6657L_))
-
-#if (defined(DEVICE_K2G))
-    p_device = platform_device_open(PLATFORM_DEVID_NORN25Q128A13ESF40F, 0);
-#else
-    p_device = platform_device_open(PLATFORM_DEVID_NORN25Q128, 0);
-#endif
-
-#else
-    p_device = platform_device_open(PLATFORM_DEVID_NORN25Q032A, 0);
-#endif
-    if (p_device == NULL)
-    {
-        printf ("NOR device open failed!\n");
-        print_platform_errno();
-        return;
-    }
-    norWriterInfo.deviceTotalBytes  = p_device->block_count * p_device->page_count * p_device->page_size;
-    norWriterInfo.blockSizeBytes    = p_device->page_count * p_device->page_size;
-
-    if ((norWriterInfo.startAddr % norWriterInfo.blockSizeBytes) != 0)
-    {
-        printf ("The start programming address 0x%8x set in %s is not at the beginning of a block, block size = 0x%4x\n",
-                norWriterInfo.startAddr,
-                norWriterInfo.file_name,
-                norWriterInfo.blockSizeBytes);
-        return;
-    }
-
-    /* Open and find the length of the data file */
-    fp = fopen (norWriterInfo.file_name, "rb");
-    if (fp == NULL)
-    {
-      printf ("Failed to open file %s\n", norWriterInfo.file_name);
-      platform_device_close(p_device->handle);
-      return;
-    }
-
-    /* Parse the CCS format file */
-    ret = find_file_length(fp);
-    fclose (fp);
-    
-    norWriterInfo.writeBytes += norWriterInfo.blockSizeBytes - 1;
-    norWriterInfo.writeBytes -= norWriterInfo.writeBytes % norWriterInfo.blockSizeBytes;
-    
-    if (ret == FALSE)
-    {
-        printf("Error in parsing CCS file %s\n", norWriterInfo.file_name);
-        platform_device_close(p_device->handle);
-        return;
-    }
-
-    /* Write the flash */
-    if (flash_nor (p_device) == FALSE)
-    {
-        printf ("NOR write failed\n");
-        platform_device_close(p_device->handle);
-        return;
-    }
-
-    /* verify the flash */
-    if(flash_verify (p_device) == FALSE)
-    {
-        printf ("NOR read verify failed\n");
-        platform_device_close(p_device->handle);
-        return;
-    }
-
-
-    printf ("NOR programming completed successfully\n");
-
-    platform_device_close(p_device->handle);
-
-    return;
-}
-
-
-
-
+/*\r
+ * Copyright (c) 2011-2015, Texas Instruments Incorporated\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ * *  Redistributions of source code must retain the above copyright\r
+ *    notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * *  Redistributions in binary form must reproduce the above copyright\r
+ *    notice, this list of conditions and the following disclaimer in the\r
+ *    documentation and/or other materials provided with the distribution.\r
+ *\r
+ * *  Neither the name of Texas Instruments Incorporated nor the names of\r
+ *    its contributors may be used to endorse or promote products derived\r
+ *    from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ */\r
+\r
+/**************************************************************************************\r
+ * FILE PURPOSE: NOR writer utility\r
+ **************************************************************************************\r
+ * FILE NAME: norwriter.c\r
+ *\r
+ * DESCRIPTION: A simple nor writer using platform lib APIs to program the NOR flash\r
+ *              with an image that the ibl can read.\r
+ *\r
+ ***************************************************************************************/\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include "platform.h"\r
+#include "types.h"\r
+\r
+/* NOR writer utility version */\r
+char version[] = "01.00.00.04";\r
+\r
+/* The input file name is hard coded */\r
+char *input_file = "nor_writer_input.txt";\r
+\r
+uint32_t swap_byte = 0;\r
+\r
+/* Parameters defined in the input_file */\r
+#define FILE_NAME      "file_name"\r
+#define START_ADDR     "start_addr"\r
+\r
+/* Memory address to store the write data */\r
+#define WRITE_DATA_ADDRESS     0x80000000\r
+\r
+/******************************************************************************\r
+ * Structure:   NOR_WRITER_INFO_T\r
+ *\r
+ *              NOR writer control data. This structure should be filled in\r
+ *              by the user before running\r
+ ******************************************************************************/\r
+#define MAX_LINE_LENGTH 40\r
+typedef struct NOR_WRITER_INFO_tag\r
+{\r
+    char        file_name[MAX_LINE_LENGTH]; /* CCS format data file name */\r
+    uint32_t    blockSizeBytes;             /* The size of each sector */\r
+    uint32_t    deviceTotalBytes;           /* Total number of bytes available in the device */\r
+    uint32_t    startAddr;                  /* Start address to write */\r
+    uint32_t    writeBytes;                 /* Number of bytes to be written into the device */\r
+    uint8_t     *writeData;                 /* Address to store the write data */\r
+    uint8_t     *readData;                  /* Address to store the read data */\r
+\r
+} NOR_WRITER_INFO_T;\r
+\r
+NOR_WRITER_INFO_T norWriterInfo;\r
+\r
+/* OSAL functions for Platform Library */\r
+uint8_t *Osal_platformMalloc (uint32_t num_bytes, uint32_t alignment)\r
+{\r
+       return malloc(num_bytes);\r
+}\r
+\r
+void Osal_platformFree (uint8_t *dataPtr, uint32_t num_bytes)\r
+{\r
+    /* Free up the memory */\r
+    if (dataPtr)\r
+    {\r
+        free(dataPtr);\r
+    }\r
+}\r
+\r
+void Osal_platformSpiCsEnter(void)\r
+{\r
+    return;\r
+}\r
+\r
+void Osal_platformSpiCsExit (void)\r
+{\r
+    return;\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    print_platform_errno\r
+ ******************************************************************************/\r
+void\r
+print_platform_errno\r
+(\r
+    void\r
+)\r
+{\r
+    printf ("Returned platform error number is %d\n", platform_errno);\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    formBlock\r
+ *\r
+ *      Form a block of data to write to the NOR. The block is\r
+ *      created as a byte stream from the 4 byte stream in which\r
+ *      the MSB is always sent first.\r
+ ******************************************************************************/\r
+void\r
+formBlock\r
+(\r
+    uint32_t      *data,\r
+    uint32_t      blockSize,\r
+    uint8_t       *scratch\r
+)\r
+{\r
+    uint32_t i, j;\r
+    \r
+    /* Convert the data to a byte stream */\r
+    for (i = j = 0; j < blockSize; i++, j+=4)\r
+    {\r
+        scratch[j+0] = (data[i] >> 24) & 0xff;\r
+        scratch[j+1] = (data[i] >> 16) & 0xff;\r
+        scratch[j+2] = (data[i] >>  8) & 0xff;\r
+        scratch[j+3] = (data[i] >>  0) & 0xff;\r
+    }\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    flash_nor\r
+ *\r
+ *              Write the image to flash.\r
+ *              Returns TRUE if the image is written successfully\r
+ *                      FALSE if the image write fails\r
+ ******************************************************************************/\r
+Bool\r
+flash_nor\r
+(\r
+    PLATFORM_DEVICE_info    *p_device\r
+)\r
+{\r
+    uint32_t      wPos, wLen;\r
+    uint32_t      block, start_block;\r
+    uint8_t       *scrach_block;\r
+\r
+    if (swap_byte)\r
+    {\r
+        scrach_block = malloc(norWriterInfo.blockSizeBytes);\r
+        if (scrach_block == NULL)\r
+        {\r
+            printf ("Can not allocate scratch block memory!\n");\r
+            return (FALSE);\r
+        }\r
+    }\r
+\r
+    start_block = norWriterInfo.startAddr / norWriterInfo.blockSizeBytes;\r
+\r
+    /* Program the NOR */\r
+    for (block = start_block, wPos = 0; wPos < norWriterInfo.writeBytes; block++, wPos += norWriterInfo.blockSizeBytes)\r
+    {\r
+        printf ("Flashing sector %d (%d bytes of %d)\n", block, wPos, norWriterInfo.writeBytes);\r
+\r
+        wLen = norWriterInfo.blockSizeBytes;\r
+        if (norWriterInfo.writeBytes - wPos < norWriterInfo.blockSizeBytes)\r
+        {\r
+            wLen = norWriterInfo.writeBytes - wPos;\r
+        }\r
+\r
+        if (swap_byte)\r
+        {\r
+            formBlock((uint32_t *)(&norWriterInfo.writeData[wPos]), norWriterInfo.blockSizeBytes, scrach_block);\r
+        }\r
+        else\r
+        {\r
+            scrach_block = &norWriterInfo.writeData[wPos];\r
+        }\r
+        if (platform_device_write(p_device->handle,\r
+                                  block*norWriterInfo.blockSizeBytes,\r
+                                  scrach_block,\r
+                                  wLen) != Platform_EOK)\r
+        {\r
+            printf ("platform_nor_write sector # %d failed!\n", block);\r
+            print_platform_errno();\r
+            if (swap_byte) free (scrach_block);\r
+            return (FALSE);\r
+        }\r
+    }\r
+\r
+    if (swap_byte) free (scrach_block);\r
+    return (TRUE);\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    flash_verify\r
+ *\r
+ *              Read back the data file that was just flashed. On errors mark the block as bad.\r
+ *              Returns TRUE if the image verified correctly.\r
+ *                      FALSE if the image verification failed\r
+ ******************************************************************************/\r
+Bool\r
+flash_verify\r
+(\r
+    PLATFORM_DEVICE_info    *p_device\r
+)\r
+{\r
+    uint32_t      rPos, rLen;\r
+    uint32_t      i, j;\r
+    uint32_t      block, start_block;\r
+    uint8_t       *scrach_block;\r
+    uint32_t      *read_data_w;\r
+\r
+    if (swap_byte) \r
+    {\r
+        scrach_block = malloc(norWriterInfo.blockSizeBytes);\r
+        if (scrach_block == NULL)\r
+        {\r
+            printf ("Can not allocate scratch block memory!\n");\r
+            return (FALSE);\r
+        }\r
+    }\r
+\r
+    start_block = norWriterInfo.startAddr / norWriterInfo.blockSizeBytes;\r
+\r
+    for (block = start_block, rPos = 0; rPos < norWriterInfo.writeBytes; block++, rPos += norWriterInfo.blockSizeBytes)\r
+    {\r
+        printf ("Reading and verifying sector %d (%d bytes of %d)\n", block, rPos, norWriterInfo.writeBytes);\r
+\r
+        if (!swap_byte)\r
+        {\r
+            scrach_block = &norWriterInfo.readData[rPos];\r
+\r
+        }\r
+        /* Read a sector of data */\r
+        if(platform_device_read(p_device->handle,\r
+                                block*norWriterInfo.blockSizeBytes,\r
+                                scrach_block,\r
+                                norWriterInfo.blockSizeBytes) != Platform_EOK)\r
+        {\r
+            printf ("Failure in sector %d\n", block);\r
+            print_platform_errno();\r
+            if (swap_byte) free (scrach_block);\r
+            return (FALSE);\r
+        }\r
+\r
+        /* Convert the packed data */\r
+        if (swap_byte)\r
+        {\r
+            read_data_w = (uint32_t *)(&norWriterInfo.readData[rPos]);\r
+            for  (i = 0, j = 0; i < norWriterInfo.blockSizeBytes; i += 4)\r
+                read_data_w[j++] = (scrach_block[i+0] << 24) | (scrach_block[i+1] << 16) | (scrach_block[i+2] << 8) | scrach_block[i+3];\r
+        }\r
+\r
+        /* Read the data from the file */\r
+        rLen = norWriterInfo.blockSizeBytes;\r
+        if (norWriterInfo.writeBytes - rPos < norWriterInfo.blockSizeBytes)\r
+        {\r
+            rLen = norWriterInfo.writeBytes - rPos;\r
+        }\r
+\r
+        for (i = rPos; i < rLen; i++)\r
+        {\r
+            if (norWriterInfo.readData[i] != norWriterInfo.writeData[i])\r
+            {\r
+                printf ("Failure in sector %d, at byte %d, (at byte %d in the data file) expected 0x%08x, read 0x%08x\n",\r
+                        block, i, rPos, norWriterInfo.writeData[i], norWriterInfo.readData[i]);\r
+                if (swap_byte) free (scrach_block);\r
+                return (FALSE);\r
+            }\r
+        }\r
+\r
+    }\r
+\r
+    if (swap_byte) free (scrach_block);\r
+    return (TRUE);\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    parse_input_file\r
+ ******************************************************************************/\r
+static Bool\r
+parse_input_file\r
+(\r
+    FILE*               fp\r
+)\r
+{\r
+    char line[MAX_LINE_LENGTH];\r
+    char tokens[] = " :=;\n\r";\r
+    char *key, *data;\r
+\r
+    memset(line, 0, MAX_LINE_LENGTH);\r
+\r
+    fgets(line, MAX_LINE_LENGTH, fp);\r
+    key  = (char *)strtok(line, tokens);\r
+    data = (char *)strtok(NULL, tokens);\r
+\r
+    if(strlen(data) == 0)\r
+    {\r
+       return FALSE;\r
+    }\r
+\r
+    if(strcmp(key, FILE_NAME) != 0)\r
+    {\r
+        return FALSE;\r
+    }\r
+\r
+    strcpy (norWriterInfo.file_name, data);\r
+\r
+    fgets(line, MAX_LINE_LENGTH, fp);\r
+    key  = (char *)strtok(line, tokens);\r
+    data = (char *)strtok(NULL, tokens);\r
+\r
+    if(strlen(data) == 0)\r
+    {\r
+       return FALSE;\r
+    }\r
+\r
+    if(strcmp(key, START_ADDR) != 0)\r
+    {\r
+        return FALSE;\r
+    }\r
+\r
+    norWriterInfo.startAddr = (uint32_t)atoi(data);\r
+\r
+    return TRUE;\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    find_file_length\r
+ ******************************************************************************/\r
+static Bool\r
+find_file_length\r
+(\r
+    FILE*               fp\r
+)\r
+{\r
+    char        line[MAX_LINE_LENGTH];\r
+    char        *pEnd;\r
+    char        *ext;\r
+    uint32_t    data_len, write_addr;\r
+\r
+    memset(line, 0, MAX_LINE_LENGTH);\r
+\r
+    ext = strrchr(norWriterInfo.file_name, '.');\r
+\r
+\r
+    if (ext && (strcmp(ext, ".dat") == 0))\r
+    {\r
+    fgets(line, MAX_LINE_LENGTH, fp);\r
+\r
+    /* Read the write address from the CCS header */\r
+    strtoul (line,&pEnd,16);\r
+    strtoul (pEnd,&pEnd,16);\r
+    write_addr = strtoul (pEnd,&pEnd,16);\r
+    strtoul (pEnd,&pEnd,16);\r
+\r
+    /* Read the data length */\r
+    data_len = (strtoul (pEnd,NULL,16)) * 4;\r
+    }\r
+    else\r
+    {\r
+        /* find the data length by seeking to the end and getting position */\r
+        fseek(fp, 0, SEEK_END);\r
+        data_len = ftell(fp);\r
+        fseek(fp, 0, SEEK_SET);\r
+    }\r
+\r
+    if (data_len > (norWriterInfo.deviceTotalBytes - norWriterInfo.startAddr))\r
+    {\r
+        printf ("The data file is too big to fit into the device.\n");\r
+        return FALSE;\r
+    }\r
+\r
+    norWriterInfo.writeBytes = data_len;\r
+    if (write_addr != WRITE_DATA_ADDRESS)\r
+        write_addr = WRITE_DATA_ADDRESS;\r
+    norWriterInfo.writeData  = (uint8_t *)write_addr;\r
+    norWriterInfo.readData   = (uint8_t *)(write_addr + norWriterInfo.deviceTotalBytes);\r
+\r
+    return TRUE;\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    main\r
+ ******************************************************************************/\r
+void main ()\r
+{\r
+    FILE                    *fp;\r
+    platform_init_flags     init_flags;\r
+    platform_init_config    init_config;\r
+    PLATFORM_DEVICE_info    *p_device;\r
+    Bool                    ret;\r
+\r
+    printf("NOR Writer Utility Version %s\n\n", version);\r
+\r
+    fp = fopen(input_file, "r");\r
+    if (fp == NULL)\r
+    {\r
+        printf("Error in opening %s input file\n", input_file);\r
+        return;\r
+    }\r
+\r
+    ret = parse_input_file(fp);\r
+    fclose (fp);\r
+\r
+    if (ret == FALSE)\r
+    {\r
+        printf("Error in parsing %s input file\n", input_file);\r
+        return;\r
+    }\r
+\r
+    /* Initialize main Platform lib */\r
+    memset(&init_config, 0, sizeof(platform_init_config));\r
+    memset(&init_flags, 1, sizeof(platform_init_flags));\r
+    init_flags.pll = 0;\r
+    init_flags.ddr = 0;\r
+    init_flags.phy = 0;\r
+    if (platform_init(&init_flags, &init_config) != Platform_EOK)\r
+    {\r
+        printf ("Platform init failed!\n");\r
+        print_platform_errno();\r
+        return;\r
+    }\r
+#if !(defined(_EVMC6657L_))\r
+\r
+#if (defined(DEVICE_K2G))\r
+    p_device = platform_device_open(PLATFORM_DEVID_NORN25Q128A13ESF40F, 0);\r
+#else\r
+    p_device = platform_device_open(PLATFORM_DEVID_NORN25Q128, 0);\r
+#endif\r
+\r
+#else\r
+    p_device = platform_device_open(PLATFORM_DEVID_NORN25Q032A, 0);\r
+#endif\r
+    if (p_device == NULL)\r
+    {\r
+        printf ("NOR device open failed!\n");\r
+        print_platform_errno();\r
+        return;\r
+    }\r
+    norWriterInfo.deviceTotalBytes  = p_device->block_count * p_device->page_count * p_device->page_size;\r
+    norWriterInfo.blockSizeBytes    = p_device->page_count * p_device->page_size;\r
+\r
+    if ((norWriterInfo.startAddr % norWriterInfo.blockSizeBytes) != 0)\r
+    {\r
+        printf ("The start programming address 0x%8x set in %s is not at the beginning of a block, block size = 0x%4x\n",\r
+                norWriterInfo.startAddr,\r
+                norWriterInfo.file_name,\r
+                norWriterInfo.blockSizeBytes);\r
+        return;\r
+    }\r
+\r
+    /* Open and find the length of the data file */\r
+    fp = fopen (norWriterInfo.file_name, "rb");\r
+    if (fp == NULL)\r
+    {\r
+      printf ("Failed to open file %s\n", norWriterInfo.file_name);\r
+      platform_device_close(p_device->handle);\r
+      return;\r
+    }\r
+\r
+    /* Parse the CCS format file */\r
+    ret = find_file_length(fp);\r
+    fclose (fp);\r
+    \r
+    norWriterInfo.writeBytes += norWriterInfo.blockSizeBytes - 1;\r
+    norWriterInfo.writeBytes -= norWriterInfo.writeBytes % norWriterInfo.blockSizeBytes;\r
+    \r
+    if (ret == FALSE)\r
+    {\r
+        printf("Error in parsing CCS file %s\n", norWriterInfo.file_name);\r
+        platform_device_close(p_device->handle);\r
+        return;\r
+    }\r
+\r
+    /* Write the flash */\r
+    if (flash_nor (p_device) == FALSE)\r
+    {\r
+        printf ("NOR write failed\n");\r
+        platform_device_close(p_device->handle);\r
+        return;\r
+    }\r
+\r
+    /* verify the flash */\r
+    if(flash_verify (p_device) == FALSE)\r
+    {\r
+        printf ("NOR read verify failed\n");\r
+        platform_device_close(p_device->handle);\r
+        return;\r
+    }\r
+\r
+\r
+    printf ("NOR programming completed successfully\n");\r
+\r
+    platform_device_close(p_device->handle);\r
+\r
+    return;\r
+}\r
+\r
+\r
+\r
+\r
diff --git a/writer/qspi_flash/docs/README.txt b/writer/qspi_flash/docs/README.txt
new file mode 100644 (file)
index 0000000..e1549b4
--- /dev/null
@@ -0,0 +1,44 @@
+QSPI flash Writer Utility\r
+\r
+QSPI flash Writer is a simple utility to program a CCS format image/data file to the QSPI flash.\r
+\r
+Steps to program the QSPI flash:\r
+\r
+1. Be sure to set the boot mode dip switch to no boot/EMIF16 boot mode on the EVM.\r
+\r
+2. Copy the binary file to writer\qspi_flash\evmxxxx\bin directory, and rename it to app.bin.\r
+\r
+3. Change the file_name and start_addr in writer\qspi_flash\evmxxxx\bin\qspi_flash_writer_input.txt if necessary. \r
+   By default the QSPI flash writer will load app.bin to DSP memory and write the data to QSPI flash device start byte address 0, \r
+   the start_addr should always be set to the start byte addess of a sector.\r
+\r
+4. Open CCS and launch the evmxxxx emulator target configuration and connect to core 0.\r
+\r
+5. Load the program writer\qspi_flash\evmxxxx\bin\qspiflashwriter_evmxxxx.out to CCS, be sure evmxxxx.gel is used in CCS \r
+   and DDR is intialized.\r
+\r
+6. Open the Memory view (in CCS, view->Memory Browser), and view the memory address 0x80000000.\r
+\r
+7. Load app.bin to 0x80000000:\r
+     * In CCS, right click mouse in memory window, select "load memory".\r
+     * Browse and select writer\qspi_flash\evmxxxx\bin\app.bin (raw data format), click "next"\r
+     * Set the Start Address to "0x80000000", Type-size to 32-bits, leave swap unchecked, click "finish"\r
+\r
+\r
+8. After the binary file is loaded into the memory, run the program (in CCS, press F8), it will start to program the \r
+   QSPI flash.\r
+\r
+9. When programming is completed, the console will print "QSPI Flash programming completed successfully", if there\r
+   is any error, the console will show the error message.\r
+\r
+\r
+Steps to re-build qspiflashwriter:\r
+\r
+Uses CCS to build qspiflashwriter:\r
+   * Import the qspiflashwriter CCS project from writer\qspi_flash\evmxxxx directory (in CCS, Project->Import Existing CCS/\r
+   CCE Eclipse Projects).\r
+   * Clean and build the qspiflashwriter project.\r
+   * After the project build is completed, qspiflashwriter_evmxxxx.out and qspiflashwriter_evmxxxx.map will be generated under \r
+     writer\qspi_flash\evmxxxx\bin directory.\r
+\r
+Please refer to MCSDK User's Guide (http://processors.wiki.ti.com/index.php/MCSDK_User_Guide_for_KeyStone_II) for more details.
\ No newline at end of file
diff --git a/writer/qspi_flash/evmk2g/.ccsproject b/writer/qspi_flash/evmk2g/.ccsproject
new file mode 100644 (file)
index 0000000..d8f3a65
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<?ccsproject version="1.0"?>
+<projectOptions>
+       <deviceVariant value="com.ti.ccstudio.deviceModel.C6000.CustomC6000Device"/>
+       <deviceFamily value="C6000"/>
+       <deviceEndianness value="little"/>
+       <codegenToolVersion value="7.4.8"/>
+       <isElfFormat value="false"/>
+       <rts value=""/>
+       <createSlaveProjects value=""/>
+       <isTargetManual value="false"/>
+</projectOptions>
diff --git a/writer/qspi_flash/evmk2g/.cproject b/writer/qspi_flash/evmk2g/.cproject
new file mode 100644 (file)
index 0000000..76e5bb7
--- /dev/null
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<?fileVersion 4.0.0?>\r
+\r
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">\r
+       <storageModule configRelations="2" moduleId="org.eclipse.cdt.core.settings">\r
+               <cconfiguration id="com.ti.ccstudio.buildDefinitions.C6000.Debug.1869204513.1450862703">\r
+                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.ti.ccstudio.buildDefinitions.C6000.Debug.1869204513.1450862703" moduleId="org.eclipse.cdt.core.settings" name="Debug">\r
+                               <macros>\r
+                                       <stringMacro name="TI_MCSDK_WRITER_DIR" type="VALUE_PATH_DIR" value="${PROJECT_ROOT}/../.."/>\r
+                               </macros>\r
+                               <externalSettings/>\r
+                               <extensions>\r
+                                       <extension id="com.ti.ccstudio.binaryparser.CoffParser" point="org.eclipse.cdt.core.BinaryParser"/>\r
+                                       <extension id="com.ti.ccstudio.errorparser.LinkErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>\r
+                                       <extension id="com.ti.ccstudio.errorparser.CoffErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>\r
+                                       <extension id="com.ti.ccstudio.errorparser.AsmErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>\r
+                               </extensions>\r
+                       </storageModule>\r
+                       <storageModule moduleId="org.eclipse.cdt.core.pathentry"/>\r
+                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">\r
+                               <configuration artifactExtension="out" artifactName="../bin/qspiflashwriter_evmk2g" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" errorParsers="com.ti.ccstudio.errorparser.LinkErrorParser;com.ti.ccstudio.errorparser.CoffErrorParser;com.ti.ccstudio.errorparser.AsmErrorParser" id="com.ti.ccstudio.buildDefinitions.C6000.Debug.1869204513.1450862703" name="Debug" parent="com.ti.ccstudio.buildDefinitions.C6000.Debug">\r
+                                       <folderInfo id="com.ti.ccstudio.buildDefinitions.C6000.Debug.1869204513.1450862703." name="/" resourcePath="">\r
+                                               <toolChain id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain.367040430" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.1944927901">\r
+                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.288528615" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">\r
+                                                               <listOptionValue builtIn="false" value="DEVICE_CONFIGURATION_ID=com.ti.ccstudio.deviceModel.C6000.CustomC6000Device"/>\r
+                                                               <listOptionValue builtIn="false" value="DEVICE_ENDIANNESS=little"/>\r
+                                                               <listOptionValue builtIn="false" value="OUTPUT_FORMAT=ELF"/>\r
+                                                               <listOptionValue builtIn="false" value="CCS_MBS_VERSION=5.5.0"/>\r
+                                                               <listOptionValue builtIn="false" value="LINKER_COMMAND_FILE=qspiflashwriter.cmd"/>\r
+                                                               <listOptionValue builtIn="false" value="RUNTIME_SUPPORT_LIBRARY=libc.a"/>\r
+                                                               <listOptionValue builtIn="false" value="RTSC_PRODUCTS=ti.pdk:3.2.0.00;"/>\r
+                                                               <listOptionValue builtIn="false" value="OUTPUT_TYPE=rtscApplication:executable"/>\r
+                                                       </option>\r
+                                                       <option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.1824325960" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="7.4.4" valueType="string"/>\r
+                                                       <targetPlatform id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug.1217582867" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.targetPlatformDebug"/>\r
+                                                       <builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug.1108437343" name="GNU Make.Debug" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.builderDebug"/>\r
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug.1401006950" name="C6000 Compiler" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.compilerDebug">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION.1480926673" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.SILICON_VERSION" value="6600" valueType="string"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.1738823684" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.ABI.eabi" valueType="enumerated"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.1048194879" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH.184549289" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.INCLUDE_PATH" valueType="includePath">\r
+                                                                       <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>\r
+                                                                       <listOptionValue builtIn="false" value="&quot;${TI_PDK_INSTALL_DIR}/packages/ti/platform&quot;"/>\r
+                                                                       <listOptionValue builtIn="false" value="&quot;${TI_PDK_INSTALL_DIR}/packages&quot;"/>\r
+                                                                       <listOptionValue builtIn="false" value="&quot;${PROJECT_ROOT}/../include&quot;"/>\r
+                                                               </option>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER.358917726" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING.1921557331" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compilerID.DIAG_WARNING" valueType="stringList">\r
+                                                                       <listOptionValue builtIn="false" value="225"/>\r
+                                                               </option>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS.1399501020" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__C_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS.497586473" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__CPP_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS.675544284" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS.88050658" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.compiler.inputType__ASM2_SRCS"/>\r
+                                                       </tool>\r
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug.1944927901" name="C6000 Linker" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exe.linkerDebug">\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE.83886186" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.OUTPUT_FILE" value="&quot;../bin/qspiflashwriter_evmk2g.out&quot;" valueType="string"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE.1626445795" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.MAP_FILE" value="&quot;../bin/qspiflashwriter_evmk2g.map&quot;" valueType="string"/>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY.612257800" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.LIBRARY" valueType="libs">\r
+                                                                       <listOptionValue builtIn="false" value="&quot;libc.a&quot;"/>\r
+                                                                       <listOptionValue builtIn="false" value="&quot;ti.platform.evmk2g.ae66&quot;"/>\r
+                                                                       <listOptionValue builtIn="false" value="&quot;ti.csl.ae66&quot;"/>\r
+                                                               </option>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH.1607010671" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.SEARCH_PATH" valueType="libPaths">\r
+                                                                       <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/lib&quot;"/>\r
+                                                                       <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>\r
+                                                                       <listOptionValue builtIn="false" value="&quot;${TI_PDK_INSTALL_DIR}/packages/ti/platform/evmk2g/platform_lib/lib/debug&quot;"/>\r
+                                                                       <listOptionValue builtIn="false" value="&quot;${TI_PDK_INSTALL_DIR}/packages/ti/csl/lib/k2g/c66&quot;"/>\r
+                                                               </option>\r
+                                                               <option id="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO.58292138" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.linkerID.XML_LINK_INFO" value="&quot;../bin/qspiflashwriter_evmk2g_linkInfo.xml&quot;" valueType="string"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS.1655005893" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS.1624440822" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__CMD2_SRCS"/>\r
+                                                               <inputType id="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS.1210868694" name="Generated Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.exeLinker.inputType__GEN_CMDS"/>\r
+                                                       </tool>\r
+                                                       <tool id="com.ti.ccstudio.buildDefinitions.C6000_7.4.hex.1655062060" name="C6000 Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.C6000_7.4.hex"/>\r
+                                               </toolChain>\r
+                                       </folderInfo>\r
+                               </configuration>\r
+                       </storageModule>\r
+                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>\r
+                       <storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>\r
+                       <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>\r
+               </cconfiguration>\r
+       </storageModule>\r
+       <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>\r
+       <storageModule moduleId="cdtBuildSystem" version="4.0.0">\r
+               <project id="qspiflashwriter_evmk2g.com.ti.ccstudio.buildDefinitions.C6000.ProjectType.317048918" name="C6000" projectType="com.ti.ccstudio.buildDefinitions.C6000.ProjectType"/>\r
+       </storageModule>\r
+       <storageModule moduleId="org.eclipse.cdt.core.language.mapping">\r
+               <project-mappings>\r
+                       <content-type-mapping configuration="" content-type="org.eclipse.cdt.core.asmSource" language="com.ti.ccstudio.core.TIASMLanguage"/>\r
+                       <content-type-mapping configuration="" content-type="org.eclipse.cdt.core.cHeader" language="com.ti.ccstudio.core.TIGCCLanguage"/>\r
+                       <content-type-mapping configuration="" content-type="org.eclipse.cdt.core.cSource" language="com.ti.ccstudio.core.TIGCCLanguage"/>\r
+                       <content-type-mapping configuration="" content-type="org.eclipse.cdt.core.cxxHeader" language="com.ti.ccstudio.core.TIGPPLanguage"/>\r
+                       <content-type-mapping configuration="" content-type="org.eclipse.cdt.core.cxxSource" language="com.ti.ccstudio.core.TIGPPLanguage"/>\r
+               </project-mappings>\r
+       </storageModule>\r
+       <storageModule moduleId="scannerConfiguration"/>\r
+</cproject>\r
diff --git a/writer/qspi_flash/evmk2g/.project b/writer/qspi_flash/evmk2g/.project
new file mode 100644 (file)
index 0000000..1854c75
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>qspiflashwriter_evmk2g</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>\r
+                       <triggers>full,incremental,</triggers>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>com.ti.ccstudio.core.ccsNature</nature>\r
+               <nature>org.eclipse.cdt.core.cnature</nature>\r
+               <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>\r
+               <nature>org.eclipse.cdt.core.ccnature</nature>\r
+               <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>\r
+       </natures>\r
+       <linkedResources>\r
+               <link>\r
+                       <name>include</name>\r
+                       <type>2</type>\r
+                       <locationURI>PARENT-1-PROJECT_LOC/include</locationURI>\r
+               </link>\r
+               <link>\r
+                       <name>src</name>\r
+                       <type>2</type>\r
+                       <locationURI>PARENT-1-PROJECT_LOC/src</locationURI>\r
+               </link>\r
+       </linkedResources>\r
+</projectDescription>\r
diff --git a/writer/qspi_flash/evmk2g/.settings/org.eclipse.cdt.codan.core.prefs b/writer/qspi_flash/evmk2g/.settings/org.eclipse.cdt.codan.core.prefs
new file mode 100644 (file)
index 0000000..98b6350
--- /dev/null
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1\r
+inEditor=false\r
+onBuild=false\r
diff --git a/writer/qspi_flash/evmk2g/.settings/org.eclipse.cdt.debug.core.prefs b/writer/qspi_flash/evmk2g/.settings/org.eclipse.cdt.debug.core.prefs
new file mode 100644 (file)
index 0000000..58d4fb2
--- /dev/null
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1\r
+org.eclipse.cdt.debug.core.toggleBreakpointModel=com.ti.ccstudio.debug.CCSBreakpointMarker\r
diff --git a/writer/qspi_flash/evmk2g/.settings/org.eclipse.core.resources.prefs b/writer/qspi_flash/evmk2g/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..bf61e70
--- /dev/null
@@ -0,0 +1,10 @@
+eclipse.preferences.version=1\r
+encoding//Debug/bin/subdir_rules.mk=UTF-8\r
+encoding//Debug/bin/subdir_vars.mk=UTF-8\r
+encoding//Debug/makefile=UTF-8\r
+encoding//Debug/objects.mk=UTF-8\r
+encoding//Debug/sources.mk=UTF-8\r
+encoding//Debug/src/subdir_rules.mk=UTF-8\r
+encoding//Debug/src/subdir_vars.mk=UTF-8\r
+encoding//Debug/subdir_rules.mk=UTF-8\r
+encoding//Debug/subdir_vars.mk=UTF-8\r
diff --git a/writer/qspi_flash/evmk2g/bin/qspi_flash_writer_input.txt b/writer/qspi_flash/evmk2g/bin/qspi_flash_writer_input.txt
new file mode 100644 (file)
index 0000000..fc922b8
--- /dev/null
@@ -0,0 +1,5 @@
+file_name  = app.bin\r
+start_addr = 0\r
+\r
+\r
+\r
diff --git a/writer/qspi_flash/evmk2g/macros.ini_initial b/writer/qspi_flash/evmk2g/macros.ini_initial
new file mode 100644 (file)
index 0000000..4ae3cc4
--- /dev/null
@@ -0,0 +1 @@
+TI_MCSDK_WRITER_DIR="../../../../\r
diff --git a/writer/qspi_flash/evmk2g/qspiflashwriter.cmd b/writer/qspi_flash/evmk2g/qspiflashwriter.cmd
new file mode 100644 (file)
index 0000000..0b6b00a
--- /dev/null
@@ -0,0 +1,78 @@
+/*\r
+ * Copyright (c) 2015, Texas Instruments Incorporated\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ * *  Redistributions of source code must retain the above copyright\r
+ *    notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * *  Redistributions in binary form must reproduce the above copyright\r
+ *    notice, this list of conditions and the following disclaimer in the\r
+ *    documentation and/or other materials provided with the distribution.\r
+ *\r
+ * *  Neither the name of Texas Instruments Incorporated nor the names of\r
+ *    its contributors may be used to endorse or promote products derived\r
+ *    from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ */\r
+\r
+/*\r
+ *  Linker command file\r
+ *\r
+ */\r
+\r
+-c\r
+-heap  0x40000\r
+-stack 0x8000\r
+\r
+/* Memory Map 1 - the default */\r
+MEMORY\r
+{\r
+    L1PSRAM (RWX)  : org = 0x0E00000, len = 0x7FFF\r
+    L1DSRAM (RWX)  : org = 0x0F00000, len = 0x7FFF \r
+\r
+    L2SRAM (RWX)   : org = 0x0820000, len = 0xe0000\r
+    MSMCSRAM (RWX) : org = 0xC000000, len = 0x100000\r
+    DDR3 (RWX)     : org = 0x80000000,len = 0x10000000\r
+}\r
+\r
+SECTIONS\r
+{\r
+    .csl_vect   >       L2SRAM\r
+    .cppi       >       L2SRAM\r
+    .linkram    >       L2SRAM\r
+    .mac_buffer >       L2SRAM\r
+    platform_lib >     L2SRAM\r
+    .text       >       L2SRAM\r
+    GROUP (NEAR_DP)\r
+    {\r
+    .neardata\r
+    .rodata \r
+    .bss\r
+    } load > L2SRAM\r
+    .stack      >       L2SRAM\r
+    .cinit      >       L2SRAM\r
+    .cio        >       L2SRAM\r
+    .const      >       L2SRAM\r
+    .data       >       L2SRAM\r
+    .switch     >       L2SRAM\r
+    .sysmem     >       L2SRAM\r
+    .far        >       L2SRAM\r
+    .testMem    >       L2SRAM\r
+    .fardata    >       L2SRAM\r
+}\r
diff --git a/writer/qspi_flash/include/types.h b/writer/qspi_flash/include/types.h
new file mode 100644 (file)
index 0000000..50dbcc4
--- /dev/null
@@ -0,0 +1,46 @@
+/*\r
+ *\r
+ * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.com/\r
+ *\r
+ *\r
+ *  Redistribution and use in source and binary forms, with or without\r
+ *  modification, are permitted provided that the following conditions\r
+ *  are met:\r
+ *\r
+ *    Redistributions of source code must retain the above copyright\r
+ *    notice, this list of conditions and the following disclaimer.\r
+ *\r
+ *    Redistributions in binary form must reproduce the above copyright\r
+ *    notice, this list of conditions and the following disclaimer in the\r
+ *    documentation and/or other materials provided with the\r
+ *    distribution.\r
+ *\r
+ *    Neither the name of Texas Instruments Incorporated nor the names of\r
+ *    its contributors may be used to endorse or promote products derived\r
+ *    from this software without specific prior written permission.\r
+ *\r
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+*/\r
+\r
+\r
+\r
+#ifndef _TYPES_H\r
+#define _TYPES_H\r
+\r
+typedef uint32_t Bool;\r
+\r
+#define FALSE 0\r
+#define TRUE  1\r
+\r
+#endif /* types.h */\r
diff --git a/writer/qspi_flash/src/qspiflashwriter.c b/writer/qspi_flash/src/qspiflashwriter.c
new file mode 100644 (file)
index 0000000..a0ec20d
--- /dev/null
@@ -0,0 +1,516 @@
+/*\r
+ * Copyright (c) 2015, Texas Instruments Incorporated\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ * *  Redistributions of source code must retain the above copyright\r
+ *    notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * *  Redistributions in binary form must reproduce the above copyright\r
+ *    notice, this list of conditions and the following disclaimer in the\r
+ *    documentation and/or other materials provided with the distribution.\r
+ *\r
+ * *  Neither the name of Texas Instruments Incorporated nor the names of\r
+ *    its contributors may be used to endorse or promote products derived\r
+ *    from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ */\r
+\r
+/**************************************************************************************\r
+ * FILE PURPOSE: QSPI Flash writer utility\r
+ **************************************************************************************\r
+ * FILE NAME: qspiflashwriter.c\r
+ *\r
+ * DESCRIPTION: A simple flash writer using platform lib APIs to program the\r
+ *              QSPI flash with an image that the ibl can read.\r
+ *\r
+ ***************************************************************************************/\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include "platform.h"\r
+#include "types.h"\r
+\r
+/* QSPI flash writer utility version */\r
+char version[] = "01.00.00.00";\r
+\r
+/* The input file name is hard coded */\r
+char *input_file = "qspi_flash_writer_input.txt";\r
+\r
+uint32_t swap_byte = 0;\r
+\r
+/* Parameters defined in the input_file */\r
+#define FILE_NAME      "file_name"\r
+#define START_ADDR     "start_addr"\r
+\r
+/* Memory address to store the write data */\r
+#define WRITE_DATA_ADDRESS     0x80000000\r
+\r
+/******************************************************************************\r
+ * Structure:   QSPI_FLASH_WRITER_INFO_T\r
+ *\r
+ *              QSPI Flash writer control data. This structure should be\r
+ *              filled in by the user before running\r
+ ******************************************************************************/\r
+#define MAX_LINE_LENGTH 40\r
+typedef struct QSPI_FLASH_WRITER_INFO_tag\r
+{\r
+    char        file_name[MAX_LINE_LENGTH]; /* CCS format data file name */\r
+    uint32_t    blockSizeBytes;             /* The size of each sector */\r
+    uint32_t    deviceTotalBytes;           /* Total number of bytes available in the device */\r
+    uint32_t    startAddr;                  /* Start address to write */\r
+    uint32_t    writeBytes;                 /* Number of bytes to be written into the device */\r
+    uint8_t     *writeData;                 /* Address to store the write data */\r
+    uint8_t     *readData;                  /* Address to store the read data */\r
+\r
+} QSPI_FLASH_WRITER_INFO_T;\r
+\r
+QSPI_FLASH_WRITER_INFO_T qspiFlashWriterInfo;\r
+\r
+/* OSAL functions for Platform Library */\r
+uint8_t *Osal_platformMalloc (uint32_t num_bytes, uint32_t alignment)\r
+{\r
+       return malloc(num_bytes);\r
+}\r
+\r
+void Osal_platformFree (uint8_t *dataPtr, uint32_t num_bytes)\r
+{\r
+    /* Free up the memory */\r
+    if (dataPtr)\r
+    {\r
+        free(dataPtr);\r
+    }\r
+}\r
+\r
+void Osal_platformSpiCsEnter(void)\r
+{\r
+    return;\r
+}\r
+\r
+void Osal_platformSpiCsExit (void)\r
+{\r
+    return;\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    print_platform_errno\r
+ ******************************************************************************/\r
+void\r
+print_platform_errno\r
+(\r
+    void\r
+)\r
+{\r
+    printf ("Returned platform error number is %d\n", platform_errno);\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    formBlock\r
+ *\r
+ *      Form a block of data to write to the QSPI flash. The block is\r
+ *      created as a byte stream from the 4 byte stream in which\r
+ *      the MSB is always sent first.\r
+ ******************************************************************************/\r
+void\r
+formBlock\r
+(\r
+    uint32_t      *data,\r
+    uint32_t      blockSize,\r
+    uint8_t       *scratch\r
+)\r
+{\r
+    uint32_t i, j;\r
+\r
+    /* Convert the data to a byte stream */\r
+    for (i = j = 0; j < blockSize; i++, j+=4)\r
+    {\r
+        scratch[j+0] = (data[i] >> 24) & 0xff;\r
+        scratch[j+1] = (data[i] >> 16) & 0xff;\r
+        scratch[j+2] = (data[i] >>  8) & 0xff;\r
+        scratch[j+3] = (data[i] >>  0) & 0xff;\r
+    }\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    write_qspi_flash\r
+ *\r
+ *              Write the image to flash.\r
+ *              Returns TRUE if the image is written successfully\r
+ *                      FALSE if the image write fails\r
+ ******************************************************************************/\r
+Bool\r
+write_qspi_flash\r
+(\r
+    PLATFORM_DEVICE_info    *p_device\r
+)\r
+{\r
+    uint32_t      wPos, wLen;\r
+    uint32_t      block, start_block;\r
+    uint8_t       *scrach_block;\r
+\r
+    if (swap_byte)\r
+    {\r
+        scrach_block = malloc(qspiFlashWriterInfo.blockSizeBytes);\r
+        if (scrach_block == NULL)\r
+        {\r
+            printf ("Can not allocate scratch block memory!\n");\r
+            return (FALSE);\r
+        }\r
+    }\r
+\r
+    start_block = qspiFlashWriterInfo.startAddr / qspiFlashWriterInfo.blockSizeBytes;\r
+\r
+    /* Program the QSPI flash */\r
+    for (block = start_block, wPos = 0; wPos < qspiFlashWriterInfo.writeBytes; block++, wPos += qspiFlashWriterInfo.blockSizeBytes)\r
+    {\r
+        printf ("Flashing sector %d (%d bytes of %d)\n", block, wPos, qspiFlashWriterInfo.writeBytes);\r
+\r
+        wLen = qspiFlashWriterInfo.blockSizeBytes;\r
+        if ((qspiFlashWriterInfo.writeBytes - wPos) < qspiFlashWriterInfo.blockSizeBytes)\r
+        {\r
+            wLen = (qspiFlashWriterInfo.writeBytes - wPos);\r
+        }\r
+\r
+        if (swap_byte)\r
+        {\r
+            formBlock((uint32_t *)(&qspiFlashWriterInfo.writeData[wPos]), wLen, scrach_block);\r
+        }\r
+        else\r
+        {\r
+            scrach_block = &qspiFlashWriterInfo.writeData[wPos];\r
+        }\r
+\r
+        if (platform_device_write(p_device->handle,\r
+                                  (block * qspiFlashWriterInfo.blockSizeBytes),\r
+                                  scrach_block,\r
+                                  wLen) != Platform_EOK)\r
+        {\r
+            printf ("platform_device_write sector # %d failed!\n", block);\r
+            print_platform_errno();\r
+            if (swap_byte) free (scrach_block);\r
+            return (FALSE);\r
+        }\r
+    }\r
+\r
+    if (swap_byte) free (scrach_block);\r
+    return (TRUE);\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    flash_verify\r
+ *\r
+ *              Read back the data file that was just flashed.\r
+ *              Returns TRUE if the image verified correctly.\r
+ *                      FALSE if the image verification failed\r
+ ******************************************************************************/\r
+Bool\r
+flash_verify\r
+(\r
+    PLATFORM_DEVICE_info    *p_device\r
+)\r
+{\r
+    uint32_t      rPos, rLen;\r
+    uint32_t      i, j;\r
+    uint32_t      block, start_block;\r
+    uint8_t       *scrach_block;\r
+    uint32_t      *read_data_w;\r
+\r
+    if (swap_byte)\r
+    {\r
+        scrach_block = malloc(qspiFlashWriterInfo.blockSizeBytes);\r
+        if (scrach_block == NULL)\r
+        {\r
+            printf ("Can not allocate scratch block memory!\n");\r
+            return (FALSE);\r
+        }\r
+    }\r
+\r
+    start_block = qspiFlashWriterInfo.startAddr / qspiFlashWriterInfo.blockSizeBytes;\r
+\r
+    for (block = start_block, rPos = 0; rPos < qspiFlashWriterInfo.writeBytes; block++, rPos += qspiFlashWriterInfo.blockSizeBytes)\r
+    {\r
+        printf ("Reading and verifying sector %d (%d bytes of %d)\n", block, rPos, qspiFlashWriterInfo.writeBytes);\r
+\r
+        if (!swap_byte)\r
+        {\r
+            scrach_block = &qspiFlashWriterInfo.readData[rPos];\r
+\r
+        }\r
+\r
+        /* Read a sector of data */\r
+        if(platform_device_read(p_device->handle,\r
+                                (block * qspiFlashWriterInfo.blockSizeBytes),\r
+                                scrach_block,\r
+                                qspiFlashWriterInfo.blockSizeBytes) != Platform_EOK)\r
+        {\r
+            printf ("Failure in sector %d\n", block);\r
+            print_platform_errno();\r
+            if (swap_byte) free (scrach_block);\r
+            return (FALSE);\r
+        }\r
+\r
+        /* Convert the packed data */\r
+        if (swap_byte)\r
+        {\r
+            read_data_w = (uint32_t *)(&qspiFlashWriterInfo.readData[rPos]);\r
+            for  (i = 0, j = 0; i < qspiFlashWriterInfo.blockSizeBytes; i += 4)\r
+            {\r
+                read_data_w[j++] = (scrach_block[i+0] << 24) |\r
+                                   (scrach_block[i+1] << 16) |\r
+                                   (scrach_block[i+2] << 8)  |\r
+                                    scrach_block[i+3];\r
+                       }\r
+        }\r
+\r
+        /* Read the data from the file */\r
+        rLen = qspiFlashWriterInfo.blockSizeBytes;\r
+        if ((qspiFlashWriterInfo.writeBytes - rPos) < qspiFlashWriterInfo.blockSizeBytes)\r
+        {\r
+            rLen = (qspiFlashWriterInfo.writeBytes - rPos);\r
+        }\r
+\r
+        for (i = rPos; i < rLen; i++)\r
+        {\r
+            if (qspiFlashWriterInfo.readData[i] != qspiFlashWriterInfo.writeData[i])\r
+            {\r
+                printf ("Failure in sector %d, at byte %d, (at byte %d in the data file) expected 0x%08x, read 0x%08x\n",\r
+                        block, i, rPos, qspiFlashWriterInfo.writeData[i], qspiFlashWriterInfo.readData[i]);\r
+                if (swap_byte) free (scrach_block);\r
+                return (FALSE);\r
+            }\r
+        }\r
+\r
+    }\r
+\r
+    if (swap_byte) free (scrach_block);\r
+    return (TRUE);\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    parse_input_file\r
+ ******************************************************************************/\r
+static Bool\r
+parse_input_file\r
+(\r
+    FILE*               fp\r
+)\r
+{\r
+    char line[MAX_LINE_LENGTH];\r
+    char tokens[] = " :=;\n\r";\r
+    char *key, *data;\r
+\r
+    memset(line, 0, MAX_LINE_LENGTH);\r
+\r
+    fgets(line, MAX_LINE_LENGTH, fp);\r
+    key  = (char *)strtok(line, tokens);\r
+    data = (char *)strtok(NULL, tokens);\r
+\r
+    if(strlen(data) == 0)\r
+    {\r
+       return FALSE;\r
+    }\r
+\r
+    if(strcmp(key, FILE_NAME) != 0)\r
+    {\r
+        return FALSE;\r
+    }\r
+\r
+    strcpy (qspiFlashWriterInfo.file_name, data);\r
+\r
+    fgets(line, MAX_LINE_LENGTH, fp);\r
+    key  = (char *)strtok(line, tokens);\r
+    data = (char *)strtok(NULL, tokens);\r
+\r
+    if(strlen(data) == 0)\r
+    {\r
+       return FALSE;\r
+    }\r
+\r
+    if(strcmp(key, START_ADDR) != 0)\r
+    {\r
+        return FALSE;\r
+    }\r
+\r
+    qspiFlashWriterInfo.startAddr = (uint32_t)atoi(data);\r
+\r
+    return TRUE;\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    find_file_length\r
+ ******************************************************************************/\r
+static Bool\r
+find_file_length\r
+(\r
+    FILE*               fp\r
+)\r
+{\r
+    char        line[MAX_LINE_LENGTH];\r
+    char        *pEnd;\r
+    char        *ext;\r
+    uint32_t    data_len, write_addr;\r
+\r
+    memset(line, 0, MAX_LINE_LENGTH);\r
+\r
+    ext = strrchr(qspiFlashWriterInfo.file_name, '.');\r
+\r
+\r
+    if (ext && (strcmp(ext, ".dat") == 0))\r
+    {\r
+    fgets(line, MAX_LINE_LENGTH, fp);\r
+\r
+    /* Read the write address from the CCS header */\r
+    strtoul (line,&pEnd,16);\r
+    strtoul (pEnd,&pEnd,16);\r
+    write_addr = strtoul (pEnd,&pEnd,16);\r
+    strtoul (pEnd,&pEnd,16);\r
+\r
+    /* Read the data length */\r
+    data_len = (strtoul (pEnd,NULL,16)) * 4;\r
+    }\r
+    else\r
+    {\r
+        /* find the data length by seeking to the end and getting position */\r
+        fseek(fp, 0, SEEK_END);\r
+        data_len = ftell(fp);\r
+        fseek(fp, 0, SEEK_SET);\r
+    }\r
+\r
+    if (data_len > (qspiFlashWriterInfo.deviceTotalBytes - qspiFlashWriterInfo.startAddr))\r
+    {\r
+        printf ("The data file is too big to fit into the device.\n");\r
+        return FALSE;\r
+    }\r
+\r
+    qspiFlashWriterInfo.writeBytes = data_len;\r
+    if (write_addr != WRITE_DATA_ADDRESS)\r
+        write_addr = WRITE_DATA_ADDRESS;\r
+    qspiFlashWriterInfo.writeData  = (uint8_t *)write_addr;\r
+    qspiFlashWriterInfo.readData   = (uint8_t *)(write_addr + qspiFlashWriterInfo.deviceTotalBytes);\r
+\r
+    return TRUE;\r
+}\r
+\r
+/******************************************************************************\r
+ * Function:    main\r
+ ******************************************************************************/\r
+void main ()\r
+{\r
+    FILE                    *fp;\r
+    platform_init_flags     init_flags;\r
+    platform_init_config    init_config;\r
+    PLATFORM_DEVICE_info    *p_device;\r
+    Bool                    ret;\r
+\r
+    printf("QSPI Flash Writer Utility Version %s\n\n", version);\r
+\r
+    fp = fopen(input_file, "r");\r
+    if (fp == NULL)\r
+    {\r
+        printf("Error in opening %s input file\n", input_file);\r
+        return;\r
+    }\r
+\r
+    ret = parse_input_file(fp);\r
+    fclose (fp);\r
+\r
+    if (ret == FALSE)\r
+    {\r
+        printf("Error in parsing %s input file\n", input_file);\r
+        return;\r
+    }\r
+\r
+    /* Initialize main Platform lib */\r
+    memset(&init_config, 0, sizeof(platform_init_config));\r
+    memset(&init_flags, 1, sizeof(platform_init_flags));\r
+    init_flags.pll = 0;\r
+    init_flags.ddr = 0;\r
+    init_flags.phy = 0;\r
+    if (platform_init(&init_flags, &init_config) != Platform_EOK)\r
+    {\r
+        printf ("Platform init failed!\n");\r
+        print_platform_errno();\r
+        return;\r
+    }\r
+\r
+    p_device = platform_device_open(PLATFORM_DEVID_QSPIFLASH_S25FL512S, 0);\r
+    if (p_device == NULL)\r
+    {\r
+        printf ("QSPI Flash device open failed!\n");\r
+        print_platform_errno();\r
+        return;\r
+    }\r
+    qspiFlashWriterInfo.deviceTotalBytes  = p_device->block_count * p_device->page_count * p_device->page_size;\r
+    qspiFlashWriterInfo.blockSizeBytes    = p_device->page_count * p_device->page_size;\r
+\r
+    if ((qspiFlashWriterInfo.startAddr % qspiFlashWriterInfo.blockSizeBytes) != 0)\r
+    {\r
+        printf ("The start programming address 0x%8x set in %s is not at the beginning of a block, block size = 0x%4x\n",\r
+                qspiFlashWriterInfo.startAddr,\r
+                qspiFlashWriterInfo.file_name,\r
+                qspiFlashWriterInfo.blockSizeBytes);\r
+        return;\r
+    }\r
+\r
+    /* Open and find the length of the data file */\r
+    fp = fopen (qspiFlashWriterInfo.file_name, "rb");\r
+    if (fp == NULL)\r
+    {\r
+      printf ("Failed to open file %s\n", qspiFlashWriterInfo.file_name);\r
+      platform_device_close(p_device->handle);\r
+      return;\r
+    }\r
+\r
+    /* Parse the CCS format file */\r
+    ret = find_file_length(fp);\r
+    fclose (fp);\r
+\r
+    qspiFlashWriterInfo.writeBytes += qspiFlashWriterInfo.blockSizeBytes - 1;\r
+    qspiFlashWriterInfo.writeBytes -= qspiFlashWriterInfo.writeBytes % qspiFlashWriterInfo.blockSizeBytes;\r
+\r
+    if (ret == FALSE)\r
+    {\r
+        printf("Error in parsing CCS file %s\n", qspiFlashWriterInfo.file_name);\r
+        platform_device_close(p_device->handle);\r
+        return;\r
+    }\r
+\r
+    /* Write the flash */\r
+    if (write_qspi_flash (p_device) == FALSE)\r
+    {\r
+        printf ("QSPI Flash write failed\n");\r
+        platform_device_close(p_device->handle);\r
+        return;\r
+    }\r
+\r
+    /* verify the flash */\r
+    if(flash_verify (p_device) == FALSE)\r
+    {\r
+        printf ("QSPI Flash read verify failed\n");\r
+        platform_device_close(p_device->handle);\r
+        return;\r
+    }\r
+\r
+\r
+    printf ("QSPI Flash programming completed successfully\n");\r
+\r
+    platform_device_close(p_device->handle);\r
+\r
+    return;\r
+}\r
+\r