Go Down

Topic: Raspberry Pi+Arduino IDE+Digispark=??? (Read 2044 times) previous topic - next topic

redcom001

I just got myself the ATTiny85 micro USB Digispark, and I've been trying to set up my Pi 3 to program it from the Arduino IDE (1.8.1), but when I try installing the Digistump AVR package, I get an error saying @tool Micronucleus is not available for your operating system. I'm running the latest Jessie image. So far, I got Micronucleus running as a separate program on the Pi. I really would rather do all my work with the Pi. Has anyone gotten one of these setups running? I've been at this for over 2 weeks to no avail. I'll provide more info if needed.

pert

I made a modified version of the digistump JSON file that should allow you to install the package via Boards Manager. This installs all the exact same files from the same locations as the official package but I have added an ARM Linux entry for the micronucleus tool. This is actually the 32 bit Linux tool so you will most likely need to replace the installed micronucleus tool with the Pi compatible version you have already. If you can point me to the location where the Pi compatible micronucleus is available I may be able to modify the JSON file so replacing the tool is not necessary and this might be useful to others who also want to install the package on their Pi.

In File > Preferences > Additional Boards Manager URLs replace the standard URL with:
Code: [Select]
https://gist.github.com/per1234/429d6e680ccdf6da6a27a7d0f722113e/raw/a6c1bf4dd28d7d52b96f19751b9280a3cd82b73f/package_per1234_digistump_armlinux_index.json

Tools > Board > Boards Manager

Wait for downloads to complete

Select Digistump AVR Boards (modified to allow installation on ARM Linux)

Click "Install"

Wait for installation to complete

Click "Close"

You will see a warning:
Quote
Warning: non trusted contribution, skipping script execution (C:\Users\per\AppData\Local\Arduino15\packages\digistump\tools\micronucleus\2.0a4\post_install.bat)
but you will get the same warning with the official JSON file.


Now you will need to find the location of the Micronucleus tool so you can replace it. The easiest way to find where it was installed is this:
  • Tools > Board > Select any digispark board
  • File > Examples > Digispark_Examples > _9DOF_Shield
  • Sketch > Show Sketch Folder


This will open .../.arduino15/packages/digistump/hardware/avr/1.6.7/libraries/Digispark_Examples/_9DOF_Shield. Micronucleus is located at .../.arduino15/packages/digistump/tools/micronucleus. When you replace the tool files with the Pi compatible version you must be careful to leave the folder structure the same.


redcom001

If you can point me to the location where the Pi compatible micronucleus is available I may be able to modify the JSON file so replacing the tool is not necessary and this might be useful to others who also want to install the package on their Pi.
Thanks man, you're a lifesaver. I'm actually using the 32 bit Linux micronucleus (2.0a4), I'm not sure if there are any ARM versions of it out there, but my Google-fu is weak. I did have it able to run from the command line.

redcom001

New problem, any sketch will compile, but I get an upload error saying-

Code: [Select]
Arduino: 1.8.1 (Linux), Board: "Digispark (Default - 16.5mhz)"

WARNING: Category '' in library EEPROM is not valid. Setting to 'Uncategorized'
Sketch uses 302 bytes (5%) of program storage space. Maximum is 6012 bytes.
Global variables use 9 bytes of dynamic memory.
An error occurred while uploading the sketch
/home/pi/.arduino15/packages/digistump/tools/micronucleus/2.0a4/launcher: 1: /home/pi/.arduino15/packages/digistump/tools/micronucleus/2.0a4/launcher: Syntax error: word unexpected (expecting ")")

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

pert

Thanks man, you're a lifesaver. I'm actually using the 32 bit Linux micronucleus (2.0a4), I'm not sure if there are any ARM versions of it out there, but my Google-fu is weak. I did have it able to run from the command line.
Cool! That certainly makes things easier. I don't know anything about Raspberry Pi compatibility but I do know my way around a Boards Manager JSON file.

Code: [Select]

An error occurred while uploading the sketch
/home/pi/.arduino15/packages/digistump/tools/micronucleus/2.0a4/launcher: 1: /home/pi/.arduino15/packages/digistump/tools/micronucleus/2.0a4/launcher: Syntax error: word unexpected (expecting ")")

Please do this:
  • File > Preferences > Show Verbose Output during > upload (check) > OK
  • Sketch > Upload
  • After the upload fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • Paste the error messages in a reply here.

redcom001

Verbose output says the exact same thing.

redcom001

#6
Mar 11, 2017, 05:43 pm Last Edit: Mar 11, 2017, 05:48 pm by redcom001
OK, I messed around with the platform.txt file under /home/pi/.arduino15/packages/digistump/hardware/avr/1.6.7 to the following-
Code: [Select]

# AVR Uploader/Programmers tools
# ------------------------------

#tools.micronucleus.cmd.path={runtime.ide.path}/hardware/digistump/avr/tools/avrdude
tools.micronucleus.cmd.path.linux={runtime.tools.micronucleus.path}/micronucleus
#tools.micronucleus.cmd.path={runtime.tools.micronucleus.path}/micronucleus

tools.micronucleus.upload.params.verbose=true
tools.micronucleus.upload.params.quiet=
#tools.micronucleus.upload.pattern="{cmd.path}" --run --timeout 60 "{build.path}/{build.project_name}.hex"
tools.micronucleus.upload.pattern="{cmd.path}" -cdigispark --timeout 60 -Uflash:w:{build.path}/{build.project_name}.hex:i


Which definitely seemed to do something. Now when I attempt to upload, the filepath to micronucleus shows up, does nothing for about 20 seconds, then spits out the following-

Code: [Select]

Global variables use 9 bytes of dynamic memory.
/home/pi/.arduino15/packages/digistump/tools/micronucleus/2.0a4/micronucleus -cdigispark --timeout 60 -Uflash:w:/tmp/arduino_build_556916/sketch_mar11a.ino.hex:i
> Please plug in the device ...
> Press CTRL+C to terminate the program.
> Device search timed out
An error occurred while uploading the sketch


Think I'm getting closer to finally getting this thing operational?

Also, when I try running ./micronucleus -help from the command line, it waits for the device to be plugged in, but when I do, it never registers. lsusb doesn't turn it up either.

pert

Verbose output says the exact same thing.
That's unfortunate. I'd expect verbose output to show the actual command that was causing the error instead of only showing the error.

If I do an upload on my Windows computer it doesn't have any error running launcher and seems to successfully start the upload but I don't own a Digispark board so I don't know if it would complete. At least on Windows the package is intended to run post_install.bat, which runs install.exe but the Arduino IDE prevents this from happening because it's a 3rd party package. I'd guess this is to install drivers. Since it's a .bat file I guess this is intended for Windows only?

I see there is a Micronucleus programmer option. Do you have that selected in the Tools > Programmer menu? Not sure if it matters. I'm pretty much just grasping at straws here because I have no experience with the Digispark, other than submitting a couple pull requests to the repository. Maybe you can get some help on their forum if all else fails. Please do keep me posted as to how things work. If the JSON file ends up being helpful I'll leave it up and maybe even move it to a repository so the URL isn't so messy but I want to be sure there aren't any changes that must be made to get the thing to work properly.

odroid

#8
Mar 29, 2017, 11:31 am Last Edit: Mar 29, 2017, 12:38 pm by odroid
I also had the same issue and I found what's wrong.

Two executable files "launcher" and "micronucleus" were built for x86 32bit platforms.
So I had to build them on my ARM board with following steps.
Code: [Select]
sudo apt install git                                 
git clone https://github.com/micronucleus/micronucleus                     
cd micronucleus/commandline/
sudo apt install libusb-dev
make
cp micronucleus ~/.arduino15/packages/digistump/tools/micronucleus/2.0a4

sudo cp 49-micronucleus.rules /etc/udev/rules.d/. 

git clone https://github.com/digistump/avr-dummy
cd avr-dummy
make
cp avrdude ~/.arduino15/packages/digistump/tools/micronucleus/2.0a4/launcher


Now I can upload my sketch file to Digispark board from my ARM board (ODROID-XU4).
I'm using the latest 1.8.2 Linux ARM Arduino IDE.
Code: [Select]
Plug in device now... (will timeout in 60 seconds)
> Please plug in the device ...
> Press CTRL+C to terminate the program.
> Device is found!
connecting: 16% complete
connecting: 22% complete
connecting: 28% complete
connecting: 33% complete
> Device has firmware version 1.6
> Available space for user applications: 6012 bytes
> Suggested sleep time between sending pages: 8ms
> Whole page count: 94  page size: 64
> Erase function sleep duration: 752ms
parsing: 50% complete
> Erasing the memory ...
erasing: 55% complete
erasing: 60% complete
erasing: 65% complete
> Starting to upload ...
writing: 70% complete
writing: 75% complete
writing: 80% complete
> Starting the user app ...
running: 100% complete
>> Micronucleus done. Thank you!


I attach two binaries for other ARM users. Just copy two files to ~~~~/2.0a4 directory.
It should work with other 32bit ARM boards.
Happy coding on ARM PC !  :)

Go Up