Atmega 1284p upload with Serial1 / UART1

I have custom board based Atmega1284p and i use Arduino mightycore. Tried to upload and i am getting an error " avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x36".
I do not get this in Arduino IDE most likely because of the follwoing:
I must use UART1/Serial1 for USB-Serial communication so i have to modify the original mighty core boards.txt and change UART0 to UART1 thus using Serial1 for USB/Serial communication.
Can i do this with platform PlatformIO?
I can see there is “mightycore1284.json” for board options with baud/speed etc… options but there is no option for a Serial1/UART1.

How do you do this in the Arduino IDE?

When Mightycore is installed it creates "C:\Users\Admin\Documents\Arduino\Hardware\MightyCore-master\avr/boards.txt.
There is an option to change the UART to “”
This allows to communicate USB/Serial1 instead of default USB Serial.
This can be done only on Atmegas with 2 UARTs/Serials.

Hm okay I see. Looking at this commit the lines{build.mcu}/{build.f_cpu}/optiboot_flash_{build.mcu}_{upload.port}_{upload.speed}_{build.f_cpu}_eeprom_support.hex

will select the bootloader file to use, and here is the repository for these bootloader files, which are named e.g. optiboot_flash_atmega1284p_UART0_115200_16000000L_eeprom_support.hex or optiboot_flash_atmega1284p_UART1_115200_16000000L_eeprom_support.hex.

However, to make things easier, can’t you just burn the bootloader once using Arduino IDE for now, and then use the bootloader’s serial port for uploading? This must only be done once.

I’m sure I can find out what controls in PlatformIO which bootloader file is flashed though.

I also use 12MHz clock and i can see in the IDE menu options 'Arduino Board Configuration" (by selecting Atmega1284 lower left corner) that there is a Clock drop down for 12Mhz. The same dropdown menu has “NO” options for bootloader. By selecting both of these i still get the same error.
In addition to the above selections do i also need to modify the “Migthycore1284.json” since it has 16Mhz or any other files?

You can change f_cpu and speed in the json file to match the bootloader you’ve burned previously.

But you can also change that per-project by using the platformio.ini override

board_build.f_cpu = 12000000L
upload_speed = 115200

see docs and docs.

1 Like

Thanks a lot.
Works OK with no bootlader upload.