Electronic – run a program, on an ATtiny85 with micronucleus bootloader, without usb connected

attinybootloaderusb

I have managed to put micronucleus bootloader on an ATtiny85. Using it, I can successfully upload programs to my ATtiny through USB and they run as they should, as long as they are connected to USB. When I only connect the Tiny to +5V and GND, it does not run the program. How can I change that? How can I make it so that my programs run even without connecting the ATtiny85 to USB?

Best Answer

The bootloader should exit and run the user program after 6 seconds if USB is not connected. If that is too slow then you can recompile with a shorter delay, or set AUTO_EXIT_NO_USB_MS >1.

If the user program doesn't appear to be running after the timeout period then you probably have some other problem. Perhaps your program has a bug that stops it from working properly if the bootloader doesn't communicate with the USB port first (check for uninitialized variables, hardware registers not being set to defined states etc.).

Also, if the board is powered by the USB port when plugged into it then make sure that your external power supply is good enough to run it stand-alone.

(in bootloaderconfig.h)

/*
 * Define bootloader timeout value. 
 * 
 *  The bootloader will only time out if a user program was loaded.
 * 
 *  AUTO_EXIT_NO_USB_MS        The bootloader will exit after this delay if no USB is connected.
 *                             Set to 0 to disable
 *                             Adds ~6 bytes.
 *                             (This will wait for an USB SE0 reset from the host)
 *
 *  AUTO_EXIT_MS               The bootloader will exit after this delay if no USB communication
 *                             from the host tool was received.
 *                             Set to 0 to disable
 *  
 *  All values are approx. in milliseconds
 */

#define AUTO_EXIT_NO_USB_MS    0
#define AUTO_EXIT_MS           5000

 /*