Here are the troubleshooting steps to follow when the adi_rom_boot() function fails.
1. Make sure that SPU and SMPU configurations are not modified such that ROM cannot access the memory anymore.
2. Make sure no interrupts are still enabled and active, else when you call the new startup and install the default empty error handlers you will vector off to them.
3. Make sure caches for L1 and L2 are all disabled and flushed if applicable before calling the boot API and reset the BTB(Branch Target Buffer). You could be booting in the content via DMA but if caches enabled the core read on the startup could be taking stale data from the previously loaded application.
4. Try setting the stack back to the same location to the boot ROM as documented in the processors boot chapter.
5. The stack space of the primary application should not interfere with the incoming secondary application.
6. The stack space of the primary application should remain uncached.
7. If primary application also uses hook routines related to bootROM API, then those section should also not get any conflicts with incoming secondary application.
8. For secure boot, the entire 8Kb space reserved for boot purpose should not be used by any of the application.
9. When the primary and secondary applications overlap, it can cause booting failures. This overlap may result in the corruption (clobbering) of both applications. To prevent this, the new application should be loaded in a way that it does not overwrite the loading function or the part of the software responsible for jumping to the start of the newly loaded application. In other words, the primary and secondary applications should not overlap. Therefore, it's important to place the bootloader code in a separate memory area to avoid conflicts.
To achieve this, use #pragma section("section_name") directive to place the code in a different memory location.
For example, if adi_rom_boot is called from Start_Application, ensure that Start_Application is placed in a memory section such as L1_Block0 or L2:
#pragma section("section_name")
void Application (void)
{
..
..
adi_rom_boot();
..
..
}