This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] [参考译文] [常见问题解答] J784S4XEVM:如何在 UFS 上创建 EXT4 rootfs 并使用 UFS 引导到 Linux

Guru**** 1815690 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1406714/faq-j784s4xevm-how-to-create-ext4-rootfs-on-ufs-and-boot-to-linux-using-ufs

器件型号:J784S4XEVM

工具与软件:

J784S4EVM 上存在 UFS。 如何使用它而不是 eMMC 来托管 rootfs 并使用它来引导至 Linux 命令提示符。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    步骤如下:

    1. 请按照 SDK 文档中的说明创建 LUN:
      https://software-dl.ti.com/jacinto7/esd/processor-sdk-linux-j784s4/09_02_00_05/exports/docs/linux/Foundational_Components /内核/ Kernel_Drivers / UFS.html
    2. 然后使用 SD 卡引导至 Linux 提示符并为 UFS /dev/sdb1创建 ext4分区
      root@j721e-evm:~# fdisk /dev/sdb
      
      Welcome to fdisk (util-linux 2.37.4).
      Changes will remain in memory only, until you decide to write them.
      Be careful before using the write command.
      
      The device contains 'ext4' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.
      
      Device does not contain a recognized partition table.
      Created a new DOS disklabel with disk identifier 0x511d1827.
      
      Command (m for help): m
      
      Help:
      
        DOS (MBR)
         a   toggle a bootable flag
         b   edit nested BSD disklabel
         c   toggle the dos compatibility flag
      
        Generic
         d   delete a partition
         F   list free unpartitioned space
         l   list known partition types
         n   add a new partition
         p   print the partition table
         t   change a partition type
         v   verify the partition table
         i   print information about a partition
      
        Misc
         m   print this menu
         u   change display/entry units
         x   extra functionality (experts only)
      
        Script
         I   load disk layout from sfdisk script file
         O   dump disk layout to sfdisk script file
      
        Save & Exit
         w   write table to disk and exit
         q   quit without saving changes
      
        Create a new label
         g   create a new empty GPT partition table
         G   create a new empty SGI (IRIX) partition table
         o   create a new empty DOS partition table
         s   create a new empty Sun partition table
      
      
      Command (m for help): p
      Disk /dev/sdb: 29.79 GiB, 31981568000 bytes, 7808000 sectors
      Disk model: THGAF8G8T23BAILB
      Units: sectors of 1 * 4096 = 4096 bytes
      Sector size (logical/physical): 4096 bytes / 4096 bytes
      I/O size (minimum/optimal): 65536 bytes / 65536 bytes
      Disklabel type: dos
      Disk identifier: 0x511d1827
      
      Command (m for help): n
      Partition type
         p   primary (0 primary, 0 extended, 4 free)
         e   extended (container for logical partitions)
      Select (default p): p
      Partition number (1-4, default 1): 
      First sector (256-7807999, default 256): [   45.123255] kauditd_printk_skb: 3 callbacks suppressed
      [   45.123262] audit: type=1334 audit(1715059470.964:17): prog-id=12 op=UNLOAD
      [   45.135361] audit: type=1334 audit(1715059470.964:18): prog-id=11 op=UNLOAD
      [   45.593936] systemd-journald[165]: Time jumped backwards, rotating.
      
      Last sector, +/-sectors or +/-size{K,M,G,T,P} (256-7807999, default 7807999): 
      
      Created a new partition 1 of type 'Linux' and of size 29.8 GiB.
      
      Command (m for help): p^H^H^H
      Disk /dev/sdb: 29.79 GiB, 31981568000 bytes, 7808000 sectors
      Disk model: THGAF8G8T23BAILB
      Units: sectors of 1 * 4096 = 4096 bytes
      Sector size (logical/physical): 4096 bytes / 4096 bytes
      I/O size (minimum/optimal): 65536 bytes / 65536 bytes
      Disklabel type: dos
      Disk identifier: 0x511d1827
      
      Device     Boot Start     End Sectors  Size Id Type
      /dev/sdb1         256 7807999 7807744 29.8G 83 Linux
      
      Command (m for help): m
      
      Help:
      
        DOS (MBR)
         a   toggle a bootable flag
         b   edit nested BSD disklabel
         c   toggle the dos compatibility flag
      
        Generic
         d   delete a partition
         F   list free unpartitioned space
         l   list known partition types
         n   add a new partition
         p   print the partition table
         t   change a partition type
         v   verify the partition table
         i   print information about a partition
      
        Misc
         m   print this menu
         u   change display/entry units
         x   extra functionality (experts only)
      
        Script
         I   load disk layout from sfdisk script file
         O   dump disk layout to sfdisk script file
      
        Save & Exit
         w   write table to disk and exit
         q   quit without saving changes
      
        Create a new label
         g   create a new empty GPT partition table
         G   create a new empty SGI (IRIX) partition table
         o   create a new empty DOS partition table
         s   create a new empty Sun partition table
      
      
      Command (m for help): w
      The partition table has been altered.
      Calling ioctl() to re-read partition table.
      [   55.711671]  sdb: sdb1
      Syncing disks.
      
      root@j721e-evm:~# lsblk -l
      NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
      sda            8:0    0   32M  0 disk 
      sda1           8:1    0   31M  0 part 
      sdb            8:16   0 29.8G  0 disk 
      sdb1           8:17   0 29.8G  0 part 
      mtdblock0     31:0    0  512K  0 disk 
      mtdblock1     31:1    0    2M  0 disk 
      mtdblock2     31:2    0    4M  0 disk 
      mtdblock3     31:3    0  128K  0 disk 
      mtdblock4     31:4    0  128K  0 disk 
      mtdblock5     31:5    0    1M  0 disk 
      mtdblock6     31:6    0 55.8M  0 disk 
      mtdblock7     31:7    0  128K  0 disk 
      mtdblock8     31:8    0  512K  0 disk 
      mtdblock9     31:9    0    2M  0 disk 
      mtdblock10    31:10   0    4M  0 disk 
      mtdblock11    31:11   0  128K  0 disk 
      mtdblock12    31:12   0  128K  0 disk 
      mtdblock13    31:13   0    1M  0 disk 
      mtdblock14    31:14   0 55.8M  0 disk 
      mtdblock15    31:15   0  128K  0 disk 
      mmcblk0      179:0    0 14.8G  0 disk 
      mmcblk0p1    179:1    0 14.8G  0 part 
      mmcblk0boot0 179:32   0 31.5M  1 disk 
      mmcblk0boot1 179:64   0 31.5M  1 disk 
      mmcblk1      179:96   0 14.8G  0 disk 
      mmcblk1p1    179:97   0  128M  0 part /boot
      mmcblk1p2    179:98   0  7.4G  0 part /
      
      root@j721e-evm:~# sudo mkfs -t ext4 /dev/sdb1 
      mke2fs 1.46.5 (30-Dec-2021)
      Creating filesystem with 7807744 4k blocks and 1954064 inodes
      Filesystem UUID: e1bac28e-f771-40a4-b06e-71f93217ad3e
      Superblock backups stored on blocks: 
              32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
              4096000
      
      Allocating group tables: done                            
      Writing inode tables: done                            
      Creating journal (32768 blocks): done
      Writing superblocks and filesystem accounting information: done   
      
      root@j721e-evm:~# sudo mkfs -t vfat /dev/sda1
      mkfs.fat 4.2 (2021-01-31)
      root@j721e-evm:~# lsblk -f
      NAME         FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
      sda                                                                                 
      `-sda1       vfat               BCF8-546B                                           
      sdb                                                                                 
      `-sdb1       ext4               e1bac28e-f771-40a4-b06e-71f93217ad3e   27.6G     0% /run/media/sdb1 


    3. 另一件事是、您需要确保内核映像具有内置的 UFS、而不是模块:
      diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
      index c59d34af1..8f613d311 100644
      --- a/arch/arm64/configs/defconfig
      +++ b/arch/arm64/configs/defconfig
      
       CONFIG_SCSI_UFS_QCOM=m
       CONFIG_SCSI_UFS_HISI=y
       CONFIG_SCSI_UFS_RENESAS=m
      -CONFIG_SCSI_UFS_TI_J721E=m
      +CONFIG_SCSI_UFS_TI_J721E=y


      制作 Linux 并将$SDK/board-support/ti-linux*下的新映像复制/arch/arm64/boot/Image 到 SD 卡/media/$USER/rootfs/arch/arm64/boot 中

    4. 将 rootfs 从 SD 卡复制到 UFS:
      mkdir /mnt/ufs
      mkdir /mnt/sd
      cp -r /mnt/sd/* /mnt/ufs
      sync
      umount /mnt/*

    5. 要从 U-Boot 传递到从 UFS rootfs 引导的引导参数:
      setenv bootargs console=ttyS2,115200n8 earlycon=ns16550a,mmio32,0x02880000 root=/dev/sdb1 rootwait
      
      setenv bootcmd "ufs init; scsi scan; ext4load scsi 1 0x82000000 boot/Image; ext4load scsi 1 0x81200000 boot/dtb/ti/k3-j784s4-evm.dtb; booti 0x82000000 - 0x81200000"
      
      boot
      此致、
      基尔西