probonopd
9/26/2018 - 10:37 PM

UltiFi.md

Reviving UltiFi in 2018

UltiFi is a 3d printer host that can run on OpenWrt. I am specifically interested in running it on am A5-V11 router.

Install OpenWRT 18.06.1 on a5-v11

  • original firmware can be logged into with admin/admin
  • Flash openwrt-18.06.1-ramips-rt305x-a5-v11
  • First need to set a password, for this press the reset button when the red light starts flashing until it flashes fast
  • Set computer IP to 192.168.1.
  • Go to http://192.168.1.1/
  • Set root password
  • http://192.168.1.1/cgi-bin/luci/admin/system/startup -> dnsmasq, firewall, odhcpd -> disable
  • Network -> Interfaces -> Edit
  • Protocol -> DHCP client
  • Switch protocol
  • Save & Apply; times out...
  • Save & Apply Unchecked
  • Now set computer IP back to DHCP
  • Find IP from router; device MAC starts with 2c:67:fb:...
  • Install kmod-usb-acm (for Prusa, Ultlimaker); kmod-usb-serial-ftdi (for Renkforce); kmod-usb-serial-cp210x (for others)
  • We have 104 KB left
  • We can immediately attach a serial dongle and it will immediately be recognized (no reboot needed)
  • (Install kmod-usb-storage results in no space left on device!)

Building a cross-compiled C program

# On host computer

wget https://downloads.lede-project.org/releases/18.06.1/targets/ramips/rt305x/openwrt-sdk-18.06.1-ramips-rt305x_gcc-7.3.0_musl.Linux-x86_64.tar.xz
tar xf openwrt-sdk-*.Linux-x86_64.tar.xz

cat > hello.c <<\EOF
#include <stdio.h>

int main()
{
        printf("Hello World\n");
        printf("We are running a cross-compiled C program\n");
        return(0);
}
EOF

CROSS=$(readlink -f openwrt-sdk-*/staging_dir/toolchain-mipsel_*/bin/)
export PATH=$CROSS:$PATH

export STAGING_DIR=$(readlink -f openwrt-sdk-*/staging_dir/)

export LC_ALL=C # Otherwise getting .as.bin: loadlocale.c:129: _nl_intern_locale_data error

mipsel-openwrt-linux-gcc hello.c -o hello

mipsel-openwrt-linux-strip hello

sudo python -m SimpleHTTPServer 80 . &

# On device

cd /tmp

root@OpenWrt:/tmp# wget http://192.168.0.15/hello
root@OpenWrt:/tmp# chmod +x hello 
root@OpenWrt:/tmp# ./hello 
Hello World
We are running a cross-compiled C program

Compiling UltiFi

wget https://raw.githubusercontent.com/daid/UltiFi/master/PrinterManagerSrc/main.c
mipsel-openwrt-linux-gcc main.c -o ManageConnection.bin
mipsel-openwrt-linux-strip ManageConnection.bin

wget https://github.com/daid/UltiFi/archive/master.zip
unzip master.zip
cp ManageConnection.bin UltiFi-master/Target/ManageConnection.bin

tar cfvz UltiFi.tar.gz UltiFi-master/Target/

# On device

cd /tmp
wget http://192.168.0.15/UltiFi.tar.gz
tar xfvz UltiFi.tar.gz

( cd / ; ln -s /tmp/UltiFi-master/Target /UltiFi )

sh /UltiFi/_setup.sh

We can now access http://192.168.0.19/cgi-bin/UltiFi/main.lua, it says "No printers found. Please connect 1 or more printers to the USB port.".

sed -i -e 's|ttyACM|ttyUSB|g' /UltiFi/www/cgi-bin/UltiFi/util.lua  
sed -i -e 's|ttyACM|ttyUSB|g' /UltiFi/www/cgi-bin/UltiFi/exec_gcode.lua 
sed -i -e 's|ttyACM|ttyUSB|g' /UltiFi/PrinterManager.sh

root@OpenWrt:/tmp#  /UltiFi/PrinterManager.sh

Start
Trying 115200
|start|
|echo:Marlin 1.1.8|
||
|echo: Last Updated: 2017-12-25 12:00 | Author: (mahowi, default config)|
|echo:Compiled: Apr  9 2018|
|echo: Free Memory: 3671  PlannerBufferBytes: 1280|
|echo:V47 stored settings retrieved (614 bytes; crc 39526)|
|echo:  G21    ; Units in mm|
|echo:  M149 C ; Units in Celsius|
||
|echo:Filament settings: Disabled|
|echo:  M200 D1.75|
|echo:  M200 D0|
|echo:Steps per unit:|
|echo:  M92 X78.82 Y78.82 Z800.00 E106.00|
|echo:Maximum feedrates (units/s):|
|echo:  M203 X300.00 Y300.00 Z20.00 E25.00|
|echo:Maximum Acceleration (units/s2):|
|echo:  M201 X500 Y500 Z100 E10000|
|echo:Acceleration (units/s2): P<print_accel> R<retract_accel> T<travel_accel>|
|echo:  M204 P500.00 R3000.00 T500.00|
|echo:Advanced: S<min_feedrate> T<min_travel_feedrate> B<min_segment_time_us> X<max_xy_jerk> Z<max_z_jerk> E<max_e_jerk>|
|echo:  M205 S0.00 T0.00 B20000 X20.00 Y20.00 Z0.40 E5.00|
|echo:Home offset:|
|echo:  M206 X0.00 Y0.00 Z0.00|
|echo:Mesh Bed Leveling:|
|echo:  M420 S0 Z0.00|
|echo:  G29 S3 X1 Y1 Z0.00000|
|echo:  G29 S3 X2 Y1 Z0.00000|
|echo:  G29 S3 X3 Y1 Z0.00000|
|echo:  G29 S3 X1 Y2 Z0.00000|
|echo:  G29 S3 X2 Y2 Z0.00000|
|echo:  G29 S3 X3 Y2 Z0.00000|
|echo:  G29 S3 X1 Y3 Z0.00000|
|echo:  G29 S3 X2 Y3 Z0.00000|
|echo:  G29 S3 X3 Y3 Z0.00000|
|echo:Material heatup parameters:|
|echo:  M145 S0 H180 B70 F255|
|echo:  M145 S1 H240 B110 F255|
|echo:PID settings:|
|echo:  M301 P22.20 I1.08 D114.00|
|echo:Linear Advance:|
|echo:  M900 K75.00 R0.00|
|echo:SD card ok|
Failed to conect

TODO

  • Solve "Failed to conect". Is it not finding the temperature? Because the printer does not send it on its own?
  • Or rewrite everything in lua?
  • Precompile ready-to-flash OpenWrt image
  • Announce services via Zeroconf
  • Implement minimal Octoprint-compatible API