This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to enable a shared directory between the booted guest OS on Morello FVP and the host linux machine

Hi,

I want to experiment with capability enabled LLVM - but would like to have a shared directory  between the Morello FVP  and the host linux. Please could you give some more detailed instructions on this, sorry if I have missed anything obvious in the documentation. 

Thanks,

Andy

  • Hi Andy,

    At the moment the FVP supports sharing files only via the network interface. If you're running Android on the FVP, you can use "adb connect" to connect to your model and then "adb push" to send your application files to the FVP. Please look at the section "Running the Android Debug Bridge (ADB) with FVP" on the user guide at https://git.morello-project.org/morello/docs/-/blob/morello/mainline/user-guide.rst.

    However, the next releases will include the virtioP9 device that allows sharing a common directory between the FVP and the host Linux.

    Regards,

    Mauricio

  • Hi Andy,

    Though not exactly what you are looking for, you can use the Remote Systems pane to create an ssh connection to the filesystem running on the FVP, and interact that way (including launching a terminal inside the GUI)

    https://developer.arm.com/documentation/102234/2020-1m0/Perspectives-and-Views/Remote-Systems-view
    https://developer.arm.com/documentation/102234/2020-1m0/Perspectives-and-Views/Remote-Systems-terminal-for-SSH-connections

    Ronan

  • Hi Mauricio,

    I've been experimenting with Poky Linux and CheriBSD so far. I haven't tried out Android route yet, but will do so later today/next week.

    Thanks,

    Andy

  • Hi Ronan,

    Thanks I'll try this out. 

    Andy

  • Hi Andy,

    Since you say you're using CheriBSD, by default cheribuild will set up the FVP to expose the guest's SSH port 22. If you look at the arguments passed to the FVP as printed out by cheribuild, you should see a pair that looks like `-C board.virtio_net.hostbridge.userNetPorts=21846=22` (that first number will likely be different for you as it's generated based on your user's id so as to avoid collisions on shared servers), meaning you can use `ssh -p 21846 root@localhost` to connect to CheriBSD. That means you can also copy files to the guest with `scp -P 21846 /path/to/source root@localhost:/path/to/dest` and from the guest with `scp -P 21846 root@localhost:/path/to/source /path/to/dest` (note the capitalisation of `-P`).

    If you update your cheribuild to the latest version in git you should now see an additional friendlier `Listening for SSH connections on localhost:21846` message printed in green (something we print for our QEMU CHERI-MIPS and CHERI-RISC-V invocations, but that did not get copied for the FVP it seems).

    You can also `kldload smbfs` and mount a shared Samba filesystem using `mount_smbfs -I 10.0.2.4 -N //10.0.2.4/share_name /mnt` (where `share_name` is whatever you've configured, and you can of course `mkdir` your own mount points, `/mnt` is just there by default if you only need one). Unlike QEMU, the FVP does not have Samba integration baked into it, but here's an example config based on what QEMU auto-generates:

    [global]
    private dir=/tmp/qemu-smb.35U1U0
    interfaces=127.0.0.1
    bind interfaces only=yes
    pid directory=/tmp/qemu-smb.35U1U0
    lock directory=/tmp/qemu-smb.35U1U0
    state directory=/tmp/qemu-smb.35U1U0
    cache directory=/tmp/qemu-smb.35U1U0
    ncalrpc dir=/tmp/qemu-smb.35U1U0/ncalrpc
    log file=/tmp/qemu-smb.35U1U0/log.smbd
    smb passwd file=/tmp/qemu-smb.35U1U0/smbpasswd
    security = user
    map to guest = Bad User
    load printers = no
    printing = bsd
    disable spoolss = yes
    case sensitive = yes
    usershare max shares = 0
    min protocol = NT1
    [my_first_share]
    path=/path/to/first/share
    read only=no
    guest ok=yes
    force user=jrtc4
    [my_second_share]
    path=/path/to/second/share
    read only=no
    guest ok=yes
    force user=jrtc4

    The /tmp/qemu-smb.35U1U0 path can be anything you like, it's just a dummy directory where you need to put the smb.conf. You can then start smbd with `smbd -l /tmp/qemu-smb.35U1U0 -s /tmp/qemu-smb.35U1U0/smb.conf` in the background or another terminal window.

  • Hi, 

    the latest Dec 2020 maintenance release now includes support for virtio_p9 - however I'm still having some issues, and have missed something obvious ... I tried Poky by (appropriately setting -C board.virtio_p9.root_path=/home/morello/SHARED in run_model.sh) and running the command below after a fresh install of FVP and rebuilding the board support. 

    ./run-scripts/run_model.sh -m ~/FVP_Morello/models/Linux64_GCC-6.4/FVP_Morello -f poky

    then after boot and log in to the model ...

    root@morello-fvp:~# mount -t 9p -o trans=virtio,version=9p2000.L FM /mnt/HOST
    [ 646.303364] 9pnet_virtio: no channels available for device FM
    mount: mounting FM on /mnt/HOST failed: No such file or directory

    My host (ubuntu20.04.1 LTS) lsmod | grep virtio
    9pnet_virtio 20480 0
    9pnet 81920 2 9p,9pnet_virtio
    virtio_input 16384 0

    Thanks,

    Andy

  • As far as I know, neither TF-A's FDT nor edk2-platform's DSDT include a description for the device and so the OS does not know it exists. You could try patching your TF-A's morello-fvp.dts to include it based on developer.arm.com/.../Morello-Platform-Model-notes-and-limitations. 

  • Hi Andy,

    To enable and use the virtio P9 device you need to follow the steps below:

    1- Enable the following kernel build flags.

    CONFIG_NET_9P
    CONFIG_NET_9P_VIRTIO
    CONFIG_9P_FS
    CONFIG_9P_FS_POSIX_ACL
    CONFIG_9P_FSCACHE
    CONFIG_9P_FS_SECURITY

    2 - Add the following configuration to your DTS:

    virtio_p9@1c1A0000 {
           compatible = "virtio,mmio";
           reg = <0x0 0x1c1a0000 0x0 0x200>;
           interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;
    };

    3 - Rebuild everything

    4 - Follow the instructions on how to use the virtio P9 located in the Fast Models Reference Manual 11.13

    I hope this helps!

    Regards,

    Mauricio

  • Hi,

    apologies - it's my first time delving into FVPs into any detail, so I'd appreciate a few more pointers if you can spare the time ...

    STEP 1 - are talking about the host linux, or the guest linux hosted via the FVP? 

    STEP 2 ...

    I'm using instructions from https://git.morello-project.org/morello/docs/-/blob/morello/mainline/user-guide.rst

    Given that it is bitbake based ... then I need to do something like?

     devtool modify trusted-firmware-a

    Add the appropriate DTS configuration to  dtsi file(s)  in the trusted-firmware-a tree, any pointers on which one(s)?

    STEP 3

    bitbake trusted-firmware-a

    bitbake core-image-minimal

    STEP 4 seems clear - is chmod 777 myHostLinuxDirectory

    still required for the host linux directory that is pointed to by the root_path configuration parameter passed to the FVP? 

    On the FVP, after trying out these steps, I get the same error as before ...

    Also using

    find /proc/device-tree/ -type f -exec head {} + | grep virtio

    to determine if the virtio_p9 is loaded,  ... so far no luck ... despite a few attempts.

    Thanks,

    Andy

  • Hi Andy,

    Apologies for my brief summary on how to enable the virtio_p9. The changes are only applied to the guest OS, the one running on the FVP. Please follow the steps below under the morello_workspace poky directory structure:

    1 - Add the build kernel flags below to <path to workspace>morello_workspace/bsp/build-poky/tmp-poky/work/morello_fvp-poky-linux/linux-yocto/5.4.51+gitAUTOINC+caafbdfe38_fed60f1c8e-r0/defconfig

    CONFIG_NET_9P=y
    CONFIG_NET_9P_VIRTIO=y
    CONFIG_9P_FS=y
    CONFIG_9P_FS_POSIX_ACL=y
    CONFIG_PCI=y
    CONFIG_VIRTIO_PCI=y
    CONFIG_9P_FSCACHE=y
    CONFIG_9P_FS_SECURITY=y

    2 - Add the virtio_p9 configuration shown below to <path to workspace>morello_workspace/bsp/build-poky/tmp-poky/work/morello_fvp-poky-linux/trusted-firmware-a/1.0+gitAUTOINC+746e7e322f-r0/git/fdts/morello-fvp.dts

    virtio_p9@1c1A0000 {
           compatible = "virtio,mmio";
           reg = <0x0 0x1c1a0000 0x0 0x200>;
           interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;
    };

    3 - Recompile TFA:

          bitbake trusted-firmware-a -C compile

    4 - Recompile linux-yocto:

         bitbake linux-yocto -C compile

    5 - Recreate the images: (You might get a few warnings showing that some tfa and linux have been modified)

        bitbake core-image-minimal

    6 - Add to <path to workspace>morello_workspace/run-scripts/run_model.sh the following model parameter (at around line 371)

      -C "board.virtio_p9.root_path=$PWD/shared_folder"

    7 - Before launching the model create a folder on the host named shared_folder

      mkdir <path to workspace>morello_workspace/shared_folder

      **On the morello_workspace you should have the following folders: bsp docs run-scripts shared_folder

    8 - Launch the model

      ./run-scripts/run_model.sh -m <path to fvp executable> -f poky

    9 - On the model, when Poky finishes booting, log in as root and on the guest terminal, create and mount the shared folder as follows:

      mkdir shared_folder

      mount -t 9p -o trans=virtio,version=9p2000.L FM shared_folder

    10 - Try to create a file from the guest terminal on the shared_folder and then reading it from the host shared folder. Try the other way round.

    Although this might not be the optimal solution, I have made it work on a poky build.

    I hope this temporary solution helps for now while we're looking into adding it to the repository.

    Best regards,

    Mauricio

  • Many many thanks, that was very easy to follow first time. For the benefit of others -  a minor thing, if you've executed a

    devtool modify trusted-firmware-a

    then you will obviously need to update the dts file ... something like

    <morello workspace>/bsp/build-poky/workspace/sources/trusted-firmware-a/fdts/morello-fvp.dts