RTEMS | bsps/i386/pc386: The CPU counter counts calls and a delay loop hangs the boot (#5728)
Sebastian Huber (@sebhub)
gitlab at rtems.org
Mon Aug 24 01:42:08 UTC 2026
Issue created by Sebastian Huber: https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5728
The i386 CPU port links the software CPU counter of
`cpukit/score/cpu/no_cpu`. `_CPU_Counter_read()` of that counter increments a
static variable per call and `_CPU_Counter_frequency()` returns 1000000000, so
nothing in it measures time. `rtems_counter_delay_nanoseconds()` therefore
delays by a count of calls.
`ts-validation-timecounter-1` installs a timecounter whose count is
`rtems_counter_read()` and whose frequency is `rtems_counter_frequency()`. With
the software counter that timecounter claims 1 GHz and advances one count per
read, so the test fails and the BSP carries an `expected-fail` state for it in
`spec/build/bsps/i386/pc386/tst-xfail-val.yml`.
The processors of this family have a time stamp counter, and the clock driver
already measures its frequency for the timecounter. That measurement runs
channel 0 of the 8254, which is the tick source, so it belongs on channel 2,
which software gates and which drives no interrupt.
`Calibrate_loop_1ms()` is a second defect of the same BSP. It measures a
software delay loop against the 8254 for `Wait_X_ms()`, and `bsp_start()` calls
it for every executable. It retries five times and then executes `while (1)`.
Under a simulator which derives its clock from the executed instructions it
reaches that point on every boot and no executable of this BSP starts:
Problem #2 in offset computation in Calibrate_loop_1ms
Calibrate_loop_1ms: too many attempts. giving up!!
Only the PS/2 keyboard, the PS/2 mouse and the IDE driver call `Wait_X_ms()`,
and channel 2 of the 8254 gives that delay without a calibration.
Found while running the full test suite on eleven simulators. This description
was created with Claude Code assistance.
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5728
You're receiving this email because of your account on gitlab.rtems.org. Unsubscribe from this thread: https://gitlab.rtems.org/-/sent_notifications/5-6ojghnjekhmxsepkms9bjbw7l-1d/unsubscribe | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | Help: https://gitlab.rtems.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260824/c40beabf/attachment.htm>
More information about the bugs
mailing list