Arduboy uploader for linux


(wd) #1

i wrote simple uploader for Erwin’s Arduboy Collection in linux/firefox

1st: /etc/udev/rules.d/99-arduboy.rules

ACTION=="add", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0036", SYMLINK+="arduboy-boot"
ACTION=="add", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="8036", SYMLINK+="arduboy"

i did not use arduino ide and other arduino things and may be arduino stuff already have same…

2nd: arduboy-proto

#!/bin/sh

TERMINAL=xterm
DEV_BOOT=/dev/arduboy-boot
DEV_RUN=/dev/arduboy
URL="${1#*:}"
TMP=$(mktemp)


$TERMINAL -e "
  echo -ne '\e]2;Arduboy Uploader - $URL\a'
  wget -O \"$TMP\" \"$URL\"
  echo waiting for $DEV_BOOT '(press RESET)'
  while [ ! -e $DEV_BOOT ]; do
    if [ -e $DEV_RUN ]; then
      echo -e '\n'$DEV_RUN found. trying to reset.
      stty -F $DEV_RUN ispeed 1200 ospeed 1200
      while [ -e $DEV_RUN ]; do sleep 0.1; done;
    fi
    echo -n .
    sleep 0.1
  done
  avrdude -p atmega32u4 -cavr109 -P$DEV_BOOT -D -Uflash:w:\"$TMP\"
  rm -f \"$TMP\"
"

save it anywhere and do chmod +x on it

3rd: add arduboy: protocol handler

  • open about:config in firefox
  • Right-click -> New -> Boolean -> Name: network.protocol-handler.expose.arduboy -> Value -> false
  • write data:text/html,<a href=arduboy:1>1</a> in location bar and press enter
  • click that link
  • FF ask u for application for it - choose file from 2nd step

now u can upload games by clickin “Upload to my Arduboy” :slight_smile:

ps:

  • ofcause u must have permissions to /dev/ttyACM* - in my case (gentoo) working user just added to uucp group, another (ugly) way - set permissions 666 by udev
  • i use arduboy clone based on leonardo from ali and ur VID:PID pairs may be anothers

(Matt) #2

This is cool. It’d be nice to throw it up on github. I’d like to tweak it to also supporting uploading hex files from the file system.


(wd) #3

for local hex i still use

#!/bin/sh

avrdude -p atmega32u4 -cavr109 -P/dev/ttyACM0 -D -Uflash:w:"$1"#                                                                                                                                                                                                                                    

but u r right. i want to do it all in one script and also i want support .arduino files in both ways
i done it in my mind days ago :slight_smile:
wait some hours


(Pharap) #4

@w_d
For people like @city41 to be able to tweak it,
it’s also going to need an open source licence.

Most Arduboy games and software use MIT, BSD 3-clause or Apache 2.0,
but here’s a list of several licences:

And an even biggger list if you’re not happy with any of those options:


(wd) #5

i prefer WTFPL


(Pharap) #6

I’d recommend not using the WTFPL because it isn’t explicit enough and has never been tested in court.
The FSF doesn’t recommend it and the OSI outright rejected it.

You’re better off going with MIT or CC0, they had actual lawyers contribute to their creation and have been well thought-out.


(wd) #7

what about ЛИПНУ?
why i must license simple script? its bad practice


(Miloslav Číž) #8

It’s a pain but you should stick a license to everything you make. Why? Because, to say it lightly, our laws aren’t exactly ideal :slight_smile: This guy has a lot to say about it.


(Matt) #9

do you want to risk being sued? :stuck_out_tongue:

I like the /dev/arduboy trick, didn’t realize you could do that.


(wd) #10

sued for what? for unlicensed script?
how license protect me from this?
its stupid
i can be sued for any “patented” stuff just for their fun
lets talk over subj?


(Matt) #11

I was joking :slight_smile: I thought the sticking out tongue would convey that. Ah well.


(Pharap) #12

Because if there isn’t a licence then legally nobody else has permission to edit the code:

Without a licence you have full copyright and nobody else is allowed to copy or modify the code.


(wd) #13

here some new:

#!/bin/bash

if [ $(ps -opgrp= -p$$) != $(ps -otpgid= -p$$) ]; then
  xterm -e "
    echo -ne '\e]2;Arduboy Uploader\a'
    $0 '$@'
  "
  exit
fi



DEV_BOOT=/dev/arduboy-boot
DEV_RUN=/dev/arduboy
TMP=$(mktemp -d --suffix=-arduboy)

usage(){
  echo
  echo "Usage:"
  echo "  `basename $0` {URL|FILE}"
  echo
}

flash(){
  echo "waiting for $DEV_BOOT (press RESET)"
  while [ ! -e "$DEV_BOOT" ]; do
    if [ -e "$DEV_RUN" ]; then
      echo -e "\n$DEV_RUN found. trying to reset."
      stty -F "$DEV_RUN" ispeed 1200 ospeed 1200
      while [ -e "$DEV_RUN" ]; do sleep 0.1; done;
    fi
    echo -n .
    sleep 0.1
  done

  avrdude -p atmega32u4 -cavr109 -P"$DEV_BOOT" -D -Uflash:w:"$1"
}

zflash(){
  HEX="${2%.*}"
  "$1" -vdc "$2" >"$TMP/${HEX##*/}"
  flash "$TMP/${HEX##*/}"
}

download(){
  wget -O "$TMP/${1##*/}" $1
  echo "$TMP/${1##*/}"
}


case "$1" in
  arduboy:*)
    FILE=$(download "${1#*:}")
    ;;
  http://*|https://*|ftp://*)
    FILE=$(download "$1")
    ;;
  *)
    FILE="$1"
    ;;
esac

case "$FILE" in
  *.arduboy|*.zip)
    unzip -d "$TMP" "$FILE" \*.hex
    HEXs=( "$TMP"/*.hex )
    case "${#HEXs[@]}" in
      0) echo "no .hex files found." ;;
      1) flash "${HEXs[0]}" ;;
      *) echo -e "\nmany .hex files found\nchoose:"
         select ans in "${HEXs[@]##*/}"
         do
           flash "$TMP/$ans"
           break
         done
         ;;
    esac
    ;;
  *.hex)
    flash "$FILE"
    ;;
  *.hex.gz)
    zflash gzip "$FILE"
    ;;
  *.hex.bz2)
    zflash bzip2 "$FILE"
    ;;
  *.hex.xz|*.hex.lzma)
    zflash zx "$FILE"
    ;;
  *)
    usage
    ;;
esac

rm -rf "$TMP"

later i will add better terminal and downloader selection depend on available in system