Category Archives: Uncategorized

Cheatsheet: Raspberry Pi + Alpine Linux + OctoPrint

The last upgrade to Raspbian Raspberry Pi OS broke the WiFi connection to my 3D printer in an inconvenient way, as it runs headless with just a 4-pin power-and-UART connection. I’ve been having pretty good luck lately with Alpine Linux on various systems (including a Docker host and a cluster of Raspberry Pi 4s I knocked together to try to wrap my head around Kubernetes), so I thought I’d put it on the Compute Module 4 that drives my printer. I backed up the OctoPrint config that was on it and got a replacement configuration running on a spare Raspberry Pi 3 at first. Here’s what I came up with in the way of what needs to be done to put Alpine Linux on a Raspberry Pi and bring up OctoPrint on the resulting system.

  • Download the Alpine Linux tarball that’s appropriate for your Raspberry Pi from here. (For the RPi 3 and up, you most likely want the aarch64 image. This is especially true for the RPi 4 and up with 4 GB or more of RAM.) Instructions on how to do this are available elsewhere, but the short version is that you want to unpack the tarball to a FAT-formatted MicroSD card (or USB stick if you’re targeting a Compute Module 4 with onboard eMMC), boot from the device, and run setup-alpine to install. Toward the end, you want to install it in “sys” mode. Reboot to bring up the new system, and then log in. You would’ve needed a monitor and keyboard to set up Alpine, but if you’ve set it up right, you can ssh into it from here on out.
  • Edit /etc/apk/repositories to enable the community repository. (This is needed for vcgencmd.)
  • Install needed software:
    doas apk add gcc make musl-dev linux-headers libffi-dev nginx raspberrypi-utils-vcgencmd python3-dev
  • Install OctoPrint:
    python -m venv --upgrade-deps octoprint
    octoprint/bin/pip install
    octoprint/bin/pip install octoprint

    (The marlin-binary-protocol installation is needed if you want to use the Firmware Updater plugin and need to use its marlinbft driver. My printer uses a BTT SKR 1.4 Turbo, an LPC1769-based board that can use this driver for firmware uploads.)
  • Edit /etc/fstab to disable tmpfs on /tmp. (Restoring backups from another OctoPrint instance will probably fail if you don’t.)
  • Copy the following to /etc/nginx/nginx.conf:
    worker_processes 1;

    events {
    worker_connections 1024;

    http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;

    map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;

    upstream "octoprint" {

    upstream "mjpg-streamer" {

    server {
    listen 80;
    server_name localhost;

    location / {
    proxy_pass http://octoprint/;
    proxy_set_header Host $http_host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Scheme $scheme;
    proxy_http_version 1.1;

    client_max_body_size 0;

    location /webcam/ {
    proxy_pass http://mjpg-streamer/;

    # redirect server error pages to the static page /50x.html
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
  • Create /etc/local.d/octoprint.start with the following and make it executable:
    #!/usr/bin/env ash
    su - salfter -c "nohup /home/salfter/octoprint/bin/octoprint serve 2>&1 >/dev/null &"

    (change “salfter” to whatever user you’re using)
  • Create /etc/local.d/octoprint.stop with the following and make it executable:
    #!/usr/bin/env ash
    pkill octoprint
  • Check /etc/inittab to make sure the serial console isn’t enabled.
  • Add the following to /boot/usercfg.txt:


    Reboot so the changes take effect.
  • Enable the nginx and local startup scripts:
    doas rc-update add nginx
    doas rc-update add local
  • Add the user under which OctoPrint runs (in my case, that would be salfter) to whatever group /dev/ttyAMA0 belongs (root, in my case).
  • Edit /etc/doas.d/doas.conf to allow doas to work without a password (needed so OctoPrint can restart itself):
    permit nopass :wheel
  • Reboot and wait for OctoPrint to come up on port 80. Restore your backup (if you have one) and you’re done!

Cheatsheet: convert WRL to STEP with open-source tools

I had some electronic component models (obtained via easyeda2kicad) that I needed to convert to STEP so they’d show up when I brought a board using these models into FreeCAD with KicadStepUp. I tried doing the job in FreeCAD alone, but while WRL files are basically meshes (not too different in theory from STL files), FreeCAD’s mesh-to-shape conversion wanted nothing to do with them. I searched for

I ended up using Wings3D to convert from WRL to STL, and then used FreeCAD to convert from STL to STEP:

  1. Import the WRL file into Wings3D. Check the “swap X & Y axes” box and set the import scale to 2.54. Export to STL.
  2. Import the STL file you just created into FreeCAD.
  3. (optional) Switch to the mesh workbench and decimate the mesh (Meshes -> Decimation…).
  4. Switch to the part workbench, create a shape from the mesh (Part -> Create shape from mesh…, then make sure “sew shape” is checked), and convert the shape to a solid (Part -> Convert to solid).
  5. Export the solid to STEP.

These models definitely won’t look as nice as models created from a proper CAD workflow (you can even import from OpenSCAD, export that to STEP, and get something pretty decent), but if you just need a model of your PCB for mechanical integration, it’ll get the job done.

On Trump and taxes

According to the Epoch Times, Donald and Melania Trump reported negative income in four of the six years’ worth of tax returns that were dumped. I’m sure the usual scumbags will try to make something of this, but as long as all the “I”s are dotted and “T”s are crossed, I don’t see anything at all wrong with this:

Anyone may arrange his affairs so that his taxes shall be as low as possible; he is not bound to choose that pattern which best pays the treasury. There is not even a patriotic duty to increase one’s taxes. Over and over again the Courts have said that there is nothing sinister in so arranging affairs as to keep taxes as low as possible. Everyone does it, rich and poor alike and all do right, for nobody owes any public duty to pay more than the law demands.

– Learned Hand

Imagine if the roles were reversed

My tax refund finally came through today, 4½ months after filing. By far, this is the longest it has ever taken. Even though I file by mail with printed forms, somewhere around 3-4 weeks is more typical.

If I owed money, do you think the IRS would tolerate such a lengthy delay without at least tacking on some penalties? Didn’t think so.

Fuck Joe Biden.

Solid advice

Hate them back:

I’m a big believer in giving back to people what they give to others. Think of it as a twist on the Golden Rule: if someone is a bad person to others, even if it isn’t you, treat them accordingly. Someone who is a bad person to people who aren’t you will eventually get around to you because it’s who they are at their core. That’s how I see Democrats, particularly Joe Biden. Jill too, but she’s such a non-entity without him she barely deserves a mention. If you are not with them, not one of them., they hate you, they really do. Return the favor.

Fuck Joe Biden.