Also just to confirm, you suggest that I can use the hex file so generated directly to program the chip just like the case with Atmel studio hex files? without actually burning the bootloader first?
Yes, but with a caveat. The Arduino IDE's Tools > Burn Bootloader actually does two things:
- Set configuration fuses on the microcontroller according to the definition of the board you have selected from the Tools > Board menu.
- Flash the bootloader file to the microcontroller.
If the users of your product will have no need to easily update the firmware, then step 2 is unnecessary. However, unless the factory default fuse settings on the ATmega2560 just happen to be what you need, you do need to set the fuses.
This can be done from the command line. If you enable verbose output during upload as in my previous instructions, do a Burn Bootloader, and then examine the contents of the black console window after, you will see the two avrdude commands the IDE generated to set the fuses and flash the bootloader .hex file. Note that step 2 actually does set the lock bits to the locked state after flashing the bootloader.
You can actually set fuses and flash you .hex file all in a single avrdude command. There was no need for Arduino to split it into multiple commands. So you can create a avrdude command that is a hybrid of the desired parts of the Upload Using Programmer and Burn Bootloader commands. Generally, avrdude runs the processes in the order they are given in the command.
You may find the avrdude manual to be a helpful reference:
So this practically means I can use a standard ISP programmer and the ISP pins of the chip to be programmed and use the HEX file directly?