Skip to content

Instantly share code, notes, and snippets.

@d-k-bo
Last active January 31, 2024 06:19
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save d-k-bo/15e53eab53e2845e97746f5f8661b224 to your computer and use it in GitHub Desktop.
Save d-k-bo/15e53eab53e2845e97746f5f8661b224 to your computer and use it in GitHub Desktop.
Install experimental driver for the goodix 55b4 fingerprint sensor on Ubuntu

🚧 This Document is archived.

I'm no longer using this exact setup, it is based on an old version of libfprint and further development is moving at a slow pace.

This document will still be available for further reference, but I don't plan to update it.

Install experimental driver for the goodix 55b4 fingerprint sensor on Ubuntu


🔧 This is not usable yet.

While the driver seems to work fine, the current fingerprint matching algorithm doesn't work with these devices and it may accept any finger or none. Don't use it to secure your device!


This will show you the steps to install an experimental driver for the goodix 55b4 fingerprint sensor on Ubuntu. You may have this sensor in your machine if the output of lsusb | grep fingerprint --ignore-case shows something like:

Bus 003 Device 004: ID 27c6:55b4 Shenzhen Goodix Technology Co.,Ltd. Fingerprint Reader

You can find more information on the related discord server.

These steps were tested on a Lenovo IdeaPad C340-14API using a live session of Ubuntu 21.04 (default gnome desktop) after setting a password and activating the universe repository.

⚠️ I'm not responsible for any damage to your device. Everything you do is at your own risk. You should check every code or command before running it. If you don't understand it, you shouldn't use it.

Flash custom firmware to the sensor

Goodix' fingerprint sensors use encrypted communication. We need to set a new encryption key by flashing a custom firmware to the sensor.

⚠️ If you dual-boot with windows, you should completely disable windows drivers for your fingerprint sensor, otherwise windows will reflash your sensor.

Don't run the flash script automatically on startup, flashing your sensor too often will break your sensor!

First, we need to install the dependencies (:information_source: this is somewhat untested, I might have forgotten something):

sudo apt install git python3-pip python3-crcmod
pip install pyusb

Then, we need to recursively clone the firmware repository:

git clone --recurse-submodules https://github.com/mpi3d/goodix-fp-dump.git

Now we can run a python script to flash the firmware.

sudo python3 goodix-fp-dump/run_55b4.py

You will see a warning message like this:

#######################################################
This program might break your device.
Consider that it may flash the device firmware.
Continue at your own risk.
But don't hold us responsible if your device is broken!
Don't run this program as part of a regular process.
#######################################################
Type 1855 to continue and confirm that you are not a bot:

After confirming that you read the warning, the script will flash the firmware to the sensor. It will wait for the detection of a finger on the sensor and exit. You should now be able to find a file called fingerprint.pgm in your folder which is an image of your finger. It should look a bit like this (no finger, but looks like it):

not a finger

Build and install experimental driver

We need to install the dependencies to download, build and use the experimental version of libfprint:

sudo apt install fprintd meson libgusb-dev libcairo2-dev libgudev-1.0-dev libgirepository1.0-dev libnss3-dev libssl-dev gtk-doc-tools

Then, we clone the source repository of the driver:

git clone https://github.com/TheWeirdDev/libfprint.git --branch 55b4-experimental
cd libfprint/

Now, we can configure the build system, compile the program and install it.

meson builddir -Ddoc=false -Dprefix=/usr
ninja -C builddir
sudo ninja -C builddir install

You should now be able to enroll your fingerprint using gnome settings or fprintd-enroll and use it to log into your system.

Troubleshooting

ℹ️ The following tips were mostly suggested by others and I didn't test them.

Problem Cause Solution
I can't login using my fingerprint the desktop manager may not be correctly configured try running sudo apt install --reinstall gdm3 or sudo pam-auth-update --enable fprintd
@TabForce
Copy link

TabForce commented Jul 2, 2022

Hello from Hamburg to Kiel,
I tried to get your firmware up and running but ran into a few issues:
I had to solve a few missing dependencies by
sudo apt-get install python3-usb sudo apt-get install python3-periphery sudo pip install spidev
but sudo python3 goodix-fp-dump/run_55b4.py gives me back
Traceback (most recent call last): File "goodix-fp-dump/run_55b4.py", line 1, in <module> import driver_55x4 File "/tmp/goodix-fp-dump/driver_55x4.py", line 11, in <module> import goodix File "/tmp/goodix-fp-dump/goodix.py", line 5, in <module> import protocol File "/tmp/goodix-fp-dump/protocol.py", line 10, in <module> class Protocol(abc.ABC): File "/tmp/goodix-fp-dump/protocol.py", line 13, in Protocol def __init__(self, vendor: int, product: int, timeout: float | None = 5): TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

and now I'm stuck. Can you help me out?

Thank you
Ray

@d-k-bo
Copy link
Author

d-k-bo commented Jul 3, 2022

@TabForce it looks like the current version of goodix-fp-dump requires Python 3.10 and you are using an older version. Try to install python3.10 (and all required python3.10-* dependencies) and use python3.10 instead of python3.

Note that the driver isn't ready yet and it will take a while until it can be regularly used. That's one of the reasons I didn't update this gist (I plan to do so when there is a usable version).

@TabForce
Copy link

TabForce commented Jul 3, 2022 via email

@izacarias
Copy link

Thank you for this mini-tutorial! It was able to reproduce it without errors (some packets were missing, but yeah, it was easy to fix).
Sadly as the last command fprintd-enroll did not work on my computer (Fedora Workstation 36). I got the following error:
Impossible to enroll: GDBus.Error:org.freedesktop.DBus.Error.NameHasNoOwner: Could not activate remote peer: startup job failed.
I was not able to debug yet... any advice?

Thanks

@d-k-bo
Copy link
Author

d-k-bo commented Jul 9, 2022

@TabForce Just to point it out: All of the actual work is being done by mpi3d and other great individuals. I just wrote this last year because I wanted to share my findings after compiling something from source for the first time.

@d-k-bo
Copy link
Author

d-k-bo commented Jul 9, 2022

@izacarias I'm sorry, I don't know anything about this error and couldn't reproduce it on my current machine. Some ideas:

  • Is your sensor model exactly 27c6:55b4?
  • I remember when I switched to Fedora some months ago, I had to fix some SELinux labels for it to work. You can use the troubleshooting tool to see if there is a warning when calling fprintd-enroll

@goodrussian
Copy link

Hi, what wrong in my case?

nurulinas@andy-laptop:~/goodix-fp-dump$ sudo ./add_fp_5110.sh 
#######################################################
This program might break your device.
Consider that it may flash the device firmware.
Continue at your own risk.
But don't hold us responsible if your device is broken!
Don't run this program as part of a regular process.
#######################################################
Type 3923 to continue and confirm that you are not a bot: 3923
__init__(20752, <class 'protocol.USBProtocol'>, 5)
Found Goodix device: "Goodix Fingerprint Device " from "Shenzhen Goodix Technology Co.,Ltd." on bus 3 address 3.
Found interface data: 1
Found endpoint in: 0x81
Found endpoint out: 0x1
empty_buffer()
nop()
enable_chip(True)
nop()
firmware_version()
Firmware: GF_ST411SEC_APP_12117
preset_psk_read(3137470467, None, None)
PSK: 4e1123ee4363ff5440d8e36b6a16c3ba327e2b462a3f3266258bca991c236c79
Valid PSK: True
reset(True, False, 20)
read_sensor_register(0, 4)
read_otp()
reset(True, False, 20)
mcu_switch_to_idle_mode(20)
write_sensor_register(544, b'\x18\x0c')
write_sensor_register(566, b'\xc2\x00')
write_sensor_register(568, b'\xc1\x00')
write_sensor_register(570, b'\xc1\x00')
upload_config_mcu(b'p\x11`q,\x9d,\xc9\x1c\xe5\x18\xfd\x00\xfd\x00\xfd\x03\xba\x00\x01\x80\xca\x00\x04\x00\x84\x00\x15\xb3\x86\x00\x00\xc4\x88\x00\x00\xba\x8a\x00\x00\xb2\x8c\x00\x00\xaa\x8e\x00\x00\xc1\x90\x00\xbb\xbb\x92\x00\xb1\xb1\x94\x00\x00\xa8\x96\x00\x00\xb6\x98\x00\x00\x00\x9a\x00\x00\x00\xd2\x00\x00\x00\xd4\x00\x00\x00\xd6\x00\x00\x00\xd8\x00\x00\x00P\x00\x01\x05\xd0\x00\x00\x00p\x00\x00\x00r\x00xVt\x004\x12 \x00\x10@*\x01\x02\x04"\x00\x01 $\x002\x00\x80\x00\x01\x00\\\x00\x80\x00V\x00\x04 X\x00\x03\x022\x00\x0c\x02f\x00\x03\x00|\x00\x00X\x82\x00\x80\x15*\x01\x82\x03"\x00\x01 $\x00\x14\x00\x80\x00\x01\x00\\\x00\x00\x01V\x00\x04 X\x00\x03\x022\x00\x0c\x02f\x00\x03\x00|\x00\x00X\x82\x00\x80\x1f*\x01\x08\x00\\\x00\x80\x00T\x00\x10\x01b\x00\x04\x03d\x00\x19\x00f\x00\x03\x00|\x00\x01X*\x01\x08\x00\\\x00\x00\x01R\x00\x08\x00T\x00\x00\x01f\x00\x03\x00|\x00\x01X\x00\x89.')
set_powerdown_scan_frequency(100)
request_tls_connection()
tls_successfully_established()
query_mcu_state(b'U', True)
mcu_switch_to_fdt_mode(b'\r\x01\xae\xae\xbf\xbf\xa4\xa4\xb8\xb8\xa8\xa8\xb7\xb7', True)
nav()
mcu_switch_to_fdt_mode(b'\r\x01\x80\xaf\x80\xbf\x80\xa3\x80\xb7\x80\xa7\x80\xb6', True)
read_sensor_register(130, 2)
mcu_get_image()
Traceback (most recent call last):
  File "/home/nurulinas/goodix-fp-dump/run_5110.py", line 3, in <module>
    driver_51x0.main(0x5110)
  File "/home/nurulinas/goodix-fp-dump/driver_51x0.py", line 363, in main
    run_driver(device)
  File "/home/nurulinas/goodix-fp-dump/driver_51x0.py", line 292, in run_driver
    device.mcu_get_image(b"\x01\x00",
  File "/home/nurulinas/goodix-fp-dump/goodix.py", line 215, in mcu_get_image
    return check_message_pack(self.protocol.read(), flags)
  File "/home/nurulinas/goodix-fp-dump/goodix.py", line 83, in check_message_pack
    raise ValueError("Invalid message pack")
ValueError: Invalid message pack
mogrify-im6.q16: unable to open image `fingerprint.pgm': Нет такого файла или каталога @ error/blob.c/OpenBlob/2924.
mkdir: невозможно создать каталог «fpr»: Файл существует
mv: не удалось выполнить stat для 'fingerprint.jpg': Нет такого файла или каталога

@d-k-bo
Copy link
Author

d-k-bo commented Aug 30, 2022

@goodrussian Sorry, I can't help you with that.

@naveen21553
Copy link

naveen21553 commented Oct 19, 2022

After following all these steps I am still getting "Impossible to enroll: GDBus.Error:net.reactivated.Fprint.Error.NoSuchDevice: No devices available".

naveen@Ideapad:~/Downloads/libfprint$ fprintd-enroll
Impossible to enroll: GDBus.Error:net.reactivated.Fprint.Error.NoSuchDevice: No devices available

@mvaello
Copy link

mvaello commented Oct 20, 2022

Any driver for 5740 Goodix fw model? Thanks

@d-k-bo
Copy link
Author

d-k-bo commented Oct 21, 2022

@naveen21553 Did you try to restart fprintd / your machine after flashing the firmware and installing the patched version of libfprint?

@d-k-bo
Copy link
Author

d-k-bo commented Oct 21, 2022

@mvaello AFAICT, there hasn't been any progress for this device.

@naveen21553
Copy link

@d-k-bo Yes I tried everything from restarting fprintd and rebooting the system; also tried repeating the process fresh after reinstalling system but it just won't work.

@naveen21553
Copy link

Can someone guide me on how to reverse this process, as in after reflashing firmware using this guide, I switched to windows and fingerprint reader is not working. It's detected but not working.

@d-k-bo
Copy link
Author

d-k-bo commented Nov 9, 2022

@naveen21553 you could try to reinstall your driver. In my case, Lenovo provides an installer for the fingerprint reader driver.

@ignoramus-benevolus
Copy link

ignoramus-benevolus commented Feb 6, 2023

There is more dependencies:
sudo apt-get install python3-spidev cmake valgrind python3-opencv libopencv-dev

@SugawaraKou
Copy link

Hello, how to build a driver for 5117?

@d-k-bo
Copy link
Author

d-k-bo commented Jul 9, 2023

@SugawaraKou It's not supported yet

@mar-things
Copy link

Hello, I have been looking al over the internet how to enable my goodix fingerprint sensor on my lenovo flex5. Apparently this is the only compatible driver i have found, however when I run the command: "sudo python3 goodix-fp-dump/run_55b4.py" I get the following error:

Traceback (most recent call last):
File "/home/martin/goodix-fp-dump/run_55b4.py", line 1, in
import driver_55x4
File "/home/martin/goodix-fp-dump/driver_55x4.py", line 11, in
import goodix
File "/home/martin/goodix-fp-dump/goodix.py", line 5, in
import protocol
File "/home/martin/goodix-fp-dump/protocol.py", line 5, in
import periphery
ModuleNotFoundError: No module named 'periphery'

I would really like your support on this issue, I am going crazy trying to figure out what to do.
Thank you in advance.

@d-k-bo
Copy link
Author

d-k-bo commented Aug 24, 2023

I think that the instructions in goodix-fp-dump's README aren't right, it should be sudo .venv/bin/python3 instead of sudo python3 (sudo ignores the activated venv).

However, I would strongly advise against using any of the above, unless you are interested in the low-level work needed to create these drivers.

@datend3nker
Copy link

Hello, on my side, installation workes. The thing thats keeps me away from using it, ist that the fingerprint recognizes a finger even not touching it. The moment i have my hinger on it thiks no finger present and waits. Is the Output a negertive bitmab?
If keepin finger iin sensor during isntallation, the pgm seems correct, so no erron on the sensorside...

@TheWeirdDev
Copy link

Hi,
I have updated the driver and rebased it on a newer version of libfprint. The matching is also based on the new SIGFM algorithm and provides better results. Try it and let me know how it works. The AUR package is also updated.

@datend3nker
Copy link

Seen you post in discord. Aur does not seem to be patched. Building from repo did break my boot (only gray gnome background and try not responding). Removing fpind seems to have fixed it. Will provide any information if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment