After watchdog reset (for example, to enter reprogramming), the AVR core restarts with watchdog enabled, contrary to a cold start after power on. The C program is not given an opportunity to disable or reset the watchdog before "main" ; and when the data and/or bss section is large enough, the watchdog triggers a CPU reset during __do_copy_data or __do_clear_bss, and the main therefore never starts.
To avoid this, I've added watchdog reset instructions in the __do_copy_data and __do_clear_bss loops. Here is a patch : *** gcc-4.5-20100311.orig/gcc/config/avr/libgcc.S 2009-05-23 09:16:07.000000000 +0200 --- gcc-4.5-20100311/gcc/config/avr/libgcc.S 2010-05-11 16:30:29.000000000 +0200 *************** *** 710,715 **** --- 710,716 ---- out __RAMPZ__, r16 rjmp .L__do_copy_data_start .L__do_copy_data_loop: + wdr /* Avoid watchdog reset if active */ elpm r0, Z+ st X+, r0 .L__do_copy_data_start: *************** *** 728,733 **** --- 729,735 ---- out __RAMPZ__, r16 rjmp .L__do_copy_data_start .L__do_copy_data_loop: + wdr /* Avoid watchdog reset if active */ elpm st X+, r0 adiw r30, 1 *************** *** 744,749 **** --- 746,752 ---- ldi r31, hi8(__data_load_start) rjmp .L__do_copy_data_start .L__do_copy_data_loop: + wdr /* Avoid watchdog reset if active */ #if defined (__AVR_HAVE_LPMX__) lpm r0, Z+ #else *************** *** 769,774 **** --- 772,778 ---- ldi r27, hi8(__bss_start) rjmp .do_clear_bss_start .do_clear_bss_loop: + wdr /* Avoid watchdog reset if active */ st X+, __zero_reg__ .do_clear_bss_start: cpi r26, lo8(__bss_end) -- Summary: AVR watchdog resets the core during initialization Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: j-etienne at users dot sourceforge dot net GCC build triplet: x86_64-apple-darwin10.2.0 GCC host triplet: x86_64-apple-darwin10.2.0 GCC target triplet: avr-unknown-none http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44082