#include <string.h>
+#include <avr/wdt.h>
+
+/*
+ * Watchdog disable.
+ *
+ * This function disable the watchdog timer early after a reset.
+ * We must do it very soon because new AVR cores do not disable
+ * the watchdog timer after a cpu reset. In this way the watchdog
+ * timer is still enabled, continuously resetting the cpu. This is
+ * necessary only with new AVR cores, for other cores this code has
+ * no effect.
+ *
+ * \{
+ */
+// Function prototype of watchdog reset.
+void wdt_init(void) __attribute__((naked)) __attribute__((section(".init3")));
+// Function implementation of watchdog reset.
+void wdt_init(void)
+{
+ MCUSR = 0;
+ wdt_disable();
+
+ return;
+}
+/* \} */
+
int main(void)
{
FlashAvr flash;
ser_init(&ser, CONFIG_BOOT_PORT);
ser_setbaudrate(&ser, CONFIG_BOOT_BAUDRATE);
- xmodem_recv(&ser, &flash.fd);
+ xmodem_recv(&ser.fd, &flash.fd);
+
kfile_close(&flash.fd);
- kfile_close(&ser.fd);
+ kfile_close(&ser.fd);
IRQ_DISABLE;