mycontroller-org / mycontroller-v1-legacy

The Open Source Controller
http://www.MyController.org
Apache License 2.0
148 stars 90 forks source link

Upload gateway firmware via USB #489

Open jpink opened 5 years ago

jpink commented 5 years ago

Hi,

I have many thin client PCs in my LAN with Arduinos connected on them via USB. Arduinos are "hard" to detach get it to my laptop, do firmware update with Arduino IDE (even small config change) and put it back to its place.

It would be great if I can update my gateway firmware also via UI like the node firmware. Documentation says that node must have MYSBootloader or DualOptiboot-bootloader. USB-serial upload doesn't need those the default Arduino bootloader is ok.

I have tested Arduino Makefile to upload Arduino .ino-files to USB connected Arduino on my thin client (Debian, i686, 128 MB RAM) via SSH connection. The process is quite simple:

  1. apt install arduino-mk as root or use sudo.
  2. adduser <username> dialup group to have permissions to use serial ports or use root.
  3. Create directory for firmware: `mkdir sketchbook && cd sketchbook'
  4. Copy sketch to that folder.
  5. Create directory for libraries mkdir libraries and copy them to it.
  6. Create build file nano Makefile. Following example uses root user:
    ARDUINO_DIR = /usr/share/arduino
    ARDUINO_PORT = /dev/ttyUSB0
    USER_LIB_PATH = /root/sketchbook/libraries
    BOARD_TAG = uno
    include /usr/share/arduino/Arduino.mk
  7. Then run make upload clean and Arduino is uploaded.

One thing to note is that function "interface" must be defined in the .ino-file heading before function body. Arduino IDE does that (precompiling), but Arduino-Makefile isn't.

jkandasa commented 5 years ago

@jpink Thanks for the great idea! I do an investigation with MyController and let you know.