Author Topic: Is there any way to remove the 5 seconds programming delay at powerup ?  (Read 99434 times)

DeuxVis

  • Full Member
  • ***
  • Posts: 107
I understand that delay is here to allow uploading of its executable code to the digispark, but I have an use in mind which would require a digispark to "start working" as soon as it is powered up.

Is there any existing way to skip that pause (by pulling a pin down or low, etc) or do I need to go tinker with the bootloader to achieve that ?

Thanks for your attention.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #1 on: February 07, 2013, 01:20:39 pm »
You'd have to remove or change the bootloader for that - which means you'll need to use a HVSP programmer since the reset pin is disabled - we'll hopefully have a chance to provide some tutorials on how to do this, but to be honest we have a long list before we get to that

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #2 on: February 07, 2013, 03:02:37 pm »
... you don't need a high voltage serial programmer to update the bootloader. the micronucleus upgrader tool can do this just fine.


@DeuxVis: If you let me know what you have in mind for how you'd like to signal to your digispark that it should skip bootloader, I can generate a version of the bootloader which does that and explain how to do the mod without needing any special tools. Keep in mind that replacing your bootloader is unsupported by digistump, so if something goes wrong you can't go to them for help, but I am quite confident in the upgrade mechanism and would do some testing on my end first.


Depending on your application, you might like the bootloader to pull a certain pin high then check if it's low, so you could hook a button up to it which you can hold down while plugging it in to enable programming mode. I'd probably push the duration up from 5 seconds to 10 seconds or even disable the timeout entirely.

semicolo

  • Full Member
  • ***
  • Posts: 137
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #3 on: February 07, 2013, 05:58:47 pm »
Could we use a standard avrisp (or an arduino with the arduino-isp sketch) to restor the bootloader if something goes wrong?

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #4 on: February 07, 2013, 06:24:08 pm »
No, you need a high voltage serial programmer, or you'd need to make the attiny fuse resetter: https://sites.google.com/site/wayneholder/attiny-fuse-reset You'll need a 12v battery or DC power supply to run this project. The voltage level needs to be between 11.5 and 12.5v.



The digispark comes with the reset pin disabled so you get six pins to play with in your programs instead of five, which is why an ISP cannot be used to reprogram a digispark (unless treated with fuse resetter first). Once you're done replacing your bootloader, you can use the ISP to restore the fuses and regain use of the reset pin.


That said, I would never recommend someone install an upgrader program which I haven't tested myself on a digispark and found to work. I have a collection of handmade digispark-equivilents with reset pin enabled which I use to test upgrader programs work correctly so that I can easily restore them to previous bootloader versions and quickly test different combinations. These digispark-analogues have an ISP attached so I can also dump the firmware and check everything uploaded correctly. I'm confident in my upgrader program - I've never observed it fail to work. The main issue it can have is if people upgrade the bootloader to a version which doesn't work well with their computer, but I think version 1.05 solves this reliability problem and still gives you an extra 66 bytes of program space (though you need to mod the digispark arduino program slightly to be able to use it - just changing a number in a text file)


So in summary, I don't expect you to need any sort of programmer tool to upgrade micronucleus from one version to another, or even to change the bootloader to a different type, like a serial bootloader.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #5 on: February 07, 2013, 07:20:41 pm »
@Bluebie - is 1.05 compatible with the upload tool we are shipping with the Digispark arduino package? We're down to 50 pre-orders to ship and almost done packing some huge wholesale orders - after that I am very eager to test the upgrader as well, and while I'm not sure we'll ever remove the "If you brick it we won't replace it" warning -  I don't know any company would, I'd certainly like to add to the wiki how to upgrade and actively encourage it for those who want to.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #6 on: February 07, 2013, 09:26:21 pm »
Yep 1.05 works fine with the upload tool in your Arduino software. The commandline tool was mostly tested with 1.04 and the 1.02 support is actually through a version-specific bug workaround. If you find 1.05 reliable I think it'd be a better version to ship with in the future- less bugs, a little more program space, cleaner spec-compliant programming protocol.

DeuxVis

  • Full Member
  • ***
  • Posts: 107
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #7 on: February 08, 2013, 12:57:10 am »
First, thank you all for the informative replys.


Bluebie, your idea seems fine, a pushbutton - or a simple on/off switch on any unused pin would do.
It would be great if you can do that modified bootloader for me.

To clarify the need, I'm going to build a battery powered door bell. The digispark will generate some sound, and also control the power to the amplifiying circuit through a relay to spare battery life. So the door button would just send some power up to the digispark, which would then need to immediately start keeping that power on for some time - and start ringing too, a 5 seconds delay before a button push turns into a ring would be very effective to repel visitors.

So for pin choice, skipping anything pwm-able (wanna make noise) and I2C needed (in case I want to play samples out of some form of external memory in a future revision).
I'd say go for P5.

I understand the updater process is not digistump supported. I'm still ok with trying it - I bought 5 units just in case bricking happens. This is one of the nice thing with those cheap beasts : you can experiment and don't lose that much if you do errors.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #8 on: February 08, 2013, 01:56:32 am »
Alright. I'll setup a version of micronucleus 1.05 which enables pullup on pin 5 then checks if the pin is low, and if it is, enters bootloader. After I've tested it a few times I'll post again with details on how to do the brain surgery. :)

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #9 on: February 08, 2013, 03:04:25 am »
Alright, I've made this version of the micronucleus bootloader. It pulls D5 high, waits 10 milliseconds, checks if the pin is pulled low by a button or something, then if it is it enters bootloader, otherwise it immediately runs the user program. To program the digispark after installing this upgrade you can connect a jumper wire directly from D5 to the GND connection point on the spark before plugging it in. Keep in mind pressing a button attached to this wire will not reset the spark - you need to unplug it and plug it back in while holding the button down.


To replace the bootloader, right click, download linked file: https://raw.github.com/Bluebie/micronucleus-t85/DeuxVis-button-to-program/upgrade/releases/deuxvis-1.05-digispark-d5-progbutton.hex to somewhere on your computer. Next, you'll need to use the 'micronucleus' program to upload this hex file to your digispark. The micronucleus program is bundled in with the digispark arduino software. I'm not totally sure where to find the files specifically on linux or windows, but I have made a tutorial video for mac which will at least give a general idea. http://vimeo.com/57036841


Just be sure to ignore the stuff about downloading bits of littlewire, and when the video drags main.hex on to the terminal, instead drag on deuxvis-1.05-digispark-d5-progbutton.hex


If there's any sort of upload error, try it again, otherwise once it's succeeded start counting - after it's had ten seconds to process, unplug the digispark, connect pin5 to ground, plug it in, and see if you can upload a program using the digispark arduino software. If all went according to plan, it will take the upload happily. If it doesn't work, try a few more times (unplugging and replugging the digispark too) and it'll start working happily. :)


If you have any trouble or want any extra changes, do let me know ^_^ <3


Oh and if you want to revert to the old-style bootloader, I whole heartedly endorse uploading this hex file: https://github.com/Bluebie/micronucleus-t85/blob/master/upgrade/releases/micronucleus-1.05-upgrade.hex - it has the usual five second timeout mechanism. I've upgraded one of my own regular digisparks via the deuxvis button upgrader linked before and then this regular 1.05 version and both upgrades (crossgrades really..) worked fine, so you shouldn't have any trouble reverting your digispark to the normal functionality ^_^

DeuxVis

  • Full Member
  • ***
  • Posts: 107
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #10 on: February 08, 2013, 06:45:13 am »
Thanks a lot Bluebie, will try that later tonight when back from work.

DeuxVis

  • Full Member
  • ***
  • Posts: 107
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #11 on: February 08, 2013, 11:19:17 am »
Works !

Uploading new bootloader : check (after a couple of aborted micronucleus runs)
Uploading new code with P5 grounded : check
Immediately running when P5 is not grounded : check
Learning you can drag a file onto a terminal to copy-paste its path : check ;)

Thanks a lot Bluebie. Dunno how I can express you my gratitude, if you ever need some custom made plastic parts for a project, my 3D printer is yours.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #12 on: February 08, 2013, 03:13:26 pm »
Wow that's awesome! I'll probably take you up on that some time! <3 ^_^

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #13 on: February 09, 2013, 07:19:09 pm »
Bluebie
Thanks for the new bootloader, it works great.

For windows, here is a how to do it:-

Firstly make sure your device is recognised by Windows, and that you have a means of connecting P5 to GND (ie ...fit the header)

Download the file https://raw.github.com/Bluebie/micronucleus-t85/DeuxVis-button-to-program/upgrade/releases/deuxvis-1.05-digispark-d5-progbutton.hex and save it in a known place on your computer.

  Open a Command Prompt (Start. All programs. Accessories ...for Win7)
  Open File Explorer ( right click on Start select Open Windows Explorer) and navigate to the directory you unzipped Digispark IDE in.
  Locate the zip file micronucleus-t85-master.zip and right click, select Extract All.
  Navigate to the micronucleus.exe file  (...\micronucleus-t85-master\micronucleus-t85-master\commandline\builds\Windows )
  Drag it onto the Command Prompt window and press space.
  Navigate back to where you saved the .hex file above, and drag that onto the Command Prompt window
    (At this stage you'll have a really long string that shows the path and name of the .exe with space and then the path and name of the hex file.)
  Press enter and it should ask you to plug the device in.

  Plug it in, and it should start.
  Don't worry about the messages as long as the last one is ..
writing: 100% complete
 >> Micronucleus done. Thank you!


As Jenna said
Quote
- after it's had ten seconds to process, unplug the digispark, connect pin5 to ground, plug it in, and see if you can upload a program using the digispark arduino software.

Cheers
Mark
« Last Edit: March 09, 2013, 12:44:54 pm by Mark »

bboyes

  • Newbie
  • *
  • Posts: 7
Re: Is there any way to remove the 5 seconds programming delay at powerup ?
« Reply #14 on: February 10, 2013, 11:00:02 am »
Wow, thanks to you all for making this mod - I had wondered the same thing, nice to know it is an option now. I have a similar idea for some off the grid lighting where the 'on' switch would first power up the 'spark and then it would turn on the lights, so a faster startup would be essential there too.