Skip to content
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

Add support for Xenomai on Toradex SoMs #239

Draft
wants to merge 4 commits into
base: scarthgap-7.x.y
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf/distro/common-torizon-xenomai3.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require conf/distro/common-torizon.conf
require conf/distro/include/xenomai.inc

DISTRO = "common-torizon-xenomai3"
DISTRO_NAME = "Common Torizon OS with Xenomai 3"
Expand Down
1 change: 1 addition & 0 deletions conf/distro/common-torizon-xenomai4.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require conf/distro/common-torizon.conf
require conf/distro/include/xenomai.inc

DISTRO = "common-torizon-xenomai4"
DISTRO_NAME = "Common Torizon OS with Xenomai 4"
Expand Down
22 changes: 22 additions & 0 deletions conf/distro/include/xenomai.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# Xenomai config

XENOMAI_KERNEL_ARGS = "audit=0 clocksource=arch_sys_counter nohz_full=1,3 \
irqaffinity=0 isolcpus=1,3 rcu_nocbs=1,3 rcu_nocb_poll=1024 \
nosoftlockup numa_balancing=disable hugepages=1024 "
Comment on lines +4 to +6
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this indentation add several spaces to the OSTree commit metadata? (since the OSTREE_KERNEL_ARGS variable is passed verbatim to ostree (https://github.com/torizon/meta-toradex-torizon/blob/scarthgap-7.x.y/classes/torizon_base_image_type.inc#L89))

OSTREE_KERNEL_ARGS:sota:append:xenomai4 = " ${XENOMAI_KERNEL_ARGS} "
OSTREE_KERNEL_ARGS:sota:append:xenomai3 = " ${XENOMAI_KERNEL_ARGS} "

PREFERRED_PROVIDER_virtual/kernel:xenomai4 = "linux-xenomai-4"
PREFERRED_PROVIDER_virtual/kernel:xenomai4:upstream = "linux-xenomai-4"
PREFERRED_PROVIDER_virtual/dtb:xenomai4:upstream = "device-tree-overlays-mainline"
LINUX_VERSION_EXTENSION:xenomai4:upstream ?= "-torizon-${LINUX_KERNEL_TYPE}-xenomai4"
Comment on lines +11 to +13
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you clarify why you need both :xenomai4 and :upstream overrides on these assignments? Looking at the distro config both overrides are added together so either override would do the job, no?

However, using one or the other might make more sense: in this stretch of code I'd imagine something like this:

PREFERRED_PROVIDER_virtual/kernel:xenomai4 = "linux-xenomai-4"
PREFERRED_PROVIDER_virtual/dtb:upstream = "device-tree-overlays-mainline"
LINUX_VERSION_EXTENSION:xenomai4 ?= "-torizon-${LINUX_KERNEL_TYPE}-xenomai4"

The xenomai specific assignments use :xenomai4 while the DTB provider selection depends on :upstream, not on the fact that we're using xenomai. Doesn't this work?


PREFERRED_PROVIDER_virtual/kernel:xenomai3 = "linux-xenomai-3"
PREFERRED_PROVIDER_virtual/kernel:xenomai3:upstream = "linux-xenomai-3"
PREFERRED_PROVIDER_virtual/dtb:xenomai3:upstream = "device-tree-overlays-mainline"
LINUX_VERSION_EXTENSION:xenomai3:upstream ?= "-torizon-${LINUX_KERNEL_TYPE}-xenomai3"

# This is required to build the upstream device trees
IMX_DEFAULT_BSP:xenomai4:upstream = "mainline"
IMX_DEFAULT_BSP:xenomai3:upstream = "mainline"
12 changes: 12 additions & 0 deletions conf/distro/torizon-upstream-xenomai3.conf
Copy link
Collaborator

Choose a reason for hiding this comment

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

This distro is building upstream kernel for all devices, or is only for the devices we use upstream kernel? I understand it's the first, right? Since upstream DISTROOVERRIDES is being added.

Couldn't we just name these torizon-xenomai[3|4]?

Copy link
Member Author

Choose a reason for hiding this comment

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

This distro is building upstream kernel for all devices, or is only for the devices we use upstream kernel? I understand it's the first, right? Since upstream DISTROOVERRIDES is being added.

For intel-corei7-64, the upstream override does not apply. This is why I had to do this:

PREFERRED_PROVIDER_virtual/kernel:xenomai4 = "linux-xenomai-4"
PREFERRED_PROVIDER_virtual/kernel:xenomai4:upstream = "linux-xenomai-4"

For Toradex machines, I'm explicitly using the upstream kernel recipe as base:

# Use BSP kernel recipe as the base
BASE_KERNEL_CONFIG:aarch64:tdx = "recipes-kernel/linux/linux-toradex-upstream_6.12.bb"

In the end, I could try to actually not use the upstream override for Toradex BSPs, even if I use the linux-toradex-upstream. But then we come to your second question, which is more conceptual than practical.

Couldn't we just name these torizon-xenomai[3|4]?

These Xenomai kernels aren't technically upstream because they are a fork of the upstream + the Xenomai patches applied:

But, from our perspective, what we call downstream are the SoC vendor BSPs, at least so far. And these Xenomai are not based on the SoC vendor BSPs. They are "just" some patches on top of upstream kernel.

We have PREEMPT_RT variants of the upstream kernel, which looks more similar to this Xenoami case than a downstream.

And we still called those linux-toradex-upstream-rt https://git.toradex.com/cgit/meta-toradex-bsp-common.git/tree/recipes-kernel/linux/linux-toradex-upstream-rt_6.6.bb?h=scarthgap-7.x.y - or at least we did before PREEMPT_RT was merged into the upstream.

I mean, whatever you guys decide, I'm in. I don't have a strong preference.

Copy link
Member Author

Choose a reason for hiding this comment

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

p.s. would the question apply the other way around? I mean, for x86 the Xenomai recipe is using the "upstream" kernel plus the patches, instead of the linux-intel which uses github.com/intel/linux-intel-lts

I don't know if we can consider this kernel Intel's downstream, or just a fork of the upstream.

But if we consider it Intel's downstream, I think that for the sake of alignment, then we should have:

  • Either: set torizon-upstream-xenomai and rename s/common-torizon-xenomai/common-torizon-upstream-xenomai/
  • Or: set torizon-xenomai and keep common-torizon-xenomai

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I understood your reasoning!
I like your suggestions. As I'm a sucker for short names, I would love to see option 2, but I think option 1 is perfectly fine as well.
@jsrc27, @rborn-tx, any opinions on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd try to keep the naming pattern at least for distros targeting our SoMs; so I'd go with torizon-upstream-xenomai.

For common-torizon I don't have any preference. If we don't foresee the possibility of providing both downstream and upstream distros or if the meaning of these terms is too blurry I wouldn't necessarily use those words in the distro file name. Thus even the current common-torizon-xenomai would be okay.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require conf/distro/torizon.conf
require conf/distro/include/xenomai.inc

DISTRO = "torizon-upstream-xenomai3"
DISTRO_NAME = "Torizon OS Upstream with Xenomai 3"

DISTRO_FLAVOUR = " (UPSTREAM XENOMAI3)"
DISTRO_FLAVOUR:experimental = " (UPSTREAM XENOMAI3 EXPERIMENTAL)"

DISTROOVERRIDES .= ":xenomai3:upstream"

IMAGE_BASENAME_SUFFIX = "-xenomai3"
13 changes: 13 additions & 0 deletions conf/distro/torizon-upstream-xenomai4.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require conf/distro/torizon.conf
require conf/distro/include/xenomai.inc

DISTRO = "torizon-upstream-xenomai4"
DISTRO_NAME = "Torizon OS Upstream with Xenomai 4"

DISTRO_FLAVOUR = " (UPSTREAM XENOMAI4)"
DISTRO_FLAVOUR:experimental = " (UPSTREAM XENOMAI4 EXPERIMENTAL)"

DISTROOVERRIDES .= ":xenomai4:upstream"

IMAGE_BASENAME_SUFFIX = "-xenomai4"

16 changes: 3 additions & 13 deletions conf/machine/include/intel-corei7-64.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ WKS_FILE_DEPENDS:remove = "tezi-metadata virtual/dtb"

OSTREE_KERNEL_ARGS:sota:append:intel-corei7-64 = "console=ttyS0,115200 root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:10 "

XENOMAI_KERNEL_ARGS = "audit=0 hpet=disable clocksource=tsc tsc=reliable intel_pstate=disable intel_idle.max_cstate=0 intel.max_cstate=0 processor.max_cstate=0 processor_idle.max_cstate=0 \
rcupdate.rcu_cpu_stall_suppress=1 mce=off nmi_watchdog=0 nosoftlockup noht numa_balancing=disable hugepages=1024 rcu_nocb_poll=1024 irqaffinity=0 isolcpus=1,3 rcu_nocbs=1,3 nohz_full=1,3 \
i915.enable_rc6=0 i915.enable_dc=0 i915.disable_power_well=0 "
OSTREE_KERNEL_ARGS:sota:append:intel-corei7-64:xenomai3 = " ${XENOMAI_KERNEL_ARGS} "
OSTREE_KERNEL_ARGS:sota:append:intel-corei7-64:xenomai4 = " ${XENOMAI_KERNEL_ARGS} "

OSTREE_BOOTLOADER:intel-corei7-64 = "grub"
OSTREE_DEPLOY_DEVICETREE:intel-corei7-64 = "0"
EFI_PROVIDER:intel-corei7-64 = "grub-efi"
Expand All @@ -26,13 +20,9 @@ PREFERRED_PROVIDER_u-boot-fw-utils = "grub-ota-fallback"
PREFERRED_RPROVIDER_u-boot-fw-utils = "grub-ota-fallback"
PREFERRED_PROVIDER_virtual/dtb = ""

PREFERRED_PROVIDER_virtual/kernel:xenomai3 = "linux-xenomai-3"
PREFERRED_VERSION_linux-xenomai-3 ?= "5.10.%"

PREFERRED_PROVIDER_virtual/kernel:xenomai4 = "linux-xenomai-4"
PREFERRED_VERSION_linux-xenomai-4 = "5.10.%"
# If an older kernel is preferred, set the PREFERRED_VERSION
#PREFERRED_VERSION_linux-xenomai-3 = "5.10%"
#PREFERRED_VERSION_linux-xenomai-4 = "5.10%"

IMAGE_INSTALL:remove = " minnowboard-efi-startup network-configuration"
LINUX_VERSION_EXTENSION ?= "-torizon-${LINUX_KERNEL_TYPE}"
LINUX_VERSION_EXTENSION:xenomai3 ?= "-torizon-${LINUX_KERNEL_TYPE}-xenomai3"
LINUX_VERSION_EXTENSION:xenomai4 ?= "-torizon-${LINUX_KERNEL_TYPE}-xenomai4"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
LINUX_VERSION_EXTENSION:prepend = "-intel-pk"

COMPATIBLE_MACHINE ?= "(intel-corei7-64|intel-core2-32)"

KERNEL_FEATURES:append = " ${KERNEL_EXTRA_FEATURES}"
KERNEL_FEATURES:append = " ${@bb.utils.contains("TUNE_FEATURES", "mx32", " cfg/x32.scc", "" ,d)}"

KCONFIG_REPO:intel-corei7-64 = "git://git.yoctoproject.org/yocto-kernel-cache"

# Add patches from
# https://github.com/YoeDistro/meta-intel/blob/scarthgap/recipes-kernel/linux/linux-intel.inc
TDX_PATCHES:append = " \
file://fix-perf-reproducibility.patch \
file://0001-menuconfig-mconf-cfg-Allow-specification-of-ncurses-.patch \
file://0002-mconf-fix-output-of-cflags-and-libraries.patch \
"
81 changes: 81 additions & 0 deletions recipes-kernel/linux/files/xenomai-common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#
# IRQ subsystem
#
CONFIG_IRQ_PIPELINE=y

#
# Timers subsystem
#
CONFIG_CONTEXT_TRACKING=y
# CONFIG_CONTEXT_TRACKING_FORCE is not set
CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
CONFIG_NO_HZ_IDLE=y
CONFIG_NO_HZ=n
CONFIG_HIGH_RES_TIMERS=y

#
# CPU/Task time and stats accounting
#
CONFIG_VIRT_CPU_ACCOUNTING=y
# CONFIG_TICK_CPU_ACCOUNTING is not set
CONFIG_VIRT_CPU_ACCOUNTING_GEN=y

#
# RCU Subsystem
#
CONFIG_RCU_EXPERT=y
CONFIG_RCU_FANOUT=64
CONFIG_RCU_FANOUT_LEAF=16
# CONFIG_RCU_FAST_NO_HZ is not set
# CONFIG_RCU_BOOST is not set
CONFIG_RCU_NOCB_CPU=y
# CONFIG_TASKS_TRACE_RCU_READ_MB is not set

#
# Processor type and features
#
CONFIG_SCHED_MC=y
CONFIG_SCHED_MC_PRIO=n
CONFIG_MCORE2=y

CONFIG_DOVETAIL=y
CONFIG_DOVETAIL_LEGACY_SYSCALL_RANGE=y

#
# Memory Management options
#
CONFIG_COMPACTION=n
CONFIG_MIGRATION=n
CONFIG_TRANSPARENT_HUGEPAGE=n

CONFIG_HZ_250=y
CONFIG_HZ=250

#
# Power management and ACPI options
#
CONFIG_SUSPEND=n
CONFIG_PM=n
CONFIG_ACPI_PROCESSOR=n

#
# CPU Frequency scaling
#
CONFIG_CPU_FREQ=n
CONFIG_CPU_FREQ_STAT=n
CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL=n
CONFIG_CPU_FREQ_GOV_ONDEMAND=n

CONFIG_DEBUG_IRQ_PIPELINE=y
# CONFIG_IRQ_PIPELINE_TORTURE_TEST is not set
CONFIG_DEBUG_DOVETAIL=y
CONFIG_RAW_PRINTK=y

#
# CPU Idle
#
CONFIG_CPU_IDLE=n
CONFIG_INTEL_IDLE=n
# end of CPU Idle
128 changes: 128 additions & 0 deletions recipes-kernel/linux/files/xenomai3.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#
# General architecture-dependent options
#
CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM=y
# end of General architecture-dependent options

CONFIG_XENOMAI=y
CONFIG_XENO_ARCH_FPU=y
CONFIG_XENO_ARCH_SYS3264=y

#
# Core features
#
# CONFIG_XENO_OPT_SCHED_CLASSES is not set
CONFIG_XENO_OPT_STATS=y
CONFIG_XENO_OPT_SHIRQ=y
CONFIG_XENO_OPT_RR_QUANTUM=1000
CONFIG_XENO_OPT_AUTOTUNE=y
# CONFIG_XENO_OPT_SCALABLE_SCHED is not set
# CONFIG_XENO_OPT_TIMER_LIST is not set
CONFIG_XENO_OPT_TIMER_RBTREE=y
CONFIG_XENO_OPT_VFILE=y
# end of Core features

#
# Sizes and static limits
#
CONFIG_XENO_OPT_REGISTRY_NRSLOTS=4096
CONFIG_XENO_OPT_SYS_HEAPSZ=4096
CONFIG_XENO_OPT_PRIVATE_HEAPSZ=256
CONFIG_XENO_OPT_SHARED_HEAPSZ=256
CONFIG_XENO_OPT_NRTIMERS=512
# end of Sizes and static limits

#
# Latency settings
#
CONFIG_XENO_OPT_TIMING_SCHEDLAT=0
CONFIG_XENO_OPT_TIMING_KSCHEDLAT=0
CONFIG_XENO_OPT_TIMING_IRQLAT=0
# end of Latency settings

CONFIG_XENO_OPT_DEBUG=y
CONFIG_XENO_OPT_DEBUG_COBALT=y
CONFIG_XENO_OPT_DEBUG_MEMORY=y
CONFIG_XENO_OPT_DEBUG_CONTEXT=y
CONFIG_XENO_OPT_DEBUG_LOCKING=y
CONFIG_XENO_OPT_DEBUG_USER=y
CONFIG_XENO_OPT_DEBUG_MUTEX_RELAXED=y
CONFIG_XENO_OPT_DEBUG_MUTEX_SLEEP=y
CONFIG_XENO_OPT_DEBUG_LEGACY=y
# CONFIG_XENO_OPT_DEBUG_TRACE_RELAX is not set
CONFIG_XENO_OPT_WATCHDOG=y
CONFIG_XENO_OPT_WATCHDOG_TIMEOUT=4

#
# Drivers
#
CONFIG_XENO_OPT_RTDM_COMPAT_DEVNODE=y
CONFIG_XENO_DRIVERS_AUTOTUNE=y

#
# Serial drivers
#
# CONFIG_XENO_DRIVERS_16550A is not set
# end of Serial drivers

#
# Testing drivers
#
CONFIG_XENO_DRIVERS_TIMERBENCH=y
CONFIG_XENO_DRIVERS_SWITCHTEST=y
CONFIG_XENO_DRIVERS_HEAPCHECK=y
CONFIG_XENO_DRIVERS_RTDMTEST=m
# end of Testing drivers

#
# CAN drivers
#
# CONFIG_XENO_DRIVERS_CAN is not set
# end of CAN drivers

#
# RTnet
#
# CONFIG_XENO_DRIVERS_NET is not set
# end of RTnet

#
# ANALOGY drivers
#
# CONFIG_XENO_DRIVERS_ANALOGY is not set
# end of ANALOGY drivers

#
# Real-time IPC drivers
#
# CONFIG_XENO_DRIVERS_RTIPC is not set
# end of Real-time IPC drivers

#
# UDD support
#
# CONFIG_XENO_DRIVERS_UDD is not set
# end of UDD support

#
# Real-time GPIO drivers
#
# CONFIG_XENO_DRIVERS_GPIO is not set
# end of Real-time GPIO drivers

#
# GPIOPWM support
#
# CONFIG_XENO_DRIVERS_GPIOPWM is not set
# end of GPIOPWM support

#
# Real-time SPI master drivers
#
# end of Real-time SPI master drivers
# end of Drivers

CONFIG_XENO_VERSION_MAJOR=3
CONFIG_XENO_VERSION_MINOR=2
CONFIG_XENO_REVISION_LEVEL=4
CONFIG_XENO_VERSION_STRING="3.2.4"
39 changes: 39 additions & 0 deletions recipes-kernel/linux/files/xenomai4.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Processor type and features
#
CONFIG_EVL=y
CONFIG_EVL_SCHED_QUOTA=y
CONFIG_EVL_SCHED_TP=y
CONFIG_EVL_SCHED_TP_NR_PART=4
# CONFIG_EVL_HIGH_PERCPU_CONCURRENCY is not set
CONFIG_EVL_RUNSTATS=y
# CONFIG_EVL_NET is not set

#
# Fixed sizes and limits
#
CONFIG_EVL_COREMEM_SIZE=2048
CONFIG_EVL_NR_THREADS=256
CONFIG_EVL_NR_MONITORS=512
CONFIG_EVL_NR_CLOCKS=8
CONFIG_EVL_NR_XBUFS=128
CONFIG_EVL_NR_PROXIES=64
CONFIG_EVL_NR_OBSERVABLES=64
# end of Fixed sizes and limits

#
# Pre-calibrated latency
#
CONFIG_EVL_LATENCY_USER=0
CONFIG_EVL_LATENCY_KERNEL=0
CONFIG_EVL_LATENCY_IRQ=0
# end of Pre-calibrated latency

# CONFIG_EVL_DEBUG is not set

#
# Out-of-band device drivers
#
CONFIG_EVL_LATMUS=y
CONFIG_EVL_HECTIC=y
# end of Out-of-band device drivers
Loading