Forum Discussion
Altera_Forum
Honored Contributor
20 years agoHi Trey,
> What comes right after the configuration data? The .elf or the .sof? When I refer to the "configuration data", I'm talking about the data contained in the sof (or pof) that is used to program the FPGA (the logic you're downloading). This data is contained in a data "packet" within the pof/sof file and ends up getting programmed starting at offset zero in the epcs device. The length of this data can be determined from header information contained in the data itself: Here's a snippet from the u-boot sources. Assume that the fist 128 bytes of the epcs memory were read into a buffer (buf), and that 'sz' is an 32-bit unsigned value. Also, assume that the bit-reversals have already been performed./* Search for the starting 0x6a which is followed by the
* 4-byte 'register' and 4-byte bit-count.
*/
p = buf;
while (p < buf + sizeof(buf)-8) {
if ( *p == 0x6a ) {
/* Point to bit count and extract */
p += 5;
sz = *p++;
sz |= *p++ << 8;
sz |= *p++ << 16;
sz |= *p++ << 24;
/* Convert to byte count */
sz += 7;
sz >>= 3;
break;
} else if (*p == 0xff) {
/* 0xff is ok ... just skip */
p++;
continue;
} else {
/* Not 0xff or 0x6a ... something's not
* right ... report 'unknown' (sz=0).
*/
break;
}
}
return (sz); The 'elf' sections immediately follow the FPGA configuration data. So, if the size of your configuration data is 0x1008c for example, the Nios-II elf sections start at offset 0x1008c in the epcs device. NOTE: The Nios-II application is not stored elf format ... it is insted, a sequence of length-address-data records so the loader can load individual sections to the appropriate addresses. This conversion (from elf to length-address-data) occurs during elf2flash. > Is there code to concatenate both the .elf and .sof into one image that gets > written after the configuration data? If your goal continues to be a single binary file that contains both configuration and Nios-II application data for run-time updates, I would recommend you discuss this more with Mike -- and take him up on his code offer -- and his experience with this -- I'm sure Mike can steer you away from alot of "gotchas". Regards, --Scott