I'm looking for a Bootloader for ATmega32U4 (not using USB) with RS485 support.
I bet I have to customize it a bit, because I have to handle the RS485 address (stored in EEPROM).
In the past I used the Chip45Boot3 bootloader, it works well but it transfer the plain HEX file.
I'm looking for something better. I found OptiBoot but I'm quite scared because I didn't find a clear procedure about how to add a new MCU. In fact, it supports atmega32 but not the atmega32u4 and the Arduino IDE refuses to burn the bootloader due to a chip signature mismatch.
make atmega32u4 RS485=B4
"/Library/Developer/CommandLineTools/usr/bin/make" atmega32u4atUART UART?=1 LED_START_FLASHES?=0
avr-gcc (AVR_8_bit_GNU_Toolchain_3.6.1_495) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
BAUD RATE CHECK: Desired: 115200, Real: 117647, UBRRL = 16, Difference=2.1%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega32u4 -DF_CPU=16000000L -DBAUD_RATE=115200 -DLED_START_FLASHES=0 -DRS485=B4 -DUART=1 -c -o optiboot.o optiboot.c
optiboot.c:429:2: warning: #warning BAUD_RATE off by greater than 2% [-Wcpp]
#warning BAUD_RATE off by greater than 2%
^
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega32u4 -DF_CPU=16000000L -DBAUD_RATE=115200 -DLED_START_FLASHES=0 -DRS485=B4 -DUART=1 -Wl,-Tlink_optiboot.ld -Wl,--relax -nostartfiles -o optiboot_atmega32u4_UART1___BB.elf optiboot.o
avr-size optiboot_atmega32u4_UART1___BB.elf
text data bss dec hex filename
494 0 0 494 1ee optiboot_atmega32u4_UART1___BB.elf
installed the gcc-avr package (Local Development Environment option)
make atmega32u4:
$ make atmega32u4
"make" atmega32u4atUART UART?=1 LED_START_FLASHES?=0
make[1]: ingresso nella directory «/home/mark/optiboot/optiboot/bootloaders/optiboot»
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
BAUD RATE CHECK: Desired: 115200, Real: 117647, UBRRL = 16, Difference=2.1%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega32u4 -DF_CPU=16000000L -DBAUD_RATE=115200 -DLED_START_FLASHES=0 -DUART=1 -c -o optiboot.o optiboot.c
optiboot.c:352:22: fatal error: inttypes.h: File o directory non esistente
compilation terminated.
make[1]: *** [<incorporato>: optiboot.o] Errore 1
make[1]: uscita dalla directory «/home/mark/optiboot/optiboot/bootloaders/optiboot»
make: *** [Makefile.usbmcus:149: atmega32u4] Errore 2
Clearly there is something to set about the include dirs, but I found nothing about in the documentation. Would you mind to put me on the right way?
I'm using Ubuntu 22.04 and I installed the required package using sudo apt install gcc-avr.
The other two packages are not mentioned so I didn't install them. Now I installed avr-libc, but avr-binutils is not available from apt.
Now I have the include file under /usr/lib/avr/include as well!
And it compiles!
Time to try it without changes and then begin to adjust to my needs!