diff --git a/.bazelrc b/.bazelrc index 51cac5a..c9cd30e 100644 --- a/.bazelrc +++ b/.bazelrc @@ -7,3 +7,19 @@ test --test_output=errors common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/ common --registry=https://bcr.bazel.build +common --host_platform=@score_bazel_platforms//:x86_64-linux + +# ------------------------------------------------------------------------------ +# QNX toolchain settings +# Common QNX build settings + +# mkifs is not a target platform specific tool, the host would be sufficient. But there is only +# target platform specific toolchains defined for QNX in this repo. +# Use --config=qnx8_0 for QNX platform builds +common:qnx8_0 --incompatible_strict_action_env +common:qnx8_0 --sandbox_writable_path=/var/tmp +common:qnx8_0 --platforms=@score_bazel_platforms//:aarch64-qnx-sdp_8.0.0-posix +common:qnx8_0 --credential_helper=*.qnx.com=%workspace%/tools/qnx_credential_helper.py + +build:qnx8_0 --extra_toolchains=@score_qnx_ifs_toolchain//:ifs-aarch64-qnx-sdp_8.0.0 + diff --git a/.bazelversion b/.bazelversion index 2bf50aa..e7fdef7 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -8.3.0 +8.4.2 diff --git a/LICENSE.md b/LICENSE.md index ed8d20a..8c69a8b 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -10,4 +10,4 @@ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and -limitations under the License. \ No newline at end of file +limitations under the License. diff --git a/MODULE.bazel b/MODULE.bazel index 01a1bc7..8ecf921 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -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", + sha256 = "9039fd6a4a639f06ea977afb93963a6fe8f8c46db727066709370d999c7232e0", + build_file = "//:sdp.BUILD", +) + +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") diff --git a/README.md b/README.md index 8e54c01..709725e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,30 @@ -# os_images +# OS images -OS Images for testing and deliveries +This module creates OS images intended for testing S-CORE software: + +* bootable [QNX IFS images using the QNX 8 SDP](qnx8/README.md). +* bootable Linux image: TODO + +**Motivation** + +The basic idea is to have generic OS images for *testing* and *verifying* S-CORE binaries. Main purposes: + +* re-usable for multiple use cases: unit-, component-, binary- and system tests and demonstrations +* stuffed with common OS utilities: shell-, file-, test utilities +* no need for rebuilding OS images to match the use case - use cases are realized by a separate partition image created by the user/tester which is attached at OS boot time and is containing files required for the use case. + +**Features**: + +* Launches `sshd` service for remote control (user `root`, empty password by default). +* Supports attaching a user-created file system to `/` (root) in case of QNX. Linux: TODO. By placing some files on this file system the user can make these adaptions: + * Configure hostname and network IP address. + * Add an autostart script launched at the end of the OS startup to start arbitrary tasks. + +=> users can focus on creating the file system with content to match their use cases and *use* the OS image of their choice. + +## Usage + +For detailed instructions on pre-requisites, building, running, and configuring QNX images, see [qnx8/README.md](qnx8/README.md). ## License diff --git a/project_config.bzl b/project_config.bzl new file mode 100644 index 0000000..6cdad0f --- /dev/null +++ b/project_config.bzl @@ -0,0 +1,5 @@ +# project_config.bzl +PROJECT_CONFIG = { + "asil_level": "QM", + "source_code": ["python"], +} diff --git a/qnx8/README.md b/qnx8/README.md new file mode 100644 index 0000000..81ae13d --- /dev/null +++ b/qnx8/README.md @@ -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//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 = "", + 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. + diff --git a/qnx8/boards/common/BUILD b/qnx8/boards/common/BUILD new file mode 100644 index 0000000..92b9164 --- /dev/null +++ b/qnx8/boards/common/BUILD @@ -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__", + ], +) diff --git a/qnx8/boards/common/common.build b/qnx8/boards/common/common.build new file mode 100644 index 0000000..50b905b --- /dev/null +++ b/qnx8/boards/common/common.build @@ -0,0 +1,483 @@ + +[uid=0 gid=0 perms=0555] + +[type=link] /bin/sh=/bin/ksh +[type=link] /tmp=/dev/shmem +[type=link] /var/log=/tmp +[type=link] /usr/tmp=/tmp + + +####################################################################### +## Block driver support libraries +####################################################################### +/lib/libcam.so=libcam.so + +/lib/dll/io-blk.so=io-blk.so +/lib/dll/cam-disk.so=cam-disk.so +/lib/dll/cam-cdrom.so=cam-cdrom.so +/lib/dll/fs-qnx6.so=fs-qnx6.so +/lib/dll/fs-dos.so=fs-dos.so + + +####################################################################### +## Network driver shared libraries +####################################################################### +/usr/lib/libedit.so=libedit.so +/usr/lib/libexpat.so=libexpat.so +/usr/lib/libfdt.so=libfdt.so +/usr/lib/librpc.so.2=librpc.so.2 +/usr/lib/libxo.so.0=libxo.so.0 + +/lib/libsocket.so=libsocket.so +/lib/libjail.so=libjail.so + +/lib/dll/mods-phy.so=mods-phy.so + +####################################################################### +## Network driver and support +####################################################################### +/sbin/dhcpcd=dhcpcd +/sbin/dhcpcd-run-hooks=${QNX_TARGET}/sbin/dhcpcd-run-hooks +[uid=0 gid=0 perms=0444] /sbin/dhcpcd-hooks/20-resolv.conf=${QNX_TARGET}/sbin/dhcpcd-hooks/20-resolv.conf +/sbin/ifconfig=ifconfig +/sbin/io-sock=io-sock +/sbin/pfctl=pfctl +[uid=0 gid=0 perms=4755] /sbin/ping=ping +/sbin/route=route +/sbin/sysctl=sysctl + +/usr/bin/netstat=netstat +/usr/bin/sockstat=sockstat +/usr/bin/vmstat=vmstat + +/usr/sbin/arp=arp +/usr/sbin/devctl=devctl +/usr/sbin/devinfo=devinfo +/usr/sbin/fs-nfs3=fs-nfs3 +/usr/sbin/if_up=if_up +/usr/sbin/ifmcstat=ifmcstat +/usr/sbin/ifwatchd=ifwatchd +/usr/sbin/ip6addrctl=ip6addrctl +/usr/sbin/ndp=ndp + +[uid=0 gid=0 perms=0444] /etc/dhcpcd.conf=${QNX_TARGET}/etc/dhcpcd.conf +[uid=0 gid=0 perms=0444] /etc/hosts=${QNX_TARGET}/etc/hosts +[uid=0 gid=0 perms=0444] /etc/netconfig=${QNX_TARGET}/etc/netconfig +[uid=0 gid=0 perms=0444] /etc/protocols=${QNX_TARGET}/etc/protocols +[uid=0 gid=0 perms=0444] /etc/services=${QNX_TARGET}/etc/services + +####################################################################### +## Remote_debug +####################################################################### +/sbin/devc-pty=devc-pty + +/usr/bin/pdebug=pdebug + +/usr/sbin/qconn=qconn + +####################################################################### +## Network services (ssh and dhcpcd) support +####################################################################### +/usr/sbin/sshd=sshd + +/usr/bin/sftp-server=${QNX_TARGET}/${PROCESSOR}/usr/libexec/sftp-server +/usr/bin/sshd-session=${QNX_TARGET}/${PROCESSOR}/usr/libexec/sshd-session + +/usr/bin/scp=scp +/usr/bin/ssh=ssh +/usr/bin/ssh-keygen=ssh-keygen + +[uid=0 gid=0 perms=0400] /etc/ssh/sshd_config = { +Protocol 2 +LoginGraceTime 600 +HostKey /etc/ssh/ssh_host_rsa_key +HostKey /etc/ssh/ssh_host_ed25519_key +Ciphers aes128-ctr,aes192-ctr,aes256-ctr +MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com +KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256 +AuthorizedKeysFile .ssh/authorized_keys +UsePAM yes +PermitRootLogin yes +# override default of no subsystems +PasswordAuthentication yes +PermitEmptyPasswords yes +Subsystem sftp /usr/bin/sftp-server +SshdSessionPath /usr/bin/sshd-session +} + +[uid=0 gid=0 perms=0400] /etc/ssh/ssh_host_rsa_key=qnx8/boards/common/ssh_host_rsa_key +[uid=0 gid=0 perms=0444] /etc/ssh/ssh_host_rsa_key.pub=qnx8/boards/common/ssh_host_rsa_key.pub +[uid=0 gid=0 perms=0400] /etc/ssh/ssh_host_ed25519_key=qnx8/boards/common/ssh_host_ed25519_key +[uid=0 gid=0 perms=0444] /etc/ssh/ssh_host_ed25519_key.pub=qnx8/boards/common/ssh_host_ed25519_key.pub + + + +####################################################################### +## PCIe driver shared libraries +####################################################################### +/lib/libpci.so=libpci.so + +/lib/dll/pci/pci_bkwd_compat.so=pci/pci_bkwd_compat.so +/lib/dll/pci/pci_cap-0x01.so=pci/pci_cap-0x01.so +/lib/dll/pci/pci_cap-0x04.so=pci/pci_cap-0x04.so +/lib/dll/pci/pci_cap-0x05.so=pci/pci_cap-0x05.so +/lib/dll/pci/pci_cap-0x07.so=pci/pci_cap-0x07.so +/lib/dll/pci/pci_cap-0x09-ffffffff.so=pci/pci_cap-0x09-ffffffff.so +/lib/dll/pci/pci_cap-0x0d.so=pci/pci_cap-0x0d.so +/lib/dll/pci/pci_cap-0x10-16c3abcd.so=pci/pci_cap-0x10-16c3abcd.so +/lib/dll/pci/pci_cap-0x10-19570400.so=pci/pci_cap-0x10-19570400.so +/lib/dll/pci/pci_cap-0x10.so=pci/pci_cap-0x10.so +/lib/dll/pci/pci_cap-0x11-ffffffff.so=pci/pci_cap-0x11-ffffffff.so +/lib/dll/pci/pci_cap-0x11.so=pci/pci_cap-0x11.so +/lib/dll/pci/pci_cap-0x12.so=pci/pci_cap-0x12.so +/lib/dll/pci/pci_cap-0x13.so=pci/pci_cap-0x13.so +/lib/dll/pci/pci_debug.so=pci/pci_debug.so +/lib/dll/pci/pci_debug2.so=pci/pci_debug2.so +/lib/dll/pci/pci_server-buscfg-generic.so=pci/pci_server-buscfg-generic.so +/lib/dll/pci/pci_server-buscfg-hotplug.so=pci/pci_server-buscfg-hotplug.so +/lib/dll/pci/pci_server-buscfg2-generic.so=pci/pci_server-buscfg2-generic.so +/lib/dll/pci/pci_server-buscfg2-hotplug.so=pci/pci_server-buscfg2-hotplug.so +/lib/dll/pci/pci_server-enable_features.so=pci/pci_server-enable_features.so +/lib/dll/pci/pci_server-event_handler.so=pci/pci_server-event_handler.so +/lib/dll/pci/pci_server-namespace.so=pci/pci_server-namespace.so +/lib/dll/pci/pci_slog.so=pci/pci_slog.so +/lib/dll/pci/pci_slog2.so=pci/pci_slog2.so +/lib/dll/pci/pci_strings.so=pci/pci_strings.so +/lib/dll/pci/pcie_xcap-0x0001.so=pci/pcie_xcap-0x0001.so +/lib/dll/pci/pcie_xcap-0x0003.so=pci/pcie_xcap-0x0003.so +/lib/dll/pci/pcie_xcap-0x000b-ffffffff.so=pci/pcie_xcap-0x000b-ffffffff.so +/lib/dll/pci/pcie_xcap-0x0015.so=pci/pcie_xcap-0x0015.so + +####################################################################### +## PCIe driver and support +####################################################################### +/sbin/pci-server=pci-server + +/usr/sbin/pci-tool=pci-tool +/usr/sbin/rsrcdb_query=rsrcdb_query + +/etc/system/config/pci/pcidatabase.com-tab_delimited.txt=${QNX_TARGET}/etc/system/config/pci/pcidatabase.com-tab_delimited.txt + +####################################################################### +## Shared libraries for security +####################################################################### +/lib/libqh.so=libqh.so +/lib/libregex.so=libregex.so +/lib/libsecpol.so=libsecpol.so +/lib/libslog2parse.so=libslog2parse.so +/lib/libslog2shim.so=libslog2shim.so +/lib/libslog2.so=libslog2.so +/lib/libtracelog.so=libtracelog.so + +/lib/dll/qcrypto-openssl-3.so=qcrypto-openssl-3.so + +/usr/lib/libcrypto.so=libcrypto.so +/usr/lib/libncursesw.so=libncursesw.so +/usr/lib/libqcrypto.so=libqcrypto.so +/usr/lib/libssl.so=libssl.so + +####################################################################### +## libqcrypto support +####################################################################### +[uid=0 gid=0 perms=0444] /etc/qcrypto.conf = { +openssl-3 tags=* +} + +####################################################################### +## Security files +####################################################################### +[uid=0 gid=0 perms=4555] /bin/login=login +[uid=0 gid=0 perms=4555] /bin/su=su + +[uid=0 gid=0 perms=455] /usr/bin/passwd=passwd + +[uid=0 gid=0 perms=0644] /etc/passwd = { +root:x:0:0:Superuser:/root:/bin/sh +sshd:x:15:6:sshd:/var/chroot/sshd:/bin/false +qnxuser:x:1000:1000:QNX User:/home/qnxuser:/bin/sh +} + +## Enabled Username/Password: root/root, qnxuser/qnxuser +[uid=0 gid=0 perms=0644] /etc/shadow = { +root::1763474425:0:0 +sshd:*:1763474425:0:0 +qnxuser::1763474425:0:0 +} + +[uid=0 gid=0 perms=0644] /etc/group = { +root:x:0:root +sshd:x:6: +qnxuser:x:1000 +} + + +####################################################################### +## PAM configurations addon build file +####################################################################### +[uid=0 gid=0 type=dir dperms=0755] / +[uid=0 gid=0 type=dir dperms=0755] /etc +[uid=0 gid=0 type=dir dperms=0755] /etc/pam.d +[uid=0 gid=0 type=dir dperms=0555] /home +[uid=1000 gid=1000 type=dir dperms=0555] /home/qnxuser +[uid=0 gid=0 type=dir dperms=0555] /lib +[uid=0 gid=0 type=dir dperms=0700] /root +[uid=0 gid=0 type=dir dperms=0555] /usr +[uid=0 gid=0 type=dir dperms=0555] /usr/lib +[uid=0 gid=0 type=dir dperms=0755] /var +[uid=0 gid=0 type=dir dperms=0755] /var/chroot +[uid=0 gid=0 type=dir dperms=0755] /var/chroot/sshd + +[perms=644] /etc/pam.d/login = { +auth requisite pam_qnx.so nullok +account requisite pam_qnx.so nullok +session requisite pam_qnx.so nullok +password requisite pam_qnx.so nullok +} + +[perms=644] /etc/pam.d/sshd = { +auth requisite pam_qnx.so nullok +account requisite pam_qnx.so nullok +session requisite pam_qnx.so nullok +password requisite pam_qnx.so nullok +} + +[perms=644] /etc/pam.d/passwd = { +auth requisite pam_qnx.so nullok +account requisite pam_qnx.so nullok +session requisite pam_qnx.so nullok +password requisite pam_qnx.so nullok +} + +[perms=644] /etc/pam.d/su = { +auth sufficient pam_rootok.so no_warn +auth requisite pam_qnx.so +account requisite pam_qnx.so +session requisite pam_qnx.so +password requisite pam_qnx.so +} + + +[uid=0 gid=0 perms=0555] /usr/lib/libpam.so=libpam.so +[uid=0 gid=0 perms=0555] /usr/lib/pam_deny.so=pam_deny.so +[uid=0 gid=0 perms=0555] /usr/lib/pam_echo.so=pam_echo.so +[uid=0 gid=0 perms=0555] /usr/lib/pam_exec.so=pam_exec.so +[uid=0 gid=0 perms=0555] /usr/lib/pam_group.so=pam_group.so +[uid=0 gid=0 perms=0555] /usr/lib/pam_permit.so=pam_permit.so +[uid=0 gid=0 perms=0555] /usr/lib/pam_qnx.so=pam_qnx.so +[uid=0 gid=0 perms=0555] /usr/lib/pam_rootok.so=pam_rootok.so +[uid=0 gid=0 perms=0555] /usr/lib/pam_secpol.so=pam_secpol.so +[uid=0 gid=0 perms=0555] /usr/lib/pam_self.so=pam_self.so + + +####################################################################### +## General shared libraries +####################################################################### +ldqnx-64.so.2=ldqnx-64.so.2 + +/lib/libc.so=libc.so +/lib/libcatalog.so=libcatalog.so +/lib/libdevice-publisher.so=libdevice-publisher.so +/lib/libgcc_s.so=libgcc_s.so +/lib/libm.so=libm.so +[+optional] /lib/libfsnotify.so=libfsnotify.so + +/usr/lib/libbacktrace.so=libbacktrace.so +/usr/lib/libc++.so=libc++.so +/usr/lib/libiconv.so=libiconv.so +/usr/lib/libintl.so=libintl.so +/usr/lib/libpanelw.so=libpanelw.so +/usr/lib/libz.so=libz.so + + +####################################################################### +## General commands +####################################################################### +/bin/confstr=confstr +/bin/df=df +/bin/hostname=hostname +/bin/kill=kill +/bin/ksh=ksh +/bin/mount=mount +/bin/on=on +/bin/pidin=pidin +/bin/slay=slay +/bin/slog2info=slog2info +/bin/slogger2=slogger2 +/bin/sync=sync +/bin/umount=umount +/bin/waitfor=waitfor +/bin/umask=umask + +/sbin/mqueue=mqueue +/sbin/pipe=pipe +/sbin/shutdown=shutdown + +/usr/bin/getconf=getconf +/usr/bin/hd=hd +/usr/bin/ldd=ldd +/usr/bin/setconf=setconf +/usr/bin/top=top +/usr/bin/use=use + +/usr/sbin/dumper=dumper +/usr/sbin/random=random + +################################################################################################ +## Toybox commands +## Note: The toybox package combines many common Linux command line utilities together into +## a single, BSD-licensed executable. The following toybox commands are supported. +## Use one of the following commands to access help for a toybox command: +## toybox command_name --help +## command_name --help +################################################################################################ +/usr/bin/toybox=toybox + +[type=link] /bin/cat=/usr/bin/toybox +[type=link] /bin/chmod=/usr/bin/toybox +[type=link] /bin/cp=/usr/bin/toybox +[type=link] /bin/dd=/usr/bin/toybox +[type=link] /bin/echo=/usr/bin/toybox +[type=link] /bin/ln=/usr/bin/toybox +[type=link] /bin/ls=/usr/bin/toybox +[type=link] /bin/mkdir=/usr/bin/toybox +[type=link] /bin/mv=/usr/bin/toybox +[type=link] /bin/pwd=/usr/bin/toybox +[type=link] /bin/rm=/usr/bin/toybox +[type=link] /bin/sed=/usr/bin/toybox +[type=link] /bin/uname=/usr/bin/toybox + +[type=link] /usr/bin/ascii=/usr/bin/toybox +[type=link] /usr/bin/base64=/usr/bin/toybox +[type=link] /usr/bin/basename=/usr/bin/toybox +[type=link] /usr/bin/bc=/usr/bin/toybox +[type=link] /usr/bin/bunzip2=/usr/bin/toybox +[type=link] /usr/bin/bzcat=/usr/bin/toybox +[type=link] /usr/bin/cal=/usr/bin/toybox +[type=link] /usr/bin/chgrp=/usr/bin/toybox +[type=link] /usr/bin/chown=/usr/bin/toybox +[type=link] /usr/bin/cksum=/usr/bin/toybox +[type=link] /usr/bin/clear=/usr/bin/toybox +[type=link] /usr/bin/cmp=/usr/bin/toybox +[type=link] /usr/bin/comm=/usr/bin/toybox +[type=link] /usr/bin/cpio=/usr/bin/toybox +[type=link] /usr/bin/crc32=/usr/bin/toybox +[type=link] /usr/bin/cut=/usr/bin/toybox +[type=link] /usr/bin/date=/usr/bin/toybox +[type=link] /usr/bin/diff=/usr/bin/toybox +[type=link] /usr/bin/dirname=/usr/bin/toybox +[type=link] /usr/bin/dos2unix=/usr/bin/toybox +[type=link] /usr/bin/du=/usr/bin/toybox +[type=link] /usr/bin/egrep=/usr/bin/toybox +[type=link] /usr/bin/env=/usr/bin/toybox +[type=link] /usr/bin/expand=/usr/bin/toybox +[type=link] /usr/bin/expr=/usr/bin/toybox +[type=link] /usr/bin/false=/usr/bin/toybox +[type=link] /usr/bin/fgrep=/usr/bin/toybox +[type=link] /usr/bin/file=/usr/bin/toybox +[type=link] /usr/bin/find=/usr/bin/toybox +[type=link] /usr/bin/grep=/usr/bin/toybox +[type=link] /usr/bin/groups=/usr/bin/toybox +[type=link] /usr/bin/gunzip=/usr/bin/toybox +[type=link] /usr/bin/gzip=/usr/bin/toybox +[type=link] /usr/bin/head=/usr/bin/toybox +[type=link] /usr/bin/id=/usr/bin/toybox +[type=link] /usr/bin/install=/usr/bin/toybox +[type=link] /usr/bin/link=/usr/bin/toybox +[type=link] /usr/bin/logname=/usr/bin/toybox +[type=link] /usr/bin/md5sum=/usr/bin/toybox +[type=link] /usr/bin/mkfifo=/usr/bin/toybox +[type=link] /usr/bin/mktemp=/usr/bin/toybox +[type=link] /usr/bin/more=/usr/bin/toybox +[type=link] /usr/bin/nl=/usr/bin/toybox +[type=link] /usr/bin/nohup=/usr/bin/toybox +[type=link] /usr/bin/od=/usr/bin/toybox +[type=link] /usr/bin/paste=/usr/bin/toybox +[type=link] /usr/bin/patch=/usr/bin/toybox +[type=link] /usr/bin/printenv=/usr/bin/toybox +[type=link] /usr/bin/printf=/usr/bin/toybox +[type=link] /usr/bin/readlink=/usr/bin/toybox +[type=link] /usr/bin/realpath=/usr/bin/toybox +[type=link] /usr/bin/rmdir=/usr/bin/toybox +[type=link] /usr/bin/seq=/usr/bin/toybox +[type=link] /usr/bin/sha1sum=/usr/bin/toybox +[type=link] /usr/bin/sleep=/usr/bin/toybox +[type=link] /usr/bin/sort=/usr/bin/toybox +[type=link] /usr/bin/split=/usr/bin/toybox +[type=link] /usr/bin/stat=/usr/bin/toybox +[type=link] /usr/bin/strings=/usr/bin/toybox +[type=link] /usr/bin/tail=/usr/bin/toybox +[type=link] /usr/bin/tar=/usr/bin/toybox +[type=link] /usr/bin/tee=/usr/bin/toybox +[type=link] /usr/bin/test=/usr/bin/toybox +[type=link] /usr/bin/time=/usr/bin/toybox +[type=link] /usr/bin/timeout=/usr/bin/toybox +[type=link] /usr/bin/touch=/usr/bin/toybox +[type=link] /usr/bin/true=/usr/bin/toybox +[type=link] /usr/bin/truncate=/usr/bin/toybox +[type=link] /usr/bin/tty=/usr/bin/toybox +[type=link] /usr/bin/uniq=/usr/bin/toybox +[type=link] /usr/bin/unix2dos=/usr/bin/toybox +[type=link] /usr/bin/unlink=/usr/bin/toybox +[type=link] /usr/bin/uudecode=/usr/bin/toybox +[type=link] /usr/bin/uuencode=/usr/bin/toybox +[type=link] /usr/bin/uuidgen=/usr/bin/toybox +[type=link] /usr/bin/wc=/usr/bin/toybox +[type=link] /usr/bin/which=/usr/bin/toybox +[type=link] /usr/bin/whoami=/usr/bin/toybox +[type=link] /usr/bin/xargs=/usr/bin/toybox +[type=link] /usr/bin/xxd=/usr/bin/toybox +[type=link] /usr/bin/yes=/usr/bin/toybox +[type=link] /usr/bin/zcat=/usr/bin/toybox + +####################################################################### +## Terminal support +####################################################################### +/usr/share/terminfo/q/qansi = ${QNX_TARGET}/usr/share/terminfo/q/qansi +/usr/share/terminfo/q/qansi-m = ${QNX_TARGET}/usr/share/terminfo/q/qansi-m +/usr/share/terminfo/x/xterm+256color = ${QNX_TARGET}/usr/share/terminfo/x/xterm+256color +/usr/share/terminfo/x/xterm = ${QNX_TARGET}/usr/share/terminfo/x/xterm + + +####################################################################### +## additional SDP files for testing support +####################################################################### +/usr/bin/awk=awk +/usr/bin/coreinfo=coreinfo +/sbin/mkdosfs=mkdosfs +/sbin/mkqnx6fs=mkqnx6fs +/sbin/chkdosfs=chkdosfs +/sbin/chkqnx6fs=chkqnx6fs +/sbin/fdisk=fdisk +/sbin/fsevmgr=fsevmgr +/usr/bin/pted=pted +/bin/vi=vi +/usr/bin/hogs=hogs +/usr/sbin/tracelogger=tracelogger +/usr/bin/iperf3=iperf3 +/usr/lib/libiperf.so=libiperf.so +/usr/sbin/tcpdump=tcpdump +/usr/sbin/traceroute=traceroute +/usr/sbin/traceroute6=traceroute6 + +####################################################################### +## security only: security policy support +####################################################################### +[uid=0 gid=0 perms=0555] /proc/boot/secpolpush=secpolpush +[uid=0 gid=0 perms=0555] /proc/boot/secpolmonitor=secpolmonitor +[uid=0 gid=0 perms=0555] /proc/boot/secpol=secpol +# only for debugging use-case using secpolgenerate: +[uid=0 gid=0 perms=0755] /proc/boot/secpolgenerate=secpolgenerate +[uid=0 gid=0 perms=0755] /lib/libsecpol-gen.so=libsecpol-gen.so + +####################################################################### +## custom files / directories +####################################################################### +[uid=0 gid=0 type=dir dperms=0755] /run +[type=link] /var/run=/run +[uid=0 gid=0 type=dir dperms=0755] /boot +[uid=0 gid=0 type=dir dperms=0755] /mnt +[uid=0 gid=0 type=dir dperms=0755] /opt +# lola requirement +[type=link] /tmp_discovery=/run/lola_discovery + + diff --git a/qnx8/boards/common/ssh_host_ed25519_key b/qnx8/boards/common/ssh_host_ed25519_key new file mode 100644 index 0000000..89c6c2b --- /dev/null +++ b/qnx8/boards/common/ssh_host_ed25519_key @@ -0,0 +1,7 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACAs7bJJdtxERfVjlfPAi3h649xT6RIRowDorA0wX4wRPAAAAJg0VhFKNFYR +SgAAAAtzc2gtZWQyNTUxOQAAACAs7bJJdtxERfVjlfPAi3h649xT6RIRowDorA0wX4wRPA +AAAEBmnSYYCYgHKfenavLLXS4XzwgUQa8ssQaKEMk7BclzFiztskl23ERF9WOV88CLeHrj +3FPpEhGjAOisDTBfjBE8AAAAFGdqdDJhYnRAQUJUMy1DLTAwMDM5AQ== +-----END OPENSSH PRIVATE KEY----- diff --git a/qnx8/boards/common/ssh_host_ed25519_key.pub b/qnx8/boards/common/ssh_host_ed25519_key.pub new file mode 100644 index 0000000..eaee9c6 --- /dev/null +++ b/qnx8/boards/common/ssh_host_ed25519_key.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICztskl23ERF9WOV88CLeHrj3FPpEhGjAOisDTBfjBE8 gjt2abt@ABT3-C-00039 diff --git a/qnx8/boards/common/ssh_host_rsa_key b/qnx8/boards/common/ssh_host_rsa_key new file mode 100644 index 0000000..90c9815 --- /dev/null +++ b/qnx8/boards/common/ssh_host_rsa_key @@ -0,0 +1,38 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn +NhAAAAAwEAAQAAAYEAtA0lqCZL5ZDmimijBh3Izp9/T4B1tjoehIXd6nPdacAIqYfNvdoK +RXC+tu2gXD2Ww/bg/lY3b8O4DfB8i3HMNhEqQPN8HrezwiOVMin0ybPVNZYh36WxZr9j3Z +kBAJr+zWCq9BOjrlzX/yo2UTl4iwy5c2YTxcVnH6Pr6YkR6DHq6zA3i1kuouj4Q4QjrixM +eW7vmbrH4OnDBzEjsSyaiDzpKA2XshInwEvGiYyxNANIdMESLtOImDEKB7EoMIKmK/FLM/ +AR8mpu0hE6Eni3wbqO03zbUgC/Oe++tWyKXH8PBxeUrjoRuQ1obEFtgxTvHBZWxc6IPOKr +xu4ZHIJsyc3CXzhzPt+i3j5XWF7SnXYn8A9VnKxIgBFmDXPqbJ/uOpsqzdzCweD0XiyKxi +YnrL9WfP6tIWpnpdeVemBYBJotIWsm3GH1/OpN157Taxzz+jaGFpUL9Y08/AYrLz9F9Ms2 +U6uWNVGhut6441ZYOsLGZWu6Dft1dXXWoVvfwOr5AAAFkLcWOxK3FjsSAAAAB3NzaC1yc2 +EAAAGBALQNJagmS+WQ5opoowYdyM6ff0+AdbY6HoSF3epz3WnACKmHzb3aCkVwvrbtoFw9 +lsP24P5WN2/DuA3wfItxzDYRKkDzfB63s8IjlTIp9Mmz1TWWId+lsWa/Y92ZAQCa/s1gqv +QTo65c1/8qNlE5eIsMuXNmE8XFZx+j6+mJEegx6uswN4tZLqLo+EOEI64sTHlu75m6x+Dp +wwcxI7Esmog86SgNl7ISJ8BLxomMsTQDSHTBEi7TiJgxCgexKDCCpivxSzPwEfJqbtIROh +J4t8G6jtN821IAvznvvrVsilx/DwcXlK46EbkNaGxBbYMU7xwWVsXOiDziq8buGRyCbMnN +wl84cz7fot4+V1he0p12J/APVZysSIARZg1z6myf7jqbKs3cwsHg9F4sisYmJ6y/Vnz+rS +FqZ6XXlXpgWASaLSFrJtxh9fzqTdee02sc8/o2hhaVC/WNPPwGKy8/RfTLNlOrljVRobre +uONWWDrCxmVrug37dXV11qFb38Dq+QAAAAMBAAEAAAGADRVrfXA9pv1EPh3jwtJaljvcNN +Br6AW0fq16S8rcSw6g/S4Y0vP2N8eSmZkORHBWn/+KUqZnOYrqZAZBYUyv/znOF+bZnSMn +lTL1aNjIU06VxA1t1rej+t3A3wh68dVRhhEWkHf2NqRuhGSdNS0iR6XGus5ZyiRRyGh8AH +4XvAdslRHtkgW1WtySYILzU3kf8YRl4DDvd2DlQtoySByqpL3FtPBlQT5f1HHCh++eV4jp +ifpsXNS9ofmQ9gV3RdcofDwMCUr8HXuZL3OC+OYG3CLEdcrNktKHksT7X3Jb57i2iHrIme +qOsOhJjRDImtLd6kR3YolMT3t8UcB/0LMlwE8hcKfpTD+tzmkvbpjaBGzGB9mQl2QoboJH +3Y+Prj7mhT/7PBfxUUH5FNX2bxf/tYhluh1zHUl29b+1sewa9GjETntOPhlCoSE2VtpEMf +yG5Tsq8D/j5MVe1B4KK8zB3gYnjjzmqM/tsQ43zVfduudl+dM6q9aEouD9ygSOhvjFAAAA +wQCZ0gt9zLSvbinM4DQpad9GHDxke5Gh98potRblwlDm5dQ94c0mwIpfSY4DYelkNR3A8B +i1OxFPhOGjEVHs+HyYYcnXNBf8DmnHaxDyv5LFxDOEZTWaSlvC1RHHN0bIsLmUIHX6TP1N +GiI3iea5twBU+t2MsqUwaySjieTG5xdjObrlWmxytRYmX2vz0XiZI8CjQBgSrQnm44wd2h +hyKpdzwALqKwBc0zHaz6u0xI+oWPBGcVcVYANq/4wjjriCGQUAAADBANI2ZF42tRkuVlAd +u83VoUo+RWZ8b+0PoFly7dMf5iAvj4ds9AlQIOJ7uW6s3PA5KyGTTpRL2emyuX33nE5DTU +ewe5itwzD7e3i4+mWWiXokSYGHSxey6cSVcxdKdilHaC9ufEgKOdvEJ43eAqoaBr/+8NO5 +ugrJlhsJ3Ffc9WkrX/ketLH4gL2H+CTmnlbVH4vIYs0u4wMrVIYL8GRqGiQuSyhRZQb7kb +tv5qnn7J3ynOt6khm7LpmRNyH4HuydRwAAAMEA20TyxKWPEQxKFctMJXDyelYtn0jO3Iqk +WlIXQyUPD4j8BWkGIdURrO2LXiR3lKko/sYZ7rW4g6923klY9UrxYTRjAixU/AKKX3cJbK +8PNfvs+9uI9DT+eYrD7y/Ixsy4EE7cpAFeh28d55kqSS2us80a7pFy4OngXf1Tjq3pgUTe +pnuao7XXPX5Ht+IiQFbDHgbrNy9t82hTkZQv1bseJ6jJCBmn1YTbLNxhwZxptShF78e85/ +LqYPUErqheiVW/AAAAFGdqdDJhYnRAQUJUMy1DLTAwMDM5AQIDBAUG +-----END OPENSSH PRIVATE KEY----- diff --git a/qnx8/boards/common/ssh_host_rsa_key.pub b/qnx8/boards/common/ssh_host_rsa_key.pub new file mode 100644 index 0000000..70942de --- /dev/null +++ b/qnx8/boards/common/ssh_host_rsa_key.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC0DSWoJkvlkOaKaKMGHcjOn39PgHW2Oh6Ehd3qc91pwAiph8292gpFcL627aBcPZbD9uD+Vjdvw7gN8HyLccw2ESpA83wet7PCI5UyKfTJs9U1liHfpbFmv2PdmQEAmv7NYKr0E6OuXNf/KjZROXiLDLlzZhPFxWcfo+vpiRHoMerrMDeLWS6i6PhDhCOuLEx5bu+Zusfg6cMHMSOxLJqIPOkoDZeyEifAS8aJjLE0A0h0wRIu04iYMQoHsSgwgqYr8Usz8BHyam7SEToSeLfBuo7TfNtSAL857761bIpcfw8HF5SuOhG5DWhsQW2DFO8cFlbFzog84qvG7hkcgmzJzcJfOHM+36LePldYXtKddifwD1WcrEiAEWYNc+psn+46myrN3MLB4PReLIrGJiesv1Z8/q0hamel15V6YFgEmi0haybcYfX86k3XntNrHPP6NoYWlQv1jTz8BisvP0X0yzZTq5Y1UaG63rjjVlg6wsZla7oN+3V1ddahW9/A6vk= gjt2abt@ABT3-C-00039 diff --git a/qnx8/boards/qemu-arm64virt/BUILD b/qnx8/boards/qemu-arm64virt/BUILD new file mode 100644 index 0000000..d77920a --- /dev/null +++ b/qnx8/boards/qemu-arm64virt/BUILD @@ -0,0 +1,32 @@ +load("@score_rules_imagefs//rules/qnx:ifs.bzl", "qnx_ifs") + +qnx_ifs ( + name = "ifs-qemu-arm64virt", + build_file = "qemu-arm64virt.build", + srcs = ["target.build", + "initscript", + "//qnx8/boards/common:common_files"] + glob(["*.sh"], exclude=["run-*.sh"]), + extension = "bin", + visibility = ["//visibility:public"], +) + +genrule( + name = "qemu-runscript", + srcs = [ + "run-qemu-arm64virt.sh", + ], + outs = [ + "run-qemu.sh", + ], + cmd = """ + cp $(execpath run-qemu-arm64virt.sh) $(execpath run-qemu.sh) + """, + visibility = ["//visibility:public"], +) + +sh_binary( + name = "run", + srcs = ["run-qemu.sh"], + data = [":ifs-qemu-arm64virt"], + args = ["$(location :ifs-qemu-arm64virt)"], +) diff --git a/qnx8/boards/qemu-arm64virt/blk-start.sh b/qnx8/boards/qemu-arm64virt/blk-start.sh new file mode 100644 index 0000000..37486d1 --- /dev/null +++ b/qnx8/boards/qemu-arm64virt/blk-start.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +# Start file system event manager. +# Required for applications utilizing inotify_...() APIs. +# Must start before any block device driver. +if [ -x /sbin/fsevmgr ]; then + echo "---> Starting fsevmgr" + /sbin/fsevmgr + waitfor /dev/fsnotify +fi + +# Start virtio block device driver +BLK_DEVICE_RAW=hd0 + +echo "---> Starting block driver" +# virtio-blk values from QEMU virt fdt... +devb-virtio cam user=20:20 blk cache=64M,auto=partition,vnode=2000,ncache=2000,commit=low virtio smem=0xa003e00,irq=79 blk ramdisk=20m + +waitfor /dev/$BLK_DEVICE_RAW 30 #Increase timeout value for arm64 as block device initialization takes longer time +if [ ! -e /dev/$BLK_DEVICE_RAW ] +then + echo "ERROR: No block device detected" +fi + + +# Start /run filesystem +if [ -e /dev/ram0 ] +then + echo "---> Preparing /run using /dev/ram0" + # Preparing for many small files: + # 4096 inodes, 512 bytes per block, no reserved blocks + mkqnx6fs -i 4096 -b 512 -r 0 -q /dev/ram0 + mount -t qnx6 /dev/ram0 /run + # Create /run/lola_discovery for lola + mkdir /run/lola_discovery +else + echo "ERROR: No /dev/ram0 detected. /run file system is not available." +fi diff --git a/qnx8/boards/qemu-arm64virt/initscript b/qnx8/boards/qemu-arm64virt/initscript new file mode 100644 index 0000000..a78ea98 --- /dev/null +++ b/qnx8/boards/qemu-arm64virt/initscript @@ -0,0 +1,64 @@ +SYSNAME=nto +TERM=xterm +ENV=/etc/profile + +procmgr_symlink ../../proc/boot/ldqnx-64.so.2 /usr/lib/ldqnx-64.so.2 + +## Needed for ksh to run the echo command below +pipe + +display_msg " " +ksh -c "echo Welcome to QNX $(uname -r) on $(uname -m) !" +display_msg " " + +############################################################################################ +display_msg "---> Starting slogger2" +############################################################################################ +/bin/slogger2 & +waitfor /dev/slog2 + +dumper +mqueue +random + + +####################################################################### +## Console SERIAL driver +####################################################################### +display_msg "---> Starting serial driver" +devc-serpl011 -e -F 0x9000000,33 +waitfor /dev/ser1 +reopen /dev/ser1 + +/sbin/devc-pty + +####################################################################### +# Initial block device setup +####################################################################### +/bin/sh /proc/boot/blk-start.sh + +####################################################################### +# Mount file systems +####################################################################### +/bin/sh /proc/boot/mount-fs.sh + +####################################################################### +# Start networking, set hostname +####################################################################### +/bin/sh /proc/boot/net-start.sh + +####################################################################### +# Starting remaining services startup script +####################################################################### +/bin/sh /proc/boot/misc-services.sh + +####################################################################### +# Starting consoles and shells +####################################################################### +display_msg "---> Starting shell ... Have fun :-)" +HOME=/root +umask 022 + +# replace this shell with an interactive one +[+session] /bin/ksh -l + diff --git a/qnx8/boards/qemu-arm64virt/misc-services.sh b/qnx8/boards/qemu-arm64virt/misc-services.sh new file mode 100644 index 0000000..12466c1 --- /dev/null +++ b/qnx8/boards/qemu-arm64virt/misc-services.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ -x /usr/sbin/qconn ]; then + echo "---> Starting qconn" + waitfor /dev/ptyp0 4 + waitfor /dev/socket 4 + /usr/sbin/qconn port=8000 +fi + +if [ -x /usr/sbin/sshd ]; then + echo "---> Starting sshd" + /usr/sbin/sshd +fi + +if [ -x /opt/score/autostart.sh ]; then + echo "---> Executing /opt/score/autostart.sh" + sh /opt/score/autostart.sh & +fi diff --git a/qnx8/boards/qemu-arm64virt/mount-fs.sh b/qnx8/boards/qemu-arm64virt/mount-fs.sh new file mode 100644 index 0000000..0521a27 --- /dev/null +++ b/qnx8/boards/qemu-arm64virt/mount-fs.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +echo "---> Mounting file systems" + +# Mount probe list: hd0... is MBR, hd0.qnx6.x is GPT +MOUNT_PROBE_LIST="hd0t177 hd0.qnx6.0 hd0.qnx6.1" +MOUNT_POINT=/opt/score + +if [ -f /boot/etc/settings/mount ]; then + . /boot/etc/settings/mount +fi + +for blk_device in $MOUNT_PROBE_LIST +do + if [ -e /dev/$blk_device ] + then + BLK_DEVICE=$blk_device + break + fi +done +if [ -n "$BLK_DEVICE" ] +then + echo "Mounting filesystem /dev/$BLK_DEVICE to $MOUNT_POINT" + mount $MOUNTOPTIONS -t qnx6 /dev/$BLK_DEVICE $MOUNT_POINT +else + echo "No root file system has been detected" +fi + diff --git a/qnx8/boards/qemu-arm64virt/net-start.sh b/qnx8/boards/qemu-arm64virt/net-start.sh new file mode 100644 index 0000000..b5a4f6c --- /dev/null +++ b/qnx8/boards/qemu-arm64virt/net-start.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +DEVICE_NAME_PREFIX=vtnet +IP_ADDRESS_vtnet0="192.168.120.20/24" +HOSTNAME=qemu-arm64virt + +if [ -f /opt/score/etc/settings/network ]; then + . /opt/score/etc/settings/network +fi + +# Set hostname +setconf _CS_HOSTNAME ${HOSTNAME} + +echo "---> Starting Ethernet driver" +io-sock -m fdt -d vtnet_mmio + +waitfor /dev/socket 1 +# Check if any network device is in the system +if [ ! -e /dev/socket ]; then + # No - exit here + echo "---> No Network device has been detected" + exit 0; +fi + + +if [ "$IP_ADDRESS_vtnet0" = dhcp ]; then + dhcpcd -bq -f /boot/etc/dhcpcd/dhcpcd.conf -c /boot/etc/dhcpcd/dhcpcd-run-hooks + # If dhcpcd not run as root, need to give it read/write access to /dev/bpf + setfacl -m user:38:rw /dev/bpf +else + # Setup static IP addresses for all defined devices + # enumerate devices from 0..3 + for i in 0 1 2 3 + do + # Try finding env var "IP_ADDRESS_" defined in network config file. + # If found, set up corresponding device. + # Build device name out of prefix + i + DEVICE_NAME=${DEVICE_NAME_PREFIX}$i + # Build env var name out of string "NET_IP_ADDRESS_" + DEVICE_NAME + IP_ADDRESS_TEMPLATE="IP_ADDRESS_$DEVICE_NAME" + # Evaluate env var name to get IP address for device + IP_ADDRESS=$(eval echo \$$IP_ADDRESS_TEMPLATE) + if [ -n "$IP_ADDRESS" ]; then + echo "---> Setting up $DEVICE_NAME with ip address $IP_ADDRESS" + if_up -r 10 -p $DEVICE_NAME + ifconfig $DEVICE_NAME $IP_ADDRESS up + fi + done +fi + +sysctl -w net.inet.icmp.bmcastecho=1 > /dev/null +sysctl -w qnx.sec.droproot=33:33 > /dev/null + +exit 0 diff --git a/qnx8/boards/qemu-arm64virt/qemu-arm64virt.build b/qnx8/boards/qemu-arm64virt/qemu-arm64virt.build new file mode 100644 index 0000000..e09f51a --- /dev/null +++ b/qnx8/boards/qemu-arm64virt/qemu-arm64virt.build @@ -0,0 +1,28 @@ +################################################################################################ +## +## Build file for a QNX operating system +## +################################################################################################ + +[-optional] +[+keeplinked] +[image=0x40080000] +[virtual=aarch64le,raw] boot = { + startup-qemu-virt + PATH=/proc/boot:/sbin:/bin:/usr/bin:/usr/sbin:/usr/libexec LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll:/lib/dll/pci procnto-smp-instr -v -mL +} + +# all owned by root +[uid=0 gid=0 perms=0555 dperms=0555] + +# add external search path in case we are building the image with bazel in context of another module *sigh* +[search=${MKIFS_PATH}:external/os_images+] + +[+script] startup-script = qnx8/boards/qemu-arm64virt/initscript + +# include the target specific build file +[+include] qnx8/boards/qemu-arm64virt/target.build + +# include the common build file +[+include] qnx8/boards/common/common.build + diff --git a/qnx8/boards/qemu-arm64virt/run-qemu-arm64virt.sh b/qnx8/boards/qemu-arm64virt/run-qemu-arm64virt.sh new file mode 100755 index 0000000..8bbb592 --- /dev/null +++ b/qnx8/boards/qemu-arm64virt/run-qemu-arm64virt.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# run-qemu-arm64virt.sh [] + +# ------------------------------------------ +# General QEMU settings +QEMU_BIN=qemu-system-aarch64 +MEM_SIZE=1G # does not run with less than 1G! +CPU_COUNT=2 + +# ------------------------------------------ +QNX_IFS=ifs-qemu-arm64virt.bin +if [ "$1" != "" ]; then + QNX_IFS=$1 + # Remove first argument so that additional args can be passed to QEMU + shift +fi + +# ------------------------------------------ +# Images generated by mkqnximage +# Get the directory where the IFS image is located +QNX_IFS_DIR="$(dirname "$QNX_IFS")" + +SCORE_DISK="${QNX_IFS_DIR}/disk-score.qcow2" +SCORE_DISK_SIZE=512M + +if [ ! -f "$SCORE_DISK" ]; then + qemu-img create -f qcow2 "$SCORE_DISK" $SCORE_DISK_SIZE + if [ $? -ne 0 ]; then + echo "Error: Failed to create QEMU disk image $SCORE_DISK" + exit 1 + fi +fi + +# ------------------------------------------ +# QEMU user network settings +# subnet. This value must match the IP address configured in guest QNX. +NETWORK=192.168.120 +# HOST TCP ports to be forwarded to VM +HOST_SSH_PORT=2210 +HOST_QCONN_PORT=8000 +HOST_DLT_PORT=3490 +HOST_DOIP_PORT=13400 +# IP for SSH port forwarding. This value must match the IP address configured in guest QNX. +VM_IP=$NETWORK.20 + + +# ------------------------------------------ +# Launch QEMU +$QEMU_BIN -machine virt-4.2 -cpu cortex-a57 -smp $CPU_COUNT -m $MEM_SIZE \ + -kernel $QNX_IFS \ + -drive file=$SCORE_DISK,if=none,id=drv0 -device virtio-blk-device,drive=drv0 \ + -netdev user,id=net0,net=$NETWORK.0/24,hostfwd=tcp::$HOST_SSH_PORT-$VM_IP:22,hostfwd=tcp::$HOST_QCONN_PORT-$VM_IP:8000,hostfwd=tcp::$HOST_DLT_PORT-$VM_IP:3490,hostfwd=tcp::$HOST_DOIP_PORT-$VM_IP:13400 \ + -device virtio-net-device,mac=52:54:00:12:34:72,netdev=net0 \ + -nographic \ + -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-device,rng=rng0 \ + -serial mon:stdio \ + "$@" diff --git a/qnx8/boards/qemu-arm64virt/target.build b/qnx8/boards/qemu-arm64virt/target.build new file mode 100644 index 0000000..9d85d59 --- /dev/null +++ b/qnx8/boards/qemu-arm64virt/target.build @@ -0,0 +1,52 @@ + +[uid=0 gid=0 perms=0755] + +[type=link] /dev/console=/dev/ser1 + + +################################################################################################ +## Serial drivers +################################################################################################ +/sbin/devc-serpl011=devc-serpl011 + + +################################################################################################ +## Block drivers +################################################################################################ +/sbin/devb-virtio=devb-virtio +/sbin/devb-loopback=devb-loopback + + +################################################################################################ +## Network driver files +################################################################################################ +/lib/dll/devs-vtnet_mmio.so=devs-vtnet_mmio.so +/lib/dll/mods-fdt.so=mods-fdt.so +/lib/dll/mods-phy_fdt.so=mods-phy_fdt.so + + +################################################################################################ +## ENV profile +################################################################################################ +[uid=0 gid=0 perms=0444] /etc/profile = { +export HOME=/ +export SYSNAME=nto +export TERM=xterm +export PATH=/proc/boot:/sbin:/bin:/usr/bin:/usr/sbin:/usr/libexec +export LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll:/lib/dll/pci + +export PCI_HW_MODULE=/lib/dll/pci/pci_hw-bcm2711-rpi4.so +export PCI_DEBUG_MODULE=/lib/dll/pci/pci_debug2.so +export PCI_SLOG_MODULE=/lib/dll/pci/pci_slog2.so +export PCI_BKWD_COMPAT_MODULE=/lib/dll/pci/pci_bkwd_compat.so +umask 022 +} + + +################################################################################################ +## startup scripts +################################################################################################ +net-start.sh = qnx8/boards/qemu-arm64virt/net-start.sh +blk-start.sh = qnx8/boards/qemu-arm64virt/blk-start.sh +mount-fs.sh = qnx8/boards/qemu-arm64virt/mount-fs.sh +misc-services.sh = qnx8/boards/qemu-arm64virt/misc-services.sh diff --git a/qnx8/boards/qemu-x86_64/BUILD b/qnx8/boards/qemu-x86_64/BUILD new file mode 100644 index 0000000..3df49c4 --- /dev/null +++ b/qnx8/boards/qemu-x86_64/BUILD @@ -0,0 +1,34 @@ +load("@score_rules_imagefs//rules/qnx:ifs.bzl", "qnx_ifs") + +qnx_ifs( + name = "ifs-qemu-x86_64", + build_file = "qemu-x86_64.build", + srcs = [ + "target.build", + "initscript", + "//qnx8/boards/common:common_files", + ] + glob(["*.sh"], exclude = ["run-*.sh"]), + extension = "bin", + visibility = ["//visibility:public"], +) + +genrule( + name = "qemu-runscript", + srcs = [ + "run-qemu-x86_64.sh", + ], + outs = [ + "run-qemu.sh", + ], + cmd = """ + cp $(execpath run-qemu-x86_64.sh) $(execpath run-qemu.sh) + """, + visibility = ["//visibility:public"], +) + +sh_binary( + name = "run", + srcs = ["run-qemu.sh"], + data = [":ifs-qemu-x86_64"], + args = ["$(location :ifs-qemu-x86_64)"], +) diff --git a/qnx8/boards/qemu-x86_64/blk-start.sh b/qnx8/boards/qemu-x86_64/blk-start.sh new file mode 100644 index 0000000..0ec920f --- /dev/null +++ b/qnx8/boards/qemu-x86_64/blk-start.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +# Start file system event manager. +# Required for applications utilizing inotify_...() APIs. +# Must start before any block device driver. +if [ -x /sbin/fsevmgr ]; then + echo "---> Starting fsevmgr" + /sbin/fsevmgr + waitfor /dev/fsnotify +fi + +# Start virtio block device driver +BLK_DEVICE_RAW=hd0 + +echo "---> Starting block driver" +# virtio-blk values from QEMU virt fdt... +devb-virtio cam user=20:20 blk cache=64M,auto=partition,vnode=2000,ncache=2000,commit=low virtio blk ramdisk=20m + +waitfor /dev/$BLK_DEVICE_RAW 3 +if [ ! -e /dev/$BLK_DEVICE_RAW ] +then + echo "ERROR: No block device detected" +fi + + +# Start /run filesystem +if [ -e /dev/ram0 ] +then + echo "---> Preparing /run using /dev/ram0" + # Preparing for many small files: + # 4096 inodes, 512 bytes per block, no reserved blocks + mkqnx6fs -i 4096 -b 512 -r 0 -q /dev/ram0 + mount -t qnx6 /dev/ram0 /run + # Create /run/lola_discovery for lola + mkdir /run/lola_discovery +else + echo "ERROR: No /dev/ram0 detected. /run file system is not available." +fi diff --git a/qnx8/boards/qemu-x86_64/initscript b/qnx8/boards/qemu-x86_64/initscript new file mode 100644 index 0000000..693fcaa --- /dev/null +++ b/qnx8/boards/qemu-x86_64/initscript @@ -0,0 +1,82 @@ +SYSNAME=nto +TERM=xterm +ENV=/etc/profile + +procmgr_symlink ../../proc/boot/ldqnx-64.so.2 /usr/lib/ldqnx-64.so.2 + +## Needed for ksh to run the echo command below +pipe + +display_msg " " +ksh -c "echo Welcome to QNX $(uname -r) on $(uname -m) !" +display_msg " " + +############################################################################################ +display_msg "---> Starting slogger2" +############################################################################################ +/bin/slogger2 & +waitfor /dev/slog2 + +dumper +mqueue + +############################################################################################ +## PCI Server +############################################################################################ +PCI_DEBUG_MODULE=/lib/dll/pci/pci_debug2.so +PCI_SLOG_MODULE=/lib/dll/pci/pci_slog2.so +PCI_BKWD_COMPAT_MODULE=/lib/dll/pci/pci_bkwd_compat.so +PCI_HW_MODULE=/lib/dll/pci/pci_hw-Intel_x86.so + +display_msg "---> Starting PCI server" +pci-server --aspace-enable +waitfor /dev/pci + +############################################################################################ +## RTC utility / random +############################################################################################ +display_msg "---> Starting RTC+random" +rtc hw +# no idea why, but need to start random in a ksh shell... +ksh -c "random -l /lib/dll/devr-virtio.so" + +####################################################################### +## Console SERIAL driver +####################################################################### +display_msg "---> Starting serial driver" +devc-ser8250 -e -b115200 +waitfor /dev/ser1 +reopen /dev/ser1 + +/sbin/devc-pty + +####################################################################### +# Initial block device setup +####################################################################### +/bin/sh /proc/boot/blk-start.sh + +####################################################################### +# Mount file systems +####################################################################### +/bin/sh /proc/boot/mount-fs.sh + +####################################################################### +# Start networking, set hostname +####################################################################### +/bin/sh /proc/boot/net-start.sh + +####################################################################### +# Starting remaining services startup script +####################################################################### +/bin/sh /proc/boot/misc-services.sh + +####################################################################### +# Starting consoles and shells +####################################################################### +display_msg "---> Starting shell ... Have fun :-)" +HOME=/root +umask 022 + +# replace this shell with an interactive one +[+session] /bin/ksh -l + diff --git a/qnx8/boards/qemu-x86_64/misc-services.sh b/qnx8/boards/qemu-x86_64/misc-services.sh new file mode 100644 index 0000000..12466c1 --- /dev/null +++ b/qnx8/boards/qemu-x86_64/misc-services.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ -x /usr/sbin/qconn ]; then + echo "---> Starting qconn" + waitfor /dev/ptyp0 4 + waitfor /dev/socket 4 + /usr/sbin/qconn port=8000 +fi + +if [ -x /usr/sbin/sshd ]; then + echo "---> Starting sshd" + /usr/sbin/sshd +fi + +if [ -x /opt/score/autostart.sh ]; then + echo "---> Executing /opt/score/autostart.sh" + sh /opt/score/autostart.sh & +fi diff --git a/qnx8/boards/qemu-x86_64/mount-fs.sh b/qnx8/boards/qemu-x86_64/mount-fs.sh new file mode 100644 index 0000000..0521a27 --- /dev/null +++ b/qnx8/boards/qemu-x86_64/mount-fs.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +echo "---> Mounting file systems" + +# Mount probe list: hd0... is MBR, hd0.qnx6.x is GPT +MOUNT_PROBE_LIST="hd0t177 hd0.qnx6.0 hd0.qnx6.1" +MOUNT_POINT=/opt/score + +if [ -f /boot/etc/settings/mount ]; then + . /boot/etc/settings/mount +fi + +for blk_device in $MOUNT_PROBE_LIST +do + if [ -e /dev/$blk_device ] + then + BLK_DEVICE=$blk_device + break + fi +done +if [ -n "$BLK_DEVICE" ] +then + echo "Mounting filesystem /dev/$BLK_DEVICE to $MOUNT_POINT" + mount $MOUNTOPTIONS -t qnx6 /dev/$BLK_DEVICE $MOUNT_POINT +else + echo "No root file system has been detected" +fi + diff --git a/qnx8/boards/qemu-x86_64/net-start.sh b/qnx8/boards/qemu-x86_64/net-start.sh new file mode 100644 index 0000000..98f7110 --- /dev/null +++ b/qnx8/boards/qemu-x86_64/net-start.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +DEVICE_NAME_PREFIX=vtnet +IP_ADDRESS_vtnet0="192.168.120.20/24" +HOSTNAME=x86_64qemu + +if [ -f /opt/score/etc/settings/network ]; then + . /opt/score/etc/settings/network +fi + +# Set hostname +setconf _CS_HOSTNAME ${HOSTNAME} + +echo "---> Starting Ethernet driver" +io-sock -m phy -m pci -m usb -d vtnet_pci + +waitfor /dev/socket 1 +# Check if any network device is in the system +if [ ! -e /dev/socket ]; then + # No - exit here + echo "---> No Network device has been detected" + exit 0; +fi + + +if [ "$IP_ADDRESS_${DEVICE_NAME_PREFIX}0" = dhcp ]; then + dhcpcd -bq -f /system/etc/dhcpcd/dhcpcd.conf -c /system/etc/dhcpcd/dhcpcd-run-hooks + # If dhcpcd not run as root, need to give it read/write access to /dev/bpf + setfacl -m user:38:rw /dev/bpf +else + # Setup static IP addresses for all defined devices + # enumerate devices from 0..3 + for i in 0 1 2 3 + do + # Try finding env var "IP_ADDRESS_" defined in network config file. + # If found, set up corresponding device. + # Build device name out of prefix + i + DEVICE_NAME=${DEVICE_NAME_PREFIX}$i + # Build env var name out of string "NET_IP_ADDRESS_" + DEVICE_NAME + IP_ADDRESS_TEMPLATE="IP_ADDRESS_$DEVICE_NAME" + # Evaluate env var name to get IP address for device + IP_ADDRESS=$(eval echo \$$IP_ADDRESS_TEMPLATE) + if [ -n "$IP_ADDRESS" ]; then + echo "---> Setting up $DEVICE_NAME with ip address $IP_ADDRESS" + if_up -r 10 -p $DEVICE_NAME + ifconfig $DEVICE_NAME $IP_ADDRESS up + fi + done +fi + +sysctl -w net.inet.icmp.bmcastecho=1 > /dev/null +sysctl -w qnx.sec.droproot=33:33 > /dev/null + +exit 0 diff --git a/qnx8/boards/qemu-x86_64/qemu-x86_64.build b/qnx8/boards/qemu-x86_64/qemu-x86_64.build new file mode 100644 index 0000000..e09872c --- /dev/null +++ b/qnx8/boards/qemu-x86_64/qemu-x86_64.build @@ -0,0 +1,28 @@ +################################################################################################ +## +## Build file for a QNX operating system on a QEMU x86_64 machine +## +################################################################################################ + +[-optional] +[+keeplinked] +[image=0x2000000] +[virtual=x86_64,multiboot] boot = { + startup-x86 -v -D8250..115200 + PATH=/sbin:/usr/sbin:/bin:/usr/bin:/proc/boot LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll/pci procnto-smp-instr -v -mL -bl +} + +# all owned by root +[uid=0 gid=0 perms=0555 dperms=0555] + +# add external search path in case we are building the image with bazel in context of another module *sigh* +[search=${MKIFS_PATH}:external/os_images+] + +[+script] startup-script = qnx8/boards/qemu-x86_64/initscript + +# include the target specific build file +[+include] qnx8/boards/qemu-x86_64/target.build + +# include the common build file +[+include] qnx8/boards/common/common.build + diff --git a/qnx8/boards/qemu-x86_64/run-qemu-x86_64.sh b/qnx8/boards/qemu-x86_64/run-qemu-x86_64.sh new file mode 100755 index 0000000..8430923 --- /dev/null +++ b/qnx8/boards/qemu-x86_64/run-qemu-x86_64.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# run-qemu-x86_64.sh [] + +# ------------------------------------------ +# General QEMU settings +QEMU_BIN=qemu-system-x86_64 +MEM_SIZE=1G # does not run with less than 1G! +CPU_COUNT=2 + +# ------------------------------------------ +QNX_IFS=ifs-qemu-x86_64.bin +if [ "$1" != "" ]; then + QNX_IFS=$1 + # Remove first argument so that additional args can be passed to QEMU + shift +fi + +# ------------------------------------------ +# Images generated by mkqnximage +# Get the directory where the IFS image is located +QNX_IFS_DIR="$(dirname "$QNX_IFS")" + +SCORE_DISK="${QNX_IFS_DIR}/disk-score.qcow2" +SCORE_DISK_SIZE=512M + +if [ ! -f "$SCORE_DISK" ]; then + qemu-img create -f qcow2 "$SCORE_DISK" $SCORE_DISK_SIZE + if [ $? -ne 0 ]; then + echo "Error: Failed to create QEMU disk image $SCORE_DISK" + exit 1 + fi +fi + +# ------------------------------------------ +# Set KVM options based on QEMU_NO_KVM if user does not have kvm - like nested VMs +if [ -z "${QEMU_NO_KVM:-}" ]; then + QEMU_KVM_OPTS="-enable-kvm -cpu host" +else + QEMU_KVM_OPTS="-cpu Cascadelake-Server-v5" +fi + +# ------------------------------------------ +# QEMU user network settings +# subnet. This value must match the IP address configured in guest QNX. +NETWORK=192.168.120 +# HOST TCP ports to be forwarded to VM +HOST_SSH_PORT=2210 +HOST_QCONN_PORT=8000 +HOST_DLT_PORT=3490 +HOST_DOIP_PORT=13400 +# IP for SSH port forwarding. This value must match the IP address configured in guest QNX. +VM_IP=$NETWORK.20 + + +# ------------------------------------------ +# Launch QEMU +$QEMU_BIN $QEMU_KVM_OPTS -smp $CPU_COUNT -m $MEM_SIZE \ + -kernel $QNX_IFS \ + -drive file=$SCORE_DISK,if=none,id=drv0 -device virtio-blk-pci,drive=drv0 \ + -netdev user,id=net0,net=$NETWORK.0/24,hostfwd=tcp::$HOST_SSH_PORT-$VM_IP:22,hostfwd=tcp::$HOST_QCONN_PORT-$VM_IP:8000,hostfwd=tcp::$HOST_DLT_PORT-$VM_IP:3490,hostfwd=tcp::$HOST_DOIP_PORT-$VM_IP:13400 \ + -device virtio-net-pci,mac=52:54:00:12:34:72,netdev=net0 \ + -nographic \ + -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 \ + -serial mon:stdio \ + "$@" diff --git a/qnx8/boards/qemu-x86_64/target.build b/qnx8/boards/qemu-x86_64/target.build new file mode 100644 index 0000000..1201cb5 --- /dev/null +++ b/qnx8/boards/qemu-x86_64/target.build @@ -0,0 +1,73 @@ + +[uid=0 gid=0 perms=0755] + +[type=link] /dev/console=/dev/ser1 + + +################################################################################################ +## PCI driver HW Modules and configuration file +################################################################################################ +/lib/dll/pci/pci_hw-AMD_x86.so=pci/pci_hw-AMD_x86.so +/lib/dll/pci/pci_hw-Intel_x86.so=pci/pci_hw-Intel_x86.so + + +################################################################################################ +## Serial drivers +################################################################################################ +/sbin/devc-ser8250=devc-ser8250 +/sbin/devc-serusb=devc-serusb +/sbin/devc-serpci=devc-serpci + + +################################################################################################ +## Block drivers +################################################################################################ +/sbin/devb-eide=devb-eide +/sbin/devb-nvme=devb-nvme +/sbin/devb-ram=devb-ram +/sbin/devb-virtio=devb-virtio +/sbin/devb-loopback=devb-loopback + + +################################################################################################ +## Network driver files +################################################################################################ +/lib/dll/devs-vtnet_pci.so=devs-vtnet_pci.so +/lib/dll/mods-pci.so=mods-pci.so +/lib/dll/mods-usb.so=mods-usb.so + +################################################################################################ +## random driver files +################################################################################################ +/lib/dll/devr-virtio.so=devr-virtio.so + +################################################################################################ +## RTC driver +################################################################################################ +/sbin/rtc=rtc + +################################################################################################ +## ENV profile +################################################################################################ +[uid=0 gid=0 perms=0444] /etc/profile = { +export HOME=/ +export SYSNAME=nto +export TERM=xterm +export PATH=/proc/boot:/sbin:/bin:/usr/bin:/usr/sbin:/usr/libexec +export LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll:/lib/dll/pci + +export PCI_HW_MODULE=/lib/dll/pci/pci_hw-Intel_x86.so +export PCI_DEBUG_MODULE=/lib/dll/pci/pci_debug2.so +export PCI_SLOG_MODULE=/lib/dll/pci/pci_slog2.so +export PCI_BKWD_COMPAT_MODULE=/lib/dll/pci/pci_bkwd_compat.so +umask 022 +} + + +################################################################################################ +## startup scripts +################################################################################################ +net-start.sh = qnx8/boards/qemu-x86_64/net-start.sh +blk-start.sh = qnx8/boards/qemu-x86_64/blk-start.sh +mount-fs.sh = qnx8/boards/qemu-x86_64/mount-fs.sh +misc-services.sh = qnx8/boards/qemu-x86_64/misc-services.sh diff --git a/sdp.BUILD b/sdp.BUILD new file mode 100644 index 0000000..d5cd5be --- /dev/null +++ b/sdp.BUILD @@ -0,0 +1,68 @@ +# ******************************************************************************* +# Copyright (c) 2026 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +"""Default BUILD file for QNX SDP archives. + +This file is shipped with score_rules_imagefs so that consumers do not need +to provide their own BUILD file for the standard QNX SDP directory layout. +It can be overridden by passing a custom `build_file` to the `imagefs.sdp` tag. +""" + +package(default_visibility = [ + "//visibility:public", +]) + +filegroup( + name = "all_files", + srcs = glob(["*/**/*"]), +) + +filegroup( + name = "target_dir", + srcs = ["target/qnx"], +) + +filegroup( + name = "host_dir", + srcs = ["host/linux/x86_64"], +) + +filegroup( + name = "target_all", + srcs = glob(["target/**/*"]), +) + +filegroup( + name = "host_all", + srcs = glob(["host/**/*"]), +) + +filegroup( + name = "mkifs", + srcs = ["host/linux/x86_64/usr/bin/mkifs"], +) + +filegroup( + name = "mkfatfs", + srcs = ["host/linux/x86_64/usr/bin/mkfatfsimg"], +) + +filegroup( + name = "mkqnx6fs", + srcs = ["host/linux/x86_64/usr/bin/mkqnx6fsimg"], +) + +filegroup( + name = "mkdiskimage", + srcs = ["host/linux/x86_64/usr/bin/diskimage"], +) diff --git a/tools/qnx_credential_helper.py b/tools/qnx_credential_helper.py new file mode 100755 index 0000000..fb4a012 --- /dev/null +++ b/tools/qnx_credential_helper.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python3 + +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +import http.cookiejar +import json +import netrc +import os +import sys +import urllib.parse +import urllib.request + + +def eprint(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + + +if __name__ == "__main__": + data = json.load(sys.stdin) + + hostname = urllib.parse.urlparse(data["uri"]).hostname or "" + if hostname != "qnx.com" and not hostname.endswith(".qnx.com"): + eprint("Unsupported domain") + sys.exit(1) + + if "SCORE_QNX_USER" in os.environ and "SCORE_QNX_PASSWORD" in os.environ: + login = os.environ["SCORE_QNX_USER"] + password = os.environ["SCORE_QNX_PASSWORD"] + else: + try: + nrc = netrc.netrc() + auth = nrc.authenticators("qnx.com") + if auth: + login, _, password = auth + else: + raise Exception("No credential found for QNX") + except Exception as excp: + eprint(excp) + eprint("Failed getting credentials from .netrc") + sys.exit(1) + + data = urllib.parse.urlencode( + {"userlogin": login, "password": password, "UseCookie": "1"} + ) + data = data.encode("ascii") + + cookie_jar = http.cookiejar.CookieJar() + cookie_processor = urllib.request.HTTPCookieProcessor(cookie_jar) + opener = urllib.request.build_opener(cookie_processor) + urllib.request.install_opener(opener) + + r = urllib.request.urlopen("https://www.qnx.com/account/login.html", data) + if r.status != 200: + eprint("Failed to login to QNX") + sys.exit(1) + + cookies = {c.name: c.value for c in list(cookie_jar)} + if not "myQNX" in cookies: + eprint("Failed to get myQNX cookie from login page") + sys.exit(1) + + myQNX = cookies["myQNX"] + print( + json.dumps( + { + "headers": { + "Cookie": [f"myQNX={myQNX}"], + } + } + ) + )