Hi all,
Sorry about the novel. My questions are summarised at the end.
I want to use a bootloader for may MEGA128 for flash programming. I already have an RS232 connection for data collection and sending simple commands to the MCU and would like to use this cable for updating the program as well. I want to send the program in intel hex format because I can use the default .hex file, it has nice little checksums, and the extra characters shouldn't really be an issue. I also like the fact that no special program is needed on the PC.
Despite the large number of bootloader topics and bootloader examples (including a intel hex specific example from P. Manwaring in the project section), I still have some questions relating to speed and timing. I hope that I haven't missed anything obvious.
Basically, if I use a baud rate of 9600bps and send 128kBytes in intel hex, I will have 43 characters per 16 bytes of information, where each byte has a frame of about 10 bits and will therefore need (128k/16 x 43 x 10b/Frame)/9600 b/s = (344 kFrames x 10b/Frame)/9600 b/s = 358 seconds.
I could possibly deal with 6 minutes, as I do not need to program often and instead of running outside with my laptop and MKII, I could go and get a coffee; however, if I could increase the baud rate to 230kbs, this would be better and if I was forced to reduce the baud to 2.4kbs, it would suck completely. So how do I allow for a high baud rate?
Given that my PC interface just sends the whole .hex file of ascii characters to the MCU, the minimum time between each character is determined by the slowest part of my bootloader routine.
Using GCC, it appears I only have the option of programming a whole flash page at a time. If so, I have no idea how long this page write operation takes. In the MEGA128 manual, table 111 indicates that up to 4.5ms are required for a page erase and write. I have been unable to follow the maths, but if even 1ms is required between sending characters, I can forget the whole thing.
So...
does it really take in the ms range to write a page of flash memory?
Is there a way of writing to flash one word at a time - thereby reducing the min time between characters by a factor of up to 128?
Can I use interrupts and a second page buffer to read incoming characters while I am carrying out a page write?
Is it recommended to use interrupts at all in a bootloader?
What happens if I am writing to a page in the NRWW section and relying on interrupts? Do I have to choose between being able to write to the NRWW section OR using interrupts in my routine?
As always, any help or ideas much appreciated!