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.
cd <insert-path-to-files>
Use the following command to transfer your file:
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:
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.
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
Verifying USB Interface
With the phyCORE-AM62x development kit booted into Linux, verify that there are 2 USB devices.
lsusb
root@phyboard-lyra-am62xx-2:~# lsusb Bus 001 Device 002: ID 0424:2514 Bus 001 Device 001: ID 1d6b:0002 Linux 6.1.33-bsp-yocto-ampliphy-am62x-pd23.2-rc1 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.
root@phyboard-lyra-am62xx-2:~# [ 2764.219680] usb 1-1.2: new high-speed USB device number 3 using xhci-hcd [ 2764.325351] usb 1-1.2: New USB device found, idVendor=0781, idProduct=5591, bcdDevice= 1.00 [ 2764.333870] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 2764.341297] usb 1-1.2: Product: SanDisk 3.2Gen1 [ 2764.346029] usb 1-1.2: Manufacturer: USB [ 2764.350144] usb 1-1.2: SerialNumber: 0401a83fbd697e437712b826697973aaaf57d1c75e9691ad879dfe7934b8a81bea020000000000000000000037ac13c5ff935d18915581076e2cc649 [ 2764.411781] usb-storage 1-1.2:1.0: USB Mass Storage device detected [ 2764.418828] scsi host0: usb-storage 1-1.2:1.0 [ 2764.424110] usbcore: registered new interface driver usb-storage [ 2765.448829] scsi 0:0:0:0: Direct-Access USB SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6 [ 2765.463168] sd 0:0:0:0: [sda] 30031872 512-byte logical blocks: (15.4 GB/14.3 GiB) [ 2765.481193] sd 0:0:0:0: [sda] Write Protect is off [ 2765.486641] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA [ 2765.504741] sd 0:0:0:0: [sda] Attached SCSI removable disk
Verify that the USB was properly recongnized by development kit.
lsusb
root@phyboard-lyra-am62xx-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-am62x-pd23.2-rc1 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.
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
Make a directory for mounting the USB device.
mkdir ~/usb_sda
Mount the USB device to the directory.
mount /dev/sda ~/usb_sda/
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.
ls ~/usb_sda/
Write to the USB Host Device
Generate a random 10 MB file to test transferring data from the storage device.
dd if=/dev/urandom of=test.file count=10 bs=1M
Copy the file to your storage device.
cp test.file ~/usb_sda/ && sync
Read from the USB Host Device
Copy the test file we previously created during the write process back to the host:
cp ~/usb_sda/test.file readback-usb.file && sync
We can double check that the file was successfully copied to and from the USB device by checking the md5sum of the file:
md5sum test.file readback-usb.file
root@phyboard-lyra-am62xx-2:~# md5sum test.file readback-usb.file d3aa3ee1db746d6f7fb66c9b42f4ea6b test.file d3aa3ee1db746d6f7fb66c9b42f4ea6b readback-usb.file
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
umount ~/usb_sda/
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.
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.
Run the following command without the SD card connected to the host machine.
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 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.
ls /dev/sd*
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 Virtual Machine and will require you to set it back up again from scratch.
umount /dev/sdX* #unmount the entire SD Card, not just any single partition sudo dd if=/dev/sdX of=~/backup.sdcard bs=1M conv=fsync && sync
Use the fdisk utility and provided command sequence to create a new, larger root filesystem partition in the SD card’s partition table:
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)
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:
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-AM62x into Linux, using the same SD Card, your file should be present in the filesystem.