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: How to create EXT4 rootfs on UFS and boot to Linux using UFS

Part Number: J784S4XEVM

Tool/software:

UFS is present on the J784S4EVM. How can one use it instead of eMMC to host rootfs and use that to boot to Linux command prompt.

  • Hi,

    Steps below:

    1. Please follow the SDK documentation to create LUNs:
      https://software-dl.ti.com/jacinto7/esd/processor-sdk-linux-j784s4/09_02_00_05/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/UFS.html
    2. Then boot to Linux prompt using SD card & make ext4 partition for UFS /dev/sdb1
      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. The other thing is that you need to make sure that kernel Image has UFS as built in and Not as module:
      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


      make linux & copy the new Image under $SDK/board-support/ti-linux*/arch/arm64/boot/Image to SD card /media/$USER/rootfs/arch/arm64/boot

    4. Copy rootfs from SD card to UFS:
      mkdir /mnt/ufs
      mkdir /mnt/sd
      cp -r /mnt/sd/* /mnt/ufs
      sync
      umount /mnt/*

    5. Bootargs to be passed from U-Boot to boot from 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
      Regards,
      Keerthy