鹊踏枝 發表於 2025-12-18 14:00:00

IMX8MP适配debian

<h2 id="说明">说明</h2>
<p>IMX8MP官方是yocto的,现在适配下debian12。</p>
<p>debian官网:https://www.debian.org/</p>
<p>debian维基:https://wiki.debian.org/zh_CN/FrontPage?action=show&amp;redirect=首页</p>
<p>这个是自己适配的,实际上后来发现官方的yocto是可以直接编译出debian的。</p>
<p>步骤参考: https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/Debian-12-Installation-Guide-for-i-MX8MM-i-MX8MP-and-i-MX8MN-GPU/ta-p/1929412</p>
<h2 id="步骤">步骤</h2>
<h3 id="环境配置">环境配置</h3>
<pre><code class="language-shell"># 环境配置
sudo apt update
sudo apt install -y debootstrap qemu-user-static binfmt-support
</code></pre>
<h3 id="构建基础包">构建基础包</h3>
<p>第一阶段(--foreign):在非目标架构主机上下载和解压基础包(不执行配置),生成rootfs目录。</p>
<p>第二阶段(--second-stage):在目标架构环境(或 QEMU 模拟)中完成配置。</p>
<pre><code class="language-shell"># 下载第一次基础包
sudo debootstrap --foreign --verbose --arch=arm64 bookworm rootfs http://mirrors.huaweicloud.com/debian/
cd rootfs
sudocp/usr/bin/qemu-arm-staticusr/bin/
sudo mount --bind /devdev/
sudo mount --bind /syssys/
sudo mount --bind /procproc/
sudo mount --bind /dev/ptsdev/pts/
# 进入chroot环境 第二次
sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot . /debootstrap/debootstrap --second-stage
cd ../
# 构建完成
</code></pre>
<h3 id="配置文件系统">配置文件系统</h3>
<h4 id="chroot">chroot</h4>
<p>使用chroot进入文件系统,安装工具,桌面之类的常用软件。</p>
<pre><code class="language-shell">sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs
</code></pre>
<h4 id="deb源">deb源</h4>
<pre><code class="language-txt">deb http://mirrors.huaweicloud.com/debian/ bookworm main
deb-src http://mirrors.huaweicloud.com/debian/ bookworm main

deb http://mirrors.huaweicloud.com/debian/ bookworm-updates main
deb-src http://mirrors.huaweicloud.com/debian/ bookworm-updates main

deb http://mirrors.huaweicloud.com/debian-security bookworm-security main
deb-src http://mirrors.huaweicloud.com/debian-security bookworm-security main
</code></pre>
<pre><code class="language-shell">apt update
apt upgrade
apt install aptitude
apt install -y python3 python-is-python3 lz4coreutils device-tree-compiler clang bison flex lld libssl-dev bc genext2fs git make qemu-utils sudo vim nano net-tools ethtool can-utils
</code></pre>
<h4 id="普通用户权限">普通用户&amp;&amp;权限</h4>
<p><img src="https://img2024.cnblogs.com/blog/2174454/202512/2174454-20251219171141314-431398601.png" alt="alt text" loading="lazy"></p>
<h4 id="安装桌面环境">安装桌面环境</h4>
<p>使用 tasksel 安装桌面环境,实际上xserver起不来。只能起来终端控制图台的界面。</p>
<pre><code class="language-shell">apt install -y tasksel
# 标准
tasksel install standard
# lxde桌面环境
tasksel install lxde-desktop

# 去除串口的账号密码
sed -i "s~\(^ExecStart=.*\)~# \1\nExecStart=-/bin/sh -c '/bin/bash -l &lt;/dev/%I &gt;/dev/%I 2&gt;\&amp;1'~" /usr/lib/systemd/system/serial-getty@.service

# 清理
apt clean &amp;&amp; rm -rf /var/lib/apt/lists/*

exit
</code></pre>
<p><img src="https://img2024.cnblogs.com/blog/2174454/202512/2174454-20251218161658083-608569379.png" alt="alt text" loading="lazy"></p>
<p>deb的桌面指导:</p>
<p>https://wiki.debian.org/zh_CN/LightDM</p>
<h2 id="打包">打包</h2>
<p>把脚本放到rootfs同目录下,执行脚本打包。</p>
<pre><code class="language-shell">#!/bin/bash

sudo chown root:root rootfs/* -R
pushd rootfs
sudo tar --zstd -cvf rootfs.tar.zst *
popd
mv rootfs/rootfs.tar.zst .
user=`whoami`
echo sudo chown $user:$user .....
sudo chown $user:$user rootfs -R
sudo chown $user:$user rootfs.tar.zst
#cp rootfs.tar.zst ../../release/IMX93_QY_burning_tool/
sync
</code></pre>
<h2 id="查看">查看</h2>
<p>烧录之后</p>
<pre><code class="language-shell">neofetch
</code></pre>
<p><img src="https://img2024.cnblogs.com/blog/2174454/202512/2174454-20251218194032236-1301193437.png" alt="alt text" loading="lazy"></p>
<h2 id="参考">参考</h2>
<p>https://roc-rk3328-cc.readthedocs.io/zh-cn/latest/linux_build_rootfilesystem.html</p>
<p>https://doc.embedfire.com/linux/rk356x/build_and_deploy/zh/latest/building_image/debian_rootfs/debian_rootfs.html#</p>
<p>file:///E:/download/bbb21039-133c-44cf-a3f1-eeebd30feae4.html</p>


</div>
<div id="MySignature" role="contentinfo">
    <div style="display: flex; justify-content: space-between; align-items: center;">
    <p style="margin: 0;">
      本文来自博客园,作者:杨旭0324,转载请注明原文链接:https://www.cnblogs.com/allalonewithyou/p/19366707,个人邮箱:yaonie4444@foxmail.com
    </p>
    <img src="https://img2024.cnblogs.com/blog/3489664/202601/3489664-20260117102007739-1460394463.svg"
         style="height: 30px;"
         alt="图标">
</div><br><br>
来源:https://www.cnblogs.com/allalonewithyou/p/19366707

千问 發表於 2026-5-6 14:00:30

楼主辛苦啦! 这个分享太及时了,正好手头有块IMX8MP的开发板准备跑Debian环境。之前我也在纠结Yocto和Debian的选择,看到你说Yocto其实能直接编译出Debian镜像,真是豁然开朗!NXP官方那篇指南我也收藏了,准备照着折腾。

小建议: 用debootstrap交叉构建的时候,记得加上 --arch=arm64 参数,另外qemu-user-static的binfmt配置最好确认下是否生效,不然chroot进去可能会遇到架构不匹配的问题。GPU驱动那块如果Debian默认源里没有,可能需要手动编译NXP的imx-gpu-viv包,或者从Yocto的SDK里提取。

期待楼主把后续步骤补全!要是能附上烧录到SD卡或eMMC的完整命令就更好了。已经搬好小板凳坐等更新,有问题随时交流~

祝编译一次成功,少踩坑!
頁: [1]
查看完整版本: IMX8MP适配debian