No Found Support for SH1106 + Luma Oled

Hello everyone,

I currently have a Raspberry pi 3b running OpenWRT. I want to add a 1.3" SH1106 128x64 Oled Display (to show some stats of the router), but I cannot find the needed drivers to detect and use it with python. With raspbian, I was able to make it work but not with OpenWRT. I have installed kmod-i2c-core and kmod-i2c-gpio, but i am not able to install the required driver for SH1106 + dependencies to use luma oled -> https://luma-oled.readthedocs.io/en/latest/software.html#installing-dependencies .

If anyone has tried anything similar, I would be grateful for some guidance!

As always, thank you for your support.

Any error from pip install?

It would be great if you described the precise steps you've taken, and where it failed.

By the looks of it, I see one major shortcoming - python3-pil has been superseded by python3-pillow, but the Luma OLED install guide still recommends the old package name. You'll need to change this and install python3-pillow from the package manager.

I'm guessing you're failing on the python3 -m pip install luma.oled step, specifically with a similar error:

Building wheels for collected packages: RPI.GPIO, spidev
  Building wheel for RPI.GPIO (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for RPI.GPIO (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [15 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-aarch64-cpython-311
      creating build/lib.linux-aarch64-cpython-311/RPi
      copying RPi/__init__.py -> build/lib.linux-aarch64-cpython-311/RPi
      creating build/lib.linux-aarch64-cpython-311/RPi/GPIO
      copying RPi/GPIO/__init__.py -> build/lib.linux-aarch64-cpython-311/RPi/GPIO
      running build_ext
      building 'RPi._GPIO' extension
      creating build/temp.linux-aarch64-cpython-311
      creating build/temp.linux-aarch64-cpython-311/source
      gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a53_musl/Python-3.11.7=Python-3.11.7 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a53_musl/Python-3.11.7=Python-3.11.7 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-13.2.0_musl/usr/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-13.2.0_musl/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-13.2.0_musl/include/fortify -fPIC -I/usr/include/python3.11 -c source/c_gpio.c -o build/temp.linux-aarch64-cpython-311/source/c_gpio.o
      error: command 'gcc' failed: No such file or directory
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for RPI.GPIO
  Building wheel for spidev (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for spidev (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      /tmp/pip-build-env-p26bj_6k/overlay/lib/python3.11/site-packages/setuptools/dist.py:476: SetuptoolsDeprecationWarning: Invalid dash-separated options
      !!

              ********************************************************************************
              Usage of dash-separated 'description-file' will not be supported in future
              versions. Please use the underscore name 'description_file' instead.

              By 2024-Sep-26, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.

              See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
              ********************************************************************************

      !!
        opt = self.warn_dash_deprecation(opt, section)
      running bdist_wheel
      running build
      running build_ext
      building 'spidev' extension
      creating build
      creating build/temp.linux-aarch64-cpython-311
      gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a53_musl/Python-3.11.7=Python-3.11.7 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-aarch64_cortex-a53_musl/Python-3.11.7=Python-3.11.7 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-13.2.0_musl/usr/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-13.2.0_musl/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-13.2.0_musl/include/fortify -fPIC -I/usr/include/python3.11 -c spidev_module.c -o build/temp.linux-aarch64-cpython-311/spidev_module.o
      error: command 'gcc' failed: No such file or directory
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for spidev
Failed to build RPI.GPIO spidev
ERROR: Could not build wheels for RPI.GPIO, spidev, which is required to install pyproject.toml-based projects

This is due to the system not having GCC installed. As OpenWrt routers are meant to be embedded, they usually do not include the usual build tools you'd find on a standard Linux distro, like gcc, make, autoconf etc.

So you'll need to install at the very least the gcc package. Fair warning, this will take up 130-150MB (thus not a possibility for truly embedded devices with limited flash size), plus the other dependencies, this can quickly grow large.

You need to install gcc.
If it still fails you need to peek into binary packages eg pillow and replicate makefiles for binary dependencies.