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.
Series navigation
THIS IS PART SEVEN OF SEVEN (7/7) - CHECK OUT THE INDEX
The Exotic Silicon website is available in ten themes, but you haven't chosen one yet!
First look at the external keyboard
As well as being a physical keyboard, this peripheral also includes a large 6000 mAh battery in it's base. From a user's point of view that's very useful, but if you've read the previous part of this series, you'll already know how complicated power supplies and battery charging can be on a phone. Adding a second battery to the mix isn't likely to make things any simpler, and will eventually require a fair amount of software logic in order to use both batteries together in an optimal way.
If it isn't obvious why this will be necessary, consider the situation when the handset is connected to the keyboard with it's second battery, and is also connected to AC power. If both batteries are charged to about 50% of their capacity, where should we direct the AC power to? Do we prioritise charging the internal battery, or the external battery? Do we charge the internal battery to 100% before charging the external battery? Or do we charge the internal battery to, say, 80%, then charge the external battery to 100%, then top off the internal battery only when the external one is full?
These are open-ended questions, with no clear-cut right or wrong answers. The optimal charging scheme depends entirely on your use case, for example whether you always use the phone in conjunction with the external keyboard, or whether you regularly connect and disconnect it. A user who leaves the external keyboard docked during the day at the office, but wants to take just the phone out with them socially in the evening, would probably prefer the internal battery to be charged to 100% by the end of the working day, regardless of the state of the keyboard battery. On the other hand, a user who leaves the keyboard docked all the time may well prefer to limit the internal battery to 80%, as this can increase the usable lifespan of lithium batteries compared with letting them remain charged to full capacity for extended periods of time.
However, the first step towards getting any of this working is obviously to see how the Pinephone with it's new keyboard attachment behaves in it's default configuration whilst running OpenBSD.
Using the correct charging port
IMPORTANT SAFETY ADVISORY:
The keyboard has it's own USB type C connector, which is supposed to be used instead of the handset's own internal USB type C connector for charging whilst the keyboard is connected to the handset.
Do NOT connect a power supply to the built-in USB connector on the handset whilst the keyboard is connected via the pogo pins.
Testing all combinations
For these tests, I'll be using a custom kernel configuration with the same patches I was using at the end of the last write-up. To recap, we've got RSB working, and the PMIC is recognised and configured to actually charge the phone's internal battery when connected to AC power. Temperature monitoring is enabled, and is hopefully working well enough that the device won't burst into flames on a whim.
Obviously we don't expect to see any data reported from the second battery at this point, but we can at least see whether it's working by looking at the charging and discharging current indications in four different scenarios. The Pinephone keyboard has a button to enable and disable it, and we can have external AC power connected or disconnected, so there are four combinations:
Four combinations
AC present
AC disconnected
Keyboard battery enabled
1
2
Keyboard battery disabled
3
4
With AC power connected and the keyboard battery enabled, we would naturally expect the phone's internal battery to charge. Likewise, with AC power disconnected and the keyboard battery disabled, we would expect the phone to be running on it's own internal power.
One interesting observation will be to see whether the battery enables itself when AC power is connected, and if it remembers it's state across disconnection and re-connection of AC power.
Starting with with AC power disconnected, and the keyboard battery enabled, we get a fairly high charging current of 1.33A from the keyboard battery to the internal battery:
hw.sensors.axppmic0.current0=0.72 A (battery charging current)
hw.sensors.axppmic0.current1=0.00 A (battery discharging current)
hw.sensors.axppmic0.amphour0=0.00 Ah (battery maximum capacity), WARNING
hw.sensors.axppmic0.amphour1=0.00 Ah (battery current capacity), WARNING
hw.sensors.axppmic0.indicator0=On (ACIN), OK
hw.sensors.axppmic0.indicator1=On (VBUS), OK
hw.sensors.axppmic0.indicator2=On (battery present), OK
hw.sensors.axppmic0.indicator3=On (battery charging), OK
hw.sensors.axppmic0.percent0=71.00% (battery percent), OK
The charging current is higher than I had expected, considering that the power supply is just a regular spare USB-A connector on my workstation. The Pinephone only charged at about 0.29A from the same USB port when connected directly to it before.
Pressing the button the keyboard to enable the battery didn't change anything, as presumably it's already enabled.
hw.sensors.axppmic0.percent0=73.00% (battery percent), OK
So now the Pinephone must be running exclusively using it's own internal battery, as we've disabled the external battery and there is no AC power connected. After a while, we see:
hw.sensors.axppmic0.current0=0.71 A (battery charging current)
hw.sensors.axppmic0.current1=0.00 A (battery discharging current)
hw.sensors.axppmic0.amphour0=0.00 Ah (battery maximum capacity), WARNING
hw.sensors.axppmic0.amphour1=0.00 Ah (battery current capacity), WARNING
hw.sensors.axppmic0.indicator0=On (ACIN), OK
hw.sensors.axppmic0.indicator1=On (VBUS), OK
hw.sensors.axppmic0.indicator2=On (battery present), OK
hw.sensors.axppmic0.indicator3=On (battery charging), OK
hw.sensors.axppmic0.percent0=73.00% (battery percent), OK
So we have external AC power present, and the internal battery is charging at 0.71A, but it's not clear what the external battery in the keyboard is doing.
A quick press on the keyboard battery button, which should enable it if it's disabled, results in no change:
No significant change after trying to enable the keyboard battery
hw.sensors.axppmic0.percent0=75.00% (battery percent), OK
This is interesting.
Actual AC power is now disconnected, but the Pinephone is seeing power from the keyboard battery, which it reports as AC. This isn't unusual. However, notice now that the PMIC is not charging the internal battery despite reporting that AC is present, (which is actually power from the external keyboard battery).
Pressing the button on the keyboard enables the external battery, and the phone starts charging it's internal battery at a relatively high current:
AC disconnected, keyboard battery discharging and powering the handset
hw.sensors.axppmic0.current0=1.33 A (battery charging current)
hw.sensors.axppmic0.current1=0.00 A (battery discharging current)
hw.sensors.axppmic0.amphour0=0.00 Ah (battery maximum capacity), WARNING
hw.sensors.axppmic0.amphour1=0.00 Ah (battery current capacity), WARNING
hw.sensors.axppmic0.indicator0=On (ACIN), OK
hw.sensors.axppmic0.indicator1=On (VBUS), OK
hw.sensors.axppmic0.indicator2=On (battery present), OK
hw.sensors.axppmic0.indicator3=On (battery charging), OK
hw.sensors.axppmic0.percent0=76.00% (battery percent), OK
So connecting and then disconnecting AC definitely seems to leave the external battery active.
Actual keyboard functionality
Extra battery power is certainly welcome, but the main purpose of the keyboard is obviously to work as a keyboard.
This aspect of the hardware uses the I2C connection which is exposed via the pogo pins on the back of the Pinephone handset. OpenBSD has an ihidev driver to support HID devices such as keyboards, mice and touchscreens via I2C, and specific support for such keyboards would be provided via the ikbd driver.
These two drivers are not enabled in the kernel configuration file for the arm64 architecture by default, but since I'm using a custom kernel configuration anyway, it was easy enough to add them.
I2C devices detected, (no keyboard)
sxitwi0 at simplebus0
iic0 at sxitwi0
"goodix,gt917s" at iic0 addr 0x5d not configured
sxitwi1 at simplebus0
iic1 at sxitwi1
"st,lis3mdl-magn" at iic1 addr 0x1e not configured
"sensortek,stk3311" at iic1 addr 0x48 not configured
"invensense,mpu6050" at iic1 addr 0x68 not configured
sxitwi2 at simplebus0
iic2 at sxitwi2
Unfortunately, I was already dubious that the device would be detected. Even without these drivers compiled in, I would have expected it to have been detected as an unconfigured device connected to iic2, but instead we just see the same internal I2C devices that we saw before:
The first device, and only device connected to iic0, is the touch panel. Connected to iic1, we see the magnetometer, ambient light sensor, and gyroscope.
Obviously, getting the keyboard detected and eventually functioning is going to take a bit more work.
I did wonder if the pogo pins were actually making a reliable connection, but removing and replacing the keyboard twice didn't change anything.
Initial conclusions on the external keyboard
Looking at the keyboard overall, and remembering that I haven't had an opportunity to actually type anything on it yet, it seems like quite a nice unit. It opens all the way up, so it can lay flat on a table or other worksurface if required. It's somewhat thicker than I had expected when closed, and also slightly heavier, but neither of these issues is a particular concern.