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.
Note
The following SCP section can be done in a Linux machine (Ubuntu) or in Windows via command prompt. Window’s command prompt can be access easily by hitting the Window’s key and typing “cmd” + Enter.
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 device, 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 uses a USB hub to split the bus to 4x locations.
Type |
Qty |
Header Location |
Speed |
Bus |
---|---|---|---|---|
USB A Double Stacked |
2 |
X13 |
3.1 |
002 |
Mini PCIe |
1 |
X31 |
2.0 |
001 |
Pin Header |
1 |
X27 (Pin 21, 22, 37, 39) |
2.0 |
001 |
Warning
The USB super speed signals are muxed between the miniPCIe interface and the USB HUB. Enabling miniPCIe (done via device tree overlay) will disable USB3.0 speeds at the stacked type-A USB connector but USB2.0 speeds will still be available. See all the available overlays in pre-built image link on Pre-Built Binaries guide.
What You Will Need
Development Kit Setup
First, ‘poweroff’ the development kit.
poweroff
Power on the development kit and stop in U-Boot when prompted.
Enable the device tree overlay.
setenv overlays k3-am64-phyboard-electra-rdk-pcie-usb2.dtbo
boot
Note
For more information about overlays see chapter Configuring the Bootloader.
Verifying USB Interface
With the phyCORE-AM64x development kit booted into Linux, see that there are 4 USB devices. There should be 2 devices on each bus.
lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux 6.1.33-bsp-yocto-ampliphy-am64x-pd23.2.0 xhci-hcd xHCI Host Controller Bus 001 Device 002: ID 0451:8242 Bus 001 Device 001: ID 1d6b:0002 Linux 6.1.33-bsp-yocto-ampliphy-am64x-pd23.2.0 xhci-hcd xHCI Host Controller
Insert a USB3.0 storage device into the top connector on X13. You should see something like the following on the serial console:
root@phyboard-electra-am64xx-2:~# [ 30.428000] usb 1-1.1: new high-speed USB device number 4 using xhci-hcd [ 30.532866] usb 1-1.1: New USB device found, idVendor=0781, idProduct=5591, bcdDevice= 1.00 [ 30.541258] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 30.548583] usb 1-1.1: Product: SanDisk 3.2Gen1 [ 30.553247] usb 1-1.1: Manufacturer: USB [ 30.557275] usb 1-1.1: SerialNumber: 0401a83fbd697e437712b826697973aaaf57d1c75e9691ad879dfe7934b8a81bea020000000000000000000037ac13c5ff935d18915581076e2cc649 [ 30.573038] usb-storage 1-1.1:1.0: USB Mass Storage device detected [ 30.580206] scsi host0: usb-storage 1-1.1:1.0 [ 31.609115] scsi 0:0:0:0: Direct-Access USB SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6 [ 31.622632] sd 0:0:0:0: [sda] 30031872 512-byte logical blocks: (15.4 GB/14.3 GiB) [ 31.636317] sd 0:0:0:0: [sda] Write Protect is off [ 31.641991] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA [ 31.664047] sd 0:0:0:0: [sda] Attached SCSI removable disk
Re-run the ‘lsusb’ command and verify that the USB drive connected to bus 002.
lsusbroot@phyboard-electra-am64xx-2:~# lsusb Bus 002 Device 001: ID 1d6b:0003 Linux 6.1.33-bsp-yocto-ampliphy-am64x-pd23.2.0 xhci-hcd xHCI Host Controller Bus 001 Device 004: ID 0781:5591 USB SanDisk 3.2Gen1 Bus 001 Device 002: ID 0451:8242 Bus 001 Device 001: ID 1d6b:0002 Linux 6.1.33-bsp-yocto-ampliphy-am64x-pd23.2.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.
lsusb -v -s 001:004
Note
“001” refers to bus 001 and “004” refers to the device number, both of these can be found in the lsusb command.
Bus 001 Device 004: ID 0781:5591 USB SanDisk 3.2Gen1
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0781
idProduct 0x5591
bcdDevice 1.00
iManufacturer 1 USB
iProduct 2 SanDisk 3.2Gen1
iSerial 3 0401a83fbd697e437712b826697973aaaf57d1c75e9691ad879dfe7934b8a81bea020000000000000000000037ac13c5ff935d18915581076e2cc649
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0020
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
..continues..
The speed of the USB device can be determined with either the lsusb -v from above or by reading the device’s “speed”
cat /sys/bus/usb/devices/usb2/speed
root@phyboard-electra-am64xx-2:~# cat /sys/bus/usb/devices/usb2/speed 5000
Note
USB3.0 has transmission speeds up to 5000 Mbit/s, also known as “super speed”. USB2.0 has transmission speeds up to 480Mbit/s, also known as “full speed”.
Mounting USB Storage Devices
Verify that a device directory was established for the USB drive.
Run the following command to confirm the USB device name.
ls /dev/sd*
root@phyboard-electra-am64xx-2:~# ls /dev/sd* /dev/sda
Remove the USB drive.
Re-run the ‘ls /dev/sd’ command to confirm the device name.
root@phyboard-electra-am64xx-2:~# [ 469.317631] usb 1-1.1: USB disconnect, device number 4 root@phyboard-electra-am64xx-2:~# ls /dev/sd* ls: /dev/sd*: No such file or directory
Re-insert the USB drive to the top connector of X13.
Note
In this example the device name for the USB drive is “sda”.
Make a directory for mounting the USB device.
mkdir ~/usb_sda
Mount the USB device to the directory.
mount /dev/sda ~/usb_sda/
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
root@phyboard-electra-am64xx-2:~# dd if=/dev/urandom of=test.file count=10 bs=1M 10+0 records in 10+0 records out 10485760 bytes (10 MB, 10 MiB) copied, 0.216022 s, 48.5 MB/s
Copy the file to your storage device.
cp test.file ~/usb_sda/ && 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
umount /dev/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