The information presented on these pages is NOT intended to be followed as a guide to installing OpenBSD on your own Pinephone device, and must not be used for this purpose.
Unlike most SBCs, the Pinephone contains a rechargeable battery intended to power the device. Correct configuration of the charging circuits, including various safety features such as thermal protection will not be enabled by the current OpenBSD kernel as of the time of writing.
THIS IS PART FIVE OF SEVEN (5/7) - CHECK OUT THE
=> Series index
Controlling the multi-coloured LED and vibration motor on the Pinephone is surprisingly easy, even from a simple shell script, since they are connected as GPIO devices.
All of the connections are to the gpio3 device, with pins 18, 19, and 20 controlling the green, red, and blue LED outputs respectively, and pin 2 controlling the vibration motor.
Some other devices are also connected to various gpio pins, such the backlight, and various sensors. The device tree file lists the pin assignments for these devices if you're curious. However, in the case of the backlight, since a driver for this device already exists in OpenBSD, there doesn't seem much point in trying to control it directly.
To use gpio devices on OpenBSD, it's necessary to configure them before the kern.securelevel sysctl is raised during the boot process. To do this, we just need to put the relevant commands in /etc/rc.securelevel:
gpioctl gpio3 2 set out Vibration motor gpioctl gpio3 18 set outGreen LED gpioctl gpio3 19 set outRed LED gpioctl gpio3 20 set outBlue LED
Then after rebooting, the configured gpio pins can be toggled from userland. It's also possible to assign a symbolic name to each of the configured pins to avoid having to hard-code pin numbers directly in the controlling program. For testing purposes, though, it's just as easy to use the numeric values.
We can start and stop the vibration motor from the shell using the following commands:
# gpioctl gpio3 2 on # gpioctl gpio3 2 off
Or alternatively we can toggle it to the opposite state using:
# gpioctl gpio3 2 toggle
Since each of the red, green, and blue LED components can either be on or off, we can set a total of seven colours, or eight if we include black:
Colour Pin 18 Pin 19 Pin 20 Black Off Off Off Blue Off Off On Red Off On Off Magenta / Purple Off On On Green On Off Off Cyan / Turquoise On Off On Yellow On On Off White On On On
The commands are similar to those used to control the vibration motor. The following will turn on the blue LED, for example:
# gpioctl gpio3 20 on
Since we don't yet have any framebuffer output to the built-in display panel, adding an LED toggle to /etc/rc.local at least allows us to see if the phone is switched on and booted into the kernel, even when not connected to the serial console.
=> Part 1 - Building the installation media and installing. | Part 2 - Booting the completed installation and initial information gathering. | Part 3 - Starting to debug USB issues. | Part 4 - Investigating errors from sxirsb.
Part 5 - Controlling the LEDs and vibration motor.
=> Part 6 - PMIC and battery charging. | Part 7 - External keyboard battery.
=> Home page of the Exotic Silicon gemini capsule. | Your use of this gemini capsule is subject to the terms and conditions of use.
Copyright 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Exotic Silicon. All rights reserved.
text/gemini; charset=utf-8
This content has been proxied by September (ba2dc).