Cross building bluez-5.46-1 for ARMHF
bluez is an interesting beast, requiring about 10 additional libraries to build if your building without a build system like dpkg-buildpackage.
Back Story: Last week I gave up cable TV (save yourself $100!!) to pursue more Linux projects to come up to speed with the community. I love PocketCHIP and RaspberryPi 3 this year. I want so many other linux gadgets (Voder, ReSpeaker V2 to name a few) I think I need to master a few before looking much further. The one constant with these small platforms is hindered by the ability to debug easily and effectively. I’ve been actually working on a MIPSEL platform for 4 months and gdbserver interferes to much with our app, its slow. But to install GDB would require to many dependencies and we only have 95MB of free space. Ideally a statically linked GDB would possibly work. For now we (our team) will rely on static code checking, gdbserver, and gdb-multiarch.
Truly the Debian community have engineered wonderful solutions to the problems of multi-platform building.
I still need pbuilder to work on stretch, I will work that out today. Once I do, I will then be able to provide ‘backport’ bluez packages to the debian community in the backports repository.
I need a Debian package sponsor!
How do I compile so fast?
quad core, but notice I’m not using -j4 to indicate four jobs.
look up and configure ccache for yourself.
A) First I check that the source and build system can build the package for the native architecture;
What surprised me here is that last week, I did a ‘sudo dpkg –add-architecture armhf’ and its still active. At least I will be ready to cross build bluez.
sudo apt-get build-dep bluez
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libasan3:armhf libatomic1:armhf libc6-dev:armhf libcap-ng0:armhf
libdbus-1-3:armhf libdbus-1-dev:armhf libdbus-glib-1-2:armhf libexpat1:armhf
libffi6:armhf libgcc-6-dev:armhf libgcrypt20:armhf libglib2.0-0:armhf
libgomp1:armhf libgpg-error0:armhf libical2:armhf libicu57:armhf
liblz4-1:armhf libpcre16-3:armhf libpcre3-dev:armhf libpcre32-3:armhf
libpcrecpp0v5:armhf libstdc++-6-dev:armhf libstdc++6:armhf libsubunit0:armhf
libsystemd0:armhf libubsan0:armhf linux-libc-dev:armhf zlib1g-dev:armhf
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
check:armhf libcap-ng-dev:armhf libdbus-glib-1-dev:armhf
libglib2.0-dev:armhf libical-dev:armhf libicu-dev:armhf libsubunit-dev:armhf
The following NEW packages will be installed:
check libcap-ng-dev libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev
libical-dev libicu-dev libpcre3-dev libpcre32-3 libpcrecpp0v5 libsubunit-dev
libsubunit0 zlib1g-dev
0 upgraded, 13 newly installed, 7 to remove and 0 not upgraded.
Need to get 0 B/21.6 MB of archives.
After this operation, 30.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
B) Well at this point I just grab my source, the source is multi-platform dpkg-buildpackage ready.
wget https://github.com/eSpecialized/bluez-5.46-rpi3/archive/5.46-1.tar.gz
tar xvf 5.46-1.tar.gz
mv bluez-5.46-rpi3-5.46-1/ bluez-5.46
C) Native architecture build time.
time dpkg-buildpackage -rfakeroot -uc -b
real 1m25.610s
user 1m13.108s
sys 0m3.988s
D) Moving on to build for arm!
https://wiki.debian.org/CrossCompiling << I use this a lot
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install build-essential crossbuild-essential-armhf
sudo apt-get build-dep -aarmhf bluez
dpkg-buildpackage -rfakeroot -Tclean -d
time CONFIG_SITE=/etc/dpkg-cross/cross-config.armhf DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -aarmhf -rfakeroot -uc -b
real 1m35.282s
user 1m21.416s
sys 0m4.432s
D) Moving on to build for mipsel!
sudo dpkg --add-architecture mipsel
sudo apt-get update
sudo apt-get install build-essential crossbuild-essential-mipsel
sudo apt-get build-dep -amipsel bluez
#you must use -d to skip deps checking for cleaning.
dpkg-buildpackage -rfakeroot -Tclean -d
time CONFIG_SITE=/etc/dpkg-cross/cross-config.mipsel DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -amipsel -rfakeroot -uc -b
real 1m47.038s
user 1m34.288s
sys 0m4.996s
Results are three platforms all ready to install
bill@BillsStretch:~/crossBuildArm/bluez-5.46$ ls ../*amd64.deb ; ls ../*armhf.deb ; ls ../*mipsel.deb
../bluez_5.46_amd64.deb ../bluez-hcidump_5.46_amd64.deb ../libbluetooth3 dbg_5.46_amd64.deb
../bluez-cups_5.46_amd64.deb ../bluez-obexd_5.46_amd64.deb ../libbluetooth-dev_5.46_amd64.deb
../bluez-dbg_5.46_amd64.deb ../libbluetooth3_5.46_amd64.deb
../bluez_5.46_armhf.deb ../bluez-hcidump_5.46_armhf.deb ../libbluetooth3-dbg_5.46_armhf.deb
../bluez-cups_5.46_armhf.deb ../bluez-obexd_5.46_armhf.deb ../libbluetooth-dev_5.46_armhf.deb
../bluez-dbg_5.46_armhf.deb ../libbluetooth3_5.46_armhf.deb
../bluez_5.46_mipsel.deb ../bluez-hcidump_5.46_mipsel.deb ../libbluetooth3-dbg_5.46_mipsel.deb
../bluez-cups_5.46_mipsel.deb ../bluez-obexd_5.46_mipsel.deb ../libbluetooth-dev_5.46_mipsel.deb
../bluez-dbg_5.46_mipsel.deb ../libbluetooth3_5.46_mipsel.deb
What comes after this?
I’ve documented cross building. Unfortunately this won’t work for your old Jessie Raspberry Pi Rasbian. If you have stretch then yes it will work. I won’t release the packages I just built until I get pbuilder up and running.
Well I will need to setup pbuilder, and setting up a debian repo for testing with. Finally getting a sponsor to provide backports.
Test out bluez 5.46 for stability. My PocketCHIP had a corrupt NAND cell (or 2). It has been re-flashed, so I will test out this build on the chip AFTER I test 5.23 with a2dp and BLE.
What is backports?
Debian backports allow you to use new software on older systems like Jessie. That or you are left with just doing what I did here. Unfortunately bluez is not in that pool of packages.
What is pbuilder?
it allows a clean room environment to build package, thus ensuring a minimal package dependency build on your target platform, and a properly built one at that. Notice that I’m using a fakeroot, but that isn’t quite the same. You still get all the packages and dependencies on my system (and Debian Stretch) that were used to build the packages.
pbuilder lets me target OS’s like Jessie and further back.