<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Lithiumee</title>
        <link>https://paragraph.com/@lithiumee</link>
        <description>Go Wild</description>
        <lastBuildDate>Thu, 04 Jun 2026 17:34:09 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>Lithiumee</title>
            <url>https://storage.googleapis.com/papyrus_images/b3360f2614fe24b50b030e15c6fa62bed0a01c8be59f925231a60198145f47aa.jpg</url>
            <link>https://paragraph.com/@lithiumee</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[Past Phone + Present Power: Kernel 6.8 & Debian 13 on Redmi 2]]></title>
            <link>https://paragraph.com/@lithiumee/past-phone-present-power-kernel-6-8-debian-13-on-redmi-2</link>
            <guid>74xtaooKgXqmSAJVajcm</guid>
            <pubDate>Mon, 26 Aug 2024 03:47:01 GMT</pubDate>
            <description><![CDATA[[Fun.001] 2024.03红米 2一台 2015 年初发布的手机，售价 699 元，2024 年居然还没有被遗忘？红米 2 外观硬实力上，红米 2 在当时就不突出。它是闻泰科技 ODM 的产品，从设计到制造都由闻泰完成，配备高通骁龙 410 SoC (MSM8916) ，1GB 运行内存，8GB 存储，4.7 寸 720P 屏幕 (312 ppi) 。MSM8916 采用 28 nm 工艺，CPU 为 4 核 1.2 GHz ARM Cortex-A53，上市之初定位便是中低端，与 2023 年的骁龙旗舰相比性能就只有可怜的 1/10 不到了。作为手机，红米 2 在 2024 年早已没有实用价值，大量红米 2 在闲鱼上的售价仅在 50-100 元之间。骁龙 410 (msm8916)软实力它却很强。红米 2 有非常丰富的第三方 Android 刷机包，出厂搭载 Android 4.4 的它能刷到 Android 10 的 Lineage OS 17.1 (Kernel Version 3.10) 。当它的性能已经不足以支撑在 Android 中多做什么时，它还可以运行接近...]]></description>
            <content:encoded><![CDATA[<p>[Fun.001] 2024.03</p><h2 id="h-2" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">红米 2</h2><p>一台 2015 年初发布的手机，售价 699 元，2024 年居然还没有被遗忘？</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ad0d4587327587af60717f0180dade0aba14e9b5158e80161aecc44461f47119.png" alt="红米 2 外观" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">红米 2 外观</figcaption></figure><p>硬实力上，红米 2 在当时就不突出。它是闻泰科技 ODM 的产品，从设计到制造都由闻泰完成，配备高通骁龙 410 SoC (MSM8916) ，1GB 运行内存，8GB 存储，4.7 寸 720P 屏幕 (312 ppi) 。MSM8916 采用 28 nm 工艺，CPU 为 4 核 1.2 GHz ARM Cortex-A53，上市之初定位便是中低端，与 2023 年的骁龙旗舰相比性能就只有可怜的 1/10 不到了。作为手机，红米 2 在 2024 年早已没有实用价值，大量红米 2 在闲鱼上的售价仅在 50-100 元之间。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/82b532dd1e6163cac690b4e812afae20cbd04b4049cfcbb334e1cb075779c165.png" alt="骁龙 410 (msm8916)" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">骁龙 410 (msm8916)</figcaption></figure><p>软实力它却很强。红米 2 有非常丰富的第三方 Android 刷机包，出厂搭载 Android 4.4 的它能刷到 Android 10 的 Lineage OS 17.1 (Kernel Version 3.10) 。当它的性能已经不足以支撑在 Android 中多做什么时，它还可以运行接近最新主线的 Linux Kernel 和 Debian, Ubuntu 等正儿八经的 Linux 发行版。可能是得益于高通官方基于 MSM8916 推出了支持 Ubuntu Linux 的 DragonBoard 410c 开发板，也得益于后续开源社区和组织的努力，MSM8916的主线内核功能已经比较完善，UART、USB、Storage (eMMC/SD card) 、WiFi/Bluetooth、GPU、Display (需要 panel 驱动)、Audio、Buttons、Vibration、Modem (SMS, voice calls with audio, mobile data) 等都得到了支持。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ca0010d5b9a85446f7ed355ed54f8465260d370dd1f5c55b51bc2513e2d2f9f7.png" alt="DragonBoard 410c" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">DragonBoard 410c</figcaption></figure><p>有了完善的 Linux 支持之后，红米 2 作为一个嵌入式 Linux 开发平台瞬间焕发新生。如果应用于只需要极少的 IO，不需要丰富的总线接口，需要利用 USB、 无线通信，甚至还恰好比较需要屏幕交互的场景，相比购买树莓派、香橙派等 Linux 开发板，手机运行 Linux 方案变得性价比极高。因此可以看到红米 2 仍具有很强的生命力，B 站上拿红米 2 做 Klipper 3D 打印上位机的案例非常丰富。同为 MSM8916 SoC 的一些低价随身 WiFi 也纷纷被装上 Linux 做小服务器。</p><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">制作过程</h2><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">调试</h3><p>没有 console log 将是调试的噩梦，能通过串口看 bootloader 和 kernel 的输出非常要紧，否则在屏幕没有成功点亮前就成了黑箱，没有排查空间。而红米 2 有完整的点位图和原理图可看，甚至预留了串口 TP，调试便完全不成问题了。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/679329bbcdd341a4da425214d0e2a50abf38a602704fbf85385a367c36531b26.png" alt="原理图中的串口TP" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">原理图中的串口TP</figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f8903733e05bdaac32552aef52763d80f6c45d659d4c53bd86ec2d2d4381733a.png" alt="点位图中的串口TP" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">点位图中的串口TP</figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5234b187a1c85cefdba5b33b8a2d47fa43e9b6056fe4762133bd41c61426de3c.png" alt="实物上的TP" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">实物上的TP</figcaption></figure><h3 id="h-lk2nd" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">lk2nd</h3><p>lk2nd 是为高通 SoC 开发的基于 Little Kernel 的二级引导程序，可以方便地引导 Linux 启动。而它本身伪装成了 Android 的 boot.img 文件，使得不必改动设备原本 bootloader 就能启动。lk2nd 提供了 fastboot 兼容，可以在电脑用 fastboot 命令实现方便的分区烧写。并且和 u-boot 类似，起到“兜底”的作用，不用担心烧进坏的镜像就彻底变砖。</p><p>项目地址：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/msm8916-mainline/lk2nd">msm8916-mainline/lk2nd: Custom bootloader for Qualcomm MSM8916/MSM8226/MSM8974/... devices (github.com)</a></p><p>我们直接利用 Release 的 0.15.0 版本 lk2nd-msm8916.img 在原厂 fastboot 中通过以下命令刷入 lk2nd，开机时亮屏后按音量下键可以进入 lk2nd 的 fastboot。</p><pre data-type="codeBlock" text="fastboot flash:raw boot lk2nd-msm8916.img
"><code>fastboot flash:raw boot lk2nd<span class="hljs-operator">-</span>msm8916.img
</code></pre><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4d3a9344724e39d7992395f29d8b3a7f81d03cb0aaf5ae12693974c3965664bc.png" alt="开发者将 lk2nd 运行在各种设备上" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">开发者将 lk2nd 运行在各种设备上</figcaption></figure><p>运行lk2nd后，烧写便可以使用下面的命令：</p><pre data-type="codeBlock" text="fastboot flash boot boot.img
fastboot flash userdata rootfs.img
"><code>fastboot flash boot boot.img
fastboot flash userdata rootfs.img
</code></pre><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">内核</h3><p>从 <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/msm8916-mainline/linux">msm8916-mainline/linux</a> 获取内核，直接编译即可</p><pre data-type="codeBlock" text="export CROSS_COMPILE=aarch64-linux-gnu-
export ARCH=arm64
make msm8916_defconfig
make menuconfig
make -j8
make deb-pkg
"><code>export CROSS_COMPILE<span class="hljs-operator">=</span>aarch64<span class="hljs-operator">-</span>linux<span class="hljs-operator">-</span>gnu<span class="hljs-operator">-</span>
export ARCH<span class="hljs-operator">=</span>arm64
make msm8916_defconfig
make menuconfig
make <span class="hljs-operator">-</span>j8
make deb<span class="hljs-operator">-</span>pkg
</code></pre><p>编译完成后会生成3部分的文件：</p><ol><li><p>arch/arm64/boot/Image.gz 压缩后的内核映像</p></li><li><p>arch/arm64/boot/dts/qcom/msm8916-wingtech-wt88047.dtb 设备树 dtb，后续需要附在内核映像后</p></li><li><p>../linux-headers-6.7.4-msm8916-dirty_6.7.4-6_arm64.deb 和 ../linux-image-6.7.4-msm8916-dirty_6.7.4-6_arm64.deb 内核头文件和内核的 deb 包，后续需要在根文件系统中安装</p></li></ol><p>将设备树 dtb，附在内核映像后</p><pre data-type="codeBlock" text="cat Image.gz msm8916-wingtech-wt88047.dtb &gt; kernel-dtb
"><code>cat Image.gz msm8916<span class="hljs-operator">-</span>wingtech<span class="hljs-operator">-</span>wt88047.dtb <span class="hljs-operator">></span> kernel<span class="hljs-operator">-</span>dtb
</code></pre><h3 id="h-debian-rootfs" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Debian rootfs</h3><p>首先尝试利用 debootstrap 创建一个 debian 的根文件系统。由于制作所用主机为 amd64 架构，而目标设备为 arm64 架构，需要利用 debootstrap 的 —foreign 选项，并准备 qemu-aarch64-static 用于模拟 arm64 指令集。</p><pre data-type="codeBlock" text="apt-get install debootstrap qemu-user-static binfmt-support
debootstrap --arch arm64 --foreign bookworm rootfs http://mirrors.tuna.tsinghua.edu.cn/debian
cp -a /usr/bin/qemu-aarch64-static rootfs/usr/bin/qemu-aarch64-static
"><code>apt<span class="hljs-operator">-</span>get install debootstrap qemu<span class="hljs-operator">-</span>user<span class="hljs-operator">-</span>static binfmt<span class="hljs-operator">-</span>support
debootstrap <span class="hljs-operator">-</span><span class="hljs-operator">-</span>arch arm64 <span class="hljs-operator">-</span><span class="hljs-operator">-</span>foreign bookworm rootfs http:<span class="hljs-comment">//mirrors.tuna.tsinghua.edu.cn/debian</span>
cp <span class="hljs-operator">-</span>a <span class="hljs-operator">/</span>usr<span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>qemu<span class="hljs-operator">-</span>aarch64<span class="hljs-operator">-</span>static rootfs<span class="hljs-operator">/</span>usr<span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>qemu<span class="hljs-operator">-</span>aarch64<span class="hljs-operator">-</span>static
</code></pre><p>然后 chroot 进入刚刚制作的根文件系统，完成 debootstrap 的第二阶段、安装 kernel-image 和 kernel-header，并自由定制自己的根文件系统</p><pre data-type="codeBlock" text="mount --bind /dev rootfs/dev
mount --bind /dev/pts rootfs/dev/pts
mount --bind /proc rootfs/proc
chroot rootfs bash

/debootstrap/debootstrap --second-stage
dpkg-reconfigure locales
dpkg -i *.deb #事先拷进来的linux-headers和linux-image
apt update
apt install usbutils network-manager sudo fdisk vim nano openssh-server iputils-ping wget curl iproute2 dialog locales kmod zip unzip u-boot-tools initramfs-tools net-tools htop screenfetch phosh
adduser debian
exit
"><code>mount <span class="hljs-operator">-</span><span class="hljs-operator">-</span>bind <span class="hljs-operator">/</span>dev rootfs<span class="hljs-operator">/</span>dev
mount <span class="hljs-operator">-</span><span class="hljs-operator">-</span>bind <span class="hljs-operator">/</span>dev<span class="hljs-operator">/</span>pts rootfs<span class="hljs-operator">/</span>dev<span class="hljs-operator">/</span>pts
mount <span class="hljs-operator">-</span><span class="hljs-operator">-</span>bind <span class="hljs-operator">/</span>proc rootfs<span class="hljs-operator">/</span>proc
chroot rootfs bash

<span class="hljs-operator">/</span>debootstrap<span class="hljs-operator">/</span>debootstrap <span class="hljs-operator">-</span><span class="hljs-operator">-</span>second<span class="hljs-operator">-</span>stage
dpkg<span class="hljs-operator">-</span>reconfigure locales
dpkg <span class="hljs-operator">-</span>i <span class="hljs-operator">*</span>.deb #事先拷进来的linux<span class="hljs-operator">-</span>headers和linux<span class="hljs-operator">-</span>image
apt update
apt install usbutils network<span class="hljs-operator">-</span>manager sudo fdisk vim nano openssh<span class="hljs-operator">-</span>server iputils<span class="hljs-operator">-</span>ping wget curl iproute2 dialog locales kmod zip unzip u<span class="hljs-operator">-</span>boot<span class="hljs-operator">-</span>tools initramfs<span class="hljs-operator">-</span>tools net<span class="hljs-operator">-</span>tools htop screenfetch phosh
adduser debian
exit
</code></pre><p>在安装新 Linux 内核包时，包管理器会调用 update-initramfs 来生成与新内核匹配的 initrd.img 文件，initrd 包含一个临时的根文件系统，运行在内存中负责初始化系统并切换到最终的根文件系统。我们需要拷贝位于 /boot 目录下的 initrd.img-xxx 文件制作进 boot.img中。</p><p>打包 rootfs.img</p><pre data-type="codeBlock" text="umount rootfs/dev/pts
umount rootfs/dev 
umount rootfs/proc
dd if=/dev/zero of=rootfs.ext4 bs=1M count=4096
mkfs.ext4 rootfs.ext4
mkdir /mnt/rootfs_dd
mount rootfs.ext4 /mnt/rootfs_dd
cp -a rootfs/. /mnt/rootfs_dd/
sync
umount /mnt/rootfs_dd/
img2simg rootfs.ext4 rootfs.img # convert to sparse image
"><code>umount rootfs<span class="hljs-operator">/</span>dev<span class="hljs-operator">/</span>pts
umount rootfs<span class="hljs-operator">/</span>dev 
umount rootfs<span class="hljs-operator">/</span>proc
dd <span class="hljs-keyword">if</span><span class="hljs-operator">=</span><span class="hljs-operator">/</span>dev<span class="hljs-operator">/</span>zero of<span class="hljs-operator">=</span>rootfs.ext4 bs<span class="hljs-operator">=</span>1M count<span class="hljs-operator">=</span><span class="hljs-number">4096</span>
mkfs.ext4 rootfs.ext4
mkdir <span class="hljs-operator">/</span>mnt<span class="hljs-operator">/</span>rootfs_dd
mount rootfs.ext4 <span class="hljs-operator">/</span>mnt<span class="hljs-operator">/</span>rootfs_dd
cp <span class="hljs-operator">-</span>a rootfs<span class="hljs-operator">/</span>. /mnt<span class="hljs-operator">/</span>rootfs_dd<span class="hljs-operator">/</span>
sync
umount <span class="hljs-operator">/</span>mnt<span class="hljs-operator">/</span>rootfs_dd<span class="hljs-operator">/</span>
img2simg rootfs.ext4 rootfs.img # convert to sparse image
</code></pre><p>打包 boot.img。在 kernel cmdline 中，通过 UUID 指定 rootfs 分区较为保险，UUID可以通过<code>file mkfs.ext4</code>命令查看</p><pre data-type="codeBlock" text="mkbootimg --base 0x80000000 \
        --kernel_offset 0x00080000 \
        --ramdisk_offset 0x02000000 \
        --tags_offset 0x01e00000 \
        --pagesize 2048 \
        --second_offset 0x00f00000 \
        --ramdisk initrd.img \
        --cmdline &quot;earlycon console=tty0 console=ttyMSM0,115200 root=UUID=b0167571-46ab-432c-9923-46772affcb75 rw loglevel=7&quot;\
        --kernel kernel-dtb -o boot.img
"><code>mkbootimg <span class="hljs-operator">-</span><span class="hljs-operator">-</span>base <span class="hljs-number">0x80000000</span> \
        <span class="hljs-operator">-</span><span class="hljs-operator">-</span>kernel_offset <span class="hljs-number">0x00080000</span> \
        <span class="hljs-operator">-</span><span class="hljs-operator">-</span>ramdisk_offset <span class="hljs-number">0x02000000</span> \
        <span class="hljs-operator">-</span><span class="hljs-operator">-</span>tags_offset <span class="hljs-number">0x01e00000</span> \
        <span class="hljs-operator">-</span><span class="hljs-operator">-</span>pagesize <span class="hljs-number">2048</span> \
        <span class="hljs-operator">-</span><span class="hljs-operator">-</span>second_offset <span class="hljs-number">0x00f00000</span> \
        <span class="hljs-operator">-</span><span class="hljs-operator">-</span>ramdisk initrd.img \
        <span class="hljs-operator">-</span><span class="hljs-operator">-</span>cmdline <span class="hljs-string">"earlycon console=tty0 console=ttyMSM0,115200 root=UUID=b0167571-46ab-432c-9923-46772affcb75 rw loglevel=7"</span>\
        <span class="hljs-operator">-</span><span class="hljs-operator">-</span>kernel kernel<span class="hljs-operator">-</span>dtb <span class="hljs-operator">-</span>o boot.img
</code></pre><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/00164260a93558083ad2a4ea6ebe28f1031baed0b42a60b2653bfed9128a5add.jpg" alt="运行 debian" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">运行 debian</figcaption></figure><h3 id="h-mobian-rootfs" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Mobian rootfs</h3><p>自制的 debian rootfs 可以启动，但图形界面中缺少的东西实在太多，因此转向修改其他机型的 mobian rootfs。mobian <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://mobian-project.org/">官网</a>下载目前前最新的镜像，得到 mobian-qcom-phosh-20240211.rootfs.img，主要安装上 linux-headers 和 linux-image 即可。</p><pre data-type="codeBlock" text="simg2img mobian-qcom-phosh-20240211.rootfs.img  mobian-rootfs.img
mount mobian-rootfs.img /mnt/rootfs_dd/
sudo mount --bind /proc /mnt/rootfs_dd/proc
sudo mount --bind /dev /mnt/rootfs_dd/dev
sudo mount --bind /dev/pts /mnt/rootfs_dd/dev/pts
sudo mount --bind /sys /mnt/rootfs_dd/sys
cp linux-headers-6.7.4-msm8916-dirty_6.7.4-6_arm64.deb /mnt/rootfs_dd/tmp/
cp linux-image-6.7.4-msm8916-dirty_6.7.4-6_arm64.deb /mnt/rootfs_dd/tmp/
sudo chroot /mnt/rootfs_dd/
dpkg-reconfigure locales
apt remove qcom-support
dpkg -l | grep -E &quot;linux-headers|linux-image&quot; |awk &apos;{print $2}&apos;|xargs dpkg -P
cd /tmp
dpkg -i *.deb
exit
"><code>simg2img mobian<span class="hljs-operator">-</span>qcom<span class="hljs-operator">-</span>phosh<span class="hljs-number">-20240211</span>.rootfs.img  mobian<span class="hljs-operator">-</span>rootfs.img
mount mobian<span class="hljs-operator">-</span>rootfs.img <span class="hljs-operator">/</span>mnt<span class="hljs-operator">/</span>rootfs_dd<span class="hljs-operator">/</span>
sudo mount <span class="hljs-operator">-</span><span class="hljs-operator">-</span>bind <span class="hljs-operator">/</span>proc <span class="hljs-operator">/</span>mnt<span class="hljs-operator">/</span>rootfs_dd<span class="hljs-operator">/</span>proc
sudo mount <span class="hljs-operator">-</span><span class="hljs-operator">-</span>bind <span class="hljs-operator">/</span>dev <span class="hljs-operator">/</span>mnt<span class="hljs-operator">/</span>rootfs_dd<span class="hljs-operator">/</span>dev
sudo mount <span class="hljs-operator">-</span><span class="hljs-operator">-</span>bind <span class="hljs-operator">/</span>dev<span class="hljs-operator">/</span>pts <span class="hljs-operator">/</span>mnt<span class="hljs-operator">/</span>rootfs_dd<span class="hljs-operator">/</span>dev<span class="hljs-operator">/</span>pts
sudo mount <span class="hljs-operator">-</span><span class="hljs-operator">-</span>bind <span class="hljs-operator">/</span>sys <span class="hljs-operator">/</span>mnt<span class="hljs-operator">/</span>rootfs_dd<span class="hljs-operator">/</span>sys
cp linux<span class="hljs-operator">-</span>headers<span class="hljs-number">-6.7</span><span class="hljs-number">.4</span><span class="hljs-operator">-</span>msm8916<span class="hljs-operator">-</span>dirty_6<span class="hljs-number">.7</span><span class="hljs-number">.4</span><span class="hljs-operator">-</span>6_arm64.deb <span class="hljs-operator">/</span>mnt<span class="hljs-operator">/</span>rootfs_dd<span class="hljs-operator">/</span>tmp<span class="hljs-operator">/</span>
cp linux<span class="hljs-operator">-</span>image<span class="hljs-number">-6.7</span><span class="hljs-number">.4</span><span class="hljs-operator">-</span>msm8916<span class="hljs-operator">-</span>dirty_6<span class="hljs-number">.7</span><span class="hljs-number">.4</span><span class="hljs-operator">-</span>6_arm64.deb <span class="hljs-operator">/</span>mnt<span class="hljs-operator">/</span>rootfs_dd<span class="hljs-operator">/</span>tmp<span class="hljs-operator">/</span>
sudo chroot <span class="hljs-operator">/</span>mnt<span class="hljs-operator">/</span>rootfs_dd<span class="hljs-operator">/</span>
dpkg<span class="hljs-operator">-</span>reconfigure locales
apt remove qcom<span class="hljs-operator">-</span>support
dpkg <span class="hljs-operator">-</span>l <span class="hljs-operator">|</span> grep <span class="hljs-operator">-</span>E <span class="hljs-string">"linux-headers|linux-image"</span> <span class="hljs-operator">|</span>awk <span class="hljs-string">'{print $2}'</span><span class="hljs-operator">|</span>xargs dpkg <span class="hljs-operator">-</span>P
cd <span class="hljs-operator">/</span>tmp
dpkg <span class="hljs-operator">-</span>i <span class="hljs-operator">*</span>.deb
exit
</code></pre><p>同样的流程打包 rootfs.img 和 boot.img，烧录即可。</p><p>启动后会发现无线不工作，还有屏幕不显示 GUI 但有终端显示的问题。究其原因是缺少了私有的 firmware， 这个部分也容易解决，从其他同机型 rootfs 镜像中直接拷贝即可。GPU Firmware 文件为 a300_pm4.fw 和 a300_pfp.fw, 无线部分有一系列 .mbn 文件和 .bxx 文件。启动后，网络和 GUI 也得以工作。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/126422bb68fc12f1e49958c9c74a47cc0ff9e9bda32654c3d2621a964b1f5f1d.jpg" alt="运行 mobian" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">运行 mobian</figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">真正的主线</h3><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/msm8916-mainline/linux">msm8916-mainline/linux</a> 这份内核虽然很接近主线，却还不是真正的主线内核 <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/torvalds/linux">torvalds/linux</a>, 有很多没有合并到主线的修改，版本也略有落后。那么 <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/torvalds/linux">torvalds/linux</a> 能否跑起来呢，有问题的话能否自行解决修复呢。</p><p>通过 git 镜像获取，并安装一些必要的包</p><pre data-type="codeBlock" text="git clone https://mirrors.tuna.tsinghua.edu.cn/git/linux-stable.git
git checkout v6.8.0
apt update
apt install -y gcc make gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu libncurses5-dev build-essential pkg-config libc6-dev bison flex libelf-dev  lz4 qemu-user-static bc libssl-dev debhelper
"><code>git clone https:<span class="hljs-comment">//mirrors.tuna.tsinghua.edu.cn/git/linux-stable.git</span>
git checkout v6<span class="hljs-number">.8</span><span class="hljs-number">.0</span>
apt update
apt install <span class="hljs-operator">-</span>y gcc make gcc<span class="hljs-operator">-</span>aarch64<span class="hljs-operator">-</span>linux<span class="hljs-operator">-</span>gnu binutils<span class="hljs-operator">-</span>aarch64<span class="hljs-operator">-</span>linux<span class="hljs-operator">-</span>gnu libncurses5<span class="hljs-operator">-</span>dev build<span class="hljs-operator">-</span>essential pkg<span class="hljs-operator">-</span>config libc6<span class="hljs-operator">-</span>dev bison flex libelf<span class="hljs-operator">-</span>dev  lz4 qemu<span class="hljs-operator">-</span>user<span class="hljs-operator">-</span>static bc libssl<span class="hljs-operator">-</span>dev debhelper
</code></pre><p>主线的内核有 wt88047 的设备树，首先尝试根据<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/msm8916-mainline/linux">msm8916-mainline/linux</a>项目的 msm8916_defconfig 配置内核，编译出一份内核，尝试启动，发现串口能够进入终端，但是屏幕没有正常显示。通过<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/torvalds/linux/compare/v6.7-rc4...msm8916-mainline:linux:msm8916/6.7-rc4?diff=split&amp;w=">对比</a> <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/msm8916-mainline/linux">msm8916-mainline/linux</a> 与同版本的 <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/torvalds/linux">torvalds/linux</a> 之间差距，除了大量的设备树 dts 文件添加与修改，还主要包含了：</p><ul><li><p>显示面板驱动 drm/panel 添加与修改</p></li><li><p>drm 和 dsi 部分关于启用禁用逻辑的调整</p></li><li><p>touchscreen, pmic 等外围设备的驱动添加</p></li><li><p>高通 SoC 外设驱动和配置调整，包括 qdsp6, memshare, cpuidle等</p></li></ul><p>着重添加好面板驱动和显示部分的逻辑，编译内核，用此内核启动后便可以正常看到phosh界面了。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/6ba23e4c129e7b902e47dc3d11da51ddfba7a52db8d1ca8cf2e1d4fa4b0f5425.jpg" alt="6.8.0-rc6 内核运行" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">6.8.0-rc6 内核运行</figcaption></figure><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">总结</h2><p>在前人的努力下，在红米 2 上跑起一个比较新的 Linux 系统变得异常轻松，离主线非常近，一切驱动、设备树、config 都已经就绪，只要编译就行，甚至连报错都不带报的。</p><p>手机SoC的快速迭代实在让人感叹，手机芯片性能已经远甩开嵌入式 Linux 开发中常用的芯片。一个 RK3399 就传了多少年，才有了 RK3588，另外即使是最新的树莓派性能也差强人意，对比一下飞速进步的手机芯片，仿佛不在一个世界。开源的力量也令人倾佩，手机厂商对于手机系统的更新精力有限，老机型没有新机型更新积极几乎必然。更别提支持周期结束之后，不负优化、计划报废就不错了。这在商业上无可厚非。但这也使得手机即使性能硬实力没有太落后，也很难不提早迎来生命的终结。而开源和社区的力量似乎提供了一条让手机发挥更大价值的道路，就如红米 2、一加 6T 等至今依然活跃的老机型，不仅作为手机的生命周期得到延长，甚至还开拓了更加广阔的应用场景，这何尝不是一种更高级的“环保”呢。好兆头是，以往芯片公司们常常将资料藏着掖着，而似乎一些公司已在开源方面有了一些动作，骁龙 845、865 等处理器都有了较好的主线内核支持，FOSDEM 2024 中也提到 Linaro 对于高通新旗舰芯片主线支持得越来越快，开放的美好未来似乎就在眼前。</p><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">参考资料</h2><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://wiki.postmarketos.org/wiki/Qualcomm_Snapdragon_410/412_(MSM8916)">https://wiki.postmarketos.org/wiki/Qualcomm_Snapdragon_410/412_(MSM8916)</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://developer.qualcomm.com/hardware/dragonboard-410c">https://developer.qualcomm.com/hardware/dragonboard-410c</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://blog.csdn.net/github_38345754/article/details/114291930">https://blog.csdn.net/github_38345754/article/details/114291930</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://blog.csdn.net/github_38345754/article/details/119808446?spm=1001.2014.3001.5501">https://blog.csdn.net/github_38345754/article/details/119808446?spm=1001.2014.3001.5501</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://juejin.cn/post/6844903937464598535">https://juejin.cn/post/6844903937464598535</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://blog.csdn.net/qq_23320955/article/details/106282930">https://blog.csdn.net/qq_23320955/article/details/106282930</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.knightli.com/2023/08/09/%E9%9A%8F%E8%BA%ABwif-idebian-%E5%9B%BA%E4%BB%B6%E7%BC%96%E8%AF%91/">https://www.knightli.com/2023/08/09/%E9%9A%8F%E8%BA%ABwif-idebian-%E5%9B%BA%E4%BB%B6%E7%BC%96%E8%AF%91/</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.kancloud.cn/handsomehacker/openstick/2637565">https://www.kancloud.cn/handsomehacker/openstick/2637565</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.bilibili.com/video/BV15N4y127mN">https://www.bilibili.com/video/BV15N4y127mN</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://codeleading.com/article/66445099704/">https://codeleading.com/article/66445099704/</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/Project-DragonPi/mobian-wt88047?tab=readme-ov-file">https://github.com/Project-DragonPi/mobian-wt88047?tab=readme-ov-file</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://blog.csdn.net/github_38345754/article/details/125825636?spm=1001.2014.3001.5502">https://blog.csdn.net/github_38345754/article/details/125825636?spm=1001.2014.3001.5502</a></p>]]></content:encoded>
            <author>lithiumee@newsletter.paragraph.com (Lithiumee)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/756fccf2fe761af88e890ea686220761a9f2a22c4b23954dc7cce659c4c0e6a8.jpg" length="0" type="image/jpg"/>
        </item>
    </channel>
</rss>