- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone,
I'm using the remote update controller (cyclone III) on my Cyclone IV GX dev board with a EPCS128 flash memory. I wish to have two firmwares in my EPCS (factory and application). Actually, I placed the firmware like this in the EPCS: 0x000000 Factory image (hw0 + sw0) 0x440000 Application image (hw1 + sw1) (I'm not using the flash programmer to load the image in flash memory) The nios II boots correctly on the factory image when I start the board. But when I try to reconfig the FPGA with the application image using the remote update controller, the Factory image is loaded... I write 0x110000 to the remote update controller, then start the reconfig for loading the application image. Is this address correct? I think my problem comes when I'm creating the application image. Here is my script to create the .flash: --- Quote Start --- java -jar C:\altera\11.0\nios2eds\bin\sof2flash.jar --epcs --input="..\..\2Dcam.sof" --output="2Dcam_sof.flash" --verbose java -jar C:\altera\11.0\nios2eds\bin\elf2flash.jar --epcs --after="2Dcam_sof.flash" --input="..\2DCam\2DCam.elf" --output="2DCam_elf.flash" --offset 0 rem merge the two files copy /b /y 2Dcam_sof.flash+2DCam_elf.flash 2DCam.flash --- Quote End --- I create factory and application image (.flash) with this script. And load the factory image at address 0x000000 and the application at address 0x440000 in EPCS. Do I have to make something different for the application image, because her address is not 0x000000? Has anyone the same problem? Best regardsLink Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hallo
You must change the bootloader for the application image to start from the new address.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply!
Can you explain me how to change the address in the bootloader? Regards- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The source code for the default bootloader is included in the Quartus distribution (C:\altera\11.1\ip\altera\nios2_ip\altera_nios2\boot_loader_sources) and must be modified for the application image. First you change the assembly file boot_loader_epcs_bits_sii_siii_ciii.S so that the bootloader for the application image jumps to the Nios code for the application image (which is just after the FPGA configuration for EPCS). Here is one way to change to this code: 1) Add a define to the offset to the application image:# define IMAGE_START 0x00440000 2) Replace all occurencs of the following code : (several places in the code) movi r_flash_ptr, xx with: movhi r_flash_ptr, %hi(IMAGE_START) ori r_flash_ptr, r_flash_ptr, xx 3) Add the following statement before fp_short_circuit: orhi r_flash_ptr, r_flash_ptr, %hi(IMAGE_START) This should work if the 16 lower bits of IMAGE_START are 0. Then run make (Last time I tried it I only got it working with the gcc3 quartus 10.0, not with gcc4). Then go to the obj directory and run: elf2hex --input="boot_loader_epcs_sii_siii_ciii.elf" --output="epcs_controller_boot_rom.hex" --base=0 --width=32 --end=1023 --record=4 --lower You must then replace the boot rom file in your design with this file. In Quartus 11.1 the file name may be changed to epcs_flash_controller_boot_rom_synth.hex. Note that you do not have to recompile the whole design, you just select 'Update Memory Iniialization File' in Quartus and run the asssembler after changing the bootloader. I have tested this for Stratix II,III,IV and Cyclone IV.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the explication!
How do you create the file "boot_loader_epcs_sii_siii_ciii.elf" or where can I find it? Regards- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The file is generated when you run "make" in the boot_loader_sources directory (it is found under obj)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply!
But I have ever the same problem. The Application image doesn't work. Here is my procedure: 1) I have changed the "boot_loader_epcs_bits_sii_siii_ciii.S" 2) run "make" 3) I have created the "epcs_controller_boot_rom.hex" with your code: --- Quote Start --- elf2hex --input="boot_loader_epcs_sii_siii_ciii.elf" --output="epcs_controller_boot_rom.hex" --base=0 --width=32 --end=1023 --record=4 --lower --- Quote End --- 4)In Quartus, I have selected "Update Memory Initialization File" and run the assembler: --- Quote Start --- Info (39025): Processed Memory Initialization File C:/Users/julien.egli/Atracsys/CI/firmware.atr.2Dcam/ODSP2b_DBC4GX150/dev/FPGA/2Dcam/sopc_2dcam_epcs_flash_controller_0_boot_rom_synth.hex --- Quote End --- 5) Created the Application image: --- Quote Start --- java -jar C:\altera\11.0\nios2eds\bin\sof2flash.jar --epcs --input="..\..\2Dcam.sof" --output="2Dcam_sof.flash" --verbose java -jar C:\altera\11.0\nios2eds\bin\elf2flash.jar --epcs --after="2Dcam_sof.flash" --input="..\2DCam\2DCam.elf" --output="2DCam_elf.flash" --offset 0 rem merge the two files copy /b /y 2Dcam_sof.flash+2DCam_elf.flash 2DCam.flash --- Quote End --- 6) Written the image at address "0x440000" in EPCS using "alt_write_flash" function 7)Then I reboot on the factory image and use the Remote Update controller to reconfig with the application image: Offset for reconfiguration image in flash: 0x110000 8)Then I start the reconfig of the FPGA Please, can you tell me if I do something wrong? Regards- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I cannot see that you do anything wrong, its correct to shift the address 2 bits right. Here are some ideas to further debugging:
1) Do you disable the watchdog ? (0 to parameter 3 of altremote_update) 2) Read out and check the registers of altremote_update before and after you try to restart in application image. Note that its confusing which value to use for read_source for Cyclone III/IV. I have come to that read_source shall be 0 for parameter 1 (Current image), 2 for parameter 4 (Boot address) and 1 for parameter 7 (Config source) 3) Make the configuration and software different for factory/application image so that you are sure that you looking at the correct image. 4) Verify that you have written the flash correctly. 5) Use signaltap to see what is happening In your final design its a good idea to check the application image on the EPCS flash before restarting to it from factory image.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Must I change the reset vector offset of the CPU for the application image?
Regards- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, you set the reset vector for the Nios processor to epcs_flash_controller with offset 0 for both factory and application image.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how can I know if the correct bootloader is taken when I use the elf2flash?
Do I need to do somthing regarding the boot record? Thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In order to check which bootloader is used from your application program, you can check the hex files for the bootloaders and find a memory location that is different and test on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you send me your customize bootloader (boot_loader_epcs_bits_sii_siii_ciii.S and epcs_controller_boot_rom.hex), please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is the file I modified in the boot loader program. I also included the original Altera code from Quartus 8.1. You must change the boot address to your application.
Note that there is a test on the Device ID in the code, so this code will for example not work for Stratix IV without modification. It may however work with cyclone IV. This test on Device ID has been removed in later versions of the boot code from Altera, and you can include my modifications in the new version. I also think you must modify the code if the lower 16 bits in the boot address is not 0.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for you reply! I found one different with my file, but it doesn't work.
I have two more questions: 1) --- Quote Start --- elf2hex --input="boot_loader_epcs_sii_siii_ciii.elf" --output="epcs_controller_boot_rom.hex" --base=0 --width=32 --end=1023 --record=4 --lower --- Quote End --- How did you choose the base address and the end address? 2) Is it correct that the bootloader point on the FPGA configuration image and not on the software image, placed just after FPGA configuration image? Thanks Regards- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have not worked on this for a while and I am not sure, but:
1) The size of the code is less than 1024 bytes (see comments in code) and probably it must fit to a 1024 byte boundary. 2) Yes, the bootloader shall point on the configuration image, not the software.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found the problem. It becames when I generate the "epcs_controller_boot_rom.hex" file with the command:
--- Quote Start --- elf2hex --input="boot_loader_epcs_sii_siii_ciii.elf" --output="epcs_controller_boot_rom.hex" --base=0 --width=32 --end=1023 --record=4 --lower --- Quote End --- The "epcs_controller_boot_rom.hex" file was filled with 0. This was the problem. Thank you very much for your help! :) Regards- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hallodu,I am facing the same problem you've described above.
Now, converting my elf file to a bigger hex file, lets say with option --end=10230, my boot hex file is filled with zero until address 0x0400, then starts the bootloader data. But if I try update this hex file on quartus it gets truncated and starts the on_chip_ram at EPCS controller base with 0s. How did you fix it? I am thinking in using the -no-zero-fill option on elf2flash program and editing the addresses and CRC for each line, but there have to be a easier way.. (?) :confused: Thank you in advance :-P- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hallodu
I am also facing the same problem. When I use the following command --- Quote Start --- elf2hex --input="boot_loader_epcs_sii_siii_ciii.elf" --output="kernel_epcs_boot_rom_synth.hex" --base=0 --width=32 --end=1023 --record=4 --lower --- Quote End --- The .hex file is filled by 0. If I add --no-zero-fill option, the .hex file has only one line. Do you fix it? Thank you- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Attached is my solution. In the .zip, you have all the files needed for the .bat. 1) Enter your application address (IMAGE_START) in boot_loader_epcs_bits_sii_siii_ciii.S file 2) running this .bat 3) copy SOPC_2Dcam_epcs_flash_controller_0_boot_rom_synth.hex in your <project>/SOPC_folder/synthesis/submodules/ 4) In Quartus, Processing -> Update Memory Initialization File 5) In Quartus, Processing -> Start -> Start Assembler Be careful, the .bat is for Quartus v11.1, if you are using another version. Open the .bat file with a text editor and change all 11.1 with your version number. for example: --- Quote Start --- set PATH=%PATH%;C:\altera\11.1\quartus\bin; -> set PATH=%PATH%;C:\altera\12.0\quartus\bin; --- Quote End ---- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- Hi, Attached is my solution. In the .zip, you have all the files needed for the .bat. 1) Enter your application address (IMAGE_START) in boot_loader_epcs_bits_sii_siii_ciii.S file 2) running this .bat 3) copy SOPC_2Dcam_epcs_flash_controller_0_boot_rom_synth.hex in your <project>/SOPC_folder/synthesis/submodules/ 4) In Quartus, Processing -> Update Memory Initialization File 5) In Quartus, Processing -> Start -> Start Assembler Be careful, the .bat is for Quartus v11.1, if you are using another version. Open the .bat file with a text editor and change all 11.1 with your version number. for example: --- Quote End --- Thank you for your reply! I just tried your code and got the correct .hex file. But now I am falling in another confusing issue. This afternoon I found another solution which is more complicate than yours. I just modified the "boot_loader_epcs_bits_sii_siii_ciii.S" file as st_f introduced in# 4 of this thread. After executing "make" command in Shell, I then used this command
nios2-elf-objdump -D boot_loader_epcs_sii_siii_ciii.elf > info.txt
to get the address information of the boot loader code. By checking the info.txt file, I found the boot loader codes start at address 0x1054, not 0x0. I have attached the info.txt file. I think that's why the commandelf2hex --input=obj\boot_loader_epcs_sii_siii_ciii.elf --output=kernel_epcs_boot_rom_synth.hex --width=32 --base=0 --end=0x3FF --record=4
will generate a .hex file with all 0. So I changed the command parameters to "--base=0x1054 --end=1453" and I got the correct boot loader code file(.hex file). I also opened your .bat file and found you use the elf2hex command with "--base=0". But your .bat file can generate the correct .hex file. I want know why this happen and what's the difference? -wei

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page