Author Topic: Bootloader?  (Read 3368 times)

benjie

  • Newbie
  • *
  • Posts: 10
Bootloader?
« on: December 06, 2012, 12:37:02 am »
I'm curious whether the Digispark bootloader will have a boot delay before it runs our code.  On my other arduino boards, I use the Adaboot modified bootloader to start up my code immediately.  It only delays to check for upload of new firmware on a reset, not a cold boot.  I'm hoping that we can do something similar on the digisparks!
« Last Edit: December 06, 2012, 12:37:02 am by benjie »

benjie

  • Newbie
  • *
  • Posts: 10
Bootloader?
« Reply #1 on: December 06, 2012, 12:51:00 am »
Or alternately, if modifying the bootloader to remove the delay is not an option, will it be possible to program the digispark with an AVR programmer and skip the bootloader altogether?

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Bootloader?
« Reply #2 on: December 06, 2012, 01:02:40 pm »
benjie - there is no reset pin (since we are using it for i/o) so the bootloader does have a delay built in (5 seconds). I suspect there will be updates to shorten that fairly soon.

As far as direct programming, this is certainly possible, but due to the reset pin being disabled you\'ll need a few tricks to enable it so you can program again - we\'ll include some simple ways to accomplish that with a breadboard, PNP transistor or relay, another Digispark or Arduino and and a 12v supply and we\'ll be releasing a special shield to do it as well.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Bootloader?
« Reply #3 on: December 11, 2012, 04:25:17 pm »
If you\'re connecting the digispark over USB and interfacing it with a program, you can ask the bootloader to run the program immediately just that one time, so then the delay is just however long the operating system takes to enumerate the device. Roughly half a second. If you\'re writing a program in C you can use micronucleus lib to control the bootloader, including causing it to run the program: https://github.com/Bluebie/micronucleus-t85/tree/master/commandline - there\'s also some code written in ruby to do the same thing.

There is some opportunity to experiment with detecting the USB SOF pulses, so the bootloader could exit after 100ms or so when powered on if it isn\'t connected to a computer\'s usb port which isn\'t asleep - i.e. usb chargers or power connected via the pins on the digispark. I haven\'t tested this theory so maybe it wouldn\'t work.

It\'s also possible to remove the bootloader if you\'re sure you wont want to reprogram the digispark or have access to a high voltage serial programmer to restore the bootloader later when needed. All it would take is rewriting the first 6 bytes of flash memory. It takes a bit of care, but it\'s not too difficult. If you don\'t need the first four interrupts you can just write it all to 0\'s and then it\'s downright trivial.