-
Notifications
You must be signed in to change notification settings - Fork 6
Initial QNX8 QEMU images for x86_64 and arm64 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0d5be98
f94b5ba
1efd176
afa9716
4ebd5cd
0b09741
4d58f32
7478d8c
28d54f8
9c5bc23
44da728
8823729
ac6ba69
46a0698
94888a4
ffa3724
3342899
b4ef597
0e686c7
10a40bc
83aaac0
6238b05
e7c61d9
23adc4e
6d7448d
d43dfb1
7e77555
8e81222
3f31ccf
f8fea10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 8.3.0 | ||
| 8.4.2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,37 @@ module( | |
| version = "1.0", | ||
| ) | ||
|
|
||
| # ------------------------------------------------------------------------------ | ||
| # QNX toolchains | ||
|
|
||
| bazel_dep(name = "score_rules_imagefs", version = "0.0.2") | ||
|
|
||
| imagefs = use_extension("@score_rules_imagefs//extensions:imagefs.bzl", "imagefs", dev_dependency = True) | ||
| imagefs.sdp( | ||
| name = "score_qnx_imagefs_toolchain_pkg", | ||
| url = "https://www.qnx.com/download/download/87174/installation_qnx_803_260305.tar.xz", | ||
|
jgetas marked this conversation as resolved.
|
||
| sha256 = "9039fd6a4a639f06ea977afb93963a6fe8f8c46db727066709370d999c7232e0", | ||
| build_file = "//:sdp.BUILD", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its not going to work for others or ? this is dev dep anyway.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? What do you mean? The sdp.BUILD? I wanted to have this in the rules_imagefs, but Nikola objected. Therefore I had to add it here. The content is IMHO generic for all QNX SDPs. So I don't expect this file will change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am asking whether each consumer of this repo now needs to have this file ? since |
||
| ) | ||
|
|
||
| imagefs.toolchain( | ||
| name = "score_qnx_ifs_toolchain", | ||
| sdp_to_import = "@score_qnx_imagefs_toolchain_pkg", | ||
| sdp_version = "8.0.0", | ||
| target_cpu = "aarch64", | ||
| target_os = "qnx", | ||
| type = "ifs", | ||
| ) | ||
|
|
||
| use_repo( | ||
| imagefs, | ||
| "score_qnx_imagefs_toolchain_pkg", | ||
| "score_qnx_ifs_toolchain", | ||
| ) | ||
|
|
||
| # ------------------------------------------------------------------------------ | ||
| # General purpose Bazel extensions | ||
|
|
||
| # Compliance and licensing toolchain | ||
| bazel_dep(name = "score_tooling", version = "1.1.0") | ||
| bazel_dep(name = "score_python_basics", version = "0.3.0") | ||
|
|
@@ -23,3 +54,6 @@ bazel_dep(name = "score_python_basics", version = "0.3.0") | |
| bazel_dep(name = "score_format_checker", version = "0.1.1") | ||
| bazel_dep(name = "aspect_rules_lint", version = "1.3.1") | ||
| bazel_dep(name = "buildifier_prebuilt", version = "7.3.1") | ||
|
|
||
| # Platform definitions | ||
| bazel_dep(name = "score_bazel_platforms", version = "0.0.3") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # project_config.bzl | ||
| PROJECT_CONFIG = { | ||
| "asil_level": "QM", | ||
| "source_code": ["python"], | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,257 @@ | ||
| # OS images for QNX 8 | ||
|
|
||
| ``` | ||
| +-------------------+ +- - - - - - - - - - - - - -+ | ||
| | QNX IFS | | Custom qnx6fs filesystem | | ||
| | | | (not part of OS image) | | ||
| | (base OS files) | | (user files) | | ||
| +-------------------+ +- - - - - - - - - - - - - -+ | ||
| ``` | ||
|
|
||
| The QNX OS images generated by this repo are intended to be generic images which serve | ||
| as a base for custom use-cases like testing. They implement the basic OS services like | ||
| block device, network device, system logging, ... support and provide standard QNX | ||
| system libraries. | ||
|
|
||
| The QNX IFS image is by nature of QNX boot image file system _read-only_. In order | ||
| to use it in a custom use case it should be paired with a custom qnx6fs file system which | ||
| can either be populated as OS run-time or before-hand by creating a qnx6fs image offline. | ||
| See section _Using QNX OS images for custom use-case_ below. | ||
|
|
||
| Following QNX 8 OS images can be created: | ||
|
|
||
| * QEMU aarch64 "virt" image using virtio block and network drivers. | ||
| * QEMU x86_64 image using virtio block and network drivers. | ||
|
|
||
| ## Using QNX OS images for custom use-case | ||
|
|
||
| ``` | ||
| +-------------------+ +---------------------------+ | ||
| | QNX IFS | | Custom qnx6fs filesystem | | ||
| | | | | | ||
| | (base OS files) | | (user files) | | ||
| +-------------------+ +---------------------------+ | ||
| | mount point: /opt/score | | ||
| +-------------------------------+ | ||
| ``` | ||
|
|
||
| The QNX OS image generated by this repo is intended to be generic and shall not be modified for custom use cases. | ||
| In order to use it for example in a test setup, create a custom partition and put your test files on it. | ||
| See the sections below for instructions. | ||
| In case of QEMU, add the partition to a disk image and pass it to QEMU. See for example the `run-qemu.sh`: | ||
|
|
||
| ``` | ||
| -drive file=$SCORE_DISK,if=none,id=drv0 -device virtio-blk-device,drive=drv0 | ||
| ``` | ||
|
|
||
| The QNX OS tries to mount the first `qnx6fs` partition on the disk image to `/opt/score`. | ||
|
|
||
| ### Attaching a user-created QNX6fs file system | ||
|
|
||
| The QNX startup script (see `qnx8/boards/<board>/initscript`) calls `mount-fs.sh` which tries to mount a file system to the system. | ||
| By default, the partition is mounted at `/` (root) and therefore a user sees a virtual file system with a combination of the IFS and the mounted file system. The path manager resolves path names first on the mounted partition, then on the IFS. This means all files on partition extend or even eclipse files on the IFS. For more information see https://www.qnx.com/developers/docs/8.0/com.qnx.doc.neutrino.sys_arch/topic/proc_Resolving_pathnames.html. | ||
|
|
||
| The generated QEMU launch script `run-qemu.sh` attaches a virtual disk `disk-score.qcow2` to the image. If it does not exist, it creates an empty virtual QEMU disk with size of 512MB before launching QEMU. | ||
|
|
||
| #### Creating a file system on-line | ||
|
|
||
| When starting up the QEMU VM with an empty virtual QEMU disk, no partitions are there. With the following commands you can create a partition and a qnx6fs file system which then gets mounted automatically on following boots: | ||
|
|
||
| ```bash | ||
| # initialize /dev/hd0 with GUID partition table | ||
| pted /dev/hd0 init -g | ||
| # Create a qnx6fs partition with 99% disk size and name 'scorefs' | ||
| pted /dev/hd0 add -t qnx6 -p 99 -n scorefs | ||
| # Re-read the partition table | ||
| mount -e /dev/hd0 | ||
| # Create QNX6 file system | ||
| mkqnx6fs /dev/hd0.qnx6.0 | ||
| # Either mount the partition... | ||
| mount /dev/hd0.qnx6.0 /opt/score | ||
| # ... or reboot to let the partition be mounted automatically at boot time | ||
| # shutdown | ||
| ``` | ||
|
|
||
| After reboot you'll see in the startup messages that a partition is found and mounted: | ||
|
|
||
| ``` | ||
| [...] | ||
| ---> Mounting file systems | ||
| Mounting filesystem /dev/hd0.qnx6.0 to /opt/score | ||
| [...] | ||
| ``` | ||
|
|
||
| #### Creating a file system offline | ||
|
|
||
| A QNX file system can be created on the host using `mkqnx6fsimg` (see https://www.qnx.com/developers/docs/8.0/com.qnx.doc.neutrino.utilities/topic/m/mkqnx6fsimg.html). | ||
|
|
||
| The [rules_imagefs](https://github.com/eclipse-score/rules_imagefs) S-CORE module supports creating qnx6fs images by making use of the | ||
| QNX SDP utilities like `mkqnx6fsimg`. | ||
|
|
||
|
|
||
| ## Pre-requisites | ||
|
|
||
| ### QNX SDP | ||
|
|
||
| #### Using the S-CORE QNX SDP package | ||
|
|
||
| The default QNX SDP package is set up in the top-level `MODULE.bazel` of this repo. It downloads the package | ||
| from `qnx.com`. For being able to do this you need to use your MyQNX account credentials set up in your in | ||
| environment variables `SCORE_QNX_USER` and `SCORE_QNX_PASSWORD`. This can be accomplished in your `~/.bazelrc`: | ||
|
|
||
| ``` | ||
| build --action_env=SCORE_QNX_USER=<...> | ||
| build --action_env=SCORE_QNX_PASSWORD=<...> | ||
| ``` | ||
|
|
||
| #### Using a custom QNX SDP package | ||
|
|
||
| Building the QNX8 OS images requires a QNX SDP 8.0.3 (or later) available during build with following additional QNX SDP packages integrated: | ||
|
|
||
| * QNX® SDP 8.0 Networking - io-sock Virtio Drivers | ||
| * QNX® SDP 8.0 Virtualization Drivers (Block) | ||
| * QNX® SDP 8.0 QEMU Virtualization Drivers (Startup) | ||
|
|
||
| Add the URL of the QNX SDP tarball to the `MODULE.bazel`: | ||
|
|
||
| ``` | ||
| [...] | ||
|
|
||
| imagefs = use_extension("@score_rules_imagefs//extensions:imagefs.bzl", "imagefs", dev_dependency = True) | ||
| imagefs.sdp( | ||
| name = "score_qnx_imagefs_toolchain_pkg", | ||
| url = "http://link/to/your/qnx80x.tar.xz", | ||
| sha256 = "<your-qnx80x.tar.xz-sha256sum>", | ||
| build_file = "//:sdp.BUILD", | ||
| ) | ||
|
|
||
| [...] | ||
|
|
||
| ``` | ||
|
|
||
| In case your QNX license requires to check out a license from a license server, you may want to add the | ||
| information to your local `~/.bazelrc`: | ||
|
|
||
| ``` | ||
| build --action_env=QNXLM_LICENSE_FILE=<...> | ||
| ``` | ||
|
|
||
| ## Building QNX OS images | ||
|
|
||
| QEMU arm64 image using "virt" VM: | ||
|
|
||
| ```bash | ||
| bazel build //qnx8/boards/qemu-arm64virt:all --config=qnx8_0 | ||
| ``` | ||
|
|
||
| QEMU x86_64 image: | ||
|
|
||
| ```bash | ||
| bazel build //qnx8/boards/qemu-x86_64:all --config=qnx8_0 | ||
| ``` | ||
|
|
||
| In case of requiring an online QNX license checkout for the QNX SDP `mkifs` utility you might have to set the QNXLM_LICENSE_FILE environment variable with the link to the license server `--action_env=QNXLM_LICENSE_FILE=...`, for example: | ||
|
|
||
| ```bash | ||
| bazel build --action_env=QNXLM_LICENSE_FILE=my@internal.qnx-license-server.com //qnx8/boards/qemu-arm64virt:all --config=qnx8_0 | ||
| ``` | ||
|
|
||
| ## Building QNX OS images from external module | ||
|
|
||
| Add a reference to this module to your `MODULE.bazel`: | ||
|
|
||
| ``` | ||
| bazel_dep(name = "os_images", version = "...") | ||
| ``` | ||
|
|
||
| Build it with the `@os_images//` prefix, the rest is identical like in the section above: | ||
|
|
||
| ```bash | ||
| bazel build @os_images//qnx8/boards/qemu-... --config=qnx8_0 | ||
| ``` | ||
|
|
||
| ## Running the images | ||
|
|
||
| ### Pre-requisites | ||
|
|
||
| In order to run the QEMU images on the host you must have `qemu-system-aarch64` and `qemu-system-x86_64` installed. The x86_64 QEMU run script uses `-accel kvm`, so the running user must have access to `/dev/kvm` for acceleration. | ||
|
|
||
| ### Get started | ||
|
|
||
| After successful build you'll find the IFS binary and an exemplary run script in `bazel-out`: | ||
|
|
||
| ``` | ||
| bazel-out/k8-fastbuild/bin/qnx8/boards/qemu-arm64virt/run-qemu.sh | ||
| bazel-out/k8-fastbuild/bin/qnx8/boards/qemu-arm64virt/ifs-qemu-arm64virt.bin | ||
| bazel-out/k8-fastbuild/bin/qnx8/boards/qemu-x86_64/run-qemu.sh | ||
| bazel-out/k8-fastbuild/bin/qnx8/boards/qemu-x86_64/ifs-qemu-x86_64.bin | ||
| ``` | ||
| #### Run the images with bazel | ||
|
|
||
| QEMU arm64virt image: | ||
|
|
||
| ``` | ||
| bazel run //qnx8/boards/qemu-arm64virt:run | ||
| ``` | ||
|
|
||
| QEMU x86_64 image: | ||
|
|
||
| ``` | ||
| bazel run //qnx8/boards/qemu-x86_64:run | ||
| ``` | ||
|
|
||
| You'll get something like: | ||
|
|
||
| ``` | ||
| Welcome to QNX 8.0.0 on QEMU_virt ! | ||
|
|
||
| ---> Starting slogger2 | ||
| ---> Starting serial driver | ||
| ---> Starting block driver | ||
| Path=0 - | ||
| target=0 lun=0 Direct-Access(0) - VIRTIO Rev: | ||
| ---> Preparing /run using /dev/ram0 | ||
| ---> Mounting file systems | ||
| No root file system has been detected | ||
| ---> Starting Ethernet driver | ||
| ---> Setting up vtnet0 with ip address 192.168.120.20/24 | ||
| ---> Starting qconn | ||
| ---> Starting sshd | ||
| ---> Starting shell ... Have fun :-) | ||
| # | ||
| ``` | ||
|
|
||
| #### Run the images manually | ||
|
|
||
| In order to run the image, change into the directory with the IFS and execute the run script: | ||
|
|
||
| ``` | ||
| cd bazel-out/k8-fastbuild/bin/qnx8/boards/qemu-arm64virt | ||
| ./run-qemu.sh | ||
| ``` | ||
|
|
||
| ### Autostart script | ||
|
|
||
| If the file `/opt/score/autostart.sh` exists on the mounted file system, it is executed at the end of the OS image startup sequence. | ||
|
|
||
| ### ssh from host into QEMU image | ||
|
|
||
| The QNX IFS images start up a `sshd` server. The user `root` has by default no password and `sshd` is configured to accept a root login w/o password. | ||
| The exemplary `run-qemu.sh` script configures QEMU to use QEMU user networking and sets up a port forwarding from localhost:2210 -> VM-IP 192.168.120.20:22. So you can open a ssh from host using: | ||
|
|
||
| ``` | ||
| ssh -p 2210 root@localhost | ||
| ``` | ||
|
|
||
| ### Configuring custom IP address + host name | ||
|
|
||
| During the startup of the VM the network is being set up, *after* mounting the virtual file system. By default host name `qemu-arm64virt` or `qemu-x86_64` and IP address 192.168.120.20/24 is set up. **Before** setting these, the `net-start.sh` script tries to read a file `/opt/score/etc/settings/network`. By installing such a file on the virtual file system and adding variables one can configure hostname and IP address of the network interface: | ||
|
|
||
| ``` | ||
| # /opt/score/etc/settings/network | ||
| IP_ADDRESS_vtnet0="192.168.100.1/24" | ||
| HOSTNAME=myqemu | ||
| ``` | ||
|
|
||
| > NOTE: This changes only the IP address of the QNX network interface. In order to make the port forwardings of the QEMU user network function correctly you'll have to adapt the QEMU user networking configuration in the `run-qemu.sh` script according to your IP address/subnet. | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| exports_files([ | ||
| "common.build", | ||
| "ssh_host_ed25519_key", | ||
| "ssh_host_ed25519_key.pub", | ||
| "ssh_host_rsa_key", | ||
| "ssh_host_rsa_key.pub", | ||
| ]) | ||
|
|
||
| filegroup( | ||
| name = "common_files", | ||
| srcs = glob(["*"]), | ||
| visibility = [ | ||
| "//qnx8/boards/qemu-arm64virt:__pkg__", | ||
| "//qnx8/boards/qemu-x86_64:__pkg__", | ||
| ], | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use name as in other repos ie
arm64-qnx8There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could do this but this is supposed to be used for x86_64 as well, because it is independent from target architecture - just using the host sdp. I did not want to create 2 configs with duplicate content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if " score_qnx_ifs_toolchain//:ifs-aarch64-qnx-sdp_8.0.0" is host x86 and target qnx8 arch/x86(is it ?) then why not the same here ?