Skip to content

Conversation

@dchordia
Copy link

@dchordia dchordia commented Oct 8, 2025

Hi,
This contribution adds cross-compilation support for QNX operating system to libmetal.

Motivation

QNX is an industry standard real-time operating system for embedded systems, particularly for vehicles, featuring safety focused features. It has also recently been made free for non-commercial use through the QNX Everywhere program, aiming for students, researchers and hobbyists to experiment with the OS.

Given that libmetal is a powerful abstraction layer across different OSes and baremetal as well as being a dependency to open-amp, it would be great to enable libmetal to run natively on free version of QNX OS.

Description of changes

Following API additions are made to support libmetal on QNX system

  • allocate and free memory
  • assert statements
  • caching support
  • condition variables
  • physical devices like static shared memory
  • i/o configurations
  • interrupt requests
  • logs
  • mutex
  • dynamic shared memory (under /dev/shmem) with precise page-wise controls sleep
  • time
  • system and misc utilities

These changes have been reviewed by QNX open-source team at supporting PR, for v2024.10.0, and additional supporting changes have been made to make it compatible with latest main.

How to build for QNX

The build-files and instructions for cross-compiling libmetal for QNX are present at qnx-ports. A free QNX8 license can be obtained here

By submitting this pull request, I confirm that my contribution is made under the terms of BSD License

PS: Tagging @arnopo for review

Following API additions are made to support libmetal on QNX systems

allocate and free memory
assert statements
caching support
condition variables
physical devices like static shared memory
i/o configurations
interrupt requests
logs
mutex
dynamic shared memory (under /dev/shmem) with precise page-wise controls
sleep
time
system and misc utilities

fix irq compilation

Signed-off-by: Deep Chordia <dchordia@blackberry.com>
@arnopo arnopo requested review from arnopo, edmooring and tnmysh October 14, 2025 08:06
@arnopo
Copy link
Contributor

arnopo commented Oct 14, 2025

Hello @dchordia,

Thanks for this contribution. First of all, if you are not aware, the v2025.10 release is planned for this month, with the associated code freeze scheduled for the end of this week. The delay will probably be too short to integrate QNX support for this release.

That said, would it be possible for you to split this PR into two parts?

  • Update this PR by removing the test part and adding a commit for the CI to enable build testing in build_ci entrypoint.
  • Add the tests in a second PR, taking a look at PR #335, which we expect to merge soon.

@dchordia
Copy link
Author

dchordia commented Oct 14, 2025

Thanks for quick response. Ah, I had planned to squeeze it in before October release but that will likely not be the case. I will split the PR based on your feedback. However, regarding build testing CI, we have not yet officially worked on integrating it in any open-source repositories. Right now I am in experimental testing (build test as well as run unit test) stage for a similar request from AWS (example run PR at qnx-ports CI).

A way ahead to enable QNX CI build job in this repository would require SDP based on maintainer registed QNXE license. Post which either a custom docker with this Software Development Platform (SDP) can be created and spin up on each QNX build run or SDP has to downloaded for before each QNX build run.

@arnopo
Copy link
Contributor

arnopo commented Oct 14, 2025

Thanks for quick response. Ah, I had planned to squeeze it in before October release but that will likely not be the case.
I will split the PR based on your feedback. However, regarding build testing CI, we have not yet officially worked on integrating it in any open-source repositories. Right now I am in experimental testing (build test as well as run unit test) stage for a similar request from AWS (example run PR at qnx-ports CI).

A way ahead to enable QNX CI build job in this repository would require SDP based on maintainer registed QNXE license. Post which either a custom docker with this Software Development Platform (SDP) can be created and spin up on each QNX build run or SDP has to downloaded for before each QNX build run.

If you are not able to add CI in the first step, we can address this later. Just be aware that, in such a case, we will not be able to ensure that updates in the Libmetal or OpenAMP libraries do not break the QNX build. The CACHE_ PR is a good example.

@dchordia
Copy link
Author

dchordia commented Oct 14, 2025

Sure. Yes, right. I will make CI additions soon. In the meantime, can one of the repository maintainers register for QNXE license and store credentials (username, password, license key) in org level GitHub secrets. CI jobs for QNX requires pulling SDP which will require the credentials

@github-actions
Copy link

This pull request has been marked as a stale pull request because it has been open (more than) 45 days with no activity.

@github-actions github-actions bot added the Stale label Nov 29, 2025
@arnopo
Copy link
Contributor

arnopo commented Dec 16, 2025

Hello @dchordia
Any plans to update this PR?
Perhaps we can forget about the CI in the first step—I would at minimum need me some clues to get credentials and commands to build it.

@github-actions github-actions bot removed the Stale label Dec 17, 2025
@dchordia
Copy link
Author

dchordia commented Dec 22, 2025

Hello @arnopo,
To build the library please follow the steps mentioned at qnx-ports/build-files/ports/libmetal. A non-commercial QNX license can be obtained here. Please refer to this video showing the license obtaining steps and feel free to reach out for any queries.

Regarding CI, legal division is making changes to licensing terms to accommodate multi-user cloud builds and hoping to get that done by January. Once that is complete, and license is signed by one of the libmetal maintainers, I can work towards CI integration.

@tnmysh
Copy link
Collaborator

tnmysh commented Dec 22, 2025

Hello @arnopo, To build the library please follow the steps mentioned at qnx-ports/build-files/ports/libmetal. A non-commercial QNX license can be obtained here. Please refer to this video showing the license obtaining steps and feel free to reach out for any queries.

Regarding CI, legal division is making changes to licensing terms to accommodate multi-user cloud builds and hoping to get that done by January. Once that is complete, and license is signed by one of the libmetal maintainers, I can work towards CI integration.

@dchordia, Could you please add a README with step by step instructions that people can use to build libmetal with QNX ?

Add QNX build process
Copy link
Contributor

@arnopo arnopo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started to review your PR and posted a few comments.

I’m not familiar with QNX, so I would like to understand if your porting could be simplified.
It seems you use Linux as a reference system. This reference might not be the most appropriate since it more complex allowing the implementation of the OpenAMP library in Linux userspace (with specific IRQ management, filesystem for shared memory, etc.).

If QNX is more similar to Zephyr, NuttX, or FreeRTOS, I suggest looking at those portings to simplify yours.

Additionally, please split your commit into two: one for the library and one for the tests.

* SPDX-License-Identifier: BSD-3-Clause
*/

/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To update in all source file in this PR ( I will create a PR for the reste of the libmetal files)

Suggested change
/*
/**

metal_log(METAL_LOG_ERROR, "cache init failed - %s\n",
strerror(errno));
return -errno;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to initialize the cache and the IRQs here?
I the libmetal is only used for the openamp library porting layer. theses initialization are probably already done during your QNX system initialization.

GENERIC_BUS_REGISTER = 1;
}

metal_unused(params);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to move at the beginning of the function

int metal_sys_io_mem_map(struct metal_io_region *io)
{
if (io->virt)
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coding style; please declare first local variable

int irq, unsigned int state);

/* QNX IRQ controller */
static METAL_IRQ_CONTROLLER_DECLARE(qnx_irq_cntr,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this for the OpenAMP porting?
The definitions of metal_irq_save_enable and metal_irq_save_disable could be sufficient here.
the rest of the IRQ management in libmetal is more of an optional extension and is not used by default in the OpenAMP library.
You can have a look to Zephyr porting as example

NULL, NULL, NULL, NULL, NULL, metal_shmem_io_close, NULL, NULL
};

static int metal_shmem_try_map(int fd, size_t size, struct metal_io_region **result)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this complexity in QNX? this seems similar to the Linux userspace implementation.

#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems that some include are useless here

@arnopo
Copy link
Contributor

arnopo commented Dec 23, 2025

Hello @arnopo, To build the library please follow the steps mentioned at qnx-ports/build-files/ports/libmetal. A non-commercial QNX license can be obtained here. Please refer to this video showing the license obtaining steps and feel free to reach out for any queries.

Thanks for the guide, I'm facing docker access restriction in my Ubuntu environment. I need first to fix that with my DIT (beginning of January)

Regarding CI, legal division is making changes to licensing terms to accommodate multi-user cloud builds and hoping to get that done by January. Once that is complete, and license is signed by one of the libmetal maintainers, I can work towards CI integration.

This seems reasonable, it let time for next release in April.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants