Because hexAIS does not work for me (http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/99/t/118523.aspx) I have written a 2 stage bootloader. However, on the second stage when the main software image runs some time between BIOS_init call and the board init function the software calls back to flash and starts running its own loader.
Details are:
I am using Direct EMIFA boot 0100b (fastboot = 0) on a DM6437.
My POR bootloader at 0x42000000 disables L1D then copies a primary bootloader to 0x10800000 which is L2 RAM area.
The primary bootloader is a C program that initialises PLL1/2 and the DDR2 and is basically a rip-off of the DM6437 GEL file. The primary bootloader C code then obtains the address in flash of the main image bootloader (the bootloader that copies the main software from flash to DDR2), casts the address to a function pointer and calls it.
The main bootloader disables L1D, invalidates L1P (not sure if I need to), invalidates L2 (I should not need to) and copies the main software image into DDR2 then jumps to its c_int00.
The main software runs from c_int00, reaches BIOS_init (the start of it anyway) and sometime before it reaches the user initialisation function somehow calls back to the flash memory and starts executing the main bootloader (which of course copies again the main software image to DDR2). This repeats continually.
I wondered if the problem is one of caching: The only way I can think that the main bootloader is being run again is if the code that originally called it from the primary bootloader is being executed again, perhaps from L1P. That's why my main bootloader invalidates L1P but I am not sure that I need to because the main software image code is running from DDR2 and the primary bootloader was run from L2 when it was set to all RAM so there should be no confusion.
I am not running self modifying code as mentioned in the cache manual in the sense that I am not modifying previously run instructions, so L1P should not be affected. However, I am careful to disable L1D so that the image DATA as it is copied is not cached in L1D before it is actually run as code.
Ideas?