Forum Discussion
EPCS fpga+nios field update
Hi,
I know this has been asked several times, but I can't seem to find an answer that fits my problem so here it goes: I have a large CIII design with a NIOS including the remote update block. What I would like to do is to load a new firmware (hw+sw) from an SD card and flash it to the epcs and the restart the system. So far I have used the an429 example from which i have fittet the parser and programmer to my design. I THINK that the flashing but when the system is restartet my board i dead. This leaves me with several questions :confused: : 1. Which files from should I used to flash the epcs? right now im using the hw.flash generated from the sof and the epcs0.flash for the nios. 2. How to i now from which address I should boot? 3. am I missing something else? :eek: thanks! greetings, mitch28 Replies
- Altera_Forum
Honored Contributor
The application selector design example for the NEEK has pretty much everything you need...altremote_update, copy from SD card, remote configuration.
The example is available on Altera's website....here (http://www.altera.com/support/examples/nios2/exm-demo-loader.html). If I were you, I'd pay particular attention to the methods used in software. Cheers, - Brendan - Altera_Forum
Honored Contributor
Just to gain some clarity here:
1 - The FPGA will always attempt to load an image starting at address 0 of the EPCS flash unless you've specifically given a different address using the altremote_update core. 2 - The default bootloader for the NIOS when booting from the EPCS will automatically look at the FPGA image, then skip to the end of the file and expect to find the beginning of your software code there. So here is the question. Are you simply going to overwrite your existing image and software in the EPCS flash or are you planning on keeping a safe image that you'll never overwrite? You may want to refer to this post: http://www.alteraforum.com/forum/showthread.php?t=5244&referrerid=2226 In any case, the data you want is the raw binary FPGA image data and the binary software data. Here is a script I have given before to produce the binary files (note that in my script I append the software to the FPGA image to create one single file):
Jake# Creating .flash file for the FPGA configuration echo Creating firmware flash file ... "$SOPC_KIT_NIOS2/bin/sof2flash" --epcs --compress --input="../altera/top.sof" --output="firmware.flash" # Creating .flash file for software code echo Creating safe and application flash files ... "$SOPC_KIT_NIOS2/bin/elf2flash" --epcs --after="firmware.flash" --input="../software/top/Release/top.elf" --output="app.flash" # Convert to binary echo Converting flash files to binary ... nios2-elf-objcopy -I srec -O binary firmware.flash firmware.bin nios2-elf-objcopy -I srec -O binary app.flash app.bin # Concatenate echo Concatenating binary files to create final programming file ... cat firmware.bin app.bin > app_image.bin - Altera_Forum
Honored Contributor
I want to keep a safe image that should never be erased.
When my factory image fpga+nios is placed at 0x0 in the EPCS, how do I make sure that the user image is placed somewhere else? Do I need a modified boot loader when I'm using the remote update controller to change the boot address? - mitch - Altera_Forum
Honored Contributor
What I have done so far is:
1. generate a combined flash file in the format sof followed by elf - offset is 0x000e0000 2. read the file and program the EPCS with the an429 programming routines 3. change the hw offset in the remote update component to 0x000e0000 4. restart unfortunately my factory image is still loaded (prgrammed at 0x0 with the flash programmer) What am I missing? - Altera_Forum
Honored Contributor
Let me explain how this works. By the way yes you do have to write a custom bootloader.
1 - You power-up the board. 2 - The FPGA begins active serial configuration and programs itself using the FPGA image stored at address 0x0 of the EPCS flash. 3 - Once the FPGA is programmed, the NIOS processor starts up and boots from an onchip RAM block located inside the EPCS flash controller component in your SoPC builder system. This is the bootloader. The source code for this bootloader can be found in your altera install directory: C:\altera\91\nios2eds\components\altera_nios2\boot_loader_sources 4 - The bootloader mentioned above looks at the FPGA image located at address 0x0 and determines how long the image is. 5 - The bootloader jumps to the end of the FPGA image where it expects to find the software image (ELF). 6 - The bootloader copies the software image to RAM and then executes a non-returnable jump to RAM to start your program running. So what you need to do is create a modified bootloader that will intervene in this process after step 2. Your bootloader needs to: 1 - Determine which FPGA image just got loaded (application or factory). 2 - Decide what to do next. If the current running FPGA image is the factory image you can: . a) stay in factory mode and load a factory software image. . or . b) use the remote update core to attempt to load the application image 3 - If the current running FPGA image is the application image then it stands to reason that you will want to load the application software. It's unfortunate the the NIOS forum crashed some time ago as all this information has been detailed in the past. Jake - Altera_Forum
Honored Contributor
hmmm sounds quite complicated!?
If I wanted to just have one image that gets overwritten which files should I use? -mitch - Altera_Forum
Honored Contributor
It's really not that bad. I can give you my modified bootloader if you want it but it's been hand-tweaked for my design and Stratix II GX. You could also post a new topic asking if anyone has a modified bootloader that they're willing to share.
But if you just want to have one image, I suggest using the script I've given above. This will create a single file that contains both your SOF and ELF files. Then you just program this file starting at address 0x0 in the flash. Jake - Altera_Forum
Honored Contributor
That would be great if I could have a look at your boot loader :D
That way I could get an idea of how it is done, and maybe adapt one myself:confused: -mitch - Altera_Forum
Honored Contributor
Here you go. I don't have a lot of time to explain all the details. Remember this one is customized for Stratix II GX. Your best bet to see what I've done is to diff these files with the ones in the original Altera install.
Feel free to ask any questions. Jake - Altera_Forum
Honored Contributor
Thanks :D
I will give it a shot! -mitch