基于官方debian10重新打包到私有固件后再刷入至板子,启动后不正常进入initramfs模式
本帖最后由 music1913 于 2022-6-22 15:24 编辑[*]以官方debian10固件为基础打包私有固件
在 firefly 的官方云盘中,可供下载的debian 10的文件包内容如下:
AIO-RV1126(1109)-JD4\Debian10\debian10_2021_0429_1902\debian10\
https://dev.t-firefly.com/data/attachment/forum/202206/21/145535ohocirehizrih26g.png
我将上述文件与路径 AIO-RV1126(1109)-JD4\Buildroot\AIO-RV1126_RV1109-JD4_IPC_2021_1206_1919\ 下的固件包先进行了合并,然后再通过RK_Dev_tool整体刷入主板的,所以最终的刷入主板的官方固件包结构是这样:
https://dev.t-firefly.com/data/attachment/forum/202206/21/145548uxtspkkbns4yxskk.png
刷入后,主板系统启动后一切运行正常。
[*]安装私有程序
在主板系统启动后,安装包括python的一些package, 各类配置文件等,通过pip install ... 和拷贝等方式,安装至系统中。
[*]打包固件
[*]准备U盘
到手一个 32G 的U盘,插入windows pc, 下载 DiskGenius 将其 format 成 ext4 格式:
插入U盘至rv1126主板,并加载(映射)U盘至本地文件夹:
sudo mount /dev/sda1 /media/usb_drive
2.导出当前固件
用工具 ff_export_rootfs进行 export:
firefly@firefly:~/Download/ff_export_rootfs_buildroot$ sudo ./ff_export_rootfs /media/usb_drive/
MEDIA FREE SPACE SIZE 55975 MBytes
EXPORT IMAGE SIZE 8568 MBytes
find: '/proc/896/task/896/net': Invalid argument
find: '/proc/896/net': Invalid argument
find: '/proc/936/task/936/net': Invalid argument
find: '/proc/936/net': Invalid argument
find: '/proc/1139/task/1139/net': Invalid argument
find: '/proc/1139/net': Invalid argument
BLOCK_COUNT 9290489
INODE_COUNT 169877
sync...
sync finish
Export rootfs to /media/usb_drive//Firefly_ext4_202206170232.img Success
可见生成的文件Firefly_ext4_202206170232.img有file size达到9G。
压缩镜像文件:
firefly@firefly:/media/usb_drive$ sudo /sbin/e2fsck -p -f Firefly_ext4_202206170232.img
到7G。
3.unpack官方固件
官方的未解离的固件文件存在于: AIO-RV1126(1109)-JD4\Debian10\shao_merge\pack\AIO-RV1126-JD4-BE-45-GPT-20211206-1919.img 将此文件重新命名为 update.img,并拷贝至一台安装了firefly-rk3399-linux-repack 工具的 Ubuntu PC机上,并运行
sudo ./unpack.sh
,可以看到运行结果:
shawn@DESKTOP-9NG0VFK:~/Downloads/firefly-rk3399-linux-repack$ sudo ./unpack.sh
start to unpack update.img...
********RKImageMaker ver 1.66********
Unpacking image, please wait...
Exporting boot.bin
Exporting firmware.img
Unpacking image success.
Android Firmware Package Tool v1.65
Check file... OK
------- UNPACK ------
package-file 0x0000000000000800 0x000000000000032C
Image/MiniLoaderAll.bin 0x0000000000001000 0x000000000003F94E
Image/parameter.txt 0x0000000000041000 0x0000000000000205
Image/uboot.img 0x0000000000041800 0x0000000000400000
Image/misc.img0x0000000000441800 0x000000000000C000
Image/boot.img0x000000000044D800 0x000000000101EC00
Image/recovery.img 0x000000000146C800 0x0000000000F97A00
Image/rootfs.img 0x0000000002404800 0x000000001EA58000
Image/oem.img 0x0000000020E5C800 0x000000000AB00000
Image/userdata.img 0x000000002B95C800 0x0000000000500000
Unpack firmware OK!
------ OK ------
Unpacking update.img OK.
Press any key to quit:
在此 Ubuntu PC 上,可以看到 unpack后的文件夹位于: xxxx\Downloads\firefly-rk3399-linux-repack\output\Image\其中的文件结构如下:
将之前私有定制后export出来的Firefly_ext4_202206170232.img 重新命名为 rootfs.img 并覆盖替换上图中的同样文件(size 490.34M),所以现在文件夹结构为(其实仅一个文件被更换了):
回到 Ubuntu PC 命令行中,进行重新(repack)打包:
shawn@DESKTOP-9NG0VFK:~/Downloads/firefly-rk3399-linux-repack$ sudo ./pack.sh
start to make update.img...
Resize rootfs partition
dumpe2fs 1.45.5 (07-Jan-2020)
Android Firmware Package Tool v1.65
------ PACKAGE ------
Add file: ./package-file
Add file: ./Image/MiniLoaderAll.bin
Add file: ./Image/parameter.txt
Add file: ./Image/uboot.img
Add file: ./Image/misc.img
Add file: ./Image/boot.img
Add file: ./Image/recovery.img
Add file: ./Image/rootfs.img
Add file: ./Image/oem.img
Add file: ./Image/userdata.img
Add CRC...
Make firmware OK!
------ OK ------
********RKImageMaker ver 1.66********
Generating new image, please wait...
Writing head info...
Writing boot file...
Writing firmware...
Generating MD5 data...
MD5 data generated successfully!
New image generated successfully!
Making update.img OK.
/home/shawn/Downloads/firefly-rk3399-linux-repack
Press any key to quit:
得到了一个新文件 new_update.img:
重新命名new_update.img 到 udpate.img,再次运行 unpack.sh:
shawn@DESKTOP-9NG0VFK:~/Downloads/firefly-rk3399-linux-repack$ sudo ./unpack.sh
start to unpack update.img...
********RKImageMaker ver 1.66********
Unpacking image, please wait...
Exporting boot.bin
Exporting firmware.img
Unpacking image success.
Android Firmware Package Tool v1.65
Check file... OK
------- UNPACK ------
package-file 0x0000000000000800 0x000000000000032C
Image/MiniLoaderAll.bin 0x0000000000001000 0x000000000003F94E
Image/parameter.txt 0x0000000000041000 0x0000000000000201
Image/uboot.img 0x0000000000041800 0x0000000000400000
Image/misc.img0x0000000000441800 0x000000000000C000
Image/boot.img0x000000000044D800 0x000000000101EC00
Image/recovery.img 0x000000000146C800 0x0000000000F97A00
Image/rootfs.img 0x0000000002404800 0x00000001D61E2C00
Image/oem.img 0x00000001D85E7800 0x000000000AB00000
Image/userdata.img 0x00000001E30E7800 0x0000000000500000
Unpack firmware OK!
------ OK ------
Unpacking update.img OK.
Press any key to quit:
得到文件结构:
将上述文件包刷入板子中:
因rootfs.img较大,此次写入需要10几分钟,完成后,通过串口连进去板子,看到如下错误,且系统进入了initramfs模式:
...
...
...
/scripts/init-top/console_setup: line 1: can't open /dev/tty5: No such device or address
/scripts/init-top/console_setup: line 1: can't create /dev/tty6: No such device or address
/scripts/init-top/console_setup: line 1: can't open /dev/tty6: No such device or address
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
Warning: fsck not present, so skipping root file system
[ 3.656794] EXT4-fs (mmcblk0p6): mounted filesystem without journal. Opts: (null)
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... Warning: overlayroot: configuring overlayroot with driver=overlay mode=device opts='dev=PARTLABEL=userdata,fstype=ext4,mkfs=1' per kernel cmdline
[ 3.801313] EXT4-fs (mmcblk0p8): warning: mounting unchecked fs, running e2fsck is recommended
[ 3.803943] EXT4-fs (mmcblk0p8): mounted filesystem without journal. Opts: (null)
[ 3.836820] EXT4-fs error (device mmcblk0p6): ext4_lookup:1706: inode #2: comm overlayroot: deleted inode referenced: 58673
[ 3.840096] EXT4-fs error (device mmcblk0p6): ext4_lookup:1706: inode #2: comm overlayroot: deleted inode referenced: 58673
mkdir: can't create directory '/root/userdata': Structure needs cleaning
[ 3.847199] EXT4-fs error (device mmcblk0p6): ext4_lookup:1706: inode #2: comm exe: deleted inode referenced: 58673
mount: mounting /userdata on /root/userdata failed: Structure needs cleaning
Failure: overlayroot: failed to move /userdata to /root/userdata
Warning: Something odd, no /lib/modules/4.19.111 in initramfs.
done.
[ 3.925953] EXT4-fs error (device mmcblk0p6): ext4_lookup:1706: inode #2: comm run-init: deleted inode referenced: 49097
run-init: /sbin/init: Structure needs cleaning
Target filesystem doesn't have requested /sbin/init.
[ 3.929671] EXT4-fs error (device mmcblk0p6): ext4_lookup:1706: inode #2: comm run-init: deleted inode referenced: 49097
run-init: /sbin/init: Structure needs cleaning
run-init: /etc/init: No such file or directory
[ 3.939371] EXT4-fs error (device mmcblk0p6): ext4_lookup:1706: inode #2: comm run-init: deleted inode referenced: 46969
run-init: /bin/init: Structure needs cleaning
[ 3.943189] EXT4-fs error (device mmcblk0p6): ext4_lookup:1706: inode #2: comm run-init: deleted inode referenced: 46969
run-init: /bin/sh: Structure needs cleaning
run-init: : No such file or directory
chvt: can't open console
No init found. Try passing init= bootarg.
Couldn't get a file descriptor referring to the console
/scripts/panic/console_setup: line 133: can't create /dev/tty1: No such device or address
/scripts/panic/console_setup: line 1: can't open /dev/tty1: No such device or address
/scripts/panic/console_setup: line 1: can't create /dev/tty2: No such device or address
/scripts/panic/console_setup: line 1: can't open /dev/tty2: No such device or address
/scripts/panic/console_setup: line 1: can't create /dev/tty3: No such device or address
/scripts/panic/console_setup: line 1: can't open /dev/tty3: No such device or address
/scripts/panic/console_setup: line 1: can't create /dev/tty4: No such device or address
/scripts/panic/console_setup: line 1: can't open /dev/tty4: No such device or address
/scripts/panic/console_setup: line 1: can't create /dev/tty5: No such device or address
/scripts/panic/console_setup: line 1: can't open /dev/tty5: No such device or address
/scripts/panic/console_setup: line 1: can't create /dev/tty6: No such device or address
/scripts/panic/console_setup: line 1: can't open /dev/tty6: No such device or address
BusyBox v1.27.2 (Ubuntu 1:1.27.2-2ubuntu3.2) built-in shell (ash)
Enter 'help' for a list of built-in commands.
(initramfs)
请问上述步骤是有哪里不对吗?
合包之后得到 new_update.img 就可以直接烧录了,为什么又解包一遍 Liuth 发表于 2022-6-23 10:12
合包之后得到 new_update.img 就可以直接烧录了,为什么又解包一遍
在得到 new_update.img 后,如果直接进行烧写,是否应该是在这个 tab 菜单下进行呢:
而我现在一直是如图的报错。
或者我先“擦除Flash”后,再“升级”,得到是此错误:
另外,之前的烧写镜像都是通过第一个 tab 菜单: "下载镜像" 中进行的,且要鼠标右导入一个 debian10.cfg 的文件,然后再一个一个选多个.img文件,然后再写入,请问这两个tab菜单(“下载镜像”,“升级固件”)有什么异同呢?
你还需要手动更换分区表。debian和buildroot用的不是同一个分区表。debian需要使用到parameter-firefly-debian-fit.txt分区表。 799959745 发表于 2022-6-23 11:33
你还需要手动更换分区表。debian和buildroot用的不是同一个分区表。debian需要使用到parameter-firefly-deb ...
firefly-rk3399-linux-repack 工具是用于打包的,还是需要手动编辑吗?
请问能提供下相关的具体步骤吗?多谢! ls -l sdk/rockdev/能看到分区表所在的位置 本帖最后由 music1913 于 2022-6-27 14:01 编辑
799959745 发表于 2022-6-23 19:08
ls -l sdk/rockdev/能看到分区表所在的位置
多谢。
因为对linux以及其文件(打包)结构都不太了解,我打包的理解完全来自于此官方步骤
导出设备系统 — Firefly Wiki (t-firefly.com)
请问能否依照上述步骤解释一下,我原帖子中的步骤有什么错误和缺失吗?
music1913 发表于 2022-6-27 11:00
多谢。
因为对linux以及其文件(打包)结构都不太了解,我打包的理解完全来自于此官方步骤https://wiki. ...
你需要拷贝sdk/device/rockchip/rv1126_rv1109/parameter-firefly-debian-fit.txt替换你打包的分区表。然后再进行打包。
或许你发一下你的分区表parameter.txt里面的内容。还有你打包的工具。 本帖最后由 music1913 于 2022-6-27 16:02 编辑
799959745 发表于 2022-6-27 11:32
你需要拷贝sdk/device/rockchip/rv1126_rv1109/parameter-firefly-debian-fit.txt替换你打包的分区表。然 ...
多谢你的回复!
附件中是从官方文档:导出设备系统 — Firefly Wiki (t-firefly.com) 指导中所涉及的,也是我现在使用的两个工具。
ff_export_rootfs_buildroot.tar 用于将当前运行系统(Debian 10) 导出(export)到一个.img文件。
firefly-rk3399-linux-repack.tgz 用于将上述.img文件打包成为系统固件的工具,以便分发和重新刷入至其它板子,也提及了您所提到的parameter.txt,见下图红色框内的字:
=======================================================
其实我在得到 export 后的文件 ,一般是这样命名规则的一个文件:Firefly_ext4_202206240234.img (在我装了一些 Python 包等之后,它尺寸达到了6G), 打包的步骤都是我推测进行的,因为在官方wiki文档中所提及的 红色框内的 官方固件文件:
我并未见到过,而我手头用于初始化刷写至板子debian 10的是这么一系列从官方云盘中下载的多个文件:
并非单一文件,我也将其中的 parameter.txt 放在附件 parameter.zip 中了。
问题有两个
问题1:合包用的 new_update.img无法刷到设备,芯片 检测设备,因为你这个脚本是 3399 打包脚本,写 芯片类型会写成3399 ,所以出错了,先不考虑合包的情况。
问题2:上写进入 系统异常,其实这个问题是因为你做的 rootfs 太大了,超出了 rootfs 的分区大小。需要手动 调整分区大小至少 要等于你的 rootfs.img ,这个其实 wiki 也有说明的。https://wiki.t-firefly.com/zh_CN/CORE-1126-JD4/Debian10.html#gu-jian-zhi-zuo
页:
[1]
2