Copying Files to the Device

There are several ways of transferring files to and from your target device. Please reference the following for some possible methods.

Using Removable Storage Devices

USB Storage Device

These instructions walkthrough exercising the USB Host interface on the development kit, but since your Ubuntu Host Machine is also a Linux system, you can similarly transfer files to the same storage media to exchange files.

The USB0 interface is brought out as a USB-C connector that supports both host and device mode (USB role switching). The USB1 interface is connected to a 4-port USB hub (U21), which provides the dual USB Type-A connector X16 and also connects to the M.2 Key-E slot and the AV connector.

USB Locations

Interface

Connector

Mode

Speed

USB0

X18 (USB-C)

Dual-role (host/device)

USB 2.0 High-Speed

USB1

X16 (dual USB Type-A, via hub U21)

Host

USB 2.0 High-Speed

What You Will Need

  • USB Storage Device

Verifying USB Interface

  • With the phyFLEX-AM62Px development kit booted into Linux, see the available USB devices.

    am62pxx-phyflex-libra-rdk-1:~# lsusb
    
  • Insert a USB storage device into one of the USB Type-A ports of X16.

  • Verify that the USB was properly recongnized by the development kit.

    am62pxx-phyflex-libra-rdk-1:~# lsusb
    Bus 001 Device 003: ID 0781:5591  USB  SanDisk 3.2Gen1
    ...
    

    Note

    Please note that the Bus and Device numbers on your board may vary slightly from those described here.

  • To list more information about the USB device and buses on the development kit use the following command.

    am62pxx-phyflex-libra-rdk-1:~# lsusb -v -s 001:003
    

    Note

    “001” refers to bus 001 and “003” refers to the device number, both of these can be found in the lsusb command.

Mounting USB Stroage Devices

  • Mount the USB device to the directory.

    am62pxx-phyflex-libra-rdk-1:~# mount /dev/sda /mnt/
    

    Note

    In this example the device name for the USB drive is “sda”. The device name can be found when plugging the USB drive into the development kit.

  • See what media is on the USB drive.

    am62pxx-phyflex-libra-rdk-1:~# ls /mnt/
    

Read from the USB Host Device

  • Copy media from the USB drive to a directory or file onto the target:

    am62pxx-phyflex-libra-rdk-1:~# cp /mnt/<file> <file destination>
    

Unmounting the Drive

Warning

Make sure the drive is unmounted prior to physically disconnecting the device. Failure to do so may result in loss of data and corruption of files

am62pxx-phyflex-libra-rdk-1:~# umount /mnt/

SD Card (Root Partition)

Since our Host Machines have access to the SD Card readers, we can use the bootable SD Card itself to transfer files to and from the development kit too, the only down side for this is that you will want to power off the development kit before removing the primary booting device.

  • Power off the development kit.

    am62pxx-phyflex-libra-rdk-1:~# poweroff
    
  • Remove the SD card and connect it to your Linux machine via an SD card reader.

  • The SD Card is formatted with a minimal root filesystem size by default and in order to transfer larger files it may become necessary to increase its size to take advantage of the full size of the SD Card.

Increase the root filesystem partition of the SD card.

  • Run the following command without the SD card connected to the host machine.

    sh-host:~$ ls /dev/sd*
    
  • Connect the bootable SD card to your Ubuntu host machine.

  • Run the following command with the SD card connected to the host machine.

    The SD card device name is of the form /dev/sd[a-z] in Linux and the letter identifier along with any partitions (signified by the numbers following the letter) on the SD card are enumerated upon connection to the host machine. Look at the second output of the command and look for new devices that appeared there, the new device will correspond to the SD card. Remember the /dev/sdX identifier corresponding to your SD card as you will need to use this in the following step.

    sh-host:~$ ls /dev/sd*
    
  • Make sure the SD card is currently not mounted:

    sh-host:~$ umount /dev/sdX*    #unmount the entire SD Card, not just any single partition
    
  • Use the fdisk utility and provided command sequence to create a new, larger root filesystem partition in the SD card’s partition table:

    Warning

    Be confident you have the correct */dev/sdX* device identified for your SD card before proceeding. Specifying the incorrect disk using the fdisk utility in the steps below can potentially destroy your Machine and will require you to set it back up again from scratch.

    sh-host:~$ sudo fdisk /dev/sdX
    
    # fdisk is an interactive utility, use the following command sequence
    # p (print the partition table and note the starting sector of the 2nd partition, call this START2.)
    # d (delete a partition)
    # 2 (select the root filesystem)
    # n (create a new partition)
    # p (make it a primary partition)
    # 2 (make it the second partition)
    # START2 (specify the same starting sector for the 2nd partition as before)
    # ENTER (just hit ENTER to use the default size, which will automatically use up the remaining space on the SD Card)
    # w (write the changes)
    
  • Disconnect and reconnect the SD card from the host machine at this point to ensure the new partition table is being picked up by the kernel.

  • Finally, grow the root filesystem to take up the entire space in the partition:

     sh-host:~$ sudo resize2fs /dev/sdX2
    
  • Drag and drop the file to the rootfs partition of the SD card using the GUI.

  • In order to copy files to the SD card using the terminal, this can be done with the standard cp (copy) command. See the above section “Transfering Media from Target” for more information.

  • The next time you boot your phyFLEX-AM62Px into Linux, using the same SD Card, your file should be present in the filesystem.

Add an additional FAT partition

  • Run the following command without the SD card connected to the host machine.

    sh-host:~$ ls /dev/sd*
    
  • Connect the bootable SD card to your Ubuntu host machine.

  • Run the following command with the SD card connected to the host machine.

    The SD card device name is of the form /dev/sd[a-z] in Linux and the letter identifier along with any partitions (signified by the numbers following the letter) on the SD card are enumerated upon connection to the host machine. Look at the second output of the command and look for new devices that appeared there, the new device will correspond to the SD card. Remember the /dev/sdX identifier corresponding to your SD card as you will need to use this in the following step.

    sh-host:~$ ls /dev/sd*
    
  • Make sure the SD card is currently not mounted:

    sh-host:~$ umount /dev/sdX*    #unmount the entire SD Card, not just any single partition
    
  • Use the fdisk utility and provided command sequence to create a new, larger root filesystem partition in the SD card’s partition table:

    Warning

    Be confident you have the correct */dev/sdX* device identified for your SD card before proceeding. Specifying the incorrect disk using the fdisk utility in the steps below can potentially destroy your Machine and will require you to set it back up again from scratch.

    sh-host:~$ sudo fdisk /dev/sdX
    
    # fdisk is an interactive utility, use the following command sequence
    # p (print the partition table and note the end sector of the 2nd partition, call this END2.)
    # n (create a new partition)
    # p (make it a primary partition)
    # 3 (make it the second partition)
    # END2 + 1 (specify the same starting sector for the 3nd partition right after the  2nd partition)
    # ENTER (just hit ENTER to use the default size, which will automatically use up the remaining space on the SD Card)
    # w (write the changes)
    
  • Disconnect and reconnect the SD card from the host machine at this point to ensure the new partition table is being picked up by the kernel.

  • Finally, grow the root filesystem to take up the entire space in the partition:

     sh-host:~$ sudo mkfs.fat /dev/sdX3
    
  • Drag and drop the file to the net partition of the SD card using the GUI.

  • In order to copy files to the SD card using the terminal, this can be done with the standard cp (copy) command. See the above section “Transfering Media from Target” for more information.

  • The next time you boot your phyFLEX-AM62Px into Linux, using the same SD Card, your file should be present in the filesystem.