How to cross-compile for RasPi3 - raspberry-pi

I am currently trying to cross-compile Qt 5.7 for my Raspberry Pi 3. This is my first cross-compiling atempt, so please be kind. :)
On the Qt Wiki I found instructions for the Raspberry Pi 2, which I am currently trying to adapt.
The compile line for RasPi 2 is as follows:
./configure -release -opengl es2 -device linux-rasp-pi2-g++ -device-option \
CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- \
-sysroot ~/raspi/sysroot -opensource -confirm-license -make libs \
-prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -v
I replaced the option
-device linux-rasp-pi2-g++
by
-device linux-rpi3-g++
as I found within the raspi-tools folder.
Now I am stuck at the option
CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-
as in the ~/raspi/tools/ folder I cannot see any obviously raspi3-related entry. There is only the arm-bcm2708/ folder. Shouldn't there be some bcm2837 entry? Does that mean there is no support for RasPi 3 yet or am I missing something?
Thank you for any hints.

After much struggle (the accepted solution does not work for me), I finally got to cross compile qt 5.6 for raspberry pi 3 on ubuntu.
You basically need to follow this well known how to. Just be sure to use the following configure:
./configure -release -opengl es2 -device linux-rpi3-g++
-device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-
-sysroot ~/raspi/sysroot -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -v -nomake examples -nomake
tests -no-use-gold-linker

The arm-bcm2708/ folder is just a name. It contains several build tool chains. It's perfectly fine to use system-installed tool chains as well. So I installed the package g++-arm-linux-gnueabihf on my build machine (Debian GNU/Linux) and used this configure call:
./configure -release -opengl es2 -device linux-rpi3-g++ \
-device-option CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- \
-sysroot /home/fs/raspi/sysroot -opensource -confirm-license \
-make libs -prefix /usr/local/qt5pi -extprefix /home/fs/raspi/qt5pi \
-hostprefix /home/fs/raspi/qt5 -v

Related

Emulating Raspberry Pi 4 with QEMU?

I want to emulate Raspberry Pi 4 using QEMU, but I am not able to find any image for RPi4. I need a kernel with which QEMU can emulate a Cortex-A72.
QEMU does not have a model of the raspberry pi 4 at this time (only the 0, 1ap, 2b, 3ap and 3b). If some other machine type that QEMU does support would be good enough for you you could build a kernel for that machine type and use that. (For instance, for a lot of people all they really want is "boots a 64-bit Linux userspace" and they don't need it to really exactly match the Raspberry Pi board hardware; for those people the 'virt' board is usually a good choice.)
Whatever you do, you need to make sure that the machine type you ask QEMU to emulate matches the machine type you've built the kernel for -- if you try to boot a kernel on a board that it does not support it will not work.
I just boot raspios bullseye on a x86 ubuntu laptop, it can show the desktop, can be login in. But it's very slow.
qemu-system-aarch64 -M virt,highmem=off -smp 8 -m 2G -cpu cortex-a72 -kernel linux-stable/arch/arm64/boot/Image -append root=PARTUUID=d97f5830-02 rw console=ttyAMA0 -serial telnet:localhost:4321,server,nowait -monitor telnet:localhost:4322,server,nowait -device VGA,id=vga1 -device secondary-vga,id=vga2 -object iothread,id=io1 -device virtio-blk-pci,drive=disk0,iothread=io1 -drive data/images/2022-01-28-raspios-bullseye-arm64.img
I build the kernel image follow this guide.
https://github.com/anholt/linux/wiki/Raspberry-Pi-development-environment#building-the-Kernel
Of course, as the raspios is emulated on the x86 laptop, it's definitely slow. So, if you can virtualize it on an arm64 host, you can use the accelerator like kvm, hvf etc.
qemu-system-aarch64 \
-M virt,highmem=off,accel=hvf \
-cpu host \
-m 1G \
-smp 4 \
-kernel $KERNEL_IMAGE_PATH -append "root=/dev/vda2 rw console=ttyAMA0" \
-netdev user,id=n1,ipv6=off,hostfwd=tcp::5555-:22 -device e1000,netdev=n1 \
-hda data/images/2022-01-28-raspios-bullseye-arm64.img \
-serial telnet:localhost:4321,server,nowait \
-monitor telnet:localhost:4322,server,nowait \
-device VGA,id=vga2 \
-drive file=data/images/2021-10-30-raspios-bullseye-armhf.img,if=virtio
there is a patch here if you want.
You can compile qemu with raspi4b2g
(Patch not from me)
https://github.com/0xMirasio/qemu-patch-raspberry4.git
or try the following branch (2019), which may or maynot be patch equivalent to that already mentioned:
https://gitlab.com/philmd/qemu/-/tree/raspi4_wip

X11 problems when compiling openjdk 9 on centos 7

I find problems when I started to compile openjdk for my first time.
Below is what I did
hg clone http://hg.openjdk.java.net/jdk9/dev 9dev
cd 9dev
bash ./get_source.sh
bash ./configure
Then, I got this error message
configure: error: Could not find X11 libraries. You might be able to fix this by running 'sudo yum install libXtst-devel libXt-devel libXrender-devel libXi-devel'.
Then, I did what it told me to do.
After the installation, the same error still exists.
So I checked where the files lies on my machine
rpm -qa | grep X11
libX11-1.6.3-3.el7.x86_64
libX11-common-1.6.3-3.el7.noarch
libX11-devel-1.6.3-3.el7.x86_64
rpm -ql libX11-1.6.3-3.el7.x86_64
/usr/lib64/libX11-xcb.so.1
/usr/lib64/libX11-xcb.so.1.0.0
/usr/lib64/libX11.so.6
/usr/lib64/libX11.so.6.3.0
so i tried the way of specifying the X11 path
bash ./configure --x-libraries=/usr/lib64
Unfortunately, the same error still stays.
Can someone help me out of here, please?
thx
update
Thank #omajid for directing me to the log file config.log, where I found that the configure is using the gcc in my linuxbrew installation.
configure:56234: /data/alex/git/brew/bin/g++ -o conftest conftest.cpp -lX11 >&5
/data/alex/git/brew/bin/ld: cannot find -lX11
collect2: error: ld returned 1 exit status
configure:56234: $? = 1
So after I exported my c compiler to the system one, the problem was fixed.
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
Here is the relevant packages needed at build time and the configure flags I use in my spec file for building unofficial OpenJDK 9 packages for Fedora/EPEL:
autoconf
automake
alsa-lib-devel
binutils
cups-devel
desktop-file-utils
fontconfig
freetype-devel
elfutils
giflib-devel
gcc-c++
gdb
gtk2-devel
lcms2-devel
libjpeg-devel
libpng-devel
libxslt
libX11-devel
libXi-devel
libXinerama-devel
libXt-devel
libXtst-devel
nss-devel
pkgconfig
xorg-x11-proto-devel
zip
java-1.8.0-openjdk-devel
bash ../configure \
--with-boot-jdk=/usr/lib/jvm/java-1.8.0-openjdk/ \
--with-native-debug-symbols=internal \
--enable-unlimited-crypto \
--with-zlib=system \
--with-libjpeg=system \
--with-giflib=system \
--with-libpng=system \
--with-lcms=system \
--with-stdc++lib=dynamic \
--disable-javac-server \
--disable-warnings-as-errors
In any case, the error messages produce by configure are a best guess. You should take a look at config.log to see what test actually failed and what the error messages are. In this case, it looks like you are probably missing one of several X11 libraries. Possibly libXinerama-devel.
If this still doesn't fix your error, please paste the error messages from your autoconf log file (should be named config.log or configure.log, I forget).

How build 64-bit version of libpq from source code?

I'm trying connect to PostgreSQL from C-code, and i have to build libpq from source, because i'm on AIX. I followed the steps in this comment
Where do i get libpq source?
but in result i got a 32-bit version of libpq.a, how build 64-bit version?
Compiling on AIX is harder than on other platforms...
Always create a script which you gradually improve till you get a working version. Possible start:
#!/bin/sh
#assuming gcc
GCCLIB=$(dirname $(gcc -maix64 -pthread -print-file-name=libgcc_s.a))
export CFLAGS='-maix64 -mtune=native -pthread'
export CPPFLAGS='-D_GNU_SOURCE -D_XOPEN_SOURCE=500 -D_ALL_SOURCE'
export LDFLAGS="-maix64 -Wl,-brtl -Wl,-blibpath:/usr/local/lib64:${GCCLIB}:/usr/lib -L/usr/local/lib64 -pthread"
export OBJECT_MODE=64
./configure --prefix=/usr/local \
--libdir=/usr/local/lib64 \
--enable-shared \
--enable-static \
2>&1 | tee log.configure
make all 2>&1 | tee log.make.all
make install 2>&1 | tee log.make.install
The -q64 compiler option enables 64 bit (there is info in the compiler docs)
A quick google search of xlC 64 bit gives this link which you might find helpful.
http://northstar-www.dartmouth.edu/doc/ibmcxx/en_US/doc/complink/tasks/tubld64a.htm

GRUB2 + VESA BIOS Extensions / VBE broken?

Whereas I did get my earlier problem with building proper boot images fixed, I've been struggling with another GRUB2-related problem for most of the day.
The problem is that even though I do set the video info request bit in my multiboot header, GRUB2 does not return proper VESA BIOS Extensions (VBE) info.
The kernel is my own work, and it's noteworthy that it Used to Work (TM) with some earlier version of GRUB2 (I could fill the screen with white pixels, no problem).
Here's my current grub.cfg:
set timeout=10
set default=0
menuentry "zero" {
set gfxmode=1024x768x24
set gfxpayload=keep
insmod vbe
insmod gfxterm
multiboot /kern
}
And here's the script I use to build my boot images:
echo Building kernel
./build.sh
echo Creating bootable CD image...
cp zero cdimg2/kern
grub-mkimage --format=i386-pc --output=core.img \
--config="cdimg2/boot/grub/grub.cfg" loadenv biosdisk \
part_msdos part_gpt fat ntfs \
ext2 ntfscomp iso9660 loopback search linux boot \
minicmd cat cpuid chain \
halt help ls reboot echo test configfile normal sleep \
memdisk tar font \
gfxterm gettext true vbe vga video_bochs video_cirrus \
multiboot multiboot2
cat /usr/lib/grub/i386-pc/cdboot.img core.img > \
cdimg2/grub.img
genisoimage -A "ZERO" -input-charset "iso8859-1" -R -b \
grub.img -no-emul-boot \
-boot-load-size 4 -boot-info-table -o cd.iso cdimg2

How can build postgresql with LOCK_DEBUG enabled?

I have been strugglling to build posqlgresql 9.1 with trace_locks on so I can check the memory addresses used by the locks, but after a couple of days effort, I still haven't made any progress.
to compile:
./configure --prefix=/usr/local/pgsql --enable-depend --enable-cassert --enable-debug
make
make install
According to postgresql documentation, LOCK_DEBUG should be set at compile time,
./configure --prefix=/usr/local/pgsql --enable-depend --enable-cassert --enable-debug LOCK_DEBUG='on'
but it doesn't seem like working.
Please help! Thanks!!!
I think you just want to get -DLOCK_DEBUG into the compiler flags, try it like this:
./configure \
--prefix=/usr/local/pgsql \
--enable-depend --enable-cassert \
--enable-debug \
CPPFLAGS='-DLOCK_DEBUG'
I added the backslashes to make it easier to read, you can use this if you want it all in one line:
./configure --prefix=/usr/local/pgsql --enable-depend --enable-cassert --enable-debug CPPFLAGS='-DLOCK_DEBUG'
You can find examples of similar things in the installation documentation, just search for "CFLAGS":
You can specify environment variables on the configure command line, for example:
./configure CC=/opt/bin/gcc CFLAGS='-O2 -pipe'