loading

After I got my DigiSparkclone, which I ordered on ebay. (remember the rev3 board that they never created? Well, I got that one from a Chinese seller), I realized something very interesting - pin 5 was still a reset pin. The fuse that makes this pin a usable GPIO pin was not set as on the genuine DigiSpark. Since my DigiSpark was having only 6012 bytes of memory I realized I could upgrade it easilly to the latest micronucleus 2.2 (or 2.02? whatever...). There's a version called t85_aggressive in this update, and it's 702 bytes smaller than the original bootloader that comes with my DigiSpark (v1.6). If I upgrade it I'll have 6714 bytes of available space! That's hell of a lot more memory, so why not? :D

This same instructable can be used to prepare raw attiny85 microchips for further usage as DigiSpark clones, and Adafruit Trinkets. You can apply it on a genuine DigiSpark, but you'll need to use Fuse Resetter to re-enable the Reset pin (which can be done with another DigiSpark!). The Trinkets already have it.

This can be done using any commercial ISP, but I decided to go cheap and used my Banana Pi to do the job. Yes, you can use your Raspberry Pi.

The setup is real simple. All you need is wiringPi and avrdude, both can be optained in a few simple commands, and I believe you already have wiringPi installed.

You can easilly obtain wiringPi for Raspberry Pi here, and the BananaPi version is available here.

avrdude can be obtained with apt-get

$ sudo apt-get install avrdude

And you'll need the hex file with the new bootloader...

$ wget https://raw.githubusercontent.com/micronucleus/micronucleus/master/firmware/releases/t85_aggressive.hex

We'll set up avrdude to use the GPIO pins of your SomethingPi in the next step...

And before you start throwing rocks and dirt at me: I do respect Digispark, Raspberry Pi, BananaPi and Adafruit, for all the work they've done bringing this technology closer to us. I recommend buying and using their original products as the right way to support them!

Step 1: Avrdude Setup

We'll edit /etc/avrdude.conf, or rather copy it and do the modifications there.

$ cp /etc/avrdude.conf ~/avrdude.conf

All you need to edit is uncomment the lines used for the "linuxgpio" programmer...

$ nano avrdude.conf

Type CTRL+W to enter the search mode of nano, type gpio, press enter, you'll scroll to the GPIO part, which you should modify it to look something like this.

programmer
id = "linuxgpio"; desc = "Use the Linux sysfs interface to bitbang GPIO lines"; type = "linuxgpio"; reset = 17; sck = 18; mosi = 23; miso = 24; ;

Saving by pressing CTRL + O, enter, then CTRL + X to exit nano.

I'm using these pins because they are right next to each other...

GPIO = Physical pin = Digispark Pin

17 = 11 = p5

18 = 12 = p2

23 = 16 = p0

24 = 18 = p1

Connect the GND and VIN of the digispark to the ground and 5V of the Banana/Raspberry Pi, too.

Almost there... :)

Step 2: Flashing

We go that that part where everything is connected and ready to go...

First of all, let's double check those fuses and make sure they match the fuses declared on digistump.com

low_fuses=0xE1
high_fuses=0xDD
extended_fuses=0xFE

We can check if everything is working by typing

$ avrdude -p attiny85 -C avrdude.conf -c linuxgpio -v 

And if that gives us information about the fuses and the chip, we'll proceed with setting the right fuses...

$ avrdude -p attiny85 -C avrdude.conf -c linuxgpio -v -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m -U efuse:w:0xfe:m

This command will NOT disable the reset function on the DigiSpark.

The one bellow however, will! And don't use it just yet. You can use it at the very end, but you'll need HVSP programmer to re-enabe the reset function for future upgrades of the bootloader. On the other hand, you'll be able to use it as an SPI programmer using Little Wire...

$ avrdude -p attiny85 -C avrdude.conf -c linuxgpio -v -U lfuse:w:0xe1:m -U hfuse:w:0x5d:m -U efuse:w:0xfe:m

To upgrade the bootloader all we need to do is...

$ avrdude -p attiny85 -C avrdude.conf -c linuxgpio -v -U flash:w:t85_aggressive.hex

Now, we just need to update our Board definitions in the Arduino IDE so that we can actually use these free bytes we just got.

All you need to do is modify boards.txt, which in my case is located under

C:\Users\Crypter\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.5\boards.txt

All you need to do is copy the existing entries for your DigiSpark (all that are related to DigiSpark, not DigiSpark Pro), give them some new name, like

digispark-tinyU.name=Digispark (Upgraded - 16.5mhz)

and change the beginnings on every line from "digispark-tiny" to something else, I just added U for upgrade. You can already notice they are a little bit different for every "board".

and change the max size a from 6012 to 6714 on each.

From now on, you'll use these entries when uploading to your upgraded DigiSpark.

Now if you want you can use those fuse bits to disable the reset function and make use of pin 5 for real. Once you do that, you'll no longer be able to use this method to upgrade your bootloader, at lease not with this hex file.

You can however downgrade it to your original micronucleus v1.6 using the following file.

https://raw.githubusercontent.com/micronucleus/micronucleus/v1.11/upgrade/releases/micronucleus-1.06-upgrade.hex

All you need to do is upload it using micronucleus.exe in windows terminal like a regular upload.

micronucleus.exe C:/Location/To/micronucleus-1.06-upgrade.hex
<p>Change title to reflect using a raspberry pi</p>
Thank you for a very interesting project. <br><br>Among other things, your notes take me back to my early days of computer programming (early 1970s) when we had to be very aware of the number of bytes used. Given two programs that accomplished the same objective, the one that used fewer bytes was considered more efficient and &quot;better&quot;. A long way from current PC programs taking megabytes of memory and storage!
<p>These days software is written with consideration that you have unlimited resources available, both storage and memory (and computing power), just so that everything is &quot;faster&quot; and &quot;better&quot;. People don't understand how efficient code can be if they change very little in it. One byte is always better than multiple booleans, and in reality the memory required for a byte is the same one for a single boolean... It always pays off in the long run to sacrifice a little bit of code readability for this.</p>

About This Instructable

4,135views

32favorites

License:

More by Crypter:Refresh your DigiSpark (clone) with a smaller bootloader Repair a broken TV Remote battery cover 
Add instructable to: