Program ATmega328PB Xplained Mini using MiniCore

I try to use Serial1 in ATmega328PB to communicate with RS-485 IC. I am having a problem when I burn boot loader. I read this forum, but still do not understand how to resolve this issue. Could you please kindly suggest how to resolve this problem? I attach the configuration under Tools. Thank you

Arduino: 1.8.10 (Mac OS X), Board: "ATmega328, Yes (UART0), 328PB, BOD 4.3V, LTO disabled, External 16 MHz"

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Users/tkawinf/Library/Arduino15/packages/MiniCore/hardware/avr/2.0.4/avrdude.conf -v -patmega328pb -cstk500v1 -P/dev/cu.usbmodem14102 -e -Ulock:w:0x3f:m -Uefuse:w:0b11110100:m -Uhfuse:w:0xd6:m -Ulfuse:w:0b11111111:m

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "/Users/tkawinf/Library/Arduino15/packages/MiniCore/hardware/avr/2.0.4/avrdude.conf"
User configuration file is "/Users/tkawinf/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.usbmodem14102
Using Programmer : stk500v1
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done. Thank you.

Error while burning bootloader.

Please note that I tried many available boards. The closet working one is GitHub - watterott/ATmega328PB-Testing: Atmel/Microchip ATmega328PB support for Arduino IDE. Serial1 can be used; however, I cannot set other pins, such as PD2 to high logic for drive enable of this IC (sn75hvd3082e).

RS485 generally means you have to toggle a pin to send... The bootloader used by MiniCore doesn't have that feature...

It was added to one fork of optiboot here - looks trivial to port to other versions.

I try to use Serial1 in ATmega328PB to communicate with RS-485 IC.
...
Arduino: 1.8.10 (Mac OS X), Board: "ATmega328, Yes (UART0), 328PB, BOD 4.3V, LTO disabled, External 16 MHz"

So are you still trying to run the bootloader/upload on Serial0 ?
What are you using for a device programmer?

Thank you @DrAzzy for your response and insight. You're right. The RS-485 library will set the TX drive enable to high and low logic during transmit data so I do not expect MiniCore to provide the feature. Your commit is a good idea. It may be useful for me in future.

Thank you @westfw for your response. I use the programmer port provided in ATmega328PB Xplained Mini. I hope to utilize a new hardware serial (Serial1) available in atmega328PB to communicate to RS-485 IC.

I found one of the posts mentioned that GitHub - watterott/ATmega328PB-Testing: Atmel/Microchip ATmega328PB support for Arduino IDE has an auto band rate, but minicore does not have it. I tried loading a couple of band rates, such as 500000, 115200, 38400, and 9600, via Atmel Studio and then set 328.menu.clock.16MHz_external.upload.speed in boards.txt. After restarting Arduino IDE, I can load my sketch with the band rate 384000 and 9600. However, I still cannot communicate with RS-485 IC. Note that I confirmed that my code is working via Serial0 when I used Arduino Uno and GitHub - watterott/ATmega328PB-Testing: Atmel/Microchip ATmega328PB support for Arduino IDE on ATmega328PB Xplained Mini. However, Serial0 does not work with Minicore.

Sketch uses 7964 bytes (24%) of program storage space. Maximum is 32256 bytes.
Global variables use 723 bytes (35%) of dynamic memory, leaving 1325 bytes for local variables. Maximum is 2048 bytes.
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Users/tkawinf/Library/Arduino15/packages/MiniCore/hardware/avr/2.0.4/avrdude.conf -v -patmega328pb -carduino -P/dev/cu.usbmodem14102 -b9600 -D -Uflash:w:/var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_240258/sensor-hub.ino.hex:i

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "/Users/tkawinf/Library/Arduino15/packages/MiniCore/hardware/avr/2.0.4/avrdude.conf"
User configuration file is "/Users/tkawinf/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.usbmodem14102
Using Programmer : arduino
Overriding Baud Rate : 9600
AVR Part : ATmega328PB
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

Programmer Type : Arduino
Description : Arduino
Hardware Version: 3
Firmware Version: 8.0
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9516 (probably m328pb)
avrdude: reading input file "/var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_240258/sensor-hub.ino.hex"
avrdude: writing flash (7964 bytes):

Writing | ################################################## | 100% 9.52s

avrdude: 7964 bytes of flash written
avrdude: verifying flash memory against /var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_240258/sensor-hub.ino.hex:
avrdude: load data flash data from input file /var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_240258/sensor-hub.ino.hex:
avrdude: input file /var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_240258/sensor-hub.ino.hex contains 7964 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 9.27s

avrdude: verifying ...
avrdude: 7964 bytes of flash verified

avrdude done. Thank you.

It’s not using the right programmer type in the avrdude cmd line for an xplained mini.
See if there is an “medbg” entry is the list of programmers.

Thank you for your help @westfw. I can use Serial to communicate with RS-485 after using either Atmel mEDBG or Arduino as ISP (ATmega32U4). However, Serial1 still does not work. I attach all programmers in this post. Thank you

Programming using AVRISP mkII, USBasp, USBtinyISP (MiniCore), USBasp (MiniCore), Arduino as ISP, or Atmel JTAGICE3 (ISP mode) does not work with Serial1 either. I tried to follow this post atmega328pb xplained mini with Arduino IDE 1.8.5 and USBasp - Microcontrollers - Arduino Forum, but could not resolve this issue.

Arduino as ISP (ATmega32U4)

Sketch uses 7964 bytes (24%) of program storage space. Maximum is 32256 bytes.
Global variables use 723 bytes (35%) of dynamic memory, leaving 1325 bytes for local variables. Maximum is 2048 bytes.
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Users/tkawinf/Library/Arduino15/packages/MiniCore/hardware/avr/2.0.4/avrdude.conf -v -patmega328pb -carduino -P/dev/cu.usbmodem14102 -b9600 -D -Uflash:w:/var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_717934/sensor-hub.ino.hex:i

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "/Users/tkawinf/Library/Arduino15/packages/MiniCore/hardware/avr/2.0.4/avrdude.conf"
User configuration file is "/Users/tkawinf/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.usbmodem14102
Using Programmer : arduino
Overriding Baud Rate : 9600
AVR Part : ATmega328PB
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

Programmer Type : Arduino
Description : Arduino
Hardware Version: 3
Firmware Version: 8.0
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9516 (probably m328pb)
avrdude: reading input file "/var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_717934/sensor-hub.ino.hex"
avrdude: writing flash (7964 bytes):

Writing | ################################################## | 100% 9.52s

avrdude: 7964 bytes of flash written
avrdude: verifying flash memory against /var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_717934/sensor-hub.ino.hex:
avrdude: load data flash data from input file /var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_717934/sensor-hub.ino.hex:
avrdude: input file /var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_717934/sensor-hub.ino.hex contains 7964 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 9.26s

avrdude: verifying ...
avrdude: 7964 bytes of flash verified

avrdude done. Thank you.

Atmel mEDBG

Sketch uses 7964 bytes (24%) of program storage space. Maximum is 32256 bytes.
Global variables use 723 bytes (35%) of dynamic memory, leaving 1325 bytes for local variables. Maximum is 2048 bytes.
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Users/tkawinf/Library/Arduino15/packages/MiniCore/hardware/avr/2.0.4/avrdude.conf -v -patmega328pb -carduino -P/dev/cu.usbmodem14102 -b9600 -D -Uflash:w:/var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_717934/sensor-hub.ino.hex:i

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "/Users/tkawinf/Library/Arduino15/packages/MiniCore/hardware/avr/2.0.4/avrdude.conf"
User configuration file is "/Users/tkawinf/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.usbmodem14102
Using Programmer : arduino
Overriding Baud Rate : 9600
AVR Part : ATmega328PB
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

Programmer Type : Arduino
Description : Arduino
Hardware Version: 3
Firmware Version: 8.0
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9516 (probably m328pb)
avrdude: reading input file "/var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_717934/sensor-hub.ino.hex"
avrdude: writing flash (7964 bytes):

Writing | ################################################## | 100% 9.52s

avrdude: 7964 bytes of flash written
avrdude: verifying flash memory against /var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_717934/sensor-hub.ino.hex:
avrdude: load data flash data from input file /var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_717934/sensor-hub.ino.hex:
avrdude: input file /var/folders/zl/p4_y2q992b97kfkhgq51yr9h0000gn/T/arduino_build_717934/sensor-hub.ino.hex contains 7964 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 9.26s

avrdude: verifying ...
avrdude: 7964 bytes of flash verified

avrdude done. Thank you.

I can use Serial to communicate with RS-485 after using either Atmel mEDBG or Arduino as ISP (ATmega32U4). However, Serial1 still does not work. I attach all programmers in this post.

I'm pretty sure that "Can't get Serial1 to work with RS485" is an entirely different problem than "can't upload code to Xplained Mini." Please start a separate thread. We probably need to see your code, and a wiring diagram of how the Xplained is connected to the (which?) rs485 chip.
Note that UART1 on the 328pb shares pins with the SPI interface. The Xplained has some isolating resistors, but I'm not sure that UART1 is actually usable, especially if you're debugging at the same time.

Thank you @westfw. I will create a new thread based on your suggestion. The 485 IC is sn75hvd3082e. Thank you again for your help :slight_smile:

I found out that my code tries to use both SPI0 and UART1 at the same time (MOSI0 and TXD1 share the same pin, MISO0 and RXD1 share the same pin). This is no problem with MiniCore. We just need to fix band rate and choose the right programmer interface in order to work with ATmega328PB Xplained Mini.