Bootloader general informatoin

Boot loader questions:

Goal: To slow the bootloader flash baud rate to 9600 so that I can use the #2 setting on the
HC-12 tx/rx module for greater distance. I am using Mega2560.

The debug serial and the flash baud rates must match for use with the HC-12 to give me
OTA programming capability.

I have been studying this project for months now and have tried various methods to burn a
modified boot loader. None have worked. To this end I decided that I do not understand
the whole process which means the odds of getting this to work is slim.

So, this first section is how to create a modified bootloader and the associated questions
that go with if.

  1. I have located the boards.txt file and can change the upload.speed for the mega2560.

  2. I have located the makefile for various loaders.

  3. I have admin rights to make the changes in these files. It was a problem for W10.

  4. ? Can this even be done?

  5. ? Where is the change to make the IDE (1.8.8) use the 9600 baud rate for the boot loader
    flash, just like it is necessary to set the port baud rate for USB serial comms.

  6. ? Other then the boards.txt, where do I change the upload.speed for the boot loader?

If I can get an understanding of these concepts, further studying on my part should be more
productive.

Thank you.

Gary

  1. Upload speed is hard coded in the bootloader, so you have to create/compile new bootloader image and upload it via ISP interface.
  2. The speed on the side of PC is defined in board.txt. That's it.

OK, that answers one question, boards.txt has to do with the PC side not the creation of or the operation of the bootloader code.

Given that, I will look in the optiboot directory for where to change the bootloader upload speed and how to compile the new .hex file to upload.

Found Makefile and found a few lines down this:
ISPTOOL = stk500v2
ISPPORT = usb
ISPSPEED = -b 115200

I would take it that the ISPSPEED is where I set the flash upload speed, right?
Then create a new .hex file based on the modified Makefile?

Gary

Mega doesn't use the Optiboot.

EDIT: Yes, but there is a support for ATmega2560 also. It is probably better to take it directly from
GitHub - Optiboot/optiboot: Small and Fast Bootloader for Arduino and other Atmel AVR chips.

Baud rate is an input parameter for the make, like: BAUD_RATE=9600.

Anyway, do you know you will need ISP programmer?

If you are using Win, you can compile it in the Atmel Studio. This is downloadable for free on Atmel (sorry Microchip) web.
This is probably easiest way to do it under Windows.

You don't need to recompile your own bootloader. Hans "MCUDude" has pre-build almost every possible combination and included them as part of the MCUDude MegaCore Core.

Install that, find it's boards.txt and edit the line that says:

2560.menu.clock.16MHz_external.upload.speed=115200

to say instead:

2560.menu.clock.16MHz_external.upload.speed=9600

Then select the appropriate board parameters (ATmega2560, 16MHz External Clock, MEGA pinout) and use the "burn bootloader" command (after setting appropriate port/programmer/etc) to burn the bootloader, and the "upload" command to upload...

Thank you so much, finally something I can act on. Can't wait to get some quiet time to try it out. I do have the ATtinyISP programmer. Thanks again. Gary

Thank you for the feedback but after hours and hours of attempts, have had no success. At every turn there is something else that does not match what I would expect.

Will keep reading and trying to understand whats going on, hopefully will eventually arrive at the solution.

Gary

Have had trouble writing a proper reply, it seems that mastering the mechanics of the forum takes time also.