Intel® Simics® Simulator for Intel® FPGAs: User Guide

ID 784383
Date 7/08/2024
Public
Document Table of Contents

7.2.2.1.1. Transferring Files With SCP Service via Forwarding Ports

You can transfer files between the host PC and the simulated target system in both directions (it is assumed that the systems support the SCP service). To support this feature, create forwarding ports in both directions. The SCP service uses the standard port 22 and uses the TCP protocol (same as SSH service).

The following example shows how to transfer files in both directions. Set up the forwarding ports. In this case, the incoming forwarding port, the host port 4022 is forwarding the traffic to the port 22 with a target IP of 10.10.0.100 which corresponds to the IP in the target system. Similarly, in the outgoing forwarding port, the port 4022 in the service node is forwarding the traffic to the port 22 in the host PC, which has the 10.122.105.138 IP. The following capture shows this setup:

HostPC | Target system
 Incoming    4022 ->  22
 Outgoing      22 <- 4022
#Intel Simics simulator CLI 

simics> connect-real-network-port-in ethernet-link = ethernet_switch0 
target-ip=10.10.0.100 target-port = 22 host-port = 4022 -tcp

Host TCP port 4022 -> 10.10.0.100:22
Warning: This can expose the target system on the host local network
simics> connect-real-network-port-out service-node-port = 4022 ethernet-link 
= ethernet_switch0 target-ip=10.122.105.138 target-port=22 -tcp
10.10.0.1 TCP port 4022 on link ethernet_switch0.link -> host 10.122.105.138:22
ff02::1:2 TCP port 4022 on link ethernet_switch0.link -> host 10.122.105.138:22
Warning: This can expose the target system on the host local network.
simics> list-port-forwarding-setup

Host TCP port 4022 -> 10.10.0.100:22
 
10.10.0.1 TCP port 4022 on link ethernet_switch0.link -> host 10.122.105.138:22
ff02::1:2 TCP port 4022 on link ethernet_switch0.link -> host 10.122.105.138:22
simics> run

Now, to verify that the SCP service works in both directions, the target2host.txt file was created in the simulated target system while the host2target.txt file was created in the host PC. Having created the files, you must move these files to the other end using the SCP command. This is shown in the following captures from the target system serial console and the host terminal.

In the host terminal, call the scp command to copy the host2target.txt file to the target system. In this command, indicate the port 4022 in the localhost (host PC). This port is the one that the host PC can see. You also indicate the user ( root ) that tries to copy the file and the file to be transferred.

# Host Terminal 

/home/simicsUser/SimicsInstallDir/project-1$ scp -P 4022 host2target.txt \ 
root@localhost:/home/root/host2target.txt

The authenticity of host '[localhost]:4022 ([127.0.0.1]:4022)' can't be established.
ECDSA key fingerprint is SHA256:6+/zF935yx3AfluQh9yk4qwGB0a3G+qf+uYYH0eJkNU.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[localhost]:4022' (ECDSA) to the list of known hosts.
host2target.txt                               100%   20     1.9KB/s   00:00
:
# After the scp from the target console is issued, this is seen here.
/home/simicsUser/SimicsInstallDir/project-1$ ls
host2target.txt  target2host.txt

In the target serial console, call the scp command to copy the target2host.txt file to the host PC. In this command, indicate the port 4022 in the service node (address 10.10.0.1). This port is the one that the target system can see. Also indicate the user (simicsUser) that attempts to copy the file and the file to be transferred.

# Target Serial Console

root@psgdevice:~# scp -P 4022 target2host.txt \ 
simicsUser@10.10.0.1:/home/simicsUser/SimicsInstallDir/project-1/

The authenticity of host '[10.10.0.1]:4022 ([10.10.0.1]:4022)' can't be established.
ED25519 key fingerprint is SHA256:XQzql2Lz5mbrPPsMX9Xc8a8Q4E3hmx3RrE7neHoO3Oc.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[10.10.0.1]:4022' (ED25519) to the list of known hosts.
simicsUser@10.10.0.1's password: 
target2host.txt                               100%   20    10.0KB/s   00:00
:
# After the scp from the host terminal is issued, this is seen here.
root@psgdevice:~# ls
host2target.txt    target2host.txt
root@psgdevice:~#

In both captures, ls command is used in each system to verify the files were copied. In these captures, you can confirm that after the calling the scp commands, both files exist in both places.