Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues after installation and tests looking good #1

Open
ma-wagner opened this issue Jan 29, 2022 · 10 comments
Open

Issues after installation and tests looking good #1

ma-wagner opened this issue Jan 29, 2022 · 10 comments

Comments

@ma-wagner
Copy link

ma-wagner commented Jan 29, 2022

Hi,
i have install this extension on a Raspberry Pi and the "make test" looking good.

Is there an issue with this line?

Warning: PHP Startup: Unable to load dynamic library 'spi.so' (tried: /home/pi/ext-spi/modules/spi.so (/home/pi/ext-spi/modules/spi.so: undefined symbol: zend_class_unserialize_deny), /home/pi/ext-spi/modules/spi.so.so (/home/pi/ext-spi/modules/spi.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Now i have insert the extension in the php.ini with "extension=/home/pi/ext-spi/modules/spi.so" but the extension isn't loaded. I have look at "php -m".
Is there a sample of code how to use and insert the class into an php-script.

Sorry for that beginner-questions but i'm stucking for days on that point.

result of my "make test":

Build complete.
Don't forget to run 'make test'.


=====================================================================
PHP         : /usr/bin/php8.0 
PHP_SAPI    : cli
PHP_VERSION : 8.0.15
ZEND_VERSION: 4.0.15
PHP_OS      : Linux - Linux raspberrypi 5.10.63-v7+ #1496 SMP Wed Dec 1 15:58:11 GMT 2021 armv7l
INI actual  : /home/pi/ext-spi/tmp-php.ini
More .INIs  :   
---------------------------------------------------------------------
PHP         : /usr/bin/phpdbg8.1 
PHP_SAPI    : phpdbg
PHP_VERSION : 8.1.2
ZEND_VERSION: 4.1.2
PHP_OS      : Linux - Linux raspberrypi 5.10.63-v7+ #1496 SMP Wed Dec 1 15:58:11 GMT 2021 armv7l
INI actual  : /home/pi/ext-spi/tmp-php.ini
More .INIs  : 
Warning: PHP Startup: Unable to load dynamic library 'spi.so' (tried: /home/pi/ext-spi/modules/spi.so (/home/pi/ext-spi/modules/spi.so: undefined symbol: zend_class_unserialize_deny), /home/pi/ext-spi/modules/spi.so.so (/home/pi/ext-spi/modules/spi.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

---------------------------------------------------------------------
CWD         : /home/pi/ext-spi
Extra dirs  : 
VALGRIND    : Not used
=====================================================================
TIME START 2022-01-29 23:23:54
=====================================================================
PASS Check if phpspi is loaded [tests/001.phpt] 
PASS Check if constants are defined [tests/002.phpt] 
PASS Test SPI\Bus::transfer on a MOSI->MISO jumper connected device [tests/transfer.phpt] 
=====================================================================
TIME END 2022-01-29 23:23:54

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   16
---------------------------------------------------------------------

Number of tests :    3                 3
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    0 (  0.0%) (  0.0%)
Tests passed    :    3 (100.0%) (100.0%)
---------------------------------------------------------------------
Time taken      :    0 seconds
=====================================================================

thanks a lot for some hints...

Martin

@flavioheleno
Copy link
Member

flavioheleno commented Feb 1, 2022

Hi @ma-wagner ! What PHP version are you using? Nevermind, just saw it from your test output.

I'll reproduce it here and get back to you ASAP!

@ma-wagner
Copy link
Author

Hi @ma-wagner ! What PHP version are you using? Nevermind, just saw it from your test output.

I'll reproduce it here and get back to you ASAP!

Thanks for your help.

@flavioheleno
Copy link
Member

I got to reproduce it and found out that you are probably facing the same issue as myself, RPi OS is installing both PHP 8.0 and 8.1, side by side.

pi@valhalla:~/ext-spi $ ls -lah /usr/bin/php*
lrwxrwxrwx 1 root root   21 Jan 11 15:43 /usr/bin/php -> /etc/alternatives/php
-rwxr-xr-x 1 root root 2.7M Jan 29 04:39 /usr/bin/php8.0
-rwxr-xr-x 1 root root 3.1M Jan 27 09:22 /usr/bin/php8.1
lrwxrwxrwx 1 root root   28 Jan 11 15:46 /usr/bin/php-config -> /etc/alternatives/php-config
-rwxr-xr-x 1 root root 4.4K Jan 29 04:39 /usr/bin/php-config8.0
lrwxrwxrwx 1 root root   24 Jan 17 10:41 /usr/bin/phpdbg -> /etc/alternatives/phpdbg
-rwxr-xr-x 1 root root 3.2M Jan 27 09:22 /usr/bin/phpdbg8.1
lrwxrwxrwx 1 root root   24 Jan 11 15:46 /usr/bin/phpize -> /etc/alternatives/phpize
-rwxr-xr-x 1 root root 4.9K Jan 29 04:39 /usr/bin/phpize8.0

The build was executed by PHP 8.0:

PHP         : /usr/bin/php8.0 
PHP_SAPI    : cli
PHP_VERSION : 8.0.15
ZEND_VERSION: 4.0.15
PHP_OS      : Linux - Linux valhalla 5.10.63-v7l+ #1488 SMP Thu Nov 18 16:15:28 GMT 2021 armv7l
INI actual  : /home/pi/ext-spi/tmp-php.ini
More .INIs  :   

The test is being executed by PHP 8.1:

PHP         : /usr/bin/phpdbg8.1 
PHP_SAPI    : phpdbg
PHP_VERSION : 8.1.2
ZEND_VERSION: 4.1.2
PHP_OS      : Linux - Linux valhalla 5.10.63-v7l+ #1488 SMP Thu Nov 18 16:15:28 GMT 2021 armv7l
INI actual  : /home/pi/ext-spi/tmp-php.ini
More .INIs  : 
Warning: PHP Startup: Unable to load dynamic library 'spi.so' (tried: /home/pi/ext-spi/modules/spi.so (/home/pi/ext-spi/modules/spi.so: undefined symbol: zend_class_unserialize_deny), /home/pi/ext-spi/modules/spi.so.so (/home/pi/ext-spi/modules/spi.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Let me figure out how to fix this :)

@flavioheleno
Copy link
Member

Ok, so I figured out that I was missing php8.1-dev and thus update-alternatives --query phpize would point to phpize8.0, which would force the build to use php8.0 instead of php8.1.

Can you ensure that you have php8.1-dev and that update-alternatives --query phpize outputs something like this:

Name: phpize
Link: /usr/bin/phpize
Slaves:
 phpize.1.gz /usr/share/man/man1/phpize.1.gz
Status: auto
Best: /usr/bin/phpize8.1
Value: /usr/bin/phpize8.1

Alternative: /usr/bin/phpize8.0
Priority: 80
Slaves:
 phpize.1.gz /usr/share/man/man1/phpize8.0.1.gz

Alternative: /usr/bin/phpize8.1
Priority: 81
Slaves:
 phpize.1.gz /usr/share/man/man1/phpize8.1.1.gz

@ma-wagner
Copy link
Author

ma-wagner commented Feb 2, 2022

Hi @flavioheleno,
so, first you are right php8.1-dev was missing. Now my output look exact like yours. But on make test i get the same and the extension still won't load:

Build complete.
Don't forget to run 'make test'.


=====================================================================
PHP         : /usr/bin/php8.0 
PHP_SAPI    : cli
PHP_VERSION : 8.0.15
ZEND_VERSION: 4.0.15
PHP_OS      : Linux - Linux raspberrypi 5.10.63-v7+ #1496 SMP Wed Dec 1 15:58:11 GMT 2021 armv7l
INI actual  : /home/pi/ext-spi/tmp-php.ini
More .INIs  :   
---------------------------------------------------------------------
PHP         : /usr/bin/phpdbg8.1 
PHP_SAPI    : phpdbg
PHP_VERSION : 8.1.2
ZEND_VERSION: 4.1.2
PHP_OS      : Linux - Linux raspberrypi 5.10.63-v7+ #1496 SMP Wed Dec 1 15:58:11 GMT 2021 armv7l
INI actual  : /home/pi/ext-spi/tmp-php.ini
More .INIs  : 
Warning: PHP Startup: Unable to load dynamic library 'spi.so' (tried: /home/pi/ext-spi/modules/spi.so (/home/pi/ext-spi/modules/spi.so: undefined symbol: zend_class_unserialize_deny), /home/pi/ext-spi/modules/spi.so.so (/home/pi/ext-spi/modules/spi.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

---------------------------------------------------------------------
CWD         : /home/pi/ext-spi
Extra dirs  : 
VALGRIND    : Not used
=====================================================================
TIME START 2022-02-02 11:53:56
=====================================================================
PASS Check if phpspi is loaded [tests/001.phpt] 
PASS Check if constants are defined [tests/002.phpt] 
PASS Test SPI\Bus::transfer on a MOSI->MISO jumper connected device [tests/transfer.phpt] 
=====================================================================
TIME END 2022-02-02 11:53:56

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   16
---------------------------------------------------------------------

Number of tests :    3                 3
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    0 (  0.0%) (  0.0%)
Tests passed    :    3 (100.0%) (100.0%)
---------------------------------------------------------------------
Time taken      :    0 seconds
=====================================================================

Output on update-alternatives --query phpize:

update-alternatives --query phpize
Name: phpize
Link: /usr/bin/phpize
Slaves:
 phpize.1.gz /usr/share/man/man1/phpize.1.gz
Status: auto
Best: /usr/bin/phpize8.1
Value: /usr/bin/phpize8.1

Alternative: /usr/bin/phpize8.0
Priority: 80
Slaves:
 phpize.1.gz /usr/share/man/man1/phpize8.0.1.gz

Alternative: /usr/bin/phpize8.1
Priority: 81
Slaves:
 phpize.1.gz /usr/share/man/man1/phpize8.1.1.gz

Output on ls -lah /usr/bin/php*:

lrwxrwxrwx 1 root root   21 Jan 29 21:42 /usr/bin/php -> /etc/alternatives/php
-rwxr-xr-x 1 root root 2.7M Jan 29 07:39 /usr/bin/php8.0
-rwxr-xr-x 1 root root 3.1M Jan 27 12:20 /usr/bin/php8.1
lrwxrwxrwx 1 root root   28 Jan 29 21:52 /usr/bin/php-config -> /etc/alternatives/php-config
-rwxr-xr-x 1 root root 4.4K Jan 29 07:39 /usr/bin/php-config8.0
-rwxr-xr-x 1 root root 4.4K Jan 27 12:20 /usr/bin/php-config8.1
lrwxrwxrwx 1 root root   24 Jan 29 21:52 /usr/bin/phpdbg -> /etc/alternatives/phpdbg
-rwxr-xr-x 1 root root 3.1M Jan 27 12:20 /usr/bin/phpdbg8.1
lrwxrwxrwx 1 root root   24 Jan 29 21:52 /usr/bin/phpize -> /etc/alternatives/phpize
-rwxr-xr-x 1 root root 4.9K Jan 29 07:39 /usr/bin/phpize8.0
-rwxr-xr-x 1 root root 4.9K Jan 27 12:20 /usr/bin/phpize8.1

So what's my fault. Sorry i don't see it and don't know what to do. Thanks for your great help.

best regards
Martin

@flavioheleno
Copy link
Member

flavioheleno commented Feb 2, 2022

Hey @ma-wagner , note that you are still building with PHP 8.0.15 and testing with PHP 8.1.2 (look at the first two blocks of your make test output.

It should look like this:

PHP         : /usr/bin/php8.1 
PHP_SAPI    : cli
PHP_VERSION : 8.1.2
ZEND_VERSION: 4.1.2
PHP_OS      : Linux - Linux valhalla 5.10.63-v7l+ #1488 SMP Thu Nov 18 16:15:28 GMT 2021 armv7l
INI actual  : /home/pi/ext-spi/tmp-php.ini
More .INIs  :   
---------------------------------------------------------------------
PHP         : /usr/bin/phpdbg8.1 
PHP_SAPI    : phpdbg
PHP_VERSION : 8.1.2
ZEND_VERSION: 4.1.2
PHP_OS      : Linux - Linux valhalla 5.10.63-v7l+ #1488 SMP Thu Nov 18 16:15:28 GMT 2021 armv7l
INI actual  : /home/pi/ext-spi/tmp-php.ini
More .INIs  : 

Note both PHP_VERSION pointing to 8.1.2.

Send the output of the commands below so I can take a look:
update-alternatives --query phpize
update-alternatives --query php-config
update-alternatives --query php

It should output something like this:

pi@valhalla:~/ext-spi $ update-alternatives --query phpize
Name: phpize
Link: /usr/bin/phpize
Slaves:
 phpize.1.gz /usr/share/man/man1/phpize.1.gz
Status: auto
Best: /usr/bin/phpize8.1
Value: /usr/bin/phpize8.1

Alternative: /usr/bin/phpize8.0
Priority: 80
Slaves:
 phpize.1.gz /usr/share/man/man1/phpize8.0.1.gz

Alternative: /usr/bin/phpize8.1
Priority: 81
Slaves:
 phpize.1.gz /usr/share/man/man1/phpize8.1.1.gz
pi@valhalla:~/ext-spi $ update-alternatives --query php-config
Name: php-config
Link: /usr/bin/php-config
Slaves:
 php-config.1.gz /usr/share/man/man1/php-config.1.gz
Status: auto
Best: /usr/bin/php-config8.1
Value: /usr/bin/php-config8.1

Alternative: /usr/bin/php-config8.0
Priority: 80
Slaves:
 php-config.1.gz /usr/share/man/man1/php-config8.0.1.gz

Alternative: /usr/bin/php-config8.1
Priority: 81
Slaves:
 php-config.1.gz /usr/share/man/man1/php-config8.1.1.gz
pi@valhalla:~/ext-spi $ update-alternatives --query php
Name: php
Link: /usr/bin/php
Slaves:
 php.1.gz /usr/share/man/man1/php.1.gz
Status: auto
Best: /usr/bin/php8.1
Value: /usr/bin/php8.1

Alternative: /usr/bin/php8.0
Priority: 80
Slaves:
 php.1.gz /usr/share/man/man1/php8.0.1.gz

Alternative: /usr/bin/php8.1
Priority: 81
Slaves:
 php.1.gz /usr/share/man/man1/php8.1.1.gz

Note that Best and Value for each query point to the 8.1 versions.

@ma-wagner
Copy link
Author

ma-wagner commented Feb 2, 2022

So here is the output:

pi@raspberrypi:~/ext-spi $ update-alternatives --query phpize
Name: phpize
Link: /usr/bin/phpize
Slaves:
 phpize.1.gz /usr/share/man/man1/phpize.1.gz
Status: auto
Best: /usr/bin/phpize8.1
Value: /usr/bin/phpize8.1

Alternative: /usr/bin/phpize8.0
Priority: 80
Slaves:
 phpize.1.gz /usr/share/man/man1/phpize8.0.1.gz

Alternative: /usr/bin/phpize8.1
Priority: 81
Slaves:
 phpize.1.gz /usr/share/man/man1/phpize8.1.1.gz
pi@raspberrypi:~ $ update-alternatives --query php-config
Name: php-config
Link: /usr/bin/php-config
Slaves:
 php-config.1.gz /usr/share/man/man1/php-config.1.gz
Status: auto
Best: /usr/bin/php-config8.1
Value: /usr/bin/php-config8.1

Alternative: /usr/bin/php-config8.0
Priority: 80
Slaves:
 php-config.1.gz /usr/share/man/man1/php-config8.0.1.gz

Alternative: /usr/bin/php-config8.1
Priority: 81
Slaves:
 php-config.1.gz /usr/share/man/man1/php-config8.1.1.gz
pi@raspberrypi:~ $ update-alternatives --query php
Name: php
Link: /usr/bin/php
Slaves:
 php.1.gz /usr/share/man/man1/php.1.gz
Status: auto
Best: /usr/bin/php8.1
Value: /usr/bin/php8.1

Alternative: /usr/bin/php8.0
Priority: 80
Slaves:
 php.1.gz /usr/share/man/man1/php8.0.1.gz

Alternative: /usr/bin/php8.1
Priority: 81
Slaves:
 php.1.gz /usr/share/man/man1/php8.1.1.gz

Why there is still 8.0 on work?

Thanks

@flavioheleno
Copy link
Member

Did you rebuild?

Run:

make clean
phpize
./configure
make
make test

@ma-wagner
Copy link
Author

ma-wagner commented Feb 2, 2022

Did you rebuild?

Oh no. This was my fault. So the test runs without errors. Sorry for that. Now is it necessary to manually insert the extension to the php.ini? Right? I insert it and php -m says that phpspi is loaded. Thats great. Do you have an php-script to test that everything is fine and how i can send some test-data.

Thank you very much for your help and sorry for my beginner-errors.

best regards

@flavioheleno
Copy link
Member

flavioheleno commented Feb 2, 2022

You can connect MOSI to MISO using a jumper wire and run this test: https://github.com/embedded-php/ext-spi/blob/main/tests/transfer.phpt

Pins 19 and 21.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants