Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12606 Discussions

NIOS Remote Update Please help

Altera_Forum
Honored Contributor II
1,085 Views

Hi..am trying to use the nios remote update feature..But i am facing few problems ... 

 

1> I would like to transfer the binary file from a remote processor to be flashed on my EPCS device through UART..In order to do this is there a standard code for sending and receiving the binary file... 

 

2>after receiving the binary file(i.e the application to be flashed after the SOF hardware image offset on the flash) how do i find the end of SOF image on my flash so that i can start flashing my application after SOF.. 

 

Thanks a lot in advance
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
383 Views

 

--- Quote Start ---  

 

1> I would like to transfer the binary file from a remote processor to be flashed on my EPCS device through UART..In order to do this is there a standard code for sending and receiving the binary file... 

--- Quote End ---  

 

 

I don't think so, it is up to you to receive the binary file and write it to flash. 

 

 

--- Quote Start ---  

 

2>after receiving the binary file(i.e the application to be flashed after the SOF hardware image offset on the flash) how do i find the end of SOF image on my flash so that i can start flashing my application after SOF.. 

--- Quote End ---  

 

 

I think you mean POF file, this is what is programmed into flash. The remote update image does not have to be immediately after the factory image, it can be in any arbitrary starting location in flash. You can look up the programming file size for the FPGA to determine how much space the factory image takes (always starting from offset 0x0 for EPCS) and just store your remote image somewhere above that.
0 Kudos
Altera_Forum
Honored Contributor II
383 Views

 

--- Quote Start ---  

I think you mean POF file, this is what is programmed into flash. 

--- Quote End ---  

Actually you need to write a RPD file into the flash. This is generated from the SOF file. Unfortunately there is another couple of snags. You need to write the configuration portion of the RPD file into the flash with the bit order reversed, but the byte order remains the same. 

 

Ex:  

Byte is 8'b00110101 -> write as 8b'10101100 

 

Ex: 

Byts are 0x55201013 -> Bytes write as 0xAA0408C8 

 

NOTE: The program section needs to have unchanged bit order and byte order. Normally this isn't a problem because the SOF files only have configuration information and the program section is written later. 

 

 

--- Quote Start ---  

end of SOF image on my flash 

--- Quote End ---  

See the default boot loader code. It tells you how to decode the beginning of the configuration section of the flash. You can also use the RPD file, but you need to pay attention to bit order.  

 

NOTE: If you use compression then the last byte of the configuration section moves with code change.
0 Kudos
Altera_Forum
Honored Contributor II
383 Views

Follow these steps to generate "images" (hardware using sof2flash and software using elf2flash): 

  1. Point the "Reset Address" of your system at the base of your epcs_controller (in SOPC Builder). 

  2. Use sof2flash (with the --epcs option) to create a flash (it's really an SREC) file for the EPCS. 

  3. Use elf2flash (with the --after option) to create your ELF file. 

  4. Program your flash with the contents of these to files using nios2-flash-programmer.
  • Refer to the Flash Programmer User Guide for help.
After these steps are followed, ensure that your board boots properly on power-up/reset. 

 

Use the same steps to create "new" hardware/software images. If you want to convert the SRECs to binary format, just use nios2-elf-objcopy...like so: 

 

nios2-elf-objcopy -I srec -O binary <ELF or SOF .flash file> <resulting_binary.bin file> 

 

You may want to re-consider using binary as the binary file won't contain any addressing information (you'd have to make sure your SOF file size doesn't change...). 

 

I'm assuming you can handle capturing the data from the UART and storing it in EPCS block-sized buffers, so the only bit which you may need some pointers on are the writing to EPCS. I would use alt_flash_erase-block() followed by alt_flash_write_block()...provided by Nios II's HAL to erase and program the EPCS one block at a time. Keep in mind that you'll have to handle boundary conditions properly when doing this or you could easily destroy data. The collateral for AN-429 has a ProgFlash() function that does this properly. 

 

You're welcome to contact me with further questions, but you should be able to find more information about what I've mentioned in this post using Altera's site search. 

 

Cheers, and Good luck! 

 

- slacker
0 Kudos
Altera_Forum
Honored Contributor II
383 Views

Thanks a lot friends for your precious time...I dont know how to find the offset of the SOF...But what i did was first i converted the SOF to flash and then flash to binary.....similarly the elf to flash and flash to binary..then i used the command concatenate command "cat" and concatenated the SOF and ELF binary files to a single binary file....Then i got this file over UART into my NIOS processor flashed it on the EPCS flash device using the EPCS flash write commands provided by the altera library ....after rebooting the application worked fine.... 

 

?????????????? 

Now i am writing two application images ...In the first application image i just jump to the starting address of the second application image..... 

In order to do this i need the address of the second application image in the RAM in order to make a jump to it... 

1>How do i make sure that the boot loader(EPCS boot loader) doesnt load the second image on top of the first image in the RAM and that it loads the second image at the address given by me(How do i give this as a input???) 

 

Currently the EPCS boot loader loads the application starting at 0x800000 in the RAM. I want my second application to be loaded at a address 0x820000 in RAM....and hence i can make a jump to this location from my first application... 

 

Please help...thanks a lot in advance
0 Kudos
Reply