Forum Discussion
Converting .sof file to .flash file for Stratix 10 GX development kit
Hello Intel,
I have the Stratix 10 GX development kit, and am needing to load a user design into the Flash for auto-configuration of the user design at power up. I've been following through the documentation, and have successfully reached the page in the Board Update Portal where you specify a hardware file.
However, the method of converting the Quartus Prime produced .sof file into the necessary .flash file, is not documented clearly.
The link to the instructions to convert the .sof file state the following:
Convert user .sof file and .elf file to the format required to program the Flash
Note: You must have the Nios® II EDS installed in order to perform this step.
1. From the Start Menu, open Nios II Command Shell
2. In the Nios II Command Shell, navigate to the build_hw.sh file and type
sh build_hw.sh yourfile_hw.sof 1
However, I cannot find the build_hw.sh script anywhere. The instructions only say to navigate to it, but do not say where it is.
A search for that filename in the Quartus Prime 23.1 installation directory does not find it. I was able to find one version of it buried deep in the design material .zip file downloaded from the Stratix 10 GX product page:
stratix10GX_1sg280uf50_fpga_revd_htile_v18.1b222_v1.0.zip\stratix10GX_1sg280uf50_fpga_revd_htile_v18.1b222_v1.0\factory_recovery\build_factory_source\PRD\build_hw.sh
But this does not appear to be the correct script (looks like it will produce a .pof, and we need a .flash right?), and anyways it does not execute correctly when invoked from within the Nios II power shell as it exits with a syntax error.
I saw this previous post with a similar question however it was never actually solved, only marked as complete as the OP stopped responding:
Please help clarify the process of converting the .sof file into whatever format is needed to load into flash from the Board Update Portal. If I need to use a specific script from within the Nios II power shell, where is that script located? Is there any alternative, or command line command I can enter manually like was done previously with the Arria 10 GX dev kit (sof2flash)?
46 Replies
- EBERLAZARE_I_Intel
Regular Contributor
Hi,
Let me try again on my side based on your testings, just to be sure again, what was the Quartus and Nios version did you worked on for the latest test?
- ChrisConger
New Contributor
I am using Quartus Prime Pro, 23.1.0 Build 115 03/30/2023 SC Pro Edition
I'm not sure the Nios version, it is whatever was installed along with the installation of this version of Quartus Prime Pro. If there is a means of checking the Nios version I'd be happy to check it, just let me know where to look.
- ChrisConger
New Contributor
Hi,
So I was able to convert the .rpd into a .flash by running the command you specified from the Windows command shell. The Nios2 command shell always gives me the "file not found" error even though tab-to-complete ensures the file is visible and entered correctly.
Should there be any issue in running the command in a Windows command shell and not the Nios2 command shell?
The command appears to execute without problem and a .flash file is produced. However, after uploading the file through the Board Update Portal (appears to successfully upload), upon power cycling the board with User Design #1 selected by setting SW3.3 correctly on the S10 dev board, it does not appear to program correctly.
After a few seconds the "Error D3" red LED lights up on the LED daughter board, and the design does not appear functional or programmed.
Any help you can offer would be greatly appreciated on why after converting .sof to .rpd, and then from .rpd to .flash, the board will not program correctly. If I manually program the FPGA with the original .sof used to perform that chain of conversion, it works fine so we know the .sof is good.
- ChrisConger
New Contributor
For clarity, below is the exact sequence of steps I am taking along with screenshots/photos.
First, I use Programming File Generator invoked from within Quartus with the project open in order to convert from .sof to .rpd. This is the first screen that pops up, and I enter the output file information. Please confirm the other settings are correct... if I choose "AVST x16" as the Configuration Mode, the .rpd file type is not offered as a conversion option so I guess Active Serial x4 is the only possible choice since you said to convert to .rpd first.
I select the .sof file just generated by building the project. This .sof file works correctly if I manually program the FPGA directly through Quartus Programmer, so we know the .sof is good:
And after clicking "Generate", I get a success notification and the .rpd file is located where I specified.
Here you can see I attempt to perform the .rpd to .flash conversion within the Nios2 command shell, but I get the "file not found" error:
If I instead run the exact same command but within the Windows command shell (note the directory paths and everything is the same), it appears to work as a .flash file is generated. I am guessing there is no success message to be expected, so a silent return to the prompt must be a good thing (?):
Next, I ensure the Stratix 10 board SW3.3 is set to load the factory build at powerup so that I can connect to the board update portal:
And upon powering up, I am able to connect to the Board Update Portal through my web browser:
For hardware file I choose the .flash file generated by the steps above. There is no embedded processor in the FPGA design and so no software file exists/needs to be specified:
Here the file can be shown to be selected just prior to clicking "upload."
We can see the upload in process here:
After uploading, I get the following success message:
Note that though it says to press some switches and look at LEDs, those switches are not labeled nor are they documented in the User Guide so I don't know which ones to press. At any rate, the design should now be able to load upon a power cycle so I skip the steps above and get ready to power cycle the board to test if the design will load automatically.
After powering off the board, I first set SW3.3 to choose the user design on power-up and not the factory load:
Finally, after powering up with the user design selected via SW3.3, after a few seconds this red LED comes on and the design is non-functional... I'm assuming this LED indicates a configuration error.
Recall that the .rpd was generated using Active Serial x4 as the configuration mode since AVST x16 doesn't give me the .rpd option... I have tried setting SW1 (MSEL selection) to both "10" as well as "01," and neither works.
Can you describe to me what steps I did incorrectly, or missed? As far as I know I have done exactly as you indicated I should do as well as how the current documentation describes the flow. Thanks again for your help with this, this is an extremely frustrating and complex method of doing such a fundamental operation as loading a user design into NVM for auto-configuration at power-up.
- EBERLAZARE_I_Intel
Regular Contributor
Hi,
I need to re-check again, as this was the step to create it for Stratix 10 devices. I will get back you again. We apologies for the inconvenience.
- EBERLAZARE_I_Intel
Regular Contributor
Hi,
From our internal team, they are the correct way to convert, as of now I am verifying the steps for the Board Update Portal.
- ChrisConger
New Contributor
That is good to hear, I suppose that means I am close then.
From the longer reply I sent above walking through every screen and every step, can you help me figure out what I am missing or doing wrong? Are you specifying Active Serial x4 as the Configuration Mode setting in the Create Programming File GUI when generating the .rpd? If not, what configuration mode should be specified? Or if so, what is your MSEL selection using SW1 when you successfully boot from Flash using the User Design you converted using these steps? The board default SW1 setting is AVST x16, does it need to be switched to something other than the default if loading a user design generated with a different Configuration Mode?
Is there supposed to be an offset provided when doing the .rpd to .flash conversion using the nios2-elf-objcopy command?
There must be some step I am missing if this is correct, I am hoping my verbose post above showing every screenshot and every board setting that I have been told to use, will help give some info as to what I am doing wrong.
- EBERLAZARE_I_Intel
Regular Contributor
Hi,
That is a good point, I'm not that familiar with the configuration let me start from that. In Quartus > Assignments > Device > Device and pin options > Configuration.
This must match your MSEL pins set on your board.
- ChrisConger
New Contributor
Well, I believe Intel should define what is the correct procedure for the customers... it is a bit confusing to get the MSEL pins to match due to the issue I mentioned in my previous verbose post where I showed every screen of the process.
You previously mentioned: "From our internal team, they are the correct way to convert, as of now I am verifying the steps for the Board Update Portal."... have you yourself successfully converted a .sof to a .flash and had it loaded into the Board Update Portal, and then successfully got the board to load that design from Flash? If so, what settings did you use?
For me, it is confusing because the default MSEL settings of the Stratix 10 board is AVST x16. However, Programming File Generator will not allow me to generate an .rpd if the Configuration Mode is set to AVST x16. (However, the factory build from Intel loads at power-up when MSEL indicates AVST x16, so Intel was able to generate a .flash that configures in AVST x16 mode).
The other options in Programming File Generator do not match the MSEL jumper settings listed in the S10 GX dev kit user guide. PFG gives me four options: Active Serial x4, and AVST x8, x16, and x32. Since any of the AVST won't allow me to generate an .rpd file, then I suppose Active Serial x4 is my only option. Are you able to confirm from your team that this is in fact the Configuration Mode setting that must be used in PFG when producing the .rpd?
On the Stratix 10 board, the MSEL settings are documented as follows in the User Guide:
Is Quad SPI (QSPI) the same as Active Serial x4? If so, should I use "Fast mode" "00" or "Normal mode" "01"? I have already tried both and neither works. Is there truly no way to produce an .rpd with AVST x16 as the configuration mode? How is the factory build .flash file produced since it does configure in AVST x16 mode?
It would be very helpful, if the Intel team is successfully converting .sof to .flash and getting the board to boot, if you could clarify explicitly what of those settings are being used.
Finally, the Flash memory map is as follows from the S10 GX dev kit user guide:
So the user design is to be loaded at offset 0x02C0_0000... are you sure there is no offset that needs to eb specified in the .rpd to .flash conversion command using nios2-edf-objcopy? There is an offset option for the command, if the design is getting loaded into the wrong location in Flash that could also cause it to not boot successfully,
Thank you again for your patience and assistance with this. I feel like I followed the steps defined exactly and showed the screenshots for full clarity, but it is still not working so helping me figure out what I am doing wrong, and/or what steps or details were accidentally omitted from the instructions, will help Intel to have the process fully and correctly documented for all customers in the future. I am happy to give any additional information that you would like. Perhaps I can produce a simple design that just toggles LEDs and does not contain any proprietary design material, so that I can share the .sof in the thread and we can both work from the same .sof?
- ChrisConger
New Contributor
It is worth confirming for you that when I produce the .sof from Quartus, the configuration mode is selected as AVST x16:
So this matches the default jumper settings on the S10 board. However the confusion occurs when it comes time to convert the .sof into an .rpd, since AVST x16 is not an option to produce an .rpd. At this point I select Active Serial x4:
Since selecting AVST x16 here will not allow me to specify an .rpd format file.
Is it a problem that the .sof is produced with AVST x16, and then the .rpd is produced with Active Serial x4? Should I produce the .sof with Active Serial x4 as well, and if so, which of the two QSPI MSEL jumper settings is correct (00, 01)? How does the Intel factory build work with jumpers set to AVST x16 mode (10) if Active Serial is the required mode to produce a .flash file?
This is the detail that would be useful if Intel could work out and clearly define. If it helps to have me guess and try things via trial and error I'm happy to do so. It's also possible that configuration mode isn't the problem and it is something else.
- ChrisConger
New Contributor
edit: got the factory build fixed, sorry for false alarm.
I regenerated the .sof with Active Serial x4 specified so that when converted to .rpd, the Configuration Mode would be consistent. I also programmed the FPGA directly with this newly-generated .sof to ensure it works correctly, and it does.
Note that I do need to revert the MSEL pins to the default of "10" to specify AVST x16 for the factory build to program... I forgot to switch it back and thought I had bricked the board when the factory build wouldn't request an IP address via DHCP for me to connect to the Update Portal. Switching the MSEL pins back to default makes the factory build work again.
So, the original .sof was generated in Quartus with Active Serial x4 specified in the Quartus > Assignments > Device > Device and pin options > Configuration menu, and then the .rpd was produced using File > Programming File Generator selecting Active Serial x4 as the Configuration Mode, .rpd as the output file type, and the .sof generated previously as the input file.
I converted that .rpd to .flash using the exact nios2-elf-objcopy command you indicated earlier (however, run from within a Windows command shell and not the Nios2 command shell). This .flash was then uploaded through the Board Update Portal, and after successfully completing I powered off the board. With power off, I switch the MSEL selection back to "01" to indicate QSPI x4 normal mode, and SW3.3 to load User Hardware1.
Powering on the board, I get four red LEDs blinking once per second and the design does not function. This happens with both "01" and "00" MSEL setting. If I revert back to "10" (AVST x16), it waits a few seconds then shows a single red LED solid on. Switching SW3.3 back to factory build, the Board Update Portal design successfully configures.
- ChrisConger
New Contributor
I've attached a .zip file with a demo design attached. All it does it toggle the green LEDs on a counter, and the user pushbuttons illuminate the red LEDs.
I generated two .sofs... one with configuration mode specified as AVST x16, and one with Active Serial 4x.
I converted both of those .sof to .rpd using the instructions you provided earlier, though note that I had to specify Active Serial 4x for both .sofs regardless of how they were produced, since that is the only option that allows the generation of .rpd
I would be curious if you are able to successfully convert either of the .rpd files to .flash, load the .flash to your L-tile S10 dev board via the Update Portal, and have that design automatically load from Flash on power cycle.
- EBERLAZARE_I_Intel
Regular Contributor
Hi,
I have configured AS x4 and AVST previously it worked, but I haven't tested using Board update portal yet, I need to have the board test set up.
- EBERLAZARE_I_Intel
Regular Contributor
Hi,
I have run through again the steps, for BUP for Stratix 10 it should be for the Hardware using ".bin" file generated using the "build_hw.sh your_sof.sof" command which will create a .bin as output as per the "build_hw.sh script", as per the document, and the Software if any, using ".flash".
Whereas, for Arria 10, it should just be ".flash" only.
Currently, I am having issue with the Nios II command shell using the script to generate the .bin for the Hardware.
Again, I apologies for the extended confusion on this issue, as we do not get Board Update Portal questions.
- ChrisConger
New Contributor
Hi, so the build_hw.sh script is what I originally asked about in this thread (see first post). That script does not exist in the Intel Quartus installation, but searching for the filename in the .zip file downloaded from the Intel website I was able to find one version of it.
However, it does not work when run, thus I posted this thread asking what the steps were. That is when you replied with the team told you to produce an .rpd from Quartus PFG and convert that to .flash using the nios2-obj-copy command.
Now we are back to using the build_hw.sh script? If so, where is that script located?