Skip to content

Instantly share code, notes, and snippets.

@maxkratz
Last active October 24, 2022 14:16
Show Gist options
  • Select an option

  • Save maxkratz/a6575a4371c056ad2125cbcf90577895 to your computer and use it in GitHub Desktop.

Select an option

Save maxkratz/a6575a4371c056ad2125cbcf90577895 to your computer and use it in GitHub Desktop.
HowTo Hello World Digispark Rubber Ducky

HowTo Hello World Digispark Rubber Ducky

This mini how-to walks you through the steps of translating Rubber Ducky scripts and installing all tools needed to flash a new firmware onto your attiny85 board.

Arduino Setup

  • Install Arduino from https://www.arduino.cc/en/main/software .
  • Open Arduino, go to File/Preferences and paste the following URL into Additional Boards Manager URLs.
  • Go to Tools/Boards/Board Manager and install Digistump AVR Boards.
  • Restart Arduino IDE.
  • Select Digispark (Default 16.5MHz) as default board under Tools/Boards.

Update bootloader

Compiler setup

  • The compiler provided by the Digispark package installation may be outdated and does not let you upload a precompiled firmware (binary) to the board. Thus you need to update it manually by compiling the latest version.
    • This error could accure: "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.3"
    • You need a version of libusb-dev and gcc installed to follow the next steps.
      • $ sudo apt install libusb-dev gcc
$ mkdir -p ~/micronucleus_build
$ cd ~/micronucleus_build
$ git clone [email protected]:micronucleus/micronucleus.git
$ cd micronucleus/commandline/
$ make
$ cd ~/.arduino15/packages/digistump/tools/micronucleus/2.0a4/
$ mv micronucleus micronucleus.OLD
$ cp ~/micronucleus_build/micronucleus/commandline/micronucleus .

UDEV Setup

  • In order to flash new binaries to the microcontroller you need to place a udev rule e.g. in /etc/udev/rules.d/49-micronucleus.rules.
# UDEV Rules for Micronucleus boards including the Digispark.
# This file must be placed at:
#
# /etc/udev/rules.d/49-micronucleus.rules    (preferred location)
#   or
# /lib/udev/rules.d/49-micronucleus.rules    (req'd on some broken systems)
#
# After this file is copied, physically unplug and reconnect the board.
#
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
#
# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
# GROUP:="somegroupname" and mange access using standard unix groups.
  • Reload the rules as root-user afterwards: $ sudo udevadm control --reload-rules

Hello World Example

(Based on README.rst from https://github.com/mame82/duck2spark .)

In order to convert the Rubber Ducky script, you need Java and python installed on your machine. You may download encoder.java and duck2spark.py from GitHub-repositories listed in section References into your workspace.

$ echo "STRING Hello World!" > hello.duck
$ java -jar encoder.java -i hello.duck -o raw.bin -l de
$ python duck2spark.py -i raw.bin -l 1 -f 2000 -o hello.ino
  • Open hello.ino with Arduino IDE, accept to place the sketchfile into a new directory.
  • Compile the script.
  • Upload it to the board.
  • Remove board from USB and reinsert it after you opened a text-editor of your choice.
    • After a few seconds the board should type "Hello World!" into your text-editor.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment