Using AVRDUDE to push sketch to Arduino

I want to compile a sketch into a single hex file and then use AVRDUDE to upload the compiled code to three different Arduino variants without the IDE.

The targets are:
Pro Mini 16MHz (with default boot loader)
Nano (with default boot loader)
Nano (with Opti-boot boot loader)

The hex file is compiled in the IDE using settings for the Arduino Nano, so I know programming space is not an issue since it will fit on the target with the least available (Opt-boot frees up at least an extra 1K vs. Nano/ProMini default boot loaders). All of the targets have the same ATMega328p clocked at the same 16MHz speed.

avrdude -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:mysketch.hex:i

So far the only thing I've noticed I have to do is change the baud rate for Nano/ProMini bootloader to be 57600, but other than that it seems to work fine.

My question: Is there any unexpected side-effect of doing this?

The Arduino IDE is just running an AVRDUDE command to upload to those boards. If you run the exact same command then you’re going to get the exact same results.

You can see the command the Arduino IDE runs if you set File > Preferences > Show verbose output during: > upload.

There is one small difference. The Arduino IDE defines a macro for each board, which can be used to make code adapt to which board it’s running on. So whichever board you compiled the .hex file for will determine that macro. However, there is no functional difference between Pro Mini and Nano so it’s quite unlikely that would ever make a difference. In fact, people would be more likely to use the AVR_ATmega328P macro which is defined the same for any of those boards.

Opt-boot frees up at least an extra 1K vs. Nano/ProMini default boot loaders

Optiboot fits in a 0.5 kB boot section. The old bootloader (ATmegaBOOT) requires a 2 kB boot section. So potential savings are 1.5 kB but unfortunately Arduino screwed up and left the boot section set to 2 kB on their new Nano boards with Optiboot. Of course that can be easily changed if you have an ISP programmer or turn an Arduino board into an “Arduino as ISP”.

Thanks, Pert. I don't really need the extra 1.5K anyway since my sketch fits on a Nano with the standard old boot loader, so it sounds like everything should be OK.