Go Down

Topic: Combining the bootloading and programming for large scale production? (Read 391 times) previous topic - next topic

shwetankv007

Hello everyone,
I have been making a product that is basically a remote monitoring system build on top of an atmega2560. The prototype and about 10 PCBs have been made and tested. I have a very general question, since in order to use the arduino IDE with atmega2560 we need to burn the bootloader in the chip and then use the serial pins to program the mega2560.
Is there a way to minimize the effort or atleast automate the process of burning the bootloader and uploading the sketch in the devices. Since I am planning to get a lot of these devices and each needs separate boards to burn the bootloader and then program it.
I came across a method to automate it using a makefile and a linux machine
https://www.instructables.com/id/Save-81-Seconds-Fast-Arduino-BootloadProgram-for-P/

Is there any other method?
Thanks
Regards

Juraj

the IDE always creates at build two hex files. one for serial upload and second with hex file with a bootloader for ISP flashing with a programmer over ISP.
for ISP you can use avrdude from command line, or change the entries in platform.txt and use Upload with programmer in Sketch menu
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

pert

For a product, the only reason to have a bootloader is to allow the user to easily change the firmware on the device. If that's not something of use for your product, then you're just wasting time and flash space with the bootloader. You can directly flash the compiled sketch to the ATmega2560 using an ISP programmer. You can get the avrdude command you need to do this by enabling File > Preferences > Show verbose output during: upload, doing a Sketch > Upload Using Programmer, and then examining the contents of the black console window at the bottom of the Arduino IDE window to see the avrdude command the Arduino IDE generated. Copy that command to the command line, a script, or a batch file (make sure to quote any paths that have spaces in them). Note that the .hex file is stored in a temporary build folder, which will be erased when you exit the Arduino IDE. You can move it somewhere safe before doing so.

shwetankv007

@pert  @juraj
Thank you for the reply, to confirm I am using a linux machine to program the atmega2560 chip ( first by adding the bootloader and then uploading the sketch). I was not able to locate the hex file in the directories, is it hidden or something?

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?

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?

Juraj

@pert  @juraj
Thank you for the reply, to confirm I am using a linux machine to program the atmega2560 chip ( first by adding the bootloader and then uploading the sketch). I was not able to locate the hex file in the directories, is it hidden or something?

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?

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?

turn on verbose mode in IDE Preferences and you will see the executed commands and file paths.
you can use the "Export compiled binary" command in Sketch menu in IDE. it will put the hex files into the sketch source folder
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

pert

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:
https://www.nongnu.org/avrdude/user-manual/avrdude_4.html#Option-Descriptions

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?
Correct.

shwetankv007

thank you everyone for the responses, I have not tested it yet but will post the details soon.

Thanks again

Go Up