Arduino Yun loses sketch when powered down(solved)

It's unlikely that the 32u4 loses the flashed sketch. Most probably the sketch is stuck at some point, like a while (!Serial).
Can you post the sketch?