ZHDA242 July   2026 TDA4VE-Q1

 

  1.   1
  2.   摘要
  3.   商标
  4. 简介
    1. 1.1 动机
    2. 1.2 范围
    3. 1.3 目标引导架构
  5. 背景
    1. 2.1 J721S2 启动流程
    2. 2.2 OSPI NOR 闪存概述
    3. 2.3 UBI 和 UBIFS 概述
  6. OSPI 闪存布局
    1. 3.1 分区布局
    2. 3.2 引导加载程序分区
    3. 3.3 根文件系统分区
  7. 刷写引导元件
    1. 4.1 引导元件概述
    2. 4.2 识别 OSPI MTD 分区
    3. 4.3 将引导元件刷写到 OSPI NOR 闪存中
    4. 4.4 验证引导元件
  8. 创建 UBIFS 根文件系统
    1. 5.1 准备 RootFS 分区
    2. 5.2 创建 UBI 设备
    3. 5.3 创建 UBIFS 卷
    4. 5.4 验证 UBIFS 操作
  9. 将 Linux 引导工件存储在 UBIFS 中
    1. 6.1 挂载 UBIFS 根文件系统卷
    2. 6.2 使用 BusyBox 创建根文件系统结构
    3. 6.3 验证 BusyBox 执行
    4. 6.4 创建 BusyBox 命令链接
    5. 6.5 创建 init 脚本
    6. 6.6 使用 chroot 测试根文件系统
    7. 6.7 复制 Linux 内核映像和 DTB
  10. 从 UBIFS 配置 Linux 引导
    1. 7.1 配置引导参数
    2. 7.2 从 UBIFS 加载内核和 DTB
    3. 7.3 测试 Linux 引导
    4. 7.4 创建可重复使用的引导命令
  11. 完全从 OSPI NOR 闪存引导 Linux
    1. 8.1 自动执行 U-Boot 中的引导序列
    2. 8.2 端到端引导流程
  12. 总结
  13. 10参考资料

验证 UBIFS 操作

UBIFS 卷可以使用 Linux UBIFS 驱动程序挂载。

创建挂载点并挂载卷。

root@j721s2-evm:~# mkdir -p /mnt/ospi_rootfs
root@j721s2-evm:~# mount -t ubifs -o compr=none ubi0:rootfs /mnt/ospi_rootfs
[  378.881540] UBIFS (ubi0:0): default file-system created
[  378.886938] UBIFS (ubi0:0): Mounting in unauthenticated mode
[  378.892793] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 1188
[  378.924191] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[  378.931604] UBIFS (ubi0:0): LEB size: 262016 bytes (255 KiB), min./max. I/O unit sizes: 16 bytes/256 bytes
[  378.941248] UBIFS (ubi0:0): FS size: 54761344 bytes (52 MiB, 209 LEBs), max 219 LEBs, journal size 2620160 bytes (2 MiB, 10 LEBs)
[  378.952889] UBIFS (ubi0:0): reserved for root: 2586513 bytes (2525 KiB)
[  378.959495] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID 0D0FF060-F89F-4D12-B474-1C6AA3288A8D, small LPT model
root@j721s2-evm:~#

可以使用标准的 Linux 文件操作来验证已挂载的文件系统。

例如,

root@j721s2-evm:~# echo hello > /mnt/ospi_rootfs/test.txt
root@j721s2-evm:~# sync
root@j721s2-evm:~# cat /mnt/ospi_rootfs/test.txt
hello
root@j721s2-evm:~#

除了在 Linux 上进行验证之外,还可以从 U-Boot 环境验证 UBIFS 卷。此步骤确保在存储 Linux 引导工件之前可以由 U-Boot 访问在 Linux 中创建的文件系统。

使用了以下命令。

=> ubi part ospi.rootfs

=> ubifsmount ubi0:rootfs

=> ubifsls /

示例输出如下所示。

=> ubi part ospi.rootfs
k3-navss-ringacc ringacc@2b800000: Ring Accelerator probed rings:286, gp-rings[96,20] sci-dev-id:272
k3-navss-ringacc ringacc@2b800000: dma-ring-reset-quirk: disabled
jedec_spi_nor flash@0: non-uniform erase sector maps are not supported yet.
cadence_spi spi@47040000: Pattern not found. Skipping calibration
SF: Detected s28hs512t with page size 256 Bytes, erase size 256 KiB, total 64 MiB
jedec_spi_nor flash@0: Software reset enable failed: -524
cadence_spi spi@47050000: Pattern not found. Skipping calibration
SF: Detected mt25qu512a with page size 256 Bytes, erase size 64 KiB, total 64 MiB
Could not find a valid device for spi-nand0
ubi0: attaching mtd7
ubi0: scanning is finished
ubi0: attached mtd7 (name "ospi.rootfs", size 55 MiB)
ubi0: PEB size: 262144 bytes (256 KiB), LEB size: 262016 bytes
ubi0: min./max. I/O unit sizes: 16/256, sub-page size 16
ubi0: VID header offset: 64 (aligned 64), data offset: 128
ubi0: good PEBs: 223, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 7/3, WL threshold: 4096, image sequence number: 1854191452
ubi0: available PEBs: 0, total reserved PEBs: 223, PEBs reserved for bad PEB handling: 0
=> ubifsmount ubi0:rootfs
UBIFS (ubi0:0): recovery needed
UBIFS (ubi0:0): recovery deferred
UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs", R/O mode
UBIFS (ubi0:0): LEB size: 262016 bytes (255 KiB), min./max. I/O unit sizes: 16 bytes/256 bytes
UBIFS (ubi0:0): FS size: 54761344 bytes (52 MiB, 209 LEBs), journal size 2620160 bytes (2 MiB, 10 LEBs)
UBIFS (ubi0:0): reserved for root: 2586513 bytes (2525 KiB)
UBIFS (ubi0:0): media format: w5/r0 (latest is w4/r0), UUID 0D0FF060-F89F-4D12-B474-1C6AA3288A8D, small LPT model
=> ubifsls /
                6  Fri May 30 02:46:03 2025  test.txt
=>

成功执行这些命令确认 U-Boot 可以正确识别在 Linux 中创建的 UBI 元数据和 UBIFS 卷,并且可以在存储 Linux 引导文件之前访问这些卷。

成功读取和写入操作确认如下。

• 可访问 OSPI NOR 闪存分区。

• UBI 设备工作正常。

• UBIFS 卷可以从 Linux 和 U-Boot 环境中挂载和使用。

此时,rootfs 卷已准备好存储下一章中所述的 Linux 内核映像、DTB 和根文件系统元件。