Programmatically Uploading Sketches

I will be using a Mega 2560 for a commercial product, and wondering what options I could provide to a user for updating the sketch on Mega.

So, for example, I ship a product out with a Mega embedded in it, then discover a bug in my code, and now have to send out an updated sketch that needs to be uploaded to the Mega.

I have read about avrdude being used to upload sketches by the Arduino IDE, but it looks like it is licensed under GPL, so that will not work.

I have also seen the TFTP Bootloader option( Arduino Playground - TFTPBootloader1 ) but would rather not do this, considering it is rather insecure and am not sure about its stability.

What other options are there? In a perfect world, I would like to make an HTTP request when the device starts up to see if an update is necessary, download it, and then automatically update itself, or have the sketch check for a location on the sd card for a new sketch, and upload it if it is found.

Thanks in advance for any advice!

stauff08:
I have read about avrdude being used to upload sketches by the Arduino IDE, but it looks like it is licensed under GPL, so that will not work.

I can't see that as a problem. You can distribute the program, but not charge for it (except for "copying costs" - which you simply do not need to do). You have no intention of modifying or re-publishing it.

Your user downloads and installs avrdude either from you or elsewhere, and your script files, plugs in the device and runs your script (which needs to locate the relevant COM port). I suspect your script could even download and install avrdude separately!

This would clearly be the simplest - and therefore best - way to approach the problem.

Basically only code in the boot loader section of memory can write to flash memory. So what ever you do it will involve changing the boot loader.

"Changing" - or using the bootloader?

Can't see why you would need to change the bootloader as such.

Paul__B:
Can't see why you would need to change the bootloader as such.

To make it do what it will not do now, as per the title of this thread "Programmatically Uploading Sketches".