I seem to have found the source of the problem which is the enabling of gprof in the BSPs. I disabled gprof support and now everything is working consistently (as far as I can tell).
While profiling isn't entirely essential, are there any suggestions as to a fix for this? Without using the "--write-gmon" in the nios2-download command, is there an [automated] way to know when the processor has reached the end? I've modified the nios2-download command to call the gdb-server with the "--wait-target-exit" switch, but the gdb-server process doesn't seem to return even after the main() process has exited.
UPDATE:
My particular implementation is automated (I test a number of different NIOS 2 architecture configurations with a number of different applications) so the program testing all of these needed to be automated. I figured out how to make nios2-download return when the NIOS 2 application was finished executing. To do this, two things must be done:
As above, modify the nios2-download script to include the "--wait-target-exit" switch on the call to nios2-gdb-server. So add the following to line 609 (just above the gdb-server call):
arglist="$arglist --wait-target-exit" In your BSP directory, find the setting "hal.make.bsp_cflags_defined_symbols", and change
the line
<value>none</value> to
<value>-dalt_break_on_exit</value> And now nios2-download should return after its finished executing. I have a fairly specific set of requirements but hopefully this is useful to someone!