前言
有很多小伙伴说需要 EMMC 做商业方案,最近我抽空处理了一下这个问题。
注意,这里不推荐使用原厂所谓的 AXDL 烧录工具进行 EMMC 的量产,已无力吐槽。
原厂烧录工具存在的问题:
一、只支持 Windows 使用 USB OTG 线烧,不支持脚本化自动烧录。
二、多机烧录无法得知此时正在烧录哪一台?如果一台机器烧录多台,一旦失败全部重来。
三、失败率贼高,不知道谁写的垃圾软件,建议别写了。(也许后来改善了)
这里个人觉得瑞芯微家的芯片量产工具最正常,图形化和脚本都支持,不过我采用 DD 方案就不考虑这些工具了。
这类工具会额外加个熔断和芯片加密保护之类的功能,可以在外部预烧录一些东西,虽然在系统上电后也能实现。
准备工作
两块 爱芯派 底板 与 核心板,加上一张 debian 系统 SD 卡,一颗大于 8GB 的 EMMC 颗粒。
最新物料为 LCD20221025 854x480 MIPI 屏幕,以及 RTL8189FS WIFI ,DDR 2GB 内存,与开源板卡系统配置保持一致。
底板按下图修改其中一块:
要 EMMC 启动的需要按下图焊上核心板,驱动一般是通用的,这里测试过 8GB 和 64GB 的不同颗粒(默认用 KLM8G1GETF-B041 )。
如何确认 EMMC 可以正常使用?使用 SD 启动底板 + 带 EMMC 颗粒的核心板启动系统使用 fdisk -l
会显示两个磁盘。
root@AXERA:~# fdisk -l
Disk /dev/mmcblk0: 7.28 GiB, 7818182656 bytes, 15269888 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mmcblk2: 58.94 GiB, 63281561600 bytes, 123596800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x32eb5429
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 * 2048 264191 262144 128M c W95 FAT32 (LBA)
/dev/mmcblk2p2 264192 12058623 11794432 5.6G 83 Linux
/dev/mmcblk2p3 12058624 70586367 58527744 27.9G 83 Linux
/dev/mmcblk2p4 70586368 123596799 53010432 25.3G 7 HPFS/NTFS/exFAT
root@AXERA:~#
这里的 Disk /dev/mmcblk0: 7.28 GiB, 7818182656 bytes, 15269888 sectors
就是 EMMC 的存储了。
但这里看不到它这个磁盘的分区情况,是因为这个是恢复系统的,系统经过 ubifs 处理的,一般情况下是解不开的,当然你也可以格式化它当一般的存储空间使用。
这样我们就得到了一个 EMMC 硬件,接着需要做还原系统,经过修改后导出系统,之后提供给预烧录即可,你也可以拿多台板子做烧录器。
恢复文件系统
这里我提供了 2023年03月13日 的镜像系统制作的 ubifs 文件系统的 emmc 系统,本文稍后会迁移到 WIKI 中。
-
得到
sipeed_m3axpi_debian11_emmc_20230329.img
镜像文件放进板子。 -
在板子上使用
dd if=sipeed_m3axpi_debian11_emmc_20230329 of=/dev/mmcblk0 bs=4M status=progress
恢复系统到 EMMC 里。 -
把 核心板 换到 EMMC 启动的底板即可启动。
在产线上就是,将预烧 EMMC 贴上,底板拆电阻即可。
可以看到和 SD 是差不多的,但注意不能再通过开源文档的方式进行设备树或内核的切换,此时文件系统划分如下:
该系统是按 blkdevparts=mmcblk0:512K(spl),1536K(uboot),1M(env),1M(dtb),32M(kernel),4096M(rootfs),5M(param),128M(soc),2048M(opt)
制作的,此时的原 SD 卡槽可独立出来供存储用途,rootfs 路径为 root=/dev/mmcblk0p6
,因此 opt 对应 root=/dev/mmcblk0p6
。
# UNCONFIGURED FSTAB FOR BASE SYSTEM
# <file system> <mount pt> <type> <options> <dump> <pass>
/dev/root / ext2 rw,noauto 0 1
proc /proc proc defaults 0 0
devpts /dev/pts devpts defaults,gid=5,mode=620,ptmxmode=0666 0 0
tmpfs /dev/shm tmpfs mode=0777 0 0
tmpfs /tmp tmpfs mode=1777 0 0
tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0
sysfs /sys sysfs defaults 0 0
#/dev/mmcblk2p1 /boot vfat noatime,nodiratime,discard 0 0
/dev/mmcblk0p7 /param ext4 noatime,nodiratime,discard 0 0
/dev/mmcblk0p8 /opt ext4 noatime,nodiratime,discard 0 0
/dev/mmcblk0p9 /boot ext4 noatime,nodiratime 0 0
在 fstab 里原 boot 目录连接到 soc 分区,而 opt 连接 opt 分区,但 /boot 分区不再支持设备树、内核、uboot 升级用途,只提供配置项目存储用途。
其他分区说明暂无,凭直觉里可以认为 kernel 分区对应内核文件。
导出文件系统
注意:在 SD 卡启动的系统里是获取不到 EMMC 系统的文件的,所以修改文件只能在 EMMC 系统上。
在 EMMC 是不能直接读到 SD 卡槽上的系统卡的,这里推荐采用 OTG U 盘的方式或另外一张只有一个分区为 FAT 或 EXT4 的 SD 卡。
root@AXERA:~# fdisk -l
Disk /dev/mmcblk0: 7.28 GiB, 7818182656 bytes, 15269888 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mmcblk2: 480 MiB, 503316480 bytes, 983040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7e57471f
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 2048 983039 980992 479M 83 Linux
Disk /dev/sda: 58.94 GiB, 63281561600 bytes, 123596800 sectors
Disk model: SD Card Reader
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x32eb5429
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 264191 262144 128M c W95 FAT32 (LBA)
/dev/sda2 264192 12058623 11794432 5.6G 83 Linux
/dev/sda3 12058624 70586367 58527744 27.9G 83 Linux
/dev/sda4 70586368 123596799 53010432 25.3G 7 HPFS/NTFS/exFAT
root@AXERA:~#
这里推荐用读卡器直接对拷 SD 系统更新的内容,修改完成后确认一下外部拓展存储区域(/dev/sda3)选择导出到 U 盘 或 SD 卡。
root@AXERA:~# mount /dev/sda2 /mnt
root@AXERA:~# ls /mnt/ -l
total 76
lrwxrwxrwx 1 root root 7 Aug 4 2022 bin -> usr/bin
drwx------ 2 root root 4096 Aug 4 2022 boot
-rwxr-xr-x 1 root root 11 Aug 4 2022 debuerreotype-epoch
drwxr-xr-x 4 root root 4096 Oct 19 07:56 dev
drwxr-xr-x 90 root root 4096 Feb 13 02:20 etc
drwxr-xr-x 15 root root 4096 Feb 17 02:29 home
lrwxrwxrwx 1 root root 7 Aug 4 2022 lib -> usr/lib
drwx------ 2 root root 4096 Aug 19 2022 lost+found
drwxr-xr-x 2 root root 4096 Aug 4 2022 media
drwxr-xr-x 2 root root 4096 Aug 4 2022 mnt
drwxrwxr-x 10 root root 4096 Oct 17 07:48 opt
drwxr-xr-x 2 root root 4096 Aug 4 2022 param
drwxr-xr-x 2 root root 4096 Aug 4 2022 proc
drwxr-xr-x 7 root root 4096 Mar 17 10:07 root
drwxr-xr-x 7 root root 4096 Oct 19 07:56 run
lrwxrwxrwx 1 root root 8 Aug 4 2022 sbin -> usr/sbin
lrwxrwxrwx 1 root root 4 Nov 10 03:06 soc -> /opt
drwxr-xr-x 2 root root 4096 Aug 4 2022 srv
drwxr-xr-x 2 root root 4096 Aug 4 2022 sys
drwxr-xr-x 2 root root 4096 Mar 20 2022 test
drwxr-xr-x 2 root root 4096 Mar 13 06:43 tmp
drwxr-xr-x 11 root root 4096 Aug 4 2022 usr
drwxr-xr-x 11 root root 4096 Aug 4 2022 var
root@AXERA:~# mount
/dev/mmcblk0p6 on / type ext4 (rw,relatime)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,noexec,size=4096k,nr_inodes=65536,mode=755)
tmpfs on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=666)
tmpfs on /run type tmpfs (rw,nosuid,nodev,size=256304k,nr_inodes=819200,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /tmp type tmpfs (rw,relatime)
/dev/sda2 on /mnt type ext4 (rw,relatime)
root@AXERA:~#
- 使用
mount /dev/sda3 /mnt/
挂载分区,注意/dev/sda3
从fdisk -l
得知,这里我使用的是 U 盘挂载的方式。
root@AXERA:~# mount /dev/sda3 /mnt/
root@AXERA:~# ls /mnt/
AX620_demo_V0.31.0_P23_20220708101907_20230327113924.axp
backup.img
lost+found/
sipeed_m3axpi_debian11_with_8g2g.img
dd if=/dev/mmcblk0 of=/mnt/sipeed_m3axpi_debian11_with_8g2g.img bs=64M status=progress
root@AXERA:~# dd if=/dev/mmcblk0 of=/mnt/sipeed_m3axpi_debian11_with_8g2g.img bs=64M status=progressmg bs=64M status=progress
7818182656 bytes (7.8 GB, 7.3 GiB) copied, 213 s, 36.7 MB/s
116+1 records in
116+1 records out
7818182656 bytes (7.8 GB, 7.3 GiB) copied, 213.799 s, 36.6 MB/s
root@AXERA:~# ls -l /mnt
total 15679308
-rw-r--r-- 1 1000 1000 419218267 Mar 27 03:41 AX620_demo_V0.31.0_P23_20220708101907_20230327113924.axp
-rw-r--r-- 1 root root 7818182656 Mar 27 06:28 backup.img
drwx------ 2 root root 16384 Mar 27 06:00 lost+found
-rw-r--r-- 1 root root 7818182656 Mar 28 11:09 sipeed_m3axpi_debian11_with_8g2g.img
root@AXERA:~#
这样你就得到了我提供的 sipeed_m3axpi_debian11_emmc_20230329.img
喔!是不是很简单呢,在其他芯片上直接还原回去就行。
局限性和优越性
这样做
晚点接着写
如果你更改了物料或外设驱动?很需要帮助?请通过企业直接发邮件到 support@sipeed.com 公司请求开案定制生产。
最后吐槽一下制作这东西巨麻烦,建议 ubifs 就地淘汰!(无奈┓( ´∀` )┏)