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


Storage devices formatted with a FAT32 file system, when connected, are automatically mounted to "/run/media/sda1". 

This process will erase all data on the flash drive. It is highly recommended to back up the contents of your Flash Drive before following these steps.

  • Connect your Flash Drive to your Windows Host Machine
  • Hit the windows key, type "Disk Management" and then hit Enter.
  • Right click your flash drive and select "Format"

  • Select FAT32 under File System and then press OK.

  • Now right click the device in File Explorer and select Eject to safely disconnect the device from your Host Machine.
  • To verify the mount point of your Flash device using the following command: 

    Target (Linux)
    mount

    Pro Tip! Try using this command once before and after connecting the Flash Drive to your hardware. This will make it easy to notice which one is the new one and where it is mounted.

  • Insert a USB storage device into the USB Type-A connector. The mount point should be sda1 in the directory /run/media/ and this can be confirmed in the printed messages output to the console when the device is registered.
  • Generate a random 100 MB file to test writing to and from the storage device. 

    Target (Linux)
    dd if=/dev/urandom of=test1.file count=100 bs=1M
  • Copy the file to your storage device:

    Target (Linux)
    cp test1.file /run/media/sda1/ && sync
  •  Copy the file back to the root file system: 

    Target (Linux)
    cp /run/media/sda1/test1.file test2.file && sync
  • To check that the read file is the same as the one that was written, you can use md5sum to compare and verify the data transfer was successful: 

    Target (Linux)
    md5sum test1.file && md5sum test2.file

    The above command will generate a long and seemingly random string of characters for both files. This long string is called a "hash" and it uniquely identifies the files. If the hash for both files match then you can be confident that both files (down to each bit) are identical. 

    Expected Output
    root@imx7d-phyboard-zeta-004:~# md5sum test1.file && md5sum test2.file
    81ad66df7f773128aef1ec7966180ebf  test1.file
    81ad66df7f773128aef1ec7966180ebf  test2.file

Removing storage devices

  • Ensure that peripheral devices are unmounted properly before disconnecting to avoid data corruption. Enter the following before disconnecting the storage device. 

    Target (Linux)
    umount /dev/sda1

In order to make the microSD connector available you will have to first boot from eMMC.

When an external SD Card is inserted, it will be mounted automatically and will also be available as /dev/mmcblk0 in Linux when booting from eMMC.

Write to the SD Card

You can use basic Linux commands to create and write files to the SD card. Below is an example:

Target (Linux)
echo "Hello World" > ~/test.txt
cp ~/test.txt /run/media/mmcblk0p1

Read from the SD Card

To read what was just written to the SD card in the previous example, use the following command:

Target (Linux)
cp /run/media/mmcblk0p1/test.txt ~/read.txt

To check that the file read (read.txt) is the same that was written (test.txt) you can use md5sum to compare and verify the data transfer was successful:

Target (Linux)
md5sum ~/test.txt && md5sum ~/read.txt

The above command will generate a long and seemingly random string of characters for both files. This long string is called a "hash" and it uniquely identifies the files. If the hash for both files match then you can be confident that both files (down to each bit) are identical. 

Unmount the SD Card

Before unplugging the device from the development kit, make sure to unmount it. You can do this by running the following command:

Target (Linux)
umount /run/media/mmcblk0p*

Before being able to transfer files using the SCP protocol, you will first need to establish a network connection and know the ip address of the target device. See the Ethernet Peripheral Guide

MacOS/Linux/Ubuntu

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

    Host (Linux)
    cd <insert-path-to-files>
  • Use the following command to transfer your file:

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

Windows

In order to use the SCP protocol you will first need the PSCP command line utility which is not a standard internal command. 

  • Use this link to download the most recent, stable version of pscp.exe (https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html).
  • Move pscp.exe to your Programs Folder and setup a PATH variable for ease of use.
  • Using the Command Prompt on your host machine, navigate to the directory containing the file you wish to transfer to the target device. 

    Host (Windows)
    dir <insert-path-to-files>
  • Use the following command to transfer your file: 

    Host (Windows)
    pscp -scp <insert-name-of-file> root@<insert-IP-address>:~
  • Your copied file will appear in the root directory on the target device.

Before being able to transfer files using the SFTP protocol, you will first need to establish a network connection and know the ip address of the target device. See the Ethernet Peripheral Guide

The following commands will work for both Ubuntu and Windows. These instructions have yet to be tested on MacOS.

  • Using the Terminal/Command Prompt 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 establish a Secure Shell connection with the target device. 

    Host
    sftp root@<insert-IP-address>

    SFTP is an interactive command line tool. Once successfully connected to the target you will be given a new SFTP prompt. 

    Expected Output
    C:\Users\user\Documents> sftp root@<insert-IP-address>
    Connected to root@<IP-address>
    sftp >
  • Use the following command to transfer files from the host machine to the root directory of the target device. 

    SFTP Prompt
    put <insert-name-of-file>
  • Use the following command to transfer files from the target device back to the current working directory of the host machine: 

    SFTP Prompt
    get <insert-name-of-file>
  • In order to end the interactive SFTP prompt, use the following command: 

    SFTP Prompt
    quit

Not Yet Tested


Server setup is not required for working with the board, however they will significantly reduce time and are highly recommended during the building and development phase.

TFTP is a "trivial" file transfer protocol used to transfer individual files across a network. Setting up a TFTP server on your Linux Host PC will allow you to exchange files with the target board. Some examples where this will be advantageous include:

  • Modifying and doing development on the Linux kernel. Barebox can be configured to remotely boot the kernel so you have access to the latest build without needing to continually reflash the target board.
  • Updating images from the bootloader. Transferring files over a network in Barebox is an alternative to using an SD card which eliminates some time consuming steps such as formatting an SD card.
  • Individual file transfer to the root fileystem. When Linux has been fully booted you may want to copy a specific file from your Host PC to the target board (images, application executables).

Install the TFTP server on your Host PC:

Host (Ubuntu)
sudo apt-get install tftpd-hpa

Specify a folder where the files will reside on your Host PC by replacing the folder path for ''TFTP_DIRECTORY'' with whatever folder you wish to use as your TFTP file storage location, or leave the folder as the default.

Host (Ubuntu)
sudo gedit /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"

If you made any changes to the settings of the TFTP server, you need to restart it for them to take effect.

Host (Ubuntu)
sudo restart tftpd-hpa

If you would like to grant every user on the system permission to place files in the TFTP directory, use the following command, replacing ''<TFTP_DIRECTORY>'' with your chosen location.

Host (Ubuntu)
sudo chmod ugo+rwx <TFTP_DIRECTORY>

Files in the ''<TFTP_DIRECTORY>'' on your Host PC can now be accessed from another machine on the same network such as the target board by simply using the IP address of the Host PC. Take note of this IP address, in a typical wired connection this will be ''inet addr'' listed under ''eth0''.

Host (Ubuntu)
ifconfig

A network filesystem (NFS) server gives other systems the ability to mount a filesystem stored on the Host PC and exported over the network. Setting up an NFS server on your Linux Host PC gives you access to the target boards root filesystem which will allow you to quickly test applications and evaluate different filesystem setups for the target board. That is, the root filesystem for the board will actually be located on the remote host Linux machine. This enables easy access and modifications to the root filesystem during development.

Install the NFS server on your Host PC:

Host (Ubuntu)
sudo apt-get install nfs-kernel-server

Exported filesystems are designated in the "/etc/exports" file and allow you to choose both the directory to be exported and many settings for accessing the exports. Below is an example for exporting a folder called "nfs_export-ex" located in a user's home directory.

Host (Ubuntu)
sudo gedit /etc/exports
# /etc/exports
/home/<user>/nfs_export-ex *(rw,sync,no_root_squash,no_subtree_check)

The options (rw, sync, no_root_squash, no_subtree_check) for this folder are essential in setting up the NFS export correctly. For more information on additional options, refer to the man page for 'exports'.

  • rw enables: read and write access when the directory is mounted
  • sync: tells the file-system to handle local access calls before remote access
  • no_root_squash: allows root access when mounting the file-system
  • no_subtree_check: reduces the number of checks the server must make to ensure that an exported sub-directory is within an exported tree and also enables access to root files in conjunction with no_root_squash

After modifying this file, in order to mount the directories as an NFS, you must force the NFS server to export all of the directories listed in "/etc/exports".

Host (Ubuntu)
sudo /usr/sbin/exportfs -va

Samba servers are an excellent way to access a Linux file-system on a Windows machine via a network connection. Using a Samba server, it is quick and easy to transfer files between systems.

To install a Samba server, use the following command:

Host (Ubuntu)
sudo apt-get install samba

Before the Samba share can be mounted on another machine it's necessary to modify the configuration file to allow write access and access to home directories. Start by editing the "/etc/samba/smb.conf" file.

Host (Ubuntu)
sudo gedit /etc/samba/smb.conf

Inside this file there are four specific things that need to be uncommented (remove the ';' at the beginning of the line) to enable the sharing of home folders and write access. Below is the section that must be modified:

/etc/samba/smb.conf Before Change
#======================= Share Definitions =======================
# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares. This will share each
# user's home directory as \\server\username
;[homes]
; comment = Home Directories
; browseable = yes
# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
; read only = no

The outcomes after the changes are made follow:

/etc/samba/smb.conf After Change
#======================= Share Definitions =======================
# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares. This will share each
# user's home directory as \\server\username
[homes]
comment = Home Directories
browseable = yes
# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
read only = no

It might also be necessary to change the ''workgroup'' line to match the workgroup for your machine.

To apply the changes, the next step is to restart all Samba-related processes.

Host (Ubuntu)
sudo restart smbd
sudo restart nmbd

Lastly, each user needs to have a password enabled to be able to use the Samba server. There are no rules for this password. The simplest method for choosing this password is to make it the same as the UNIX user's password, but it is not a requirement. After typing in the command below, you will be prompted to enter the password for the specified user.

Host (Ubuntu)
sudo smbpasswd -a <user>

As mentioned in the configuration file, the samba share can be connected by accessing "\\<host machine ip>\\<user>" by either mounting a network share or using Windows explorer to navigate to it.

  • No labels