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 a Network

Note

Before being able to transfer files using network protocols, you will first need to establish a network connection and know the ip address of the target device. See the Ethernet interface guide for more information.

Secure Copy Protocol

Secure Copy Protocol (SCP) is built around a Secure Shell connection (SSH) and offers all the same security features. One advantage of using this method for transferring single files is that it is generally pretty fast but you won’t get interactive functionality when pulling multiple files from a remote server. For example, you won’t be able to list out directory contents and see what other files are available. SCP also has no file size limitations.

  • Using the Terminal on your host machine, navigate to the directory containing the file you wish to transfer to the target device.

    host:~$ cd <insert-path-to-files>
    
  • Use the following command to transfer your file:

    host:~$ sudo scp <insert-name-of-file> root@<insert-IP-address>:~
    
  • Your copied file will appear in the root directory on the target device.

  • To go the other direction and retrieve files from the Target Hardware, just flip the source and destination arguments:

    host:~$ sudo scp root@<insert-IP-address>:<insert-name-of-file> <insert-path-to-destination>
    

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 type-C connector (X34). The USB1 interface uses a USB HUB to split the bus to 3x locations.

USB Locations

Type

Qty

Header Location

Speed

Bus

USB A Double Stacked

2

X43

2.10

001

Mini PCIe

1

X36

2.10

001

USB C

1

X34

2.10

003

What You Will Need

  • USB Storage Device

Verifying USB Interface

  • With the phyCORE-AM62Ax development kit booted into Linux, verify that there are 2 USB devices.

    phyboard-lyra-am62axx-2:~# lsusb
    
    Expected Output
    phyboard-lyra-am62axx-2:~# lsusb
    Bus 001 Device 002: ID 0424:2514
    Bus 001 Device 001: ID 1d6b:0002 Linux 6.1.33-bsp-yocto-ampliphy-am62ax-pd23.1.0 xhci-hcd xHCI Host Controller
    
  • Insert a USB device into either x43 (Double stack USB-A port) or x34 (USB-C). This guide demonstrates the USB-A bottom port.

    Expected Output
    phyboard-lyra-am62axx-2:~# [ 1103.995685] usb 1-1.2: new high-speed USB device number 3 using xhci-hcd
    [ 1104.101203] usb 1-1.2: New USB device found, idVendor=0781, idProduct=5591, bcdDevice= 1.00
    [ 1104.109724] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    [ 1104.117146] usb 1-1.2: Product:  SanDisk 3.2Gen1
    [ 1104.121870] usb 1-1.2: Manufacturer:  USB
    [ 1104.125981] usb 1-1.2: SerialNumber: 0401b360e7f994fa1045253b46381e7f4adf9e70e08383c7595d67e9a36da3592f6c0000000000000000000000c41f01009e5d18915581076e2cc63b
    [ 1104.197541] usb-storage 1-1.2:1.0: USB Mass Storage device detected
    [ 1104.204385] scsi host0: usb-storage 1-1.2:1.0
    [ 1104.209411] usbcore: registered new interface driver usb-storage
    [ 1105.232338] scsi 0:0:0:0: Direct-Access      USB      SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6
    [ 1105.242820] sd 0:0:0:0: [sda] 30031872 512-byte logical blocks: (15.4 GB/14.3 GiB)
    [ 1105.251756] sd 0:0:0:0: [sda] Write Protect is off
    [ 1105.257122] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
    [ 1105.274728] sd 0:0:0:0: [sda] Attached SCSI removable disk
    
  • Verify that the USB was properly recongnized by development kit.

    phyboard-lyra-am62axx-2:~# lsusb
    
    Expected Output
    phyboard-lyra-am62axx-2:~# lsusb
    Bus 001 Device 003: ID 0781:5591  USB  SanDisk 3.2Gen1
    Bus 001 Device 002: ID 0424:2514
    Bus 001 Device 001: ID 1d6b:0002 Linux 6.1.33-bsp-yocto-ampliphy-am62ax-pd23.1.0 xhci-hcd xHCI Host Controller
    
  • To list more information about the USB device and buses on the development kit use the following command.

    This command will output a good chunk of information. This guide will only show a snippet of the expected output for the USB drive that was just connected.

    phyboard-lyra-am62axx-2:~# 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.

    phyboard-lyra-am62axx-2:~# 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.

    phyboard-lyra-am62axx-2:~# ls /mnt/
    

Read from the USB Host Device

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

    phyboard-lyra-am62axx-2:~# cp /mnt/<file> <file destination> && sync
    

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

phyboard-lyra-am62axx-2:~# 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.

    phyboard-lyra-am62axx-2:~# poweroff
    
  • Remove the SD card and connect it to your Linux machine via an SD card reader.

    Note

    You will not be able to place files on the SD card using Windows because the SD Card is formatted for Linux. Windows does not recognize the format.

    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.

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

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

    3. 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 Ubuntu 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.

      host:~$ ls /dev/sd*
      
    4. It is best to first backup the SD card to a file just in case something goes terribly wrong and you end up losing its contents:

      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.

      host:~$ umount /dev/sdX*    #unmount the entire SD Card, not just any single partition
      host:~$ sudo dd if=/dev/sdX of=~/backup.sdcard bs=1M && sync
      
    5. Use the fdisk utility and provided command sequence to create a new, larger root filesystem partition in the SD card’s partition table:

      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. START2=196608 using the pre-built software)
      # 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)
      
    6. 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.

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

      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 phyCORE-AM62Ax into Linux, using the same SD Card, your file should be present in the filesystem.