Failed to debug CMSIS NN with stm32f4 discovery on gnu eclipse

I am new to development on STM32F4 discovery and I am trying to execute cmsis nn example on stm32f407VG board. I am using GDB OpenOCDDebugging for debugging with configure option -f board/stm32f4discovery.cfg and under Common tab I selected shared file with Debug and Run selected.

To build the project I have added -flto -ffreestanding -nostdlib in Linker flag and -ffreestanding -flto in Compiler flag. When I am trying to debug it runs for around 700 seconds and then stops with the following error:

Error: Failed semihosting operation
Error: jtag status contains invalid mode value - communication failure
Polling target stm32f4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Info : Previous state query failed, trying to reconnect
Error: jtag status contains invalid mode value - communication failure
Polling target stm32f4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 300ms
Info : Previous state query failed, trying to reconnect
Polling target stm32f4x.cpu failed, trying to reexamine
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints

The code is available under https://github.com/ARM-software/CMSIS_5/tree/develop/CMSIS/NN/Examples/ARM/arm_nn_examples/cifar10.

Please let me know why it is not printing any customized message on console and why it is taking so long to execute. Am I doing it in a wrong way, please guide me.

Thank you.

More questions in this forum