build_factory_source: For advanced users The build_restore.sh script generates the restore_0 and restore_1 factory flash files from files created by various Altera tools. This directory contains the files used to build the BUP restore flash object files. Build_restore.sh script commands may be run individually at a unix, linux, or Nios II EDS command shell. a2gx125_fpga_bup hardware sof files from the project directories are converted using Nios II Tool sof2flash to attain flash files: sof2flash --offset=0x020000 --input=a2gx125_fpga_bup.sof --output=a2gx125_fpga_bup.flash --pfl --optionbit=0x18000 --programmingmode=PS sof2flash --offset=0x640000 --input=bts_config.sof --output=bts_config.flash --pfl --optionbit=0x18000 --programmingmode=PS a2gx125_fpga_bup software - run make flash from the app\web_server dir after running make to build software elf make flash actual rebuilding script of restore files can happen here for the end user: For eventual memory map - cat flash files for external flash die cat boot_code.flash pfl_bits.flash boardInfo.srec a2gx125_fpga_bup.flash bts_config.flash html_a2gx125.flash ext_flash.flash > temp_restore.flash delete unnecessary s-records after concatenation: sed '/^S[05789]/ d' temp_restore.flash > restore_a2gx125_fpga.flash delete temp files rm -f temp_restore.flash To restore flash after building the restore files, follow instructions as specified in the Getting Started User's Guide, Page A-4: "Restoring the Flash Device with the Factory Settings" Note that the flash files may also be programmed individually using nios2-flash-programmer as follows: nios2-flash-programmer -b 0x08000000 a2gx125_fpga_bup.flash nios2-flash-programmer -b 0x08000000 bts_config.flash nios2-flash-programmer -b 0x08000000 html_a2gx125.flash nios2-flash-programmer -b 0x08000000 ext_flash.flash nios2-flash-programmer -b 0x08000000 pfl_bits.flash nios2-flash-programmer -b 0x08000000 boot_code.flash For proper restore to work, the board FPGA should still also be one-time configured as described in the User's Guide, entitled: "Restoring the Flash Device with the Factory Settings" Errata: Re: Nios II EDS 11.0 tool : sof2flash.exe -------------------------------------------------------------------------------- Arria II GX Board Update Portal Design - Flash Recovery - Errata July 25, 2011 -------------------------------------------------------------------------------- Problem Description: The release of Nios II EDS 11.0 tool "sof2flash" does not include support for Arria II GX. Work-around: To create the recovery files, Quartus II "Convert Programming Files" option was used to create a POF file. This file was written to the flash on the board. The individual flash files "a2gx125_fpga_bup.flash" and "bts_config.flash" and the PFL Option register section "pfl_bits.flash" were then read using Nios II EDS nios2-flash-programmer command on the command line. Please read instructions for using Quartus II "Convert Programming Files" and Quartus II Programmer before attempting to prepare a design to be written to flash. At any time, the board factory files may be restored using the factory_recovery build script "./restore.sh" command. Please consult the User Guide for more instructions before proceeding! Instructions for performing the work-around on any design: -------------------------------------------------------------------------------- 1. Convert the Quartus II HW design sof to pof using Quartus II "Convert Programming Files" option. a. Make sure the a2gx_config.sof file is renamed to bts_config.sof. b. Under "Conversion setup files", select "Open Conversion Setup Data" and choose /a2gx125_fpga_bup/software_examples/factory_recovery/build_factory_source/a2gx_bup_bts_recovery.cof c. Select Generate to create the "a2gx125_fpga_bup_bts_recovery.pof" file (approximately 65MB) 2. Set Sw4.4 on the board to "0" (ON) position and cycle power to the board. 3. Use Quartus II Programmer to configure "a2gx_pfl_programming.sof" as described in the User Guide chapter entitled: "Configuring the FPGA Using the Quartus II Programmer" 4. Write the pof "a2gx125_fpga_bup_bts_recovery.pof" to the device using Quartus II Programmer as described in the "Using FPGA-Based Parallel Flash Loader with the Quartus II Software" chapter entitled: "Programming the Parallel Flash Device Using PFL in User Design" www.altera.com/literature/an/an478.pdf 5. Write "a2gx125_fpga_bup.sof" to the device using Quartus II Programmer. 6. Use nios2-flash-programmer to read (thus create) the configuration images to .flash files: >nios2-flash-programmer --base=0x8000000 --read=a2gx125_fpga_bup.flash --read-bytes=0x0020000,0x0060A78F >nios2-flash-programmer --base=0x8000000 --read=bts_config.flash --read-bytes=0x0640000,0x0060A78F >nios2-flash-programmer --base=0x8000000 --read=pfl_bits.flash --read-bytes=0x018000,0x100 7. Use these as reliable flash images in a similar script to the build_restore.sh found in build_factory_source directory. 8. Use the ./restore script in fcatory_recovery directory to write the generated restore flash files as described in the User's Guide chapter entitled: "Restoring the Flash Device with the Factory Settings" Please consult the User Guide for instructions before proceeding! For more information, please visit the Altera Arria II GX Development Kit website located at: http://www.altera.com/products/devkits/altera/kit-aiigx-pcie.html -------------------------------------------------------------------------------- Errata Revision: Date Description ---- ----------- July 22, 2009 Nios II EDS 9.0sp2 tool : sof2flash.exe does not include support for Arria II GX. July 25, 2011 Updated QII version number. Edited item 1, 2, 4 and added item 5. --------------------------------------------------------------------------------