I have some very strange behavior going on and I'm not able to pinpoint why exactly it's happening. Everything runs exactly as expected in both release and debug configurations with the FET attached. However, on a debug load, disconnecting it from the FET tool causes it to brick completely. When doing a simple load & program without the debugger, the device will not boot (again, only in debug).
I tore apart my code and added everything back in one by one until narrowing it down to one function, inside a switch case. What's interesting is that it doesn't seem to be a specific line or function that breaks it- uncommenting anything inside that switch case will cause the device to brick as I explained. And this code is not even being called at run time - it's existence in the .code section breaks the device - and ONLY when the FET tool is disconnected.
// Works case(CASE_1): if (!parsing_string) { return IBL_ERROR_LEX; } // commented_code1 // commented_code2 break; // Device bricks when unplugging FET tool (even though this code is never reached) case(CASE_1): if (!parsing_string) { return IBL_ERROR_LEX; } un-commented_code1 un-commented_code2 break;
I thought this could possibly be a stack size issue, but again - the code is never even called anyways. I tried more than doubling (160 -> 1024) the stack size anyways but it didn't make a difference. I'm thinking this is a compiler issue somehow, but the build settings are nearly identical between release and debug - including optimization level.