Digistump Forums
The Digispark => Digispark (Original) Support => Topic started by: Julian on September 26, 2013, 02:40:31 am
-
Hi again,
After patching keyboard lib I would like to make some changes on micronucleus. The thing is I'm a novice in embedded sotware and I'm sure I'm gonna brick my device sooner or later.
So please, can you tell me a "easy programmer" to load the original bootloader inside Digispark even if a crashing bootloader is already in. I mean, any particular product or brand?
Thanks in advance,
Julian
-
You'd need a high voltage programmer, I think the AVR-dragon is the cheapest on the market.
-
Something like this would also work: http://www.ebay.com/itm/SLboat-AVR-HVSP-High-Voltage-Serial-Programming-Programer-for-ATtiny-seriel-/181217227729?pt=LH_DefaultDomain_0&hash=item2a316373d1 (http://www.ebay.com/itm/SLboat-AVR-HVSP-High-Voltage-Serial-Programming-Programer-for-ATtiny-seriel-/181217227729?pt=LH_DefaultDomain_0&hash=item2a316373d1)
You can also make your own HVSP with a Arduino or Digispark
See:
http://digistump.com/board/index.php?topic=1039.0 (http://digistump.com/board/index.php?topic=1039.0)
https://digistump.com/board/index.php?topic=901.0 (https://digistump.com/board/index.php?topic=901.0)
http://digistump.com/wiki/digispark/tutorials/programming (http://digistump.com/wiki/digispark/tutorials/programming)
-
you don't need the debugging features of the dragon, my bad.
-
I don't have a HVSP device. I just use a regular ISP programmer (a LittleWire in fact!) to make the bootloader. I test it on chips which don't have the reset pin disabled, and then when I'm confident it's working I load it in to a digispark using my 'upgrade' installer system (you can find it in the micronucleus site on github) to finally test that it's all working well before providing those .hex binaries to other people. So far I haven't bricked a digispark.
To use a regular ISP programmer you need either to build an attiny fuse resetter project, to convert one digispark so the d5 pin isn't usable in software, but it can be programmed via ISP device, or a blank attiny85 chip and the necessary components to connect it to a USB port (check out the LittleWire hardware circuit diagram for a good example of this circuit - often you can do without the zenner diodes too, depending on the computer you're plugging it in to)
Probably a HVSP device would be a good idea. I've never used one. They seem so big and complicated. I like tiny things ^_^
-
@semicolo @digistump
Thanks for your replies. Can you confirm if these are the steps to load the bootloader? I think I should:
1. Build the bootloader (output should be a .hex file)
2. Connect the programmer to my Digispark. I mean:
| P0 to SDI |
| P1 to SII |
| P2 to SD0 |
| P3 to SCI |
| P4 to (none) |
| P5 to Reset/Gnd* |
| |
| 5V to VCC |
| GND to Reset/Gnd* |
| VIN to (none) |
*In the HVSP programmer suggested by Digistump RST and GND are together. Is this Ok?
3. Connect the programmer to my computer via USB
4. Run some software tool that let me select the .hex file to load the bootloader.
@Bluebie
Thanks for your comment. By now I just have a Digispark and my PC. I read about your upgrader and if I understand it correctly its like a chainloader, like grub but persistent. It's a cool idea.
I plan to patch micronucleus to run "user code as soon as possible". I would like to use Digispark as a BIOS compatible keyboard. I suspect the 5s delay is interfering with the BIOS HID boot protocol implementation. The thing is the keyboard works if I connect it manually but do not work if I restart the PC with the device already connected. That's why I'm digging into restoring bricked Digiskpark.
-
No, upgrader isn't a chainloader as far as I understand them. The AVR memory is laid out as interrupt vector table, user program, then right at the end, bootloader. When the digispark starts up it starts at the reset vector which jumps to the bootloader at the end. The bootloader does some stuff and eventually jumps back to the user program so it can run. Upgrader works by uploading a program in to the user area like any other digispark upload, but inside that program is a copy of a new bootloader, and when it runs it first rewrites the interrupt vector table so in the future the chip just runs straight in to the upgrader program. Next, it erases and overwrites the existing bootloader at the end of progmem with the new version. Finally it rewrites the interrupt vector table to point to the new bootloader, and then makes a beeping sound if you have a speaker attached, and then jumps to reset, launching the new bootloader. To the user it looks like the upload the hex file, and about half a second later the bootloader comes back online but is a new version. It doesn't use any extra flash memory to use upgrader instead of a HVSP device or similar.
Also, it sounds like you might just want the jumper firmware! This has already been made! The jumper firmware gets rid of the few seconds delay on startup and instead sets d5 to be an input, turns on the internal pullup, waits about 10 milliseconds, then checks if d5 is high or low. If it is high, the bootloader jumps in to the user program a few instructions later. If it is low, it enters the bootloader without a timeout, and stays in the bootloader until the host computer tells it to run the user program at the end of an upload (using the --run option, which digispark arduino app does use). It is called jumper because the typical use is either a button or a wire you connect from d5 to ground, and you connect it before plugging in the device only when you want to do a software update. If your project already needs a button for something, connect it through d5 (that pin isn't useful for much else anyway) and you get the feature for free pretty much!
There's more information on the jumper bootloader at http://digistump.com/board/index.php/topic,320.0.html and you can grab the latest version of -jumper from https://github.com/Bluebie/micronucleus-t85/tree/master/upgrade/releases - grab the 1.06-jumper-v2 release. If by the time you read this there are versions numbered higher than 1.06 you should probably use those instead!
-
Hi Bluebie,
Thanks for your comments! You are right, with the command line utility and the jumper bootloader I'm able to run user code without delay. Thanks for sharing!
Unfortunately I still have original problem: my "digispark keyboard" doesnt work with BIOS unless if I connect it manually. :'(
Any idea is appreciated!
-
@Julian - new software release within the next week will feature a DigiKeyboard library that is boot compatible and can report keyboard LED status
-
@digistump
Thanks, where I can find the release? I dont see it here: http://digistump.com/wiki/digispark/tutorials/connecting
Regards,
Julian