Friday, May 25, 2018

iPhone 6 Bending Issue is Known by Apple

Apple claimed that iPhone 6 bending is not an issue. (read here, 2014 news)

Not true. Apple knows that it is an issue. read here.


Wednesday, May 16, 2018

Compile Raspberry Pi Desktop Linux Kernel

Compile Raspberry Pi Desktop Linux Kernel



What is Raspberry Pi Desktop? Raspberry Pi Desktop is Raspbian OS, a Debian Linux specially made for Raspberry Pi. The desktop version is a port on x86, made it a lightweight desktop OS. (Note: RPi is an ARM platform)

Since RPi Desktop is Linux. This is a simple tutorial on how to compile Linux kernel.
There are many reasons why you need to recompile the linux kernel, but before you compile, you should know that recompile kernel need a lot of hard disk space (10Gb) and long waiting time (4 hours, depends on the machines).

1. Prerequisites to compile kernel
1b. Update firmware
2. Download the source
3. Kernel configuration
4. compile
5. install

Prerequisites



# apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc


Update firmware



# rpi-update (update firmware and kernel source?)


Download kernel source


Original Linux kernel from http://kernel.org/, Raspbian kernel source can be git clone from git://github.com/raspberrypi/linux.git. The clone size (with history) is quite large (about 3-4Gb), to save time and disk space use shallow clone (git 1.7 or above).

$ cd /usr/src
# git clone --depth 1 git://github.com/raspberrypi/linux.git (about 1.5Gb)
(The version I get 4.14.37.)
# cd linux; make nconfig
(or you can use the old # make menuconfig)

Configuration


The is the most difficult part, different machine, different user may need different configuration. The configuration will be save as .config file. There is a copy of the kernel config in /boot/config-. Can use it as a reference.
There are few thousands of items to be configured, I don't know all of them.
Compile
After configuration.

# make bzImage
# make modules
# make modules_install

(This will take a long time, may be 2-6 hours)

Installation


# make install

This will copy the kernel image to /boot directory, create the initrd image and update grub bootloader.
After this you can reboot, see if you can boot the new kernel successfully.

Sunday, February 11, 2018

Compile PHP PostgreSQL undefined symbol lo_lseek64() error

Upgrade PHP with PostgreSQL connect support


My php installed on OS X doesn't have PostgreSQL connect support, I need an upgrade.
$ brew install php56 --with-postgresql [--with-httpd]
doesn't work for my, so I try to compile manually from source.
Download the source from php.net. For PREFIX, you can set it to your preferred location, the /usr/local/Cellar location is used by Homebrew.

$ ./configure --prefix=/usr/local/Cellar/php/7.2.2 --with-pgsql=/usr/local/Cellar/postgres/10.2

This compile successfully, but I am not replacing the old php on the system, the apache always load the old php version. I need libphp.so (libphp5.so or libphp7.so) for apache to locate the new php.


$ ./configure --prefix=/usr/local/Cellar/php/7.2.2 --with-pgsql=/usr/local/Cellar/postgres/10.2 --with-apxs2=`which apxs`
(apxs command is from Apache)
This fail.
There are 3 groups of undefined symbols

1. undefined symbol _lo_lseek64()
- error from PostgreSQL, some issue with the configuration, I link it to libpq.a to solve.
2. undefined symbol _SSL_XXX
- link openssl-1.1, which is an older version on my system
3. Disable GSSAPI on Postgresql
- $ brew edit postgresql, delete --with-gssapi
- $ brew reinstall postgresql

You might not experience all the 3 issues.
How to link the missing library?
$ edit php-7.2.2/Makefile
For a quick hack, I just add in MH_BUNDLE_FLAGS =
either -L/usr/local/Cellar/postgresql/10.2 -lpq or /usr/local/Cellar/postgresql/10.2/lib/libpq.a
openssl
-L/usr/local/Cellar/openssl@1.1/lib -lcrypto -lssl
or
/usr/local/Cellar/openssl@1.1/lib/libcryptio.a /usr/local/Cellar/openssl@1.1/lib/libssl.a

My system is Mac OS X 10.9 Mavericks, Homebrew. I have tried compiling php-5.6 and php-7.2, both seems ok for me. I try php7.
$ ./configure --prefix=/usr/local/Cellar/php72/7.2.2_13 --with-mysqli=/usr/local/Cellar/mysql/5.6.25/bin/mysql_config --with-pdo-mysql=/usr/local/Cellar/mysql/5.6.25 --with-pgsql=/usr/local/Cellar/postgresql/10.2 --with-pdo-pgsql=/usr/local/Cellar/postgresql/10.2 --with-apxs2=`which apxs`
$ cp libs/libphp7.so /usr/local/libexec

$ edit /etc/apache2/httpd.conf
# LoadModule php5_module libexec/apache2/libphp5.so
LoadModule php5_module /usr/local/libexec/libphp5.so
LoadModule php7_module /usr/local/libexec/libphp7.so

$ sudo apachectl stop
$ sudo apachectl -M
...
rewrite_module (shared)
php5_module (shared)
php7_module (shared)
hfs_apple_module (shared)
Syntax OK
$ sudo apachectl start
$ curl http://localhost/php/phpinfo.php
()

PHP Version 7.2.2

PostgreSQL Support enabled