firmware upgrade for BF514F


I want to be able to upgrade the firmware located in the internal flash in a BF514F. I have an SD card connector hooked up to the RSI peripheral. The user would insert an SD card with the proper file, and when the BF514F was booted up, it would see that the correct file is located on the SD card, and overwrite the old program with the new one. I've been reading a bunch of application notes, and the loader manual, but I'm still pretty confused as to where I should begin. Any suggestions would be much appreciated!