Closed geneva1 closed 4 years ago
First, you're not supposed to compile on the device, instead you're supposed to cross compile on your host machine. Secondly to att something to buildroot, do something like https://github.com/OP-TEE/optee_os/issues/2505#issuecomment-415703943.
I could not run this op-tee example without the following software.
I.e., none of the software there is needed to run optee_example host/ta's. Just create an OP-TEE/QEMU build as described on the docs and after you've booted up the solution, run optee_example_hello_world
etc.
Oh and btw, since you can run xtest already, you probably already have the setup working, so simply try run optee_example_hello_world
, optee_example_hotp
, ...
make QEMU_VIRTFS_ENABLE=y QEMU_USERNET_ENABLE=y
However, how do I transfer the cross-compiled binary from host to qemu ?
make QEMU_VIRTFS_ENABLE=y QEMU_USERNET_ENABLE=y
However, how do I transfer the cross-compiled binary from host to qemu ?
It's written in the section you linked to. I.e., follow the instruction there, then you simply just have to copy whatever files you need between the host (your PC) and the device (QEMU). Personally I tend to wrap this stuff into an alias that I run on the device. Here is an example, were I use a script to create such an alias. That is probably not exactly what you're after, but it should give you an idea how one can work with a mounted/shared folder when running QEMU.
However, the host mount point has the following error :
# mkdir -p /mnt/host
# mount -t 9p -o trans=virtio host /mnt/host
9pnet_virtio: no channels available for device host
mount: mounting host on /mnt/host failed: No such file or directory
# ls -al /mnt
total 0
drwxr-xr-x 3 root root 60 May 29 08:04 .
drwxr-xr-x 18 root root 420 May 29 08:02 ..
drwxr-xr-x 2 root root 40 May 29 08:04 host
#
# Accessing a shared folder on the host from QEMU:
# # Set QEMU_VIRTFS_ENABLE to 'y' and adjust QEMU_VIRTFS_HOST_DIR
# # Then in QEMU, run:
# # $ mount -t 9p -o trans=virtio host <mount_point>
QEMU_VIRTFS_ENABLE ?= y
QEMU_VIRTFS_HOST_DIR ?= $(ROOT)
kconfigs/qemu.conf:CONFIG_NET_9P=y
kconfigs/qemu.conf:CONFIG_NET_9P_VIRTIO=y
kconfigs/qemu.conf:CONFIG_9P_FS=y
kconfigs/qemu.conf:CONFIG_9P_FS_POSIX_ACL=y
kconfigs/qemu.conf:CONFIG_PCI=y
kconfigs/qemu.conf:CONFIG_VIRTIO_PCI=y
kconfigs/qemu.conf:#CONFIG_PCI_HOST_GENERIC=y
@jbech-linaro @jforissier
I have already enabled virtfs
in common.mk
, but I still could not mount the host share folder. I have also checked that all relevant 9P
options are enabled in kconfigs/qemu.conf
as described in https://wiki.qemu.org/Documentation/9psetup
Welcome to Buildroot, type root or test to login
buildroot login: root
# mkdir /mnt/host
# mount -t 9p -o trans=virtio,version=9p2000.L hostshare /mnt/host/
9pnet_virtio: no channels available for device hostshare
mount: mounting hostshare on /mnt/host/ failed: No such file or directory
#
mount -t 9p -o trans=virtio host /mnt/host/
is the right command to use to avoid the "no channels available" error.
# Add symlink to the TA from the host
CMD_3="ln -sf /host/${OEMCRYPTO_TA} /lib/optee_armtz/${TA_FILE}"
However, I do not quite understand how the above symlink works. @jbech-linaro
I have already added the host directory prefix inside common.mk
, but I still could not transfer files from host OS to qemu.
QEMU_CONFIGURE_PARAMS_COMMON = --cc="$(CCACHE)gcc" --extra-cflags="-Wno-error" \
'--enable-debug' '--enable-kvm' '--prefix=/home/$(USER)/qemu/'
Note: 9p
module is already enabled on host OS
lsmod | grep 9p
9pnet_virtio 20480 0
9pnet 77824 1 9pnet_virtio
Ok, all I do is this
jbech@goby /media/jbech/TSHB_LINUX/devel/optee_projects/qemu/build
$ make -j8 QEMU_VIRTFS_ENABLE=y run
ln -sf /media/jbech/TSHB_LINUX/devel/optee_projects/qemu/build/../out-br/images/rootfs.cpio.gz /media/jbech/TSHB_LINUX/devel/optee_projects/qemu/build/../out/bin/
urxvt: no visual found for requested depth 5, using default visual.
urxvt: no visual found for requested depth 5, using default visual.
cd /media/jbech/TSHB_LINUX/devel/optee_projects/qemu/build/../out/bin && /media/jbech/TSHB_LINUX/devel/optee_projects/qemu/build/../qemu/arm-softmmu/qemu-system-arm \
-nographic \
-serial tcp:localhost:54320 -serial tcp:localhost:54321 \
-smp 2 \
-s -S -machine virt,secure=on -cpu cortex-a15 \
-d unimp -semihosting-config enable,target=native \
-m 1057 \
-bios bl1.bin \
-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0,max-bytes=1024,period=1000 -fsdev local,id=fsdev0,path=/media/jbech/TSHB_LINUX/devel/optee_projects/qemu/build/..,security_model=none -device virtio-9p-device,fsdev=fsdev0,mount_tag=host -netdev user,id=vmnic -device virtio-net-device,netdev=vmnic
QEMU 3.0.93 monitor - type 'help' for more information
(qemu) c
- In the normal world QEMU console, I do this.
buildroot login: root
build optee-widevine-ref qemu buildroot optee_benchmark soc_term ce_cdm optee_client string-compare ce_cdm.nxp optee_examples toolchains entr optee_os trusted-firmware-a find_ta.py optee_test u-boot linux out makefile.gcc out-br #
That's all and as you can see it just works. I.e., from the QEMU normal world side I can see my files on my PC. Then it's just to copy (or symlink to your needs).
from the QEMU normal world side I can see my files on my PC.
I also see the same thing here, but those directories and files are not really accessible from host OS.
So, how to copy files (cross-compiled binaries) from host OS into QEMU session ?
from the QEMU normal world side I can see my files on my PC.
This is only one-way from QEMU to host OS. What about copying files (cross-compiled binaries) from host OS into QEMU session ?
That's what I'm doing
# cp /host/optee-widevine-ref/out/ta/oemcrypto/*.ta /lib/optee_armtz/
That takes a cross compile TA from my host and copy it into the file system that QEMU normal world uses.
Wait, those directories and files are not really accessible from host OS.
And why /lib/optee_armtz
which is also not accessible from host OS ?
Wait, those directories and files are not really accessible from host OS.
Yes they are ... the whole QEMU/OP-TEE tree is available by default.
And why
/lib/optee_armtz
which is also not accessible from host OS ?
Because you've mounted it within QEMU.
Because you've mounted it within QEMU.
So, how do I access or copy files from host OS into QEMU ?
So, how do I access or copy files from host OS into QEMU ?
I must fail expressing my self. I did write that above, i.e.,
# cp /host/optee-widevine-ref/out/ta/oemcrypto/*.ta /lib/optee_armtz/
I.e., in QEMU
# cp /host/<files_from_my_host_pc_not_running_qemu_under_the_flag_QEMU_VIRTFS_HOST_DIR> /<to_somewhere_within_my_qemu_instance>`.
None of the following files or directories are accessible from host ubuntu OS. Do you understand what I mean ?
Welcome to Buildroot, type root or test to login
buildroot login: root
# ls -al /mnt/host/
total 76
drwxrwxr-x 18 tee tee 4096 May 27 15:22 .
drwxr-xr-x 3 root root 60 Jun 1 08:09 ..
drwxrwxr-x 7 tee tee 4096 May 28 09:51 .repo
drwxrwxr-x 12 tee tee 4096 Jun 1 08:12 build
drwxrwxr-x 16 tee tee 4096 May 27 15:22 buildroot
drwxrwxr-x 25 tee tee 4096 Jun 1 08:08 linux
drwxrwxr-x 4 tee tee 4096 May 27 09:25 optee_benchmark
drwxrwxr-x 8 tee tee 4096 May 27 09:25 optee_client
drwxrwxr-x 9 tee tee 4096 May 27 09:25 optee_examples
drwxrwxr-x 12 tee tee 4096 May 27 09:29 optee_os
drwxrwxr-x 9 tee tee 4096 May 27 09:25 optee_test
drwxrwxr-x 3 tee tee 4096 May 27 15:22 out
drwxrwxr-x 6 tee tee 4096 Jun 1 08:08 out-br
drwxrwxr-x 47 tee tee 12288 Jun 1 08:09 qemu
drwxrwxr-x 3 tee tee 4096 May 28 02:30 soc_term
drwxrwxr-x 4 tee tee 4096 May 27 15:20 toolchains
drwxrwxr-x 19 tee tee 4096 May 27 15:22 trusted-firmware-a
drwxrwxr-x 25 tee tee 4096 Jun 1 08:08 u-boot
#
Is QEMU_VIRTFS_HOST_DIR
inside common.mk
correct ?
# Accessing a shared folder on the host from QEMU:
# # Set QEMU_VIRTFS_ENABLE to 'y' and adjust QEMU_VIRTFS_HOST_DIR
# # Then in QEMU, run:
# # $ mount -t 9p -o trans=virtio host <mount_point>
QEMU_VIRTFS_ENABLE ?= y
QEMU_VIRTFS_HOST_DIR ?= $(ROOT)
Do you understand what I mean ?
I think I understand, but I wonder if you know what you're asking :)
None of the following files or directories are accessible from host ubuntu OS.
Ok, so where do those files and folder originate from? Try on your Ubuntu host PC to cd into your the OP-TEE/QEMU folder that you've created with repo the first time you installed it. In that folder run "ls" and compare that with what you are seeing in your QEMU output above. See any similarities?
I try to redo the VIRTFS, but I have the following issue:
# ls -al /mnt/
total 0
drwxr-xr-x 3 root root 60 Jun 24 09:11 .
drwxr-xr-x 19 root root 440 Jun 24 08:46 ..
drwxr-xr-x 2 root root 40 Jun 24 08:49 host
# mount -t 9p -o trans=virtio host /mnt/host
mount: mounting host on /mnt/host failed: No such device
# lsmod | grep 9p
#
This issue has been marked as a stale issue because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this issue will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time.
how to install additional software inside qemu buildroot session ?
I could not run this op-tee example without the following software.
Note that xtest finished with no test failure.