Arduino Forum

Using Arduino => Avrdude, stk500, Bootloader issues => Topic started by: tomk825 on Jun 08, 2018, 10:13 pm

Title: Trouble Burning Bootloader onto Pro Mini 5V 16MHz
Post by: tomk825 on Jun 08, 2018, 10:13 pm
I'm very new to all of this but I'll try to be as specific as I can.

My project uses a WS2812B LED strip for sequential turn signals to put in my car's tail lights. The Aruino is being powered by the pulse of the turn signal so it must boot up and begin running the code very quickly. Using an Uno R3, the sketch fires up with great speed and the project works great.

However, for the sake of making the project smaller and cheaper, I decided to use a Pro Mini 5V 16MHz. The Pro Mini takes a couple of seconds to boot up. I need to install Optiboot or just use "Burn Bootloader" as far as I know, but I've had little luck.

Here's what I've done:

I bought the AVR Pocket Programmer.
I installed the AVR driver which appropriately shows the device as USBtiny
I made the necessary connections from the AVR Programmer to the Pro Mini, I am certain these are correct.
With USB I used the AVR to "Burn Bootloader" onto the Pro Mini however it gives the following error:
"***failed; 
avrdude: WARNING: invalid value for unused bits in fuse "efuse", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xfd instead of 0x05 (double check with your datasheet first)."

I have checked the boards.txt file others have used for the Pro Mini 5v 16 MHz and have found that they too used 0x05 for the efuse..

Sketches no longer upload to the Pro Mini unless I do it through the Programmer. And the sketches that do upload do not run correctly (my LED strip sketch looks as if it started the sketch then freezes).
I'm sorry for not going into further detail but I have to go to work right now, I'll post more later if needed.
Title: Re: Trouble Burning Bootloader onto Pro Mini 5V 16MHz
Post by: pert on Jun 08, 2018, 10:32 pm
avrdude: WARNING: invalid value for unused bits in fuse "efuse", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xfd instead of 0x05 (double check with your datasheet first)."
That warning is a red herring. Ignore it. It has nothing to do with your problem.

Please do this:
Title: Re: Trouble Burning Bootloader onto Pro Mini 5V 16MHz
Post by: tomk825 on Jun 08, 2018, 10:59 pm
That warning is a red herring. Ignore it. It has nothing to do with your problem.

Please do this:
  • File > Preferences > Show verbose output during: > compilation (uncheck) > upload (check) > OK
  • Tools > Burn Bootloader
  • After the process fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • Paste the error messages in a reply here USING CODE TAGS (</> button on the toolbar).

Thanks for the reply! I'll post the error message when I get back home tonight.
Title: Re: Trouble Burning Bootloader onto Pro Mini 5V 16MHz
Post by: tomk825 on Jun 10, 2018, 10:24 am
That warning is a red herring. Ignore it. It has nothing to do with your problem.

Please do this:
  • File > Preferences > Show verbose output during: > compilation (uncheck) > upload (check) > OK
  • Tools > Burn Bootloader
  • After the process fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • Paste the error messages in a reply here USING CODE TAGS (</> button on the toolbar).

I am still having issues!

I do not get any error messages when I click Burn Bootloader but I will send the output that prints in the bottom window of the IDE in my following replies.

I have tried uploading the sketch using the programmer but the sketch still takes about 2 seconds to run after the arduino gets power. I cannot upload any sketches to the Pro mini anymore with my FTDI Breakout, the error I get when trying to do so is:
Code: [Select]
Arduino: 1.8.1 (Windows 8.1), Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"

In file included from C:\Users\keegat2\Documents\GolfR\Code\Tail_light_seq\tail_light_v2\tail_light_v2.ino:1:0:

C:\Users\keegat2\Documents\Arduino\libraries\FastLED/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.008

 #    pragma message "FastLED version 3.001.008"

                     ^

Sketch uses 5046 bytes (16%) of program storage space. Maximum is 30720 bytes.
Global variables use 372 bytes (18%) of dynamic memory, leaving 1676 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM3 -b57600 -D -Uflash:w:C:\Users\keegat2\AppData\Local\Temp\arduino_build_639905/tail_light_v2.ino.hex:i

avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x83
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x83
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x83
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x83
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x83
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x83
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x83
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x83
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x83
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x83

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Title: Re: Trouble Burning Bootloader onto Pro Mini 5V 16MHz
Post by: pert on Jun 10, 2018, 10:28 am
I have tried uploading the sketch using the programmer
When you do that you erase the bootloader so you always need to do a Tools > Burn Bootloader after you do an upload using the programmer before you can go back to uploading via the FTDI breakout again.
Title: Re: Trouble Burning Bootloader onto Pro Mini 5V 16MHz
Post by: tomk825 on Jun 10, 2018, 10:39 am
So clicking "Burn Bootloader" results in about 5 seconds of the IDE working on it then just completing without any errors. Maybe I'm unclear on this, but shouldn't the Pro Mini boot up immediately if this worked correctly? It still takes 2 seconds as I said in my last message.

Anyway, here's the output I get in the bottom window:
Code: [Select]
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cusbtiny -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m

avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\\.\libusb0-0001--0x1781-0x0c9f
         AVR Part                      : ATmega328P
         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
           efuse          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

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: Using SCK period of 10 usec
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3F:
avrdude: load data lock data from input file 0x3F:
avrdude: input file 0x3F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0x05"
avrdude: writing efuse (1 bytes):

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cusbtiny -Uflash:w:C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex:i -Ulock:w:0x0F:m

avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\\.\libusb0-0001--0x1781-0x0c9f
         AVR Part                      : ATmega328P
         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
           efuse          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

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported


Title: Re: Trouble Burning Bootloader onto Pro Mini 5V 16MHz
Post by: tomk825 on Jun 10, 2018, 10:44 am
Thanks for that heads up, Pert. I just tried out what you said and was able to upload via FTDI breakout again. The LED strip is still taking two seconds to light up after giving the Arduino power so I'm assuming something is wrong. This is the rest of the output (from attempting to Burn Bootloader) as it was too big for one post:

Code: [Select]
avrdude: Using SCK period of 10 usec
Writing |  ***failed;  
################################################## | 100% 0.04s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: input file 0x05 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: WARNING: invalid value for unused bits in fuse "efuse", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xfd instead of 0x05 (double check with your datasheet first).
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xDA"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDA:
avrdude: load data hfuse data from input file 0xDA:
avrdude: input file 0xDA contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude done.  Thank you.

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: Using SCK period of 10 usec
avrdude: reading input file "C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex"
avrdude: writing flash (32670 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 32670 bytes of flash written
avrdude: verifying flash memory against C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex:
avrdude: load data flash data from input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex:
avrdude: input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex contains 32670 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 32670 bytes of flash verified
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude done.  Thank you.
Title: Re: Trouble Burning Bootloader onto Pro Mini 5V 16MHz
Post by: macguyverwho on Jun 11, 2018, 04:49 am
So I read your project idea and I cant help with your issue however I have done something very similar using 2 uno's, fadecandy and the processing software for fadecandy. The car part was the easy bit (25 years MECP mast BUT noob to MCU's. Anywho, Heise makes 12v ws2811s now and a controller with user programmable patterns via SD card. I'd just as soon hack the remote it comes with than go thru all that again. Ive spent 3 days off/on trying to sort out avrdude: initialization failed rc=-1 for a gimbal controller and i coulda amazon'd a new one. Sometimes its just easier to hack something but oh the satisfaction.... Hope your T.Lights go well!
Title: Re: Trouble Burning Bootloader onto Pro Mini 5V 16MHz
Post by: pert on Jun 11, 2018, 08:10 am
So clicking "Burn Bootloader" results in about 5 seconds of the IDE working on it then just completing without any errors. Maybe I'm unclear on this, but shouldn't the Pro Mini boot up immediately if this worked correctly? It still takes 2 seconds as I said in my last message.
There is a delay in the bootloader on startup where it's waiting for an upload. If you want a shorter delay then you can install the more modern Optiboot bootloader instead of the outdated and buggy bootloader used on the Pro Mini:

After that you have to remember to always select Tools > Board > Arduino/Genuino Uno when you use your Pro Mini. You can't select Tools > Board > Arduino Pro Mini any more after that because of the different bootloader.

If you don't want any delay at all then you need to remove the bootloader by doing a Sketch > Upload Using Programmer. Remember that without the bootloader you can't upload over your FTDI breakout anymore and so you will always need to Upload Using Programmer. Now I remember you said this:
Now here's
I have tried uploading the sketch using the programmer but the sketch still takes about 2 seconds to run after the arduino gets power.
After removing the bootloader if you still have a delay then there must be something else causing the delay. That could be something in your code. Try uploading this sketch:
Code: [Select]
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                       // wait for a second
}

With that sketch, you should see the onboard LED blinking fast immediately and continuously on startup.

If you still have a delay with that code then it could be a hardware problem. The ATmega328P microcontroller on your Pro Mini is configured to not start until it has a power supply of >2.7V. So if you had a circuit where there was a high power draw on startup it could cause a delay. Try running the Pro Mini alone with nothing connected to it or the power supply.
Title: Re: Trouble Burning Bootloader onto Pro Mini 5V 16MHz
Post by: tomk825 on Jun 12, 2018, 02:37 am
There is a delay in the bootloader on startup where it's waiting for an upload. If you want a shorter delay then you can install the more modern Optiboot bootloader instead of the outdated and buggy bootloader used on the Pro Mini:
  • Tools > Board > Arduino/Genuino Uno
  • Tools > Burn Bootloader

After that you have to remember to always select Tools > Board > Arduino/Genuino Uno when you use your Pro Mini. You can't select Tools > Board > Arduino Pro Mini any more after that because of the different bootloader.

If you don't want any delay at all then you need to remove the bootloader by doing a Sketch > Upload Using Programmer. Remember that without the bootloader you can't upload over your FTDI breakout anymore and so you will always need to Upload Using Programmer.
Thanks again, Pert! Both of the methods you have suggested result in the Pro Mini booting up and starting the code quickly. The project runs perfectly fine but only when it is powered by USB. When I power it by battery or my car's turn signal wire, it seems that the Pro Mini does not allow enough current to illuminate the strip and instead freezes the code halfway through. When I change the code to use only a few LEDs for the turn signal (any amount of LEDs under 6), it runs OK. I looked at the specs on the Pro Mini and found that it allows far more current when it is powered by USB than when it is powered externally. My next question is: is there some way I can trick the Pro Mini into thinking it's being powered by the USB?  I tried Googling with no luck so I guess I will make another post elsewhere so that this thread stays relevant to the OP.

Heise makes 12v ws2811s now and a controller with user programmable patterns via SD card.
Thanks for the suggestion! I tried Googling that but could only find the LED strip (not the controller). Do you have a link for the LED strip/controller combo? That strip only has 67 LEDs/meter relative to the 144 on mine, but I'll still keep that idea as a backup plan if I can't get my project to work using a Pro Mini. My project does work flawlessly with an Uno but I want it to be cheaper/smaller.
Title: Re: Trouble Burning Bootloader onto Pro Mini 5V 16MHz
Post by: pert on Jun 12, 2018, 04:00 am
is there some way I can trick the Pro Mini into thinking it's being powered by the USB?
The reason you have more current when powered via USB is because you're powering the Pro Mini directly from a 5 V source and thus are not using the voltage regulator. If you instead power the Pro Mini at  a higher voltage then you must connect it to the Vin pin, where it goes through a 5 V regulator. This tiny voltage regulator is the cause of the current limitation. So the solution is to simply power the LEDs from a higher current source. You can get switching DC-DC step down modules for this purpose.
Title: Re: Trouble Burning Bootloader onto Pro Mini 5V 16MHz
Post by: tomk825 on Jun 14, 2018, 09:24 am
The reason you have more current when powered via USB is because you're powering the Pro Mini directly from a 5 V source and thus are not using the voltage regulator. If you instead power the Pro Mini at  a higher voltage then you must connect it to the Vin pin, where it goes through a 5 V regulator. This tiny voltage regulator is the cause of the current limitation. So the solution is to simply power the LEDs from a higher current source. You can get switching DC-DC step down modules for this purpose.
I bought a LM 7805 voltage regulator that takes the 12V turn signal as an input and outputs a 5V signal to power the Pro Mini in the VCC pin. All LEDs light up super bright now and the Arduino is still booting up very quickly. Electrical and programming parts are complete. Now it's just time to make the project weatherproof.

Thanks again for your help!