Go Down

Topic: Can upload sketch to Arduino pro mini only once (Read 313 times) previous topic - next topic

nbenm

Hi,

 

I have a bootloader issue (I think so).
One of my two Arduino Pro Mini 3.3V 8MHz refuses to upload sketchs. I MUST press reset button to make it upload.

So I have reflashed the bootloader.
That solved the problem. But at subsequent uploads, I have the same error.
In fact, after burning the bootloader, I can upload a sketch only once!
I always need to reflash the bootloader before.

I use IDE option "Burn bootloader". It generates the 2 following commands:

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cusbasp -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cusbasp -Pusb -Uflash:w:/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex:i -Ulock:w:0x0F:m

 

My second Arduino Pro Mini works perfectly.

Both are genuine Arduino Pro Mini (Adafruit).

 

I've spent all day searching. From what I've read, these commands seem correct.

So I don't understand what's happening.

Any idea?

pert

"can only upload once" usually indicates a problem with the auto-reset circuit.

Are you using the same USB to TTL serial adapter (AKA "FTDI") on both the working and non-working Pro Mini? Do you connect it exactly the same on both Pro Minis?

nbenm

Are you using the same USB to TTL serial adapter (AKA "FTDI") on both the working and non-working Pro Mini? Do you connect it exactly the same on both Pro Minis?
Yes, I have 3 same adapters.
It's the same with the three.
One arduino works always, and one is uploadable only once after burning bootloader.

pert

Try this to determine whether the problem is with the auto-reset circuit on the bad Pro Mini:

If you don't have a working auto-reset circuit, you'll need to manually reset your Arduino during the upload. When you don't have that auto-reset, and are resetting manually, you need to get the timing right. If you press the reset button too early, the bootloader will have already timed out by the time the upload starts. The tricky thing is that when you press the "Upload" button in the Arduino IDE, it first compiles your sketch before starting the actual upload. So you need to wait until after the compilation finishes before pressing the reset button. The way to get the timing right is to watch the black console window at the bottom of the Arduino IDE window. As soon as you see something like this:
Code: [Select]
Sketch uses 444 bytes (1%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

press and release the reset button. The upload should now proceed successfully.

nbenm

Pressing the reset button at compile time always makes the sketch be uploaded.

pert

OK! So we now know this is a problem with the auto-reset circuit, since the upload problem is solved by a manual reset. The reason you are able to upload once without a manual reset after burning the bootloader is because when you burn the bootloader the sketch is erased from your Pro Mini and when there is no sketch the bootloader is permanently activated. Once you have uploaded that first sketch after burning the bootloader, then a reset is required to activate the bootloader. Normally this is done automatically at just the right time during the upload via the auto-reset circuit.

We also know it's not a problem with your USB to TTL serial adapter, since the problem only occurs when the adapter is connected to the bad Pro Mini. So I think it's clear that you received a defective board. I recommend contacting Adafruit Customer Service with a complete description of the symptoms.

nbenm


pert

You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per

nbenm

#8
Aug 24, 2019, 01:24 pm Last Edit: Aug 24, 2019, 01:26 pm by nbenm Reason: Issue solved
Good news!
I have checked with a scope what's happening on DTR and RESET pin.
When DTR goes down, there's no pulse on the RESET pin.
On the "good" module, I can see this pulse.
So I have replaced C2 (0.1

pert

Great work on identifying and fixing the hardware problem nbenm. Assuming it was a new board that hadn't been mistreated, I do think Adafruit would have replaced the board for you, but likely it would have been just as much work dealing with customer service as it was to just fix the problem.

It makes me really happy when I can fix something that's broken instead of taking the "throw away and replace" approach that is too common in this time.

Go Up