MiniCore uploading problems

Hi,

I have made a custom PCB with a 328pb and decided to use MiniCore by @MCUdude. I can upload the bootloader and the program without a bootloader through ISP, but serial programming is not working as intended. If I use an FTDI adapter, programming straight up doesn´t work at all (serial monitor does work). If I use a CP2102 adapter, it only works if I reset the board at a specific time, which is hard to hit.

I suspect this is some sort of problem with the urboot bootloader and the timing of the reset through the DTR pin. Has anyone encountered and solved this issue?

This is the output while uploading:

avrdude: Version 7.2-arduino.1
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is C:\Users\HAU-NB_HLX03\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.2\avrdude.conf

         Using Port                    : COM5
         Using Programmer              : urclock
         Overriding Baud Rate          : 115200
avrdude urclock_getsync() warning: attempt 1 of 10: not in sync
avrdude urclock_getsync() warning: attempt 2 of 10: not in sync
avrdude urclock_getsync() warning: attempt 3 of 10: not in sync
avrdude urclock_getsync() warning: attempt 4 of 10: not in sync
avrdude urclock_getsync() warning: attempt 5 of 10: not in sync
avrdude urclock_getsync() warning: attempt 6 of 10: not in sync
avrdude urclock_getsync() warning: attempt 7 of 10: not in sync
avrdude urclock_getsync() warning: attempt 8 of 10: not in sync
avrdude urclock_getsync() warning: attempt 9 of 10: not in sync
avrdude urclock_getsync() warning: attempt 10 of 10: not in sync
avrdude urclock_recv() warning: programmer is not responding; try -xstrict and/or vary -xdelay=100
avrdude main() error: unable to open programmer urclock on port COM5

avrdude done.  Thank you.

Failed uploading: uploading error: exit status 1

But it worked ok on your breadboard prototype?

I have/had no breadboard prototype.

I have found the cause of the problem! Here it is:

You will need to post the schematic, it is much more likely that there is a problem with the circuitry on the RESET pin than with the bootloader.

@PaulRB Very funny. :roll_eyes:

@david_2018 Here is the schematic. The reset circuit is the same as with the usual Arduino boards.

I used the reference schematic from the MiniCore GitHub page:

But true!

Thanks for the schematic. I was going to ask if you had the cap and pull-up on the reset pin, because that might have explained the symptoms. But what you have shown looks good. That's how I have done it previously, using CP2102. I did not have to click reset button at all to upload code like that.

I see you have no external crystal in your circuit (also like my circuits). Did you set to 8MHz internal clock before burning the bootloader?

I do have an external 16 MHz resonator. The Atmega otherwise works fine. My code runs just fine, only uploading through serial in the IDE is an issue.

Ah, sorry, I missed it.

It's got built-in caps, right? I assume that's why it's shown with a ground connection. If not, and it's a 2-pin crystal, gotta have them caps!

Yes. That´s why I called it a resonator and not a crystal. :wink: It has 15 pF caps. P/N CSTNE16M0V53L000R0 if you want to look it up.

As I said, the microcontroller works just fine, I only have an issue with uploading through serial.

Like @david_2018, it sounded like a reset circuit problem to me. But you have used the "standard" cap and pull-up, which has always worked well for me with CP2102, MiniCore, 328p 28-pin DIP.

Have you 'scoped-out the reset pin signal when you hit the upload button?

Just want to verify that you did not upload a sketch via ISP, that will erase the bootloader. Does not seem to be the case here, since you can upload by manually resetting.

And you did not select UART1 by accident, before doing "burn bootloader"?

I am using the 328PB on my DIY boards and the urboot bootloader works well and on both UART's the BP has.

Some things that have helped me with serial programming a stand alone 328PB. Make sure the variant "328PB" is selected (though that normally gives a device sig error if it isn't selected), make sure you are using the MiniCore 328 board. Close out of all serial monitor sessions in the IDE and from terminal emulators if you are using one (this is a big one, open serial monitor sessions will give the error you see).

Check for solder bridges anywhere on the 328 chip. I have run into issues a few times from this. I solder my chips using solder paste and a heat bed along with hot air, it took me awhile to get a good process down to where I wasn't created bridges all the time. Now it only happens occasionally, but it will stop the serial programming in its tracks.

I use the DSD Tech FTDI 232 USB Serial TTL, Tx -> Tx, Rx -> Rx, RST -> reset through a 100nF cap (which looks like you have). I have also used Uno R3s as a USB Serial adapter. Take out the 328P chip and connect with Tx, Rx, RST, Gnd, and 5V.

I also suspect a reset circuit problem and not a software one, so I scoped the reset pin while pressing upload and this is what I´ve got:

The datasheet of the 328pb mentiones a lower reset threshold voltage of 0.2*Vcc (so 1V for 5V Vcc). However it seems like the reset pin only goes down to 1.78V. Could this be my problem? Do I need a larger pullup resistor and/or smaller cap?

So the solution to my problem is to either use a 3.3V serial programmer, or with a 5V programmer use a protection diode on the reset pin to prevent the 328pb from enetring HV programming mode (which it apperantly did).