I have a flash erase function that uses the RAMFUNC attribute. The project compiled and linked without errors, but I was getting some really weird bugs when running it that culminated in a hard fault.
They seemed like the type of bugs caused by overzealous optimization, which made no sense because I had optimization set to none.
I dug into the assembly, and while the first dozen lines were normal and doing what they should do, it quickly went off the rails doing a few operations that made zero sense before finally trying to load a CPU register from an invalid address and hard faulting.
When I removed the RAMFUNC attribute, everything worked fine and the assembly looked like I would expect it to.
For now, this will be my solution, as I don't erase the flash page that the function is located in, so I don't NEED to run this from RAM. It would be nice to be able to though.
Is there something else I need to do to get a function to properly execute from RAM?
This is on a SAMG55, which is Cortex M4 based. IDE is AS 7.0.1645