
.. _developer_notes_eMMC_filesystem:

How To Use EMMC Based Filesystem
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**The PSDK QNX release focuses on filesystems on the SD card. How can an eMMC based filesystem be made accessible/used on a PSDK QNX release?**

To make use of the eMMC filesystem on the |dev_platform| EVM with the PSDK QNX |psdk_qnx_version| release, the below steps can be followed.

.. NOTE::
   These steps were tested on the |dev_platform| EVM using the PSDK QNX |psdk_qnx_version| release, and may change with newer revisions of the TI PSDK QNX release.

-  Refer :ref:`getting_started_|dev_platform|` and :ref:`release_notes` to get the |dev_platform| EVM running with SD boot (either SBL or SPL).

- From the above step, an SD card will be created with an etx4 file system (rootfs) which holds the remote core firmware used by the bootloader. Since QNX cannot read or format ext4 file systems, this firmware will have to be moved to the boot partition before copying the boot files to the SD card (our u-boot uEnv.txt file will look for firmware here if booting from eMMC). This way we can transfer the firmware to the eMMC inside QNX OS. **If you don't plan to load remote core firmware, you can skip this step.**

.. code:: bash

   # command ran on host machine with fully populated & working SD card
   cp -rv <path_to_SD_card_mount_dir>/rootfs/lib/firmware/ <path_to_SD_card_mount_dir>/boot

- After booting the |dev_platform| EVM to the QNX prompt run the below commands to format and create an eMMC partition. For further information on usage of eMMC filesystems in the QNX environment please reference QNX’s Online User Guide.

.. code:: bash

   # Check the partition information:
   fdisk /dev/emmc0 info

.. code:: bash

   # Delete all existing partitions:
   fdisk /dev/emmc0 delete -a
   fdisk /dev/emmc0 show

.. code:: bash

   # Create a 256MB and a 8GB FAT32 partition from the beginning of the eMMC device:
   fdisk /dev/emmc0 add -t 12 -c 0,255
   fdisk /dev/emmc0 add -t 12 -c 256,8256
   fdisk /dev/emmc0 show

.. code:: bash

   #Enumerate the partitions:
   mount -e /dev/emmc0
   ls /dev/emmc0*

.. code:: bash

   # Format the FAT32 partition and mount it:
   mkdosfs /dev/emmc0t12
   mkdosfs /dev/emmc0t12.1

.. code:: bash

   # Mount
   mount -t dos /dev/emmc0t12 /emmc_boot
   mount -t dos /dev/emmc0t12.1 /emmc_ti_fs

.. code:: bash

   # Copy the filesystem contents from the SD card to the newly created eMMC partition
   ls /emmc_boot
   cp -Rvf /boot/* /emmc_boot
   cp -Rvf /ti_fs/* /emmc_ti_fs
   sync


- If using a |dev_platform| EVM, power down and reconfigure your bootmode switches to choose eMMC boot. Remove your sd card and power on your EVM. If using SPL (U-Boot) You will need to interrupt the U-Boot prompt and enter the following commands:

.. code:: bash

   setenv mmcdev 0
   run envboot


**To automatically boot without the need to interrupt the u-boot prompt, you will need to rebuild u-boot.** Change the default value of mmcdev in /board/ti/|dev_platform|/|dev_platform|.env to 0, and rebuild.

.. seealso::

   Refer to PSDK LINUX documentation for more information on u-boot
   https://software-dl.ti.com/jacinto7/esd/processor-sdk-linux-j784s4/latest/exports/docs/linux/Foundational_Components_U-Boot.html#u-boot-user-s-guide

