<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Buildroot on Rishav's Digital Garden</title><link>https://blog.rishavs.in/tags/buildroot/</link><description>Recent content in Buildroot on Rishav's Digital Garden</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 25 Nov 2025 19:07:00 +0000</lastBuildDate><atom:link href="https://blog.rishavs.in/tags/buildroot/index.xml" rel="self" type="application/rss+xml"/><item><title>Buildroot on QEMU</title><link>https://blog.rishavs.in/posts/buildroot-on-qemu/</link><pubDate>Tue, 25 Nov 2025 19:07:00 +0000</pubDate><guid>https://blog.rishavs.in/posts/buildroot-on-qemu/</guid><description>&lt;h2 id="overview">Overview&lt;/h2>
&lt;p>Buildroot is a powerful tool that automates building cross‑compilers, kernel images, bootloaders, root filesystems, and entire minimal Linux environments. Combined with QEMU, it provides a fast and fully emulated setup without needing physical hardware.&lt;/p>
&lt;h2 id="steps">Steps&lt;/h2>
&lt;h3 id="0-dependencies">0. Dependencies&lt;/h3>
&lt;p>Before building Buildroot, ensure the following packages are installed on your host system:&lt;/p>
&lt;p>&lt;strong>For Debian/Ubuntu:&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>sudo apt install build-essential git wget cpio unzip rsync bc python3 &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> qemu-system-arm qemu-system-misc qemu-utils flex bison libssl-dev
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>For Fedora:&lt;/strong>&lt;/p></description></item><item><title>Generating Package Patch for Buildroot</title><link>https://blog.rishavs.in/posts/generating-package-patch-for-buildroot/</link><pubDate>Tue, 20 May 2025 10:13:00 +0000</pubDate><guid>https://blog.rishavs.in/posts/generating-package-patch-for-buildroot/</guid><description>&lt;h2 id="generating-a-patch-using-diff">Generating a Patch Using &lt;code>diff&lt;/code>&lt;/h2>
&lt;h3 id="1-extract-the-original-source">1. Extract the Original Source&lt;/h3>
&lt;p>Ensure you have a pristine copy of the original source for comparison. You can extract it from the tarball in the &lt;code>dl&lt;/code> directory:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>tar -xf dl/&amp;lt;package&amp;gt;-&amp;lt;version&amp;gt;.tar.gz -C /tmp/
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This will create a directory like &lt;code>/tmp/&amp;lt;package&amp;gt;-&amp;lt;version&amp;gt;/&lt;/code>.&lt;/p>
&lt;h4 id="using-buildroots-mechanism">Using buildroot&amp;rsquo;s mechanism&lt;/h4>
&lt;p>Clean the build directory and apply current patches of buildroot&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>make &amp;lt;pkg&amp;gt;-dirclean &lt;span style="color:#75715e"># Remove &amp;lt;pkg&amp;gt; build directory&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>make &amp;lt;pkg&amp;gt;-extract &lt;span style="color:#75715e"># Extract &amp;lt;pkg&amp;gt; sources&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>make &amp;lt;pkg&amp;gt;-patch &lt;span style="color:#75715e"># Apply patches to &amp;lt;pkg&amp;gt; (Optional)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>cp -r output/build/&amp;lt;package&amp;gt; /tmp/
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="2-generate-the-patch">2. Generate the Patch&lt;/h3>
&lt;p>Use the &lt;code>diff&lt;/code> command to create a unified diff between the original and modified sources:&lt;/p></description></item><item><title>External Toolchain in Buildroot</title><link>https://blog.rishavs.in/posts/external-toolchain-in-buildroot/</link><pubDate>Fri, 04 Apr 2025 12:00:00 +0000</pubDate><guid>https://blog.rishavs.in/posts/external-toolchain-in-buildroot/</guid><description>&lt;h2 id="using-external-toolchain">Using External Toolchain&lt;/h2>
&lt;h3 id="option-1-give-tarball-url">Option 1: Give tarball URL&lt;/h3>
&lt;p>Specify URL for the tarball in &lt;code>BR_TOOLCHAIN_EXTERNAL_URL&lt;/code>&lt;/p>
&lt;p>Example:&lt;/p>
&lt;pre tabindex="0">&lt;code class="language-config" data-lang="config">BR_TOOLCHAIN_EXTERNAL_URL=http://artifactory/my-toolchain.tar.xz
&lt;/code>&lt;/pre>&lt;blockquote>
&lt;p>In this case you will have to deselect &lt;code>BR2_PRIMARY_SITE_ONLY&lt;/code> option&lt;/p>&lt;/blockquote>
&lt;h3 id="option-2-give-tarball-relative-dl-path">Option 2: Give tarball relative dl path&lt;/h3>
&lt;p>If &lt;code>BR2_PRIMARY_SITE_ONLY&lt;/code> option is selected then you have to keep the toolchain inside &lt;code>dl/toolchain-external-custom/&lt;/code> directory and pass the name of tarball to &lt;code>BR_TOOLCHAIN_EXTERNAL_URL&lt;/code>&lt;/p>
&lt;p>Example:&lt;/p>
&lt;pre tabindex="0">&lt;code class="language-config" data-lang="config">BR2_PRIMARY_SITE=&amp;#34;http://artifactory/buildroot-sources&amp;#34;
BR2_PRIMARY_SITE_ONLY=y
BR_TOOLCHAIN_EXTERNAL_URL=my-toolcahin.tar.xz
&lt;/code>&lt;/pre>&lt;p>This will extract the toolchain to buildroot&amp;rsquo;s build directory &lt;code>output/host/opt/ext-toolchain&lt;/code>&lt;/p></description></item><item><title>Buildroot Relocatable SDK</title><link>https://blog.rishavs.in/posts/buildroot-relocatable-sdk/</link><pubDate>Mon, 10 Mar 2025 12:17:00 +0000</pubDate><guid>https://blog.rishavs.in/posts/buildroot-relocatable-sdk/</guid><description>&lt;h2 id="overview">Overview&lt;/h2>
&lt;p>A relocatable toolchain/SDK is a self-contained set of cross-compilation tools that can be moved to different locations without breaking dependencies. Buildroot provides an option to generate such a toolchain, allowing developers to use it for cross-compiling applications without depending on a fixed absolute path.&lt;/p>
&lt;h2 id="prepare-relocatable-sdk">Prepare Relocatable SDK&lt;/h2>
&lt;h3 id="configure-buildroot-for-sdk-generation">Configure Buildroot for SDK Generation&lt;/h3>
&lt;p>Disable &lt;code>BusyBox&lt;/code> and set &lt;code>/bin/sh&lt;/code> to &lt;code>None&lt;/code> under &lt;code>System configuration&lt;/code>. This prevents unnecessary shell dependencies within the SDK, ensuring better relocatability.&lt;/p></description></item><item><title>Making File System</title><link>https://blog.rishavs.in/posts/making-file-system/</link><pubDate>Mon, 11 Nov 2024 19:14:00 +0000</pubDate><guid>https://blog.rishavs.in/posts/making-file-system/</guid><description>&lt;h2 id="overview">Overview&lt;/h2>
&lt;ol>
&lt;li>Get the final files into a directory eg. &lt;code>target&lt;/code> and treat it as root(&lt;code>/&lt;/code>) directory of target board/system.&lt;/li>
&lt;li>Generate users eg. &lt;code>root&lt;/code>, &lt;code>admin&lt;/code>, &lt;code>ssh&lt;/code>, etc&lt;/li>
&lt;li>Generate device lists&lt;/li>
&lt;li>Clean few files&lt;/li>
&lt;li>Generate ext image using &lt;code>mkfs&lt;/code>&lt;/li>
&lt;/ol>
&lt;p>Taking reference from buildroot &lt;code>common.mk&lt;/code> and &lt;code>ext2.mk&lt;/code>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>scripts/makedevs -d output/build/buildroot-fs/full_devices_table.txt output/build/buildroot-fs/ext2/target
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>mkfs.ext4 -d output/build/buildroot-fs/ext2/target -r &lt;span style="color:#ae81ff">1&lt;/span> -N &lt;span style="color:#ae81ff">0&lt;/span> -m &lt;span style="color:#ae81ff">5&lt;/span> -L rootfs -O ^64bit output/images/rootfs.ext2 2G
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Fakeroot execution complete&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>/opt/rk3588_nvrx/host/sbin/resize2fs -M output/images/rootfs.ext2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>/opt/rk3588_nvrx/host/sbin/e2fsck -fy /output/images/rootfs.ext2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>/opt/rk3588_nvrx/host/sbin/resize2fs -M /output/images/rootfs.ext2
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="fakeroot-script">Fakeroot Script&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#!/bin/sh
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>set -ex
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>chown -h -R 0:0 &lt;span style="color:#66d9ef">$(&lt;/span>TARGET&lt;span style="color:#66d9ef">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">$(&lt;/span>HOST_DIR&lt;span style="color:#66d9ef">)&lt;/span>/bin/makedevs -d full_devices_table.txt &lt;span style="color:#66d9ef">$(&lt;/span>TARGET&lt;span style="color:#66d9ef">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">$(&lt;/span>HOST_DIR&lt;span style="color:#66d9ef">)&lt;/span>/sbin/mkfs.ext4 -d &lt;span style="color:#66d9ef">$(&lt;/span>TARGET&lt;span style="color:#66d9ef">)&lt;/span> -r &lt;span style="color:#ae81ff">1&lt;/span> -N &lt;span style="color:#ae81ff">0&lt;/span> -m &lt;span style="color:#ae81ff">5&lt;/span> -L &lt;span style="color:#e6db74">&amp;#34;rootfs&amp;#34;&lt;/span> -O ^64bit rootfs.ext2 &lt;span style="color:#e6db74">&amp;#34;2G&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="post-ext4">Post EXT4&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">$(&lt;/span>HOST_DIR&lt;span style="color:#66d9ef">)&lt;/span>/sbin/resize2fs -M rootfs.ext2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">$(&lt;/span>HOST_DIR&lt;span style="color:#66d9ef">)&lt;/span>/sbin/e2fsck -fy rootfs.ext2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">$(&lt;/span>HOST_DIR&lt;span style="color:#66d9ef">)&lt;/span>/sbin/tune2fs -m &lt;span style="color:#ae81ff">5&lt;/span> rootfs.ext2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">$(&lt;/span>HOST_DIR&lt;span style="color:#66d9ef">)&lt;/span>/sbin/resize2fs -M rootfs.ext2
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="testing-on-host">Testing on Host&lt;/h2>
&lt;pre tabindex="0">&lt;code>sudo mount -o loop path/to/rootfs.ext4 /tmp/fs_path
&lt;/code>&lt;/pre>&lt;h3 id="makedevs">Makedevs&lt;/h3>
&lt;p>Creates a batch of special files as specified in a device table.&lt;/p></description></item></channel></rss>