My app is running correctly when loaded via JTAG directly to SDRAM, but im unable to make it running from QSPI flash memory (or any external non-volatile memory).
The most scary part is that i made it run (and properly boot) a couple of times just by messing with uart init and simple prints at the start of main, before my OS kicks in.
For example, similar codes, one of them is working, other dont.
if (core_number == 1) h_print("Initializing"); // code is beeing executed - image works from QSPI
if (core_number == 2) h_print("Initializing"); // code is not beeing executed (no 3 core) - image didn't work from QSPI.
I found also that image "correctness" is somehow based on payload of this simple print as below.
if (core_number) h_print("Ini"); // image working
if (core_number) h_print("Init"); // image not working
I though that this is strictly related to uart so i disabled it in preloader image (no serial support), and fully disabled it from my code base. Result was the same. Image was randomly working, depending on code.
All codes runs directly from SDRAM without any problems.
I tested that issue on couple dev boards (Cyclone V SoC Developement Kit, De0 nano SoC and custom board), while booting from QSPI Flash and SD card. Results were the same.