program stuck after few hours

Does someone know how to compare the flash with the compiled code?

The avrdude function does that as it uploads the hex file. Any discrepancies are reported.