diff --git a/JOURNAL.md b/JOURNAL.md index 4ca71fe..267342b 100644 --- a/JOURNAL.md +++ b/JOURNAL.md @@ -3897,3 +3897,20 @@ Wrote a small tool `plictool` to dump the state of the PLIC: Interestingly, the auxiliar UART interrupts don't seem to be working very well. Also, is there another source 33 enabled? + +I have also noticed that the clock is running with the wrong frequency. +Everything is about twice as slow. For example, `sleep 1` takes 2 seconds. +So I assume the kernel thinks the clock goes faster than it actually does. + +The timer is at 50 KHz: + + timebase-frequency = <50000>; /* 50 kHz */ + +So, the frequency of this "clock" is done by using the "general" clock which +goes at 50 MHz, and then using a simple counter that counts up to 1525, so the +frequency is: + + 32786.88524590164 Hz + +Assuming that it actually works well. Let's try that and see if we can have a +more realistic reading for the CLINT interrupt frequency. diff --git a/ox-plic.dts b/ox-plic.dts index 6d2309e..09b9442 100644 --- a/ox-plic.dts +++ b/ox-plic.dts @@ -16,8 +16,10 @@ cpus { #address-cells = <1>; #size-cells = <0>; - /* Timer */ - timebase-frequency = <50000>; /* 50 kHz */ + + // The RTC timer is clocked at the CPU frequency / 1525, so + // around 32786.88 Hz + timebase-frequency = <32786>; CPU0: cpu@0 { clock-frequency = <50000000>; /* 50 MHz */ device_type = "cpu";