Skip to content

Volcano Show

Mark Boszko edited this page Aug 17, 2018 · 39 revisions

This is all very much a WIP. I need to go back and document stuff I've already done.

Parts

Raspberry Pi Setup

System Setup

  • Install Raspbian:
    • Installing with NOOBS
    • Download the NOOBS Installer. I used V1.9.0, released 2016-03-18.
    • Unzip the NOOBS package.
    • Download and use SD Formatter to format the SD card as FAT. I named it TIKINOOK.
    • Copy all files from the NOOBS_v1_9_0 folder into the root of the SD card.
    • Eject the SD card and insert in the Raspberry Pi. Hook up the Pi to Ethernet, an HDMI display, and a USB keyboard and mouse, then connect the Micro USB power.
    • When NOOBS boots, check the box for Raspbian, and click Install. Confirm you want to overwrite the SD card.
      • Note: The full Raspbian install probably contains a lot of unnecessary stuff, but I haven't whittled down to exactly what I need for the Tiki Nook. Still, should be OK.
    • Go get a cup of coffee while Raspbian installs.
    • Click OK when done; the Pi will reboot.
  • Use the Adafruit Raspberry Pi Finder to connect to the headless Pi over the network and set up the bootstrap process.
    • Launch PiFinder.app (I'm on OS X)
    • Click Find My Pi!
    • Once it finds the Pi, change the Hostname (I use tikinook) and enter the Wi-fi SSID and password, and click Bootstrap!
    • As far as I can tell, PiFinder's Bootstrap did not change the hostname (the Pi remains at raspberrypi.local), and I'm not sure about the Wi-fi either. the other bootstrap stuff seemed to work though? its hard to tell, since the bootstrap terminal window disappears as soon as it finishes, so I cant see if there are any error messages.
  • On the Pi itself:
    • Menu > Preferences > Raspberry Pi Configuration
    • Change the password to something other than the default raspberry
    • Change the Hostname here to tikinook, because the PiFinder method didn't stick.
    • Interfaces > SPI > Enabled
    • Localization > Locale > Country > US
    • Timezone > Areas: US, Location: Pacific
    • Click OK and when it asks you to reboot, say Yes
  • Set up reserved LAN IP address
    • Find the Wi-fi MAC address of the RPi by running ifconfig wlan0. The MAC address is reported as HWaddr.
    • In AirPort Utility, click on the AirPort and then click Edit. Click on the Network tab, and under DHCP Reservations, click the .
      • Description: Tiki Nook
      • Reserve Address By: MAC Address
      • MAC Address: ab:cd:ef:01:23:45 (the address from wlan0)
      • IPv4 Address: 192.168.10.14 (or whatever IP address you'd like it to have)
    • This way, every time your RPi connects to the LAN, the AirPort will give it the same IP address.
  • Set up port forwarding for ssh
    • Not necessary, but I like to be able to get to ssh from outside of my home network.
    • In AirPort Utility, click on the AirPort and then click Edit. Click on the Network tab, and under Port Settings, click the .
      • Firewall Entry Type: IPv4 Port Mapping
      • Description: Tiki Nook SSH
      • Public TCP Ports: 8123 (or whatever port you prefer)
      • Private IP Address: 192.168.10.14 (the reserved IP address for your RPi)
      • Private TCP Ports: 22
    • Then you can connect from the outside by using ssh -p 8123 [email protected] (or whatever your WAN-facing IP address is)
  • Install VNC

Other Libraries

Wiring and Hardware

  • 2016-03-06 - Distributing power along one side of the nook shelves, so that we get better voltage and truer colors to more pixels
    • I don't really think this is working. According to Adafruit "Powering NeoPixels", I need 60 / pixel for max brightness on 294 pixels, which is ~18A. My current power supply is only 10A -- fine for most color work, but for bright white, it's not gonna work. (HAHAHA and my mains circuit is only 15A, so obviously this will work perfectly.)

2018 Changes

Upgrading to use python-osc for communication between TouchOSC on an iOS device, a Mac mini, and the Raspberry Pi, which means I have to use Python 3.4 or later.

Boot launch controller script

That also means I need to run the script with python3 at boot, instead of python, so I need to change the service that launches the script on boot.

Only, I forgot how I set it up in the first place! See here for the detective work.

To change it, edit the current crontab (don't forget to use sudo!):

$ sudo crontab -e

# Default crontab file contents, all commented out
# ...
# Then at the end:
@reboot sudo python /home/pi/tikinook/nook_controller.py

That last line should now be:

@reboot sudo python3 /home/pi/tikinook/nook_controller.py &

2018-08-14 pm, I've commented it out for now, so I can develop the new scripts without having to kill the boot-launched one.

Update firmware

Just to make sure everything is updated before we install the new Python, run:

$ sudo rpi-update

Before this update, I had a State: degraded in the systemctl status results. I ran systemctl --failed to see what was failing, and it was hciuart.service, something to do with the Bluetooth radio. After running rpi-update, the degraded status resolved itself.

Python upgrade

$ python3 --version
Python 3.4.2

If I'm going to use Python 3, let's upgrade to the latest 3.7.0 (as of 2018-08-14), so I don't have to do this again soon.

I'm installing with these instructions to build from source, but updating for Python 3.7.

Install the pre-requisites:

$ sudo apt-get update
$ sudo apt-get install build-essential checkinstall
$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

Python installation with this failed. Another guide says that a missing libffi-dev may be the culprit. It also says to install all of these:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus
sudo apt-get install libncursesw5-dev libgdbm-dev libc6-dev
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev
sudo apt-get install libssl-dev openssl
sudo apt-get install libffi-dev

This worked. But I did it after installing the above, so I'm not sure if it's 100% on its own.

Download and extract Python 3.7.0:

$ cd /usr/src
$ sudo wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
$ sudo sudo tar xzf Python-3.7.0.tgz

Compile Python. configure will take a while. make will take a long while. Go have dinner.

$ cd Python-3.7.0
$ sudo -s
# bash configure
# make altinstall
# exit

Make Python 3.7 the default

From this Unix Stack Exchange answer:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.4 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2
sudo update-alternatives --config python

Set python3.7 as default. You can run python3 --version to check.

FIXME: This python installation still isn't working because it's not building with SSL for some reason, so I can't install other packages. See this question on Raspberry Pi Stack Exchange.

Upgrade the OS

Since the Python installation continued to not work, I decided to upgrade the OS, with these instructions to upgrade from Jessie to Stretch. Quoted below:

Prepare

Get up to date.

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade

Verify nothing is wrong. Verify no errors are reported after each command. Fix as required (you’re on your own here!).

$ dpkg -C
$ apt-mark showhold

Optionally upgrade the firmware.

$ sudo rpi-update

Prepare apt-get

Update the sources to apt-get. This replaces “jessie” with “stretch” in the repository locations giving apt-get access to the new version’s binaries.

$ sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list
$ sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list.d/raspi.list

Verify this caught them all. Run the following, expecting no output. If the command returns anything having previously run the sed commands above, it means more files may need tweaking. Run the sed command for each.

$ grep -lnr jessie /etc/apt    

Speed up subsequent steps by removing the list change package.

$ sudo apt-get remove apt-listchanges

Do the Upgrade

$ sudo apt-get update && sudo apt-get upgrade -y $ sudo apt-get dist-upgrade -y Cleanup old outdated packages.

$ sudo apt-get autoremove -y && sudo apt-get autoclean

Verify with cat /etc/os-release.

Update Firmware

You’ve come this far, might as well get the latest firmware.

$ sudo rpi-update    

Try Upgrading Python Again

I was then looking at these instructions to compile Python 3.7 on the Raspberry Pi, and it said to install these prerequisites:

apt install libffi-dev libbz2-dev liblzma-dev libsqlite3-dev libncurses5-dev libgdbm-dev zlib1g-dev libreadline-dev libssl-dev tk-dev build-essential libncursesw5-dev libc6-dev openssl git

TODO: Are these different from the above prerequisites?

I did that and then re-ran configure and make in the Python instructions above, and it worked!

Fixing pip

I then had this error when using pip install [something]:

subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1.

And then after digging and trying a few things this advice seemed to work, much like an appendectomy:

sudo rm /usr/bin/lsb_release

Hope I didn't need it!

Upgrade numpy

It didn't want to uninstall the system-supplied numpy, so I had to do it this way:

pip3 install --ignore-installed numpy

Install OSC

$ sudo pip3 install python-osc

Other packages

Seems that the RPi.GPIO package wasn't in Python 3, as well as a few other things:

$ sudo pip3 install RPi.GPIO
$ sudo pip3 install rpi_ws281x
$ sudo pip3 install opencv-python

This doesn't work on 3.7! Need 3.5. Dammit. Shit. Shit. Fuck.

Upgrade ws2801 code

I updated the paleopixels.py script, and it works, but the colors are all screwed up. I think in set_pixel_color_rgb() the char() stuff I added is not working on python3, and I need to return to the basics. It looks like Adafruit's ws2801 code has been updated for python3, so let's try getting that to work:

TODO: download WS2801.py and test it. Once it's working, update paleopixel.py to match.