Forum Discussion
Altera_Forum
Honored Contributor
21 years agoHi doleksy,
> I am a bit confused on when I need to flush the icache. You should invalidate the appropriate icache line before executing its code whenever the cache is no longer coherent. For example, if you load an S-Record into memory that contains executable code, you should invalidate the associated icache lines before attempting to execute newly loaded code -- otherwise you might execute the old code that is still resident in the cache. > I've looked at u-boot and it seems to flush the icache after every srec > record has been written to memory. Is this overkill? No -- it's just the strategy chosen by u-boot. Since an srec file does not include any information on whether or not the new data is executable code or not, u-boot makes a conservative assumption: it assumes each srec contains both executable code and data ... and invalidates the icache and flushes the dcache immediately after decoding and writing the srec to memory. Since u-boot can load individual S-Records, it must invalidate/flush the caches as each record arrives -- otherwise you would always need an end record (to know when to flush everything). > As long as you aren't running the new code yet it seems like you could just > call alt_icache_flush_all when you are finished. This would work fine. Regards, --Scott