cancel
Showing results for 
Search instead for 
Did you mean: 

__libc_init_array triggers _exit() and main() is never reached.

Dfarr.1
Senior

I've been doing lots of work in TouchGFX. But something changed between two commits which caused my project not to run in debug mode anymore. The code builds, the debugger connects, then then immediately branches to _exit() where it stays.

I've traced the problem to startup_stm32f746nghx.s where it branches to __libc_init_array

When the code enters _exit(), LR is 0x0801FFF5

Searching through *.list gets me to:

0801fff4 <__assert_func>:

 801fff4: b51f    push {r0, r1, r2, r3, r4, lr}

 801fff6: 461c    mov r4, r3

but I'm not sure what to do with that information.

Everything I've searched so far suggests its a linker issue, or a memory (stack/heap size) issue. But I haven't been able to solve it. I've increased my stack size to maximum, no change. I'm using MX for configuration, so I'm not manually editing the *.ld file.

This problem is over my head. Has anyone seen this before? What else can I try?

2 REPLIES 2
KnarfB
Principal III

__assert_func is used in the assert macro. You can set breakpoint at __assert_func and inspect the call stack and/or the file+line parameters to see where what assertion failed.

Dfarr.1
Senior

I followed your advice and tracked my problem down. Thankyou.

I had created a set of global application colors for my touchGFX application in a separate cpp file as externs which could be included in each of my views using a matching header file.

But I was calling touchgfx::Color::getColorFrom24BitRGB() to create the colors. Unfortunately, I did not know that the HAL must be initialized before that function can be used. If its not, it throws an assert.