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)
- Terminal Emulator (you need to give root priviliges)
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.
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-freedeb-src http://deb.debian.org/debian buster main contrib non-freedeb http://deb.debian.org/debian buster-updates main contrib non-freedeb-src http://deb.debian.org/debian buster-updates main contrib non-freedeb http://deb.debian.org/debian buster-backports main contrib non-freedeb-src http://deb.debian.org/debian buster-backports main contrib non-freedeb http://security.debian.org/debian-security/ buster/updates main contrib non-freedeb-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 virtualenvsudo 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 --versionpip 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
Somekev explained it really well in his website, Here it is: https://somekev.com/2019/04/10/adapting-an-s6-for-octoprint/
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.
7 comments:
What was the init system that you have set?
Have you tried octo4a? https://github.com/feelfreelinux/octo4a
Hello machetie,
If i was going to install only octoprint, octo4a was the logical way to take, but actually i wanted install klipper that's why i used a chroot environment with LinuxDeploy. After that i installed octoprint besides.
Hello,
I can not manage to get a ROM with usb drivers for my S6.
I tryed stock, NNE 4.5, NNE 5.1, LineageOS 18.1, ...
Everytime, I dit not have new usb device in /dev, but data connection with my PC always work.
Do you know any ROM that works on S6 ?
Am I missing something ?
Hello LD40,
somekev managed to install it on his s6. here is the link to his site:
https://somekev.com/2019/04/03/octoprint-on-a-galaxy-s6/
Thank you Erçin
I've found this link before finding your own post.
But at the end this is the same problem : no new usb device in /dev
Probably not working on my french S6 variant
Hello, following your guide, and it has been very helpful...however...
The python version i'm getting is 3.7.3, and I don't seem to have pip, i guess it isn't included in that version.
I was able to solve this with sudo apt-get install python3-pip.
Hope this helps someone
Post a Comment