Ubuntu Server 22.04 64 & 32-Bit Binding Error?

Hi,

I don’t know if this is a binding error or something else OS related but I just can’t get my Zymkey 4i’s working with Ubuntu Server 22.04.2 (LTS). I’ve tried both 32-Bit and 64-Bit versions and the results are the same.

For reference, the hardware I’m using is an OnLogic FR201 (effectively a CM4) with 4GB memory, no eMMC and a 64GB M.2 SSD. Here’s my high-level experience:

  • Flash a USB stick with Ubuntu Server 22.04.2 (LTS) using the Raspberry Pi Imager,
  • Boot the FR201 with said USB stick (it will boot from the USB stick if it’s there otherwise it falls back to the SSD),
  • Once the unit is up and running I SSH to the device and check that “dtparam=i2c_arm=on” is in the /boot/firmware/config.txt file,
  • After confirming this (it always is), I install the Zymbit client software:

curl -G https://s3.amazonaws.com/zk-sw-repo/install_zk_sw.sh | sudo bash

  • This runs without exceptions and then the device reboots as expected,
  • During reboot the Zymkey is rapidly flashing blue, shortly after boot completes it stops flashing completely

After the above has finished, I can’t do anything with the Zymkey (I know this is because it hasn’t completed the binding process successfully).

My problem is that I can’t find any error logs or anything that will tell me why this failed. I’ve tried with the stock pin mapping, I’ve tried moving pin GPIO4 and enabling I2C0 and rewiring the i2c pins to 27 & 28. No joy, always the same result.

Just for fun, I tried running one of the test python scripts and I got this result:

root@onlogic-ubuntu:~# python3 zk_app_utils_test.py
Exception ignored in: <function Zymkey.__del__ at 0xb667c808>
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/zymkey/__init__.py", line 231, in __del__
    raise AssertionError("bad return code %d" % ret)
AssertionError: bad return code -1
Testing data lock...
Traceback (most recent call last):
  File "/root/zk_app_utils_test.py", line 6, in <module>
    dst = zymkey.client.lock(src)
AttributeError: 'NoneType' object has no attribute 'lock'

Similarly, I tried running the following line from this guide Raspberry pi 4, Ubuntu 22.04, LUKS with fallback

zklockifs root.key > /var/lib/zymbit/key.bin.lock

And I got:

Could not read stage 1 salt file. read returned -1, errno = 9

I’m confident the issue isn’t with the device or with my physical installation of the Zymkey though because I can install the latest Raspberry Pi OS (Lite 32-Bit released 2023-02-21) and the setup works. The Zymkey binds successfully, I get the slow blinking blue LED and I can run the test scripts (zk_app_utils_test.py & zk_crypto_test.py) without any errors.

Does anyone have any ideas, or anywhere I can look for faults? If there is more information required I’m happy to provide it.

The reason I’m keen to use Ubuntu Server 22.04 rather than Raspberry OS is due to the fact it’s got long-term support and I want to use Zymkey’s for a commercial project.

I think what is going on is depending on how you flash the 22.04 image, you may or may not have a gpio group. If the group is not there, our install script adds it and adds permissions/rules. If the gpio group is there, it skips adding additional rules. I think you can fix after the fact with the following commands. Run as sudo, then reboot.

#!/bin/bash

# Modify /etc/rc.local to change the group of /etc/sys/class/gpio
grep "chown -R root:gpio" /etc/rc.local &>/dev/null
if [ $? -ne 0 ]
then
    echo "chown -R root:gpio /sys/class/gpio" >> /etc/rc.local
    echo "chmod -R ug+rw /sys/class/gpio" >> /etc/rc.local
fi
# Check for existence of udev rule
if [ ! -f "/etc/udev/rules.d/80-gpio-noroot.rules" ]
then
  echo "ACTION==\"add\", SUBSYSTEM==\"gpio\", PROGRAM=\"/bin/sh -c 'chown -R root:gpio /sys/${DEVPATH}; chmod -R g+w /sys/${DEVPATH}'\"" >> /etc/udev/rules.d/80-gpio-noroot.rules
fi

I’ll update our install script to cover both cases for jammy.

Thank you so much for the speedy reply and resolution @Bob_of_Zymbit!

I’d ended up trashing most of my test images and such so I started from scratch with a fresh 22.04 image, ran the standard zk install script and it’s working perfectly now.

Top service :raised_hands: