Using and reviving Digispark clones
I have a big collection of microprocessors and boards I don’t use, and for some reason I keep adding more to the list. This article is about getting a Digispark clone to work, since I keep having to investigate the same topic every time I want to use it.
I’ll try to keep it short. The basic steps are:
- Upgrading the bootloader
- Installing the Arduino extension
- Upgrading micronucleus binaries in the extension
If you own digispark clone, you know that one way or the other you will end up needing to upgrade the Micronucleus bootloader. This not only gives you more room to play with, but also adds much needed stability.
The easiest way is to upgrade it through micronucleus itself. Download the upgrade file from here https://github.com/micronucleus/micronucleus/tree/master/upgrade/releases and then upgrade with:
micronucleus --run upgrade-t85_default.hex
(Source: https://www.iot-experiments.com/micronucleus-bootloader-upgrade/ )
But if you are like me, then you will probably have issues doing that, the app will freeze, and the bootloader would be incorrectly burnt. Don’t worry, there is always the option to do it over ISP or as a last resource: High Voltage Programming.
I will leave the ISP steps mostly so I can remember them in the future
As you can see the connection to your ISP is pretty straight forward. After that just use avrdude to burn the new bootloader hex file, from the Micronucleus github page ( https://github.com/micronucleus/micronucleus/tree/master/firmware/releases ). Here is the sample command line to use an AVR MK II ISP.
avrdude -pattiny85 -cavrispmkII -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m -U efuse:w:0xfe:m -U flash:w:micronucleus/firmware/releases/t85_default.hex -e -v
In order to use the Arduino IDE, you need to add the board from here:
After the installation you will be able to select Digispark (Default - 16,5mhz) but there is still one missing piece. The boards you just installed come with a VERY old Micronucleus binary, so uploading things can become a nightmare.
The solution is to manually compile Micronucleus from here https://github.com/micronucleus/micronucleus
Compile the commandline if you are on linux, or go to builds/Windows to find the pre-compiled binary, then copy it over the old binary: ./.arduino15/packages/digistump/tools/micronucleus/2.0a4/micronucleus
After that you will be able to upload a blink test. Just remember that the LED is in port number 1 (in case you have to manually define it in your code).
Good luck!
Final notes:
- *_aggressive.hex bootloader binaries are smaller, but there is a high chance of bricking the device on flash failure. You will have to manually flash the bootloader again when it happens. It did happen to me several times, so I recommend you stick with *_default.hex binaries, either upgrade or manual flashing.
- I don’t recommend disabling the RESET at all as the official Digispark page recommends. This comes in handy when you brick the device so you can avoid High Voltage Programming.
- You can still use PB5 pin as a push button even when you don’t disable the reset functionality. You just use it as an analog input and make sure you never go below the RESET voltage by using a few resistors. Here is project I wrote that uses it like this. Check the schematics and the code: LP spinner for ultrasonic cleaners download | SourceForge.net