danieljon.es

index posts opinions portfolio

Posts

My posts about programming and things.
Date format is day/month/year because I'm sane.

Micro USB Digispark Pro issues and how I solved them

26/4/2016

EDIT: It seems communication via USB is possible via this library. I am as happy as ever!
EDIT: I shorted the board and it is dead, I give up on electronics.

Today I received a recent, off-the-whim Ebay purchase - a Digispark Pro microprocessor. The product was cheap and to be honest I kind of expected it to be a fake/remake (and to be honest I can't tell if it is). The one I purchased can be found here.
Like with everything in life I did zero research and happily accepted what the listing described to me - what a stupid mistake. I won't go into why it isn't what I expected, however, I can happily say THIS BOARD DOES NOT SUPPORT SERIAL COMMUNICATION! Be warned, don't learn the hard way and waste five dollars. (I bought this product for serial communication in a project, that to me is hilarious)
For once, however this post isn't about bitching, instead, it is how I managed to get code uploaded to this board via the Arduino IDE on a Linux system.
I am running a 64bit Arch Linux installation - this shouldn't really matter, however. If your problem is with Windows, I can't help you.

The first issue I encountered and the solution I found:
I can't find the board in the serial port list and dmesg gives me an output simmilar to this:
[369166.755711] usb 2-1.8: device not accepting address 87, error -32
[369166.755890] usb 2-1-port8: unable to enumerate USB device

When I encountered this error I had tried many things including changing USB port, micro USB cable and using another Linux system the result however, on each attempt was the same. It just didn't seem like it was working.
Now, the answer to this is not simple, and I won't be explaining it, but let it be known, this device does not appear as a standard ttyUSB device when in use. So, how do you upload code? Well, for five seconds upon initial USB connection your computer and thus the program used to upload code (more on this soon) can communicate with the board for a short ammount of time. I have found supposed libraries that allow you to communicate with the board via serial during use, however I have not tested nor used them and can't give an opinion on the subject. (see this for more information)
So, how do I fix the errors? You don't, I guess, it is supposed to do that, and even now, once I managed to get code running on the boad, the same errors occur. (probably due to this board not being meant to be connected via USB for anything more than code upload)

Great, we now know that we are not meant to see this board in our serial list and that dmesg errors are normal, but how do I upload code to the board?
Be warned, the fun starts now and I suggest you have some command line knowledge before continuing.
Now, the first thing that needs to be done is to set your Arduino IDE up to use the Digistump package that includes the piece of software that is the centre of this post, micronucleus.
You must at this point follow the tutorial here in its entirety!
If, after you follow the tutorial linked above you are able to upload code to your board without a hitch, great! You don't need to read on, go enjoy your new microprocessor.
however, if at this point the Arduino IDE spits out the following:
Warning: device with unknown new version of Micronucleus detected.
This tool doesn't know how to upload to this new device. Updates may be available.
Device reports version as: 2.2

You have a little work to do yet! But don't fret, the solution is simple.
It seems the version of the Micronucleus bootloader on Digispark boards (in my case at least) is newer than what comes with the Arduino software you installed earlier in this tutorial. To fix this issue, we just need to replace it with a newer version!
I'm going to go through the steps assuming you know what the commands do, if not, why are you playing with a microcontrller on Linux anyway?
First, we will make a directory in which we will install and compile the newer version of Micronucleus.
mkdir ~/compiled
mkdir ~/compiled/micronucleus

Next we will clone the Github repository of the project. I assume you have Git installed, if not, Google is your friend.
cd ~/compiled/micronucleus
git clone https://github.com/micronucleus/micronucleus/
Next we will compile the code into a binary that will replace the version in use now. I also assume you have development libraries installed.
cd ~/compiled/micronucleus/micronucleus-master/commandline/ make
Now the new version of Micronucleus is compiled and ready to be switched with the current version in use by the Arduino IDE. (your directory structure may differ sightly)
#backup the old micronucleus binary just in case we need it later
mv ~/.arduino15/packages/digistump/tools/micronucleus/2.0a4/micronucleus ~/.arduino15/packages/digistump/tools/micronucleus/2.0a4/micronucleus_old
#copy our new compiled binary to replace the one we just backed up
cp ~/compiled/micronucleus/micronucleus-master/commandline/micronucleus ~/.arduino15/packages/digistump/tools/micronucleus/2.0a4/micronucleus
Now that an up to date version of Micronucleus is installed you should now be able to upload code to your Digispark microcontroller - well, I could at least!
At this point I shall also warn you that I only managed to get Micronucleus running correctly if I opened the Arduino IDE as root, now, I suspect there is a solution for that out there, but I am yet to come accross it.
My experience using the Digispark pro microcontroller spans over a few hours as I received the product earlier today, but I have learnt a lot, and can hopefully help someone else one day.



RSS feed
FSF member

page generated 10/4/2023 using websitegenerator in C