Sebastian Huber f1cab61e2c bsps/or1k/generic_or1k: Fix the clock driver
The driver declared a cycle time of 10 nanoseconds, which is 100 MHz,
while the tick timer of Qemu counts at 20 MHz for the or1k-sim and the
virtual machine alike.  See TIMER_PERIOD in hw/or1k/cputimer.c.  The
timecounter therefore ran at a fifth of the real rate.

The period was a constant of 0x09ED9 counts and ignored the configured
microseconds per tick, so the system time advanced at a rate which had
nothing to do with the configuration.  Derive it from the configured
value and the timer frequency.  The result is computed once, because the
tick handler must not need a 64-bit division.

The timer ran in restart mode, which resets the counter at every period,
and it did not run at all until the driver programmed it.  An
application without a clock driver read a counter which never moved, and
_CPU_Counter_frequency() was the no_cpu placeholder and claimed 1 GHz.
Run the timer in continue mode, so that the counter is free running, and
start it from a system initialization item of its own.  The counter is
the CPU counter and the timecounter of this BSP.

The timer compares the time period with the low 28 bits of the counter.
A time period which the counter passed matches only after the counter
runs through the field, which takes 13 s at this frequency.  Take the
counter as the base of the next tick when the handler is late.  Hold the
interrupts off while the handler reads the counter and writes the
period, so that nothing extends the distance between the two.

Update #5684.

Assisted-by: Claude:claude-opus-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2026-09-01 20:08:57 +00:00
…
…
…
…

Real-Time Executive for Multiprocessing Systems

RTEMS is a real-time executive (kernel) which provides a high performance environment for embedded applications with the following features:

  • Standards based user interfaces.
  • Multitasking capabilities.
  • Homogeneous and heterogeneous multiprocessor systems.
  • Symmetric Multiprocessing (SMP):
    • Cluster scheduling: Job-level fixed prority scheduler (EDF) with support for one-to-one and one-to-all thread to processor affinities.
    • Locking protocols with transitive priority inheritance, priority ceiling, MRsP and OMIP.
  • Event-driven, priority-based, preemptive scheduling.
  • Scalable timer and timeout support.
  • Optional rate monotonic scheduling.
  • Intertask communication and synchronisation.
  • Priority inheritance.
  • Responsive interrupt management.
  • Dynamic memory allocation.
  • Dynamic code loading using run-time link editing.
  • File systems, IMFS, FAT, RFS, JFFS, NSFv4 (with LibBSD)
  • High level of user configurability.
  • Link-time configurable schedulers.
  • Linker-set based initialization (similar to global C++ constructors).
  • Drivers for I2C, SPI and LibBSD has NIC, USB, SD/MMC and Framebuffer.
  • Open source with a friendly user license.

RTEMS Project:

Project git repositories are located at:

Online documentation is available at:

RTEMS Doxygen for CPUKit:

RTEMS POSIX 1003.1 Compliance Guide:

RTEMS Discourse User forum for questions, answers and examples:

RTEMS Discord for support:

RTEMS Mailing Lists for general purpose use the users list and for developers use the devel list.

The version number for this software in releases is located in the VERSION file if present.

S
Description
RTEMS is a ​real-time executive in use by embedded systems applications around the world and beyond
Readme
141 MiB
0 Stars 1 Watchers 0 Forks
Languages
C 93.9%
Assembly 3.4%
Ada 1.4%
Python 0.3%
HTML 0.3%
Other 0.4%