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++
12589 Discussions

How to convert .srec to .rbf for flash progr.?

Altera_Forum
Honored Contributor II
2,446 Views

Hello, 

 

how do I convert a Nios1 software file (.srec or .flash) to a .rbf file (raw binary file) that I can use to program directly a flash via that Nios? 

 

Thanks for your help, 

 

damc
0 Kudos
10 Replies
Altera_Forum
Honored Contributor II
761 Views

nios2-elf-objcopy is quite good for converting files between different formats. You probably need to convert your file to "raw" format using the switch `-O raw`.

0 Kudos
Altera_Forum
Honored Contributor II
761 Views

Thanks wombat 

 

for the idea! 

 

It seems that nobody has done it until now. 

I am just wondering how customers can program Nios software updates into their products ... 

 

Regards, 

 

damc
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

 

--- Quote Start ---  

originally posted by damc@Feb 10 2005, 03:29 AM 

thanks wombat 

 

for the idea! 

 

it seems that nobody has done it until now. 

i am just wondering how customers can program nios software updates into their products ... 

 

regards, 

 

damc 

--- Quote End ---  

 

How about the NIOS II flash program tool ..
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

 

--- Quote Start ---  

originally posted by kwokwong+feb 10 2005, 10:26 am--><div class='quotetop'>quote (kwokwong @ feb 10 2005, 10:26 am)</div> 

--- quote start ---  

<!--quotebegin-damc@Feb 10 2005, 03:29 AM 

thanks wombat 

 

for the idea! 

 

it seems that nobody has done it until now. 

i am just wondering how customers can program nios software updates into their products ... 

 

regards, 

 

damc 

--- Quote End ---  

 

How about the NIOS II flash program tool .. [/b] 

--- Quote End ---  

 

Not possible. 

The FPGA-hardware is only accessible via a serial line. 

So the new flash contents (the new Nios software) must be downloaded first into SDRAM and then programmed via the Nios itself into flash.
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

Use HAL flash api to program. 

 

Other threads in this forum discussed about the image fomats (FPGA and application). 

Do a search on key words: boot, epcs_controller and/or flash.
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

 

--- Quote Start ---  

originally posted by kwokwong@Feb 10 2005, 01:00 PM 

use hal flash api to program. 

 

other threads in this forum discussed about the image fomats (fpga and application). 

do a search on key words: boot, epcs_controller and/or flash. 

--- Quote End ---  

 

It&#39;s an old Nios1 design, so I have no HAL. 

But that&#39;s also not the problem. Functions (nr_flash_erase_sector, nr_flash_write_buffer, ...) for programming the flash are avilable and working, but I didn&#39;t found any convinient file format (or converter) for the software that I could use. 

For firmware Quartus offers the .rbf (raw binary format) or the .rpd (raw programming data) format, but for software I couldn&#39;t find any conversion tool or utility. 

So at the moment I guess I have to write one by myself ...
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

Any objcopy will convert any SREC file for any processor to binary. Where objcopy starts being processor specific is when its dealing with ELF files. 

 

So for a conversion from SREC to binary you can use any objcopy: the nios2 one, the x86 one (I can&#39;t remember if the nios1 kit had one). I misspoke earlier, the option you need is -O binary. 

 

Of course if you want to convert an ELF file to binary then you must use the correct objcopy.
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

The file format sent to your application over the serial can be anything you want: raw binary, s-record, etc. You&#39;ll just need code in you Nios application to parse whatever format you use and construct an image in RAM that you can then program into flash. 

 

I would also add some sanity checks to the image you download. First, add a unique hardware specific signature string at a known offset (I put one just after the "Nios" string that the GERMs boot loader looks for) so your code can verify that that the downloaded image is indeed a code image intended for your particular hardware. This will prevent problems if your users accidently try and download the wrong file. 

 

Second, add some sort of self-consistency check in the image itself to ensure that the image in RAM is complete and uncorrupted before programming the flash. I embedd the size of the downloaded image near the start (again, at a known offset), and append a 16-bit CRC check code to the end of the image. The code recalculates the CRC of the downloaded image (using the length) and ignores the image if the CRCs don&#39;t match.
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

scs: Thanks for your hints. The data transmission is done in a save way, so I can be sure to have only correct data for programming. 

 

wombat: Instead of objcopy, what has a lot of parameters to play with, I downloaded from the web a simple srec2bin tool. With this tool I am able now to make out of a .flash file a .rbf file what I can download and program directly into flash. 

 

Thanks again for your ideas and hints!!! 

 

damc
0 Kudos
Altera_Forum
Honored Contributor II
761 Views

If you have access to Nios II (and the Nios II IDE), you could use this command line tool "nios2-srec2flash" then use "nios2-flash-programmer" to flash the design over (after doing all that I&#39;d probably end up upgrading). 

 

Sorry for not being more help (never used flash with Nios I, just GERMS and mif files). 

 

Good-luck
0 Kudos
Reply