Overclock STM32G0 64MHz -> 96MHz

I’m just showing it is obviously possible, and it seems fun to me.

DISCLAIMER
As with any overclock, boost & etc, if it is not allowed by the manufacturer, you do that at your own risk & etc. Blah.

Patch
diff --git a/src/stm32/Kconfig b/src/stm32/Kconfig
index b44842049..710ad8a97 100644
--- a/src/stm32/Kconfig
+++ b/src/stm32/Kconfig
@@ -205,7 +205,7 @@ config CLOCK_FREQ
     default 168000000 if MACH_STM32F4x5
     default 180000000 if MACH_STM32F446
     default 216000000 if MACH_STM32F765
-    default 64000000 if MACH_STM32G0
+    default 96000000 if MACH_STM32G0
     default 170000000 if MACH_STM32G431
     default 170000000 if MACH_STM32G474
     default 520000000 if MACH_STM32H723
diff --git a/src/stm32/stm32g0.c b/src/stm32/stm32g0.c
index d02d5728b..c07c59dd6 100644
--- a/src/stm32/stm32g0.c
+++ b/src/stm32/stm32g0.c
@@ -18,7 +18,7 @@
  * Clock setup
  ****************************************************************/
 
-#define FREQ_PERIPH 64000000
+#define FREQ_PERIPH CONFIG_CLOCK_FREQ
 #define FREQ_USB 48000000
 
 // Map a peripheral address to its enable bits

Well, it is an M0+ chip, with what seems to be a pretty simple clock architecture, and this is just a coincidence, that with the current code, it is enough to literally change the clock to the nearest one number (and only one) is 96 MHz, so 192 / 96 = 2, any different would require slightly more changes and it is not really what I’m looking for.

From the performance perspective, instruction per clock would not change, but the number of instructions per second would. So, overall, timers would be faster.

General step benchmark (arm-none-eabi-gcc (15:14.2.rel1-1) 14.2.1 20241119):

  • 1 stepper - 55 clocks, 1163K → 1745K steps per second.
  • 3 steppers - 239 clocks, 803K → 1205K steps per second.

What places it near the: SAM4S8C with 1690K, 1385K.

That is it on my side.

Thanks!


Ref: Tune TIMER_MIN_TRY_TICKS


Tested on my EBB, it seems to work fine.
So, I hope that if someone needs more performance from Manta E3/M4P/M5P/M8P V1.1, it should deliver it.

4 Likes