I have written a bootloader for my mega128 using the xmodem protocol. One role of the bootloader is to tell whether it should enter the application code or keep repeating itself, based on whether there is a valid application in the program memory.
Is there a good way to tell if there is a valid application?
At the moment my bootloader, if it runs into any difficulty associated with the Xmodem data transfer (it assumes all page writes and other internal operations are successful) writes a few words of zeros at the start of flash. Upon booting, it checks these words and if they are full of zeros, it keeps looping until it gets a new program loaded.
This works, but doesn't seem very tidy. I read one guy did a CRC check, but on what? The whole flash memory? And how would the resulting CRC word tell me if the application were valid or not?
I'm a bit new to this stuff, so if you pros have a better method of checking for a valid application, I would love to hear about it!