Hi,
please look at this thread for compiling the boot loader:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1255016475/1#1You have to add the following line to get a boot loader for the pro 8 Mhz with ATmega328:
%DIRAVRUTIL%\make.exe atmega328_pro8
To
increase the wait time, you have to change the Makefile in the opposite way. You are using "F_CPU>>40" = 8M / 2^40 which is exactly 0 in integer arithmetic, so there will be no wait time at all.
Try using something like '-DMAX_TIME_COUNT=F_CPU>>1' which means 8 times (2^3) longer than normal.
You can also use the WDT for the reset, but then you have to change the code a bit. Look at the following code lines:
#ifdef WATCHDOG_MODS
ch = MCUSR;
MCUSR = 0;
WDTCSR |= _BV(WDCE) | _BV(WDE);
WDTCSR = 0;
// Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot.
if (! (ch & _BV(EXTRF))) // if its a not an external reset...
app_start(); // skip bootloader
#else
You have to comment out the last two lines when you want to enter the bootloader using the WDT:
//if (! (ch & _BV(EXTRF))) // if its a not an external reset...
// app_start(); // skip bootloader
Also, I noticed that 328P chips have bootloaders that run at 57600, even with 8 mhz chips. I was under the impression this baud rate had error issues?
Whether this baud rate has issues, depends very much on the other side of the serial cable. What cable are you using?
To improve the baudrate calculation, you can change the baud-rate calculation in the bootloader to the formula of HardwareSerial which is more exact because of better rounding:
UBRR0H = ((F_CPU / 16 + BAUD_RATE / 2) / BAUD_RATE - 1) >> 8;
UBRR0L = ((F_CPU / 16 + BAUD_RATE / 2) / BAUD_RATE - 1);
MikeT