I have read "installing octoprint on a smartphone" on reddit and decided to do it. Here is my documentation about how to install Octoprint on an Android-Phone (LG G4)
For any rom, if you want to connect it to Ender 3, you need "ch341" driver added/activated in the kernel or you need a custom implementation of it (look for octo4a program). You could understand it by connecting the phone with a USB OTG cable to your printer and execute command "ls /dev | grep tty". If there is "ttyusb" or "ttyacm" , it means that kernel has the driver. If kernel does not have the driver you have two options:
- You need to compile a kernel with driver support. Also keep in mind that kernel needs to support "loopback" functionality to host a virtual linux system and accept/direct connections to that virtual linux over its loopback.
- You can install octo4a, which installs custom a ch34x driver. and you need to mount the serial pipe of the octo4a (you can check that part from: https://github.com/d4rk50ul1/klipper-on-android)
Installing Ubuntu - "Linux Deploy"
Before installing Ubuntu, be sure to have the serial drivers installed (kernel) on the phone, otherwise you will waste too much time.
Leave folders as default.
Newest Ubuntu that i succeded to install is Debian Buster
3. Open LinuxDeploy and go to settings and check
- Lock-wifi
- Wake lock
- Auto-start
- Auto-start delay : 30 seconds
- Debug : Useful to understand if something goes wrong (like kernel version is old etc.)
Go to properties menu and and configure below:
- Distribution: debian buster
- Architecture: arm64
- Username: pi (octoprint scripts are for raspberry-pi installation, pi user will make our job easier)
- Password: your-password
- Installation type: file (default)
- Installation path: $(EXTERNAL_STORAGE)/linux.img (default)
- Image Size: 4096 MB
- enable ssh
- Init: enabled
- Mounts: enabled
- Mount points: source: /sdcard target: /sdcard
Start installation
To eliminate local network problems, first try to connect to linux over the phone itself. ssh to "localhost"
Change root password with command "sudo passwd root"
Installing Python & Octoprint
Default Python version on Debian Buster is 2.7.16 which is ok for octoprint, klipper etc.
1.Change user shell from sh to bash, and close and restart your ssh session.
sudo usermod --shell /bin/bash pi
2. Update "sources.list" file and add the sources below
sudo nano /etc/apt/sources.list
deb http://deb.debian.org/debian buster main contrib non-free
deb-src http://deb.debian.org/debian buster main contrib non-free
deb http://deb.debian.org/debian buster-updates main contrib non-free
deb-src http://deb.debian.org/debian buster-updates main contrib non-free
deb http://deb.debian.org/debian buster-backports main contrib non-free
deb-src http://deb.debian.org/debian buster-backports main contrib non-free
deb http://security.debian.org/debian-security/ buster/updates main contrib non-free
deb-src http://security.debian.org/debian-security/ buster/updates main contrib non-free
3. Upgrade ubuntu and install prerequisites
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential checkinstall -y
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev -y
sudo apt-get install python-pip python-dev python-setuptools -y
4. Upgrade PIP (also for virtualenv)
sudo pip install wheel
sudo apt install virtualenv
sudo pip install --upgrade "pip < 21.0" virtualenv virtualenvwrapper --ignore-inst
6.Create and enter into virtual env. Install virtualenv with
mkdir venvs
cd venvs/
virtualenv octoprint
source /home/pi/venvs/octoprint/bin/activate
7.Check python and pip version inside virtualenv (python 2.7.16, pip 20.x)
python --version
pip install --upgrade "pip < 21.0"
pip install --upgrade setuptools
pip --version
8. Install octoprint (inside venv)
pip install wheel
pip install octoprint
8. Start octoprint
/home/pi/venvs/octoprint/bin/octoprint serve
Start Octoprint On Debian Boot Automatically
Download necessary script files:
wget https://github.com/foosel/OctoPrint/raw/master/scripts/octoprint.init && sudo mv octoprint.init /etc/init.d/octoprint
wget https://github.com/foosel/OctoPrint/raw/master/scripts/octoprint.default && sudo mv octoprint.default /etc/default/octoprint
sudo chmod +x /etc/init.d/octoprint
sudo systemctl octoprint enable
Change the daemon path in "/etc/default/octoprint" file with vi/nano (whatever text editor is your favorite) to:
sudo nano
DAEMON=/home/pi/venvs/octoprint/bin/octoprint
Screen Off - Sleep Problems
For an always on Linux installation on Android, some battery and cpu optimization settings need to be changed otherwise Linux becomes unreachable when screen is of after a while:
1. Change wifi settings to "keep wifi always on"
2. Install
Wake-Lock Rewamp: Select "Screen_DIM_wake_lock" option for phone not to (deep)sleep when the screen is off.
3. Change Battery Settings: Disable optimization for LinuxDeploy and WakeLock application.
4. Change minimum cpu frequency & cpu governer: Change min frequency to 600Mhz and governor to performance. You could use
SmartPack-Kernel Manager
Astroprint plugin
First install missing packages:
sudo apt-get install libjpeg-dev
Then you could install it Astroprint plugin from octoprint web page.
Restarting Phone Over Octoprint Webpage
Temporary Files
If temporary files uses too much space, at the end your 4gb image could fill and octorint might stop working. Keep an eye on the octoprint main page, under upload file menu you could see the.
Logfiles of octoprint are located at "/home/pi/.octoprint/logs". Linux temp files are under "/tmp".
Problems
If i restart my phone, after Linux deploy started, i need to unplug and plug the microusb on phone side, then usb is recognized.