mincrmatt12 / elan-spi-fingerprint

prototype linux driver for elantech spi-based fingerprint sensors
39 stars 4 forks source link

Asus VivoBook S15 sensor testing #1

Open markkuit opened 4 years ago

markkuit commented 4 years ago

Thanks for putting your time and effort into this project!

As the title states, I've got an Asus VivoBook S15 with an ElanTech fingerprint sensor and I've tested your prototype. Placing the custom udev rule and triggering a reload successfully spawned the wanted devices in /dev/, which I had to manually pass as arguments to the prototype binary or it would stick to Failed to detect SPI or HID!. I could then successfully format the resulting data into a fingerprint image with the Python tool. Is there any way to test all of this for system unlocking already?

I'm attaching some more information about the machine (can provide the resulting files privately if needed), and I'll be glad to provide more as needed.

Distro: Manjaro Linux Kernel: 5.7.19-2-MANJARO x86_64 Machine type: Laptop System: ASUSTeK VivoBook_ASUSLaptop X530FN_S530FN Mobo: ASUSTeK X530FN udevadm_spidev0.0.txt udevadm_hidraw0.txt

mincrmatt12 commented 4 years ago

Thanks for the report!

If the prototype works and the python utility dumps an image, then there's a good chance that the prototype libfprint driver will for you. I've made a branch of the current one (which only checks for one touchpad ID) over on the elan-spi-s530fn branch of mincrmatt12/libfprint which should work for your laptop. Make sure you build it with all drivers enabled (meson build -D drivers=all) since the new elanspi driver isn't enabled by default.

Because libfprint doesn't really do well with small image size sensors I've used the same trick that the USB elantech drivers do which is to treat the sensor as a swipe-style sensor to get a bigger image, so I'd recommend reading the comments in the README here (specifically the parts about good/bad images).

If the libfprint examples seem to work you should be able to build fprintd normally and use that to login.

gadgetreviews commented 3 years ago

I have 2 Asus Vivobook laptops which have same ELAN fingerprint sensors.

Asus Vivobook F510UA Asus Vivobook S510UN

Both running same OS: OS: Ubuntu 20.04 LTS Kernel: 5.4.0-58

I can see devices as: /sys/bus/spi/devices/spi-ELAN7001:00 which is a symbolic link to /sys/devices/pci0000:00/0000:00:1e.2/pxa2xx-spi.3/spi_master/spi0/spi-ELAN7001:00

So, what is the project status? Can I use this driver for my fingerprint sensor? Where should I start? How can I help you for the development? Thanks

mincrmatt12 commented 3 years ago

You should be able to try using the prototype.

First, find the VID/PID numbers for your touchpad. You can either find these on windows (in device manager) or by looking at the symlinks in /sys/class/hidraw; one of them should be pointing at an I2C device and have the VID:PID combo in the path (e.g. /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-6/i2c-ELAN1300:00/0018:04F3:3087.0001 is for VID 04F3 and PID 3087)

You've already got the ACPI ID for your sensor (ELAN7001) which is the default in the repo. Update these values in proto/hkeyvalue.h to what you found earlier and compile the prototype. You can do that by going into the proto folder, making a new folder called build, going into that folder and running cmake .. && make. If this doesn't work, make sure you have the cmake, build-essential and libudev-dev packages installed.

If it compiles properly, make sure you have the spidev kernel driver installed (it is on your kernel by default) and that it's loaded for the fingerprint device. If you're not sure you can try using the udev rules in udev/99-elan-spi.rules by copying it into /etc/udev/rules.d and running sudo udevadm trigger.

In theory once you do all that you can run the prototype by going into the proto/build folder you made and running sudo ./prototype udev. It should output a bunch of information, ask for a path to output a fingerprint image, and then wait for you to put your finger on the sensor.

If all that works, you can either try using the python script tool/printdump.py here to see if the image looks correct, or try using my libfprint fork here (making sure to again modify the VID/PID constants in libfprint/driver/elanspi.h) which might even allow you to use the sensor to login.

Vvamp commented 3 years ago

I tried doing what you stated in your comment and it all worked for me(running the prototype udev and then looking at the image with tool/printdump.py. For anyone else trying, you can test your output by calling python printdump.py <prototype_output> <destination_jpeg1> <destination_jpeg2>. I didn't find the usage on that so I had to fiddle around for a bit. I'm far from experienced in this field, so I probably overlooked a lot.

However I then tried to use your libfprint fork and I wanted to try the img-capture in the examples folder. So I made a 'build' directory, ran meson . build and then ninja -C build. After installing some dependencies it compiled nicely. However running the img-capture program(and the enroll program etc) all gave me the error 'no driver found for usb device'.

Can you tell me what I am doing wrong here? I am quite out of my comfort zone with testing this, but I'd love to help with testing. I am on an Asus VivoBook pro 15, but the sensor is the exact same as stated above

mincrmatt12 commented 3 years ago

Hi!

Given that the prototype worked without modifications, you probably just didn't end up compiling libfprint with the driver enabled. Try generating the build directory with meson . build -D drivers=all and recompiling.

nosemeocurrenada commented 3 years ago

Hi

I'm on an Asus S510UQ/Ubuntu 20.04. The ACPI ID is ELAN7001, and the VID:PID pair is 04F3:3057.

The prototype on this repo worked fine, but had to add the rules to /etc/udev/rules.d/, altough I never disabled the spidev driver or any driver for that matter.

Then I've built freedesktop/libfprint, there was an non obvious build dependency: The error

libfprint/meson.build:344:4: ERROR: Dependency "gobject-introspection-1.0" not found, tried pkgconfig and cmake

was solved by installing the package libgirepository1.0-dev

Once I was done with building that, and got with terms with the fact that I didn't compile the correct code, I've built your fork (the branch elan-spi) without further issues.

Then I tried to run libfprint/build/examples/img-capture, and got some confusing results:

In hopes of giving it a quick fix I looked at the code and found a hack, so I add one log and rebuilt:

$ git diff
diff --git a/libfprint/drivers/elanspi.c b/libfprint/drivers/elanspi.c
index c6414dd..66b0a27 100644
--- a/libfprint/drivers/elanspi.c
+++ b/libfprint/drivers/elanspi.c
@@ -630,6 +630,7 @@ static void elanspi_init(FpiDeviceElanSpi *self, GError **err) {
                                if ( ((raw_height != 0x40) || (raw_width != 0x58)) &&
                                     ((raw_height != 0x50) || (raw_width != 0x50)) ) {
                                        // Old sensor hack??
+                                       g_debug("Using the old sensor hack");
                                        self->sensor_width = 0x78;
                                        self->sensor_height = 0x78;
                                        self->sensor_ic_version = 0;

And the program actually goes through this line.

So this is the output:

(process:35231): libfprint-elanspi-DEBUG: 18:26:30.541: 18586571551: ../libfprint/drivers/elanspi.c:1008
(process:35231): libfprint-elanspi-DEBUG: 18:26:30.541: Beginning init
(process:35231): libfprint-elanspi-DEBUG: 18:26:30.542: SPIStatus = 80
(process:35231): libfprint-elanspi-DEBUG: 18:26:30.542: Raw sensor dimensions 96x0
(process:35231): libfprint-elanspi-DEBUG: 18:26:30.542: Using the old sensor hack
(process:35231): libfprint-elanspi-DEBUG: 18:26:30.542: Found sensor ID 0 => [eFSA120S] (120 x 120)
(process:35231): libfprint-elanspi-DEBUG: 18:26:30.546: Calibrating sensor
^C^C^CTerminated

The SPIStatus line sometimes displays 81

And I've just found something amazing: If I have my finger in the touchpad, not even near the sensor, it actually finds the correct sensor and dimensions!

(process:35338): libfprint-elanspi-DEBUG: 18:32:38.639: 18954669155: ../libfprint/drivers/elanspi.c:1008
(process:35338): libfprint-elanspi-DEBUG: 18:32:38.639: Beginning init
(process:35338): libfprint-elanspi-DEBUG: 18:32:38.639: SPIStatus = 81
(process:35338): libfprint-elanspi-DEBUG: 18:32:38.640: Raw sensor dimensions 96x96
(process:35338): libfprint-elanspi-DEBUG: 18:32:38.640: Found sensor ID 6 => [eFSA96SA] (96 x 96)
(process:35338): libfprint-elanspi-DEBUG: 18:32:38.645: Calibrating sensor
(process:35338): libfprint-elanspi-DEBUG: 18:32:38.749: mean value 1 = 413
(process:35338): libfprint-elanspi-DEBUG: 18:32:38.799: calibration ok at 0

Just checked and the prototype doesn't have this last issue.

mincrmatt12 commented 3 years ago

Alright, that's a little bizzarre. Probably has something to do with power management, I'd guess. What happens if you add a call to elanspi_do_swreset right at line 590 of libfprint/drivers/elanspi.c? something like

--- a/libfprint/drivers/elanspi.c
+++ b/libfprint/drivers/elanspi.c
@@ -587,6 +587,7 @@ static void elanspi_init(FpiDeviceElanSpi *self, GError **err) {
        g_debug("SPIStatus = %.2x", spistatus);

        elanspi_do_hwreset(self, err);
+       elanspi_do_swreset(self->spi_fd, err);
        if (*err) return;

        guint8 raw_height = elanspi_read_height(self->spi_fd, err);
nosemeocurrenada commented 3 years ago

I've tested it three times in every order (software then hardware, and hardware then software) In both cases it solves the issue.

mincrmatt12 commented 3 years ago

Interesting. This is just adding yet more evidence to the pile that "hwreset does nothing and was a red herring in the win driver" but for now I'll just leave both in there. My current hypothesis is that the hwreset only does something right after a cold boot (or, from the newer driver, has something to do with ESD recovery?)

arnavgr commented 2 years ago

I tried doing what you stated in your comment and it all worked for me(running the prototype udev and then looking at the image with tool/printdump.py. For anyone else trying, you can test your output by calling python printdump.py <prototype_output> <destination_jpeg1> <destination_jpeg2>. I didn't find the usage on that so I had to fiddle around for a bit. I'm far from experienced in this field, so I probably overlooked a lot.

However I then tried to use your libfprint fork and I wanted to try the img-capture in the examples folder. So I made a 'build' directory, ran meson . build and then ninja -C build. After installing some dependencies it compiled nicely. However running the img-capture program(and the enroll program etc) all gave me the error 'no driver found for usb device'.

Can you tell me what I am doing wrong here? I am quite out of my comfort zone with testing this, but I'd love to help with testing. I am on an Asus VivoBook pro 15, but the sensor is the exact same as stated above

do i have to copy the script as it is or do i have edit the destination and protoype output. If so wat should the prototype output be?

mincrmatt12 commented 2 years ago

If you want to test something now, I'd recommend just working off of the actual libfprint source on gitlab which is where the maintained version of this driver is merged. If your sensor isn't detected by that then file an issue there.

arnavgr commented 2 years ago

If you want to test something now, I'd recommend just working off of the actual libfprint source on gitlab which is where the maintained version of this driver is merged. If your sensor isn't detected by that then file an issue there.

do i just clone this and menson build -D drivers=all; cd build; ninja; sudo ninja install or do i have to git checkout mincrmatt12/elan-spi-new before installing? Also do i have to build prototype before installing libfprint?

mincrmatt12 commented 2 years ago

no, it has been merged into master. Just build master with all drivers enabled, and install it -- or wait until whatever distro you uses incorporates libfprint 1.94 which has the driver as well (ubuntu 22.04 for example is supposed to include it)

arnavgr commented 2 years ago

no, it has been merged into master. Just build master with all drivers enabled, and install it -- or wait until whatever distro you uses incorporates libfprint 1.94 which has the driver as well (ubuntu 22.04 for example is supposed to include it)

does arch(kde plasma) support it?

mincrmatt12 commented 2 years ago

https://repology.org/project/libfprint/versions

arnavgr commented 2 years ago

ok i got everything working . the only problem being that my fingerprint is not being matched at login

AKgit834 commented 1 year ago

There are not devices listed in sys/bus/spi/devices eventhough i have a fingerprint reader please tell me how i can fix this issue.

AKgit834 commented 1 year ago

I am on asus vivobook x515 and after enrolling the fingerprint when i tried to verify it says "fingerprint not verified" and because of that i was not able to login in my pop os and had to clean install it. Please help how I can fix this problem.

gazella-nqn commented 9 months ago

Hi guys! i was reading the whole thread. i am not a programmer. i would like to know if anyone has a video or something to follow the steps but i would like to get my FingerPrint (Asus S510U) working. I've been doing steps and steps for more than 5 tutorials and I can't get anything.

ayusc commented 7 months ago

Hi guys! i was reading the whole thread. i am not a programmer. i would like to know if anyone has a video or something to follow the steps but i would like to get my FingerPrint (Asus S510U) working. I've been doing steps and steps for more than 5 tutorials and I can't get anything.

Hi you you follow this guide here if you are stuck somewhere i will help you.

gazella-nqn commented 7 months ago

Hi guys! i was reading the whole thread. i am not a programmer. i would like to know if anyone has a video or something to follow the steps but i would like to get my FingerPrint (Asus S510U) working. I've been doing steps and steps for more than 5 tutorials and I can't get anything.

Hi you you follow this guide here if you are stuck somewhere i will help you.

I will try it! thank you very much for your kindness.

ayusc commented 7 months ago

Hi guys! i was reading the whole thread. i am not a programmer. i would like to know if anyone has a video or something to follow the steps but i would like to get my FingerPrint (Asus S510U) working. I've been doing steps and steps for more than 5 tutorials and I can't get anything.

Hi you you follow this guide here if you are stuck somewhere i will help you.

I will try it! thank you very much for your kindness.

Sorry, I forgot to tell you everything here have been merged to the master branch of libfprint download the latest release from https://gitlab.freedesktop.org/libfprint/libfprint/-/releases and inside the folder run

meson build -D drivers=all
cd build
meson compile

Then, inside the build directory run sudo meson install or sudo ninja install

Check if it's working or not inside the build directory cd examples

Run sudo ./img_capture it will show a lot of spam text on the screen swipe your finger in circular motion on the fingerprint sensor it will take some time to capture. Finally you can view the captured image with display finger.pgm