How to flag Kinetis bootloader to load new fw

bootloaderfreescalemicrocontroller

I have a board that features a Freescale Kinetis K60 MCU and I want to write a bootloader for it but I don't have hardware in place to signal it after a reset to go into "load new firmware" mode vs. "normal operation" mode.
What are my alternative possibilities?
Can I set a flag in flash to signal the bootloader to enter one or the other mode? How would I do this? Any ideas?

Best Answer

That really depends on how complex a bootloader you want to write, and what you have in place in the way of communications options.

For example, if the bootloader is using a UART to take in the application code, you could include a minimal console (menu-driven, for simplicity) in the bootloader that allows you to issue various commands, e.g. erase the existing application, start the existing application, or load a new application. Include a startup timeout - if you don't press a key within 3 seconds of boot, it automatically starts the existing application, if there is one, otherwise it stays in the menu waiting for an application to be loaded.

If the bootloader implements a simple, well-documented and widely supported serial file transfer protocol e.g. Y-Modem (yes, Z-modem is far, far better, but it's complicated), then you can upload application binaries from just about any terminal program.