SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world.
And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download two short videos (registration required) highlighting:

System Workbench for STM32

SW4STM32 doesn't move to main loop

Another way you can force the inclusion of the infinite while() loop (with optimization on) would be to declare the i variable volatile, like this:

volatile uint32_t i;
while (1)

Doing this is also useful when you want to create a software delay and don’t care about accuracy, like this:

volatile uint32_t i;
for (i = 100000; i > 0; i--) ;

As for use of compiler optimization, I normally set the optimization level to “optimize for debug (-Og)” for the debug build of my projects, and use higher level optimization, normally “optimize for size (-Os)” for the release build.