Can someone give me a tutorial how to compile a MegaCore bootloader? I couldn't find anything useful in the internet.
I need a bootloader with these specs:
Processor: ATmega 2560
F_CPU: 16000000
BAUD: 460800
BOD: BOD 2.7V
LTO disabled
Arduino MEGA pinout
UART0
The problem is only the baud rate because 16Mhz only has a bootloader precompiled with 500000 baud rate. But I got the Arduino Mega 2560 to work at 460800 in my normal program.
I have tried this so far:
$ make atmega2560 AVR_FREQ=16000000L BAUD_RATE=460800 UART=0 LED=B7 LED_START_FLASHES=2
if not exist "bootloaders\atmega2560\16000000L" mkdir bootloaders\atmega2560\16000000L
-n Using avr-gcc\
Microsoft Windows [Version 10.0.18362.239]
(c) 2019 Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\Fabio\AppData\Local\Arduino15\packages\MegaCore\hardware\avr\2.0.2\bootloaders\optiboot_flash>
I have PC's with macOS and Windows available to compile it.
I got the Arduino Mega 2560 to work at 460800 in my normal program.
No you didn't. The 2560 at 16MHz can not support 460800bps.
It probably LOOKS like it is working because the ATmega16u2 used as the USB/Serial converter has the same limitation, and will run at the same (not-quite 460800bps) as the 2560.
Go ahead and use the 500kbps bootloader; it'll probably work fine. (It's somewhat possible that Serial.begin() and the the 16u2 firmware both truncate instead of properly rounding and give you 400000bps when you ask for 460800, so you can try that as well, if 500k doesn't work.)
(You compile process looks fine, BTW. Presumably you're getting the error:)
Sadly it doesn't work. I'm using an HC05 module and want to upload at a higher speed than 115200. But the Bluetooth module only supports the baud rates like 460800. I have a big sketch and over USB it takes 12 Seconds to upload. Over Bluetooth it takes 30sec. Do you think Bluetooth is the bottle neck in my case? If it is the case, then I have to switch to WLAN. (I tried WLAN but also failed to get any upload going using esp-link).
The Mega2560 (and all other classic 16MHz AVRs) is incapable of generating 460800 baud serial. It generates the serial clock by dividing the 16MHz system clock, and needs at least 8 samples for each bit (with U2X enabled, which it is for Arduino sketches, with that off, it needs 16).
There is no integer that you can divide (16/8=) 2MHz by to get 460800 or anything close to it.
115200 is the fastest "standard" baud rate you can get the serial port on a 16MHz Arduino to run at.
Yeah it is really a pain if you upload 100-200 times a day and you have to reconnect Serial and put the PC away because the Arduino is on a driving robot. Is there a Bluetooth module with 500000baud rate?