<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mardy (Posts about raspberrypi)</title><link>http://mardy.it/</link><description></description><atom:link href="http://mardy.it/categories/raspberrypi.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2026 &lt;a href="mailto:info@mardy.it"&gt;Alberto Mardegan&lt;/a&gt; </copyright><lastBuildDate>Sat, 11 Apr 2026 13:53:52 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>A simple cross-compiler for the Raspberry Pi</title><link>http://mardy.it/blog/2020/02/a-simple-cross-compiler-for-the-raspberry-pi.html</link><dc:creator>Alberto Mardegan</dc:creator><description>&lt;p&gt;I've recently found some use for a first-generation Raspberry Pi (Pi 1 model
B) which had been lying in a drawer since many years. A few days ago I've
installed the Raspbian distribution in it, and was about to install
&lt;a href="https://motion-project.github.io/"&gt;motion&lt;/a&gt; on it, but I stopped as soon as I
noticed that &lt;code&gt;apt&lt;/code&gt; was suggesting to bring in 1 GB worth of dependencies. Adding
&lt;code&gt;--no-install-recommends&lt;/code&gt; reduced the proposal a bit, but it was still around
700 MB -- a bit too much for my taste. I figured out that the &lt;code&gt;motion&lt;/code&gt; package
for Debian (and Raspbian) depends on MySQL, PostgreSQL, FFmpeg and what not;
so, I decided that I could probably just recompile it and disable all the stuff
I didn't need at &lt;code&gt;configure&lt;/code&gt; time.&lt;/p&gt;
&lt;p&gt;But I didn't want to install all the build dependencies and the cross-compiler in
my machine; containers exist for a reason, after all. So I had a look at the
&lt;a href="https://github.com/ubports/crossbuilder/"&gt;crossbuilder&lt;/a&gt; tool that we use in
UBports: this is a nice little shell program that uses an Ubuntu-based LXD
image to cross-compile a package after automatically fetching all its
dependencies, and installs it into an UBports device. It does some magic with
&lt;code&gt;adb&lt;/code&gt; and stuff, but I thought that the basic functionality should work with
minor modifications on any Debian-based distribution.&lt;/p&gt;
&lt;p&gt;And indeed, some hours later, I got &lt;a href="https://github.com/mardy/crossbuilder/tree/raspbian"&gt;a
branch&lt;/a&gt; where I can use
&lt;code&gt;crossbuilder&lt;/code&gt; to build packages for the Raspberry Pi. Assuming that you have
LXD properly setup, the command&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;crossbuilder --raspbian source motion
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;will cause crossbuilder to create a container and download the Debian source
package for &lt;code&gt;motion&lt;/code&gt;; at this point you can modify the source code as you see
fit, and rebuild it. I only changed the &lt;code&gt;debian/rules&lt;/code&gt; file to add a few flags
such as &lt;code&gt;--without-mysql&lt;/code&gt;, &lt;code&gt;--without-ffmpeg&lt;/code&gt;, etc.  And&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;crossbuilder --raspbian
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;is the command to run in order to perform the build. This will first download
all the dependencies (according to the &lt;code&gt;debian/control&lt;/code&gt; file), build the
package, and create a &lt;code&gt;tar&lt;/code&gt; archive containing all the generated &lt;code&gt;.deb&lt;/code&gt; files.
This archive can then be copied into the target device and unpacked there.&lt;/p&gt;
&lt;p&gt;Now, there's a small problem in that Raspbian claims to be &lt;code&gt;armhf&lt;/code&gt;, while in
fact its floating-point processor is somehow not compliant with the armhf
architecture. So, you generally cannot use an &lt;code&gt;armhf&lt;/code&gt; package from Debian or
Ubuntu on the Raspberry Pi. Given that I didn't have the time to prepare a
proper Raspbian image for LXD, I used the Debian distribution as a base
instead, and I chose to target the &lt;code&gt;armel&lt;/code&gt; architecture: this might impose some
penalties on the performance (at least for floating-point code), but it seems
to work fine on the Raspberry Pi. Unfortunately, this means that you cannot
just install the generated packages o the Pi, as &lt;code&gt;dpkg&lt;/code&gt; will complain about the
architecture mismatch (your package is &lt;code&gt;armel&lt;/code&gt;, while the distro claims to be
&lt;code&gt;armhf&lt;/code&gt;). But unpacking the debian package with&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;dpkg -x motion_&amp;lt;...&amp;gt;.deb tmp
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;will indeed give you package that you can use.&lt;/p&gt;
&lt;p&gt;I will eventually get back to this and make the script work better with
Raspbian, but this is a quick start.&lt;/p&gt;</description><category>english</category><category>informatica</category><category>kdeplanet</category><category>Linux</category><category>programmation</category><category>raspberrypi</category><category>Ubports</category><category>Ubuntu</category><guid>http://mardy.it/blog/2020/02/a-simple-cross-compiler-for-the-raspberry-pi.html</guid><pubDate>Wed, 19 Feb 2020 20:44:42 GMT</pubDate></item></channel></rss>