Arduino: The program exited the loop early and execute setup() repeatedly
This can happen when your sketch uses too much memory - the board can no longer assign addresses so it resets leading to an endless loop. Try reducing the amount of memory you are allocating.