Send a couple of bytes to Arduino automatically before programming?

I've got an arduino with an RS-485 shield. I can remotely get the arduino to jump to a modified version of optiboot if I give it a 6-byte command first. Then, the modified opitboot will allow me to send it a new sketch as usual. This works fine.

Is there a way to automatically get the arduino upload button to send that 6-byte run-the-bootloader string to the same com port that avrdude will be aimed at before calling avrdude? That would be very helpful.

(Using windows if that matters)

One method would be to write your own program that...

• Opens the serial port using the same command-line parameter used by avrdude

• Sends the six byte command

• Closes the serial port

• Runs avrdude passing the entire command-line that was passed

Armed with such a program one small change to platforms.txt would get you going.