Firefly开源社区

[技术讨论] 基于官方debian10重新打包到私有固件后再刷入至板子,启动后不正常进入initramfs模式

80

积分

0

威望

0

贡献

技术小白

积分
80
发表于 5 天前     
问题描述及复现步骤:
本帖最后由 music1913 于 2022-6-22 15:24 编辑

  • 以官方debian10固件为基础打包私有固件

在 firefly 的官方云盘中,可供下载的debian 10的文件包内容如下:

AIO-RV1126(1109)-JD4\Debian10\debian10_2021_0429_1902\debian10\



我将上述文件与路径 AIO-RV1126(1109)-JD4\Buildroot\AIO-RV1126_RV1109-JD4_IPC_2021_1206_1919\ 下的固件包先进行了合并,然后再通过RK_Dev_tool整体刷入主板的,所以最终的刷入主板的官方固件包结构是这样:


刷入后,主板系统启动后一切运行正常。
  • 安装私有程序
在主板系统启动后,安装包括python的一些package, 各类配置文件等,通过pip install ... 和拷贝等方式,安装至系统中。
  • 打包固件
  • 准备U盘
到手一个 32G 的U盘,插入windows pc, 下载 DiskGenius 将其 format ext4 格式:


image.png

插入U盘至rv1126主板,并加载(映射)U盘至本地文件夹:
  1. 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。
压缩镜像文件:
  1. 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机上,并运行
  1. 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.img  0x0000000000441800      0x000000000000C000
Image/boot.img  0x000000000044D800      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\  其中的文件结构如下:


image.png



将之前私有定制后export出来的Firefly_ext4_202206170232.img 重新命名为 rootfs.img 并覆盖替换上图中的同样文件(size 490.34M),所以现在文件夹结构为(其实仅一个文件被更换了):


image.png



回到 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:

image.png



重新命名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.img  0x0000000000441800      0x000000000000C000
Image/boot.img  0x000000000044D800      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:


得到文件结构:

image.png


将上述文件包刷入板子中:
image.jpg

因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)

请问上述步骤是有哪里不对吗?



none.zip

154 Bytes, 下载次数: 0, 下载积分: 灯泡 -1 , 经验 -1

回复

使用道具 举报

894

积分

0

威望

0

贡献

技术大神

Rank: 3Rank: 3

积分
894
发表于 4 天前     
合包之后得到 new_update.img 就可以直接烧录了,为什么又解包一遍
回复

使用道具 举报

80

积分

0

威望

0

贡献

技术小白

积分
80
发表于 4 天前     
Liuth 发表于 2022-6-23 10:12
合包之后得到 new_update.img 就可以直接烧录了,为什么又解包一遍

在得到 new_update.img 后,如果直接进行烧写,是否应该是在这个 tab 菜单下进行呢:

image.png

而我现在一直是如图的报错。

或者我先“擦除Flash”后,再“升级”,得到是此错误:
image.png




另外,之前的烧写镜像都是通过第一个 tab 菜单: "下载镜像" 中进行的,且要鼠标右导入一个 debian10.cfg 的文件,然后再一个一个选多个.img文件,然后再写入,请问这两个tab菜单(“下载镜像”,“升级固件”)有什么异同呢?
回复

使用道具 举报

1万

积分

7

威望

0

贡献

神级创客

Rank: 8Rank: 8

积分
10474

突出贡献

发表于 4 天前     
你还需要手动更换分区表。debian和buildroot用的不是同一个分区表。debian需要使用到parameter-firefly-debian-fit.txt分区表。
回复

使用道具 举报

80

积分

0

威望

0

贡献

技术小白

积分
80
发表于 4 天前     
799959745 发表于 2022-6-23 11:33
你还需要手动更换分区表。debian和buildroot用的不是同一个分区表。debian需要使用到parameter-firefly-deb ...

firefly-rk3399-linux-repack 工具是用于打包的,还是需要手动编辑吗?
请问能提供下相关的具体步骤吗?多谢!
回复

使用道具 举报

1万

积分

7

威望

0

贡献

神级创客

Rank: 8Rank: 8

积分
10474

突出贡献

发表于 4 天前     
ls -l sdk/rockdev/能看到分区表所在的位置
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表