Giter Site home page Giter Site logo

32bit_fwupdate_for_octoprint's Introduction

32bit FWupdate for Octoprint

Bash script for Firmware Update on 32Bit Boards (Marlin)

At first, it is not Plug & Play and it is more "Quick and Dirty" than "Nice and Clean". But it is my way I managed a "One click Firmware Update" for my SKR V1.3 Board, and it works. Yay!

Baseline

  • I have my Marlin Firmware Files on Google Drive, so I can access it from different pc's.
  • My 3D Printer is connected to my WiFi over an RPi 3B+ with Octoprint running on it.
  • I use PlatformIO to compile the 32bit Marlin Firmware

My Goal was

  • making firmware changes
  • hit PIO Upload
  • press one Button in Octoprint
  • Done!

Setup

Here I describe my Setup, I don't know if it works with other Setups. It is possible to work without Google Drive and send the firmware.bin from the local Machine, but more on this later in the Setup.

1. PlatformIO

Platformio.ini

In the environment Section of your Processor, in my case [env:LPC1768], it is possible to define additional Upload Ports. By default, the compiled File is stored in the Folder ...\.pioenvs\LPC1768\firmware.binif you hit Compile. If you click PIO Upload, PlatformIO stores the File in the folder and tries to upload to the Board, if it is connected via USB. If no Board is present, the file will be uploaded to the additionally defined Upload Ports. In My case, I defined one Port for each of my PC's.

platformio.ini

2. Octopi

Scripts

I don't know exactly why, but i needed two Scripts. The first Script updateFW contains all the stuff like mount SD card, backup the Firmware, download the firmware.binand push it to the SD card, unmount and reset the Board. The second one FWupdate only calls the first Scrip and give the exit 0Status back to Octoprint.

Here are the Memory Locations and the Scripts

/usr/local/bin/updateFW

#!/bin/bash
sudo mount -t vfat /dev/sda1 /mnt  ##mount Printerboards SDcard
cp --backup=numbered /mnt/* /home/pi/Documents/Firmware_Backup  ##Backup all files on the SDcard
sudo rm -f /mnt/*  ##clear all files on the SDcard

##download the firmware-file from GoogleDrive online
fileid="FileID_from_share_link"  ##copy and paste the part after "id=" of the "share-link" something like "0B3nIRrOFv6hVcE9IWEI1QnVZYjT" keep quotation marks
filename="/mnt/firmware.bin"  ##destination path and filename  keep quotation marks
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o ${filename}

##alternativly download the firmware-file from a local workstation
# sudo mount -t cifs //192.168.XXX.XXX/LPC1768 /mnt/lan -o username=NAME,password=PASSWORD  ## IP/networkshare, username and password of the local machine
# sudo cp /mnt/lan/firmware.bin /mnt/firmware.bin
# sudo umount -t cifs //192.168.XXX.XXX/LPC1768 /mnt/lan

sudo umount -t vfat /dev/sda1 /mnt  ##UNmount Printerboards sdcard
echo "M997" >> /dev/ttyACM0  ##reboot the Printerboard and initialize the firmware

/home/pi/bin/FWupdate

#!/bin/bash
sudo /usr/local/bin/updateFW
exit 0

Make sure the Rights are set correctly and the Scripts are executable

$ sudo chmod 755 /path/to/file

Sudoers

Normally every Command executed with sudo needs a Password. Since we cannot enter the Password while the Script is running, we need to tell the System to execute the sudoCommands within these two Scripts without a Password entry. Therefore we create a file in the Directory /etc/sudoers.d/. The Name of this File is non-essential. We name it updatescript. Type the following in the Terminal:

$ sudo visudo -f /etc/sudoers.d/updatescript

Write these two lines into the File

pi ALL=(ALL:ALL) NOPASSWD: /usr/local/bin/updateFW
pi ALL=(ALL:ALL) NOPASSWD: /home/pi/bin/FWupdate

Safe the changes with CTRL+O and exit the editor with CTRL+X

Make sure the Rights for this file are set to 440 and the owner is root $ sudo chmod 440 /path/to/file $ sudo chown root /path/to/file

3. Octoprint

The last step is to configure the "System Command Editor". After the installation over Plugin manager, open the Settings and right click on the green Frame. Choose Create Command and configure it like this:

Sys Cmd Editor

Hit Safe and You're Done! Here is Your "Update Button"

Update Button

32bit_fwupdate_for_octoprint's People

Contributors

ruedib avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.