Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / IoT

Intel® IoT Platforms: File Transfer for Linux using SCP

0.00/5 (No votes)
13 Nov 2015CPOL4 min read 21K  
In this guide you will learn how to transfer files between your computer and Intel® IoT device such as the Intel® Edison or Intel® Galileo board.

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.

Overview

In this guide you will learn how to transfer files between your computer and Intel® IoT device such as the Intel® Edison or Intel® Galileo board.

Note: This guide is currently only for the Linux OS; Windows* and OS X* guides are coming later.

Requirements

Your Intel IoT device has up-to-date firmware installed and is connected to a network.

How to Flash Intel® Edison board Firmware: Windows* OS X* Linux*

How to Flash Intel® Galileo board Firmware: Windows* OS X* Linux*

Steps

SCP stands for "Secure Copy" and is a file transfer method that uses the Secure Shell (SSH) protocol. To set up SCP, follow the steps below:

  1. Update OpenSSH on your computer. Open a terminal and enter the following commands in bold:

    • sudo apt-get remove openssh-client openssh-server

    • When asked, enter Y and press Enter.

    • sudo apt-get install openssh-client openssh-server

    • When asked, enter Y and press Enter.

    • After the installation is complete, you should see output similar to what is in Figure 1.

    Image 1

    Figure 1: Output after installation of OpenSSH
  2. Find the IP address of your computer on the local network. Open a terminal on your computer and enter the following command:

    • ifconfig

    In the output, look for eth0 if your computer is connected to your router/modem through Ethernet or wlan0 if you are connected through Wi-Fi*. Following either eth0 or wlan0 look for inet addr: xxx.xxx.x.xxx. The xxx.xxx.x.xxx is the IP address that you will use to transfer files to and from your computer. In Figure 2 the IP address is circled and in this case is 192.168.1.158.

    • Note: Your IP address will most likely not be 192.168.1.158

    Image 2

    Figure 2
  3. Plug in your Intel IoT device through the USB connection. Your device should power on.

  4. Connect to your device through the serial connection using a utility called ‘screen’. Open a terminal on your computer and enter the following commands in bold.

    • If you do not have screen installed, first run: sudo apt-get install screen

    • To connect to your device run: sudo screen /dev/ttyUSB0 115200

    • Enter your device name or root for the username as well as a password depending how you have configured it. To reconfigure your device run configure_edison through a serial terminal.

  5. On your computer, navigate to where you want to move files to or from your device. I have created the folder /home/root/transfer for this purpose. So I would navigate there by entering the following in my device’s terminal:

    • cd /home/root/transfer

  6. To transfer files from your computer to your device use the following command where USERNAME is your computer username, xxx.xxx.x.xxx is the IP address from step 2, /file/to/transfer is the path to the file you wish to transfer on your computer, and /path/to/location is where on your device you want to transfer the file to:

    • scp USERNAME@xxx.xxx.x.xxx:/file/to/transfer /path/to/location

    If you are asked to establish a trusted connection, enter Y and press Enter. You will also be asked for your computer username and password. Enter them and press Enter.

    For example, this is how I would transfer the file "example.txt" from /home/user/martin/example.txt on my computer to my device:

    • scp martin@192.168.1.158:/home/user/martin/example.txt ./

    Note: The ./ at the end of the line means the file will copy into your current folder, or continuing from the example in step 5 into /home/root/transfer on my device; however, you may enter any path you wish.

    If the transfer was successful if you see output similar to what is in Figure 3.

  7. To transfer files from your device to your computer use the following command where USERNAME is your computer username, xxx.xxx.x.xxx is the IP address from step 2, /file/to/transfer is the file you wish to transfer to your computer, and /path/to/location is the path to where the file will be transferred to on your computer:

    • scp /file/to/transfer USERNAME@xxx.xxx.x.xxx:/path/to/location

    If you are asked to establish a trusted connection enter Y and press Enter. You will also be asked for your computer username and password, enter them and press Enter.

    For example, this is how I would transfer a file named "example.txt" from /home/root/transfer/example.txt on my device to my computer:

    • scp /home/root/transfer/example.txt martin@192.168.1.158:/home/user/martin/

    If the transfer was successful if you see output similar to what is in Figure 3

    Image 3

    Figure 3: A successful scp transfer

Troubleshooting

If you have any issues or questions, please go to Intel Edison Forums to post your questions and look for solutions.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)