Last active
February 7, 2021 02:07
-
-
Save cryptolok/65de63e29b6b809b2c4a80aa1d149931 to your computer and use it in GitHub Desktop.
stm32f103c-blue-pill-overclock.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# you can use any desired programmer, like JTAG/ST-LINK | |
# assuming you're using Arduino IDE | |
# package : https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json | |
# the default library already should be at max stock clock (72MHz <=> RCC PLL multiplier of 9 for HSE crystal of 8MHz) | |
LIBVERSION=1.9.0 | |
ARDVERSION=15 | |
HOME=$HOME | |
BOARD=PILL_F103XX | |
CONF="$HOME/.arduino$ARDVERSION/packages/STM32/hardware/stm32/$LIBVERSION/variants/$BOARD/variant.cpp" | |
# please change versions and home to adapt to your configuration | |
CURRENT=$(grep RCC_PLL_MUL "$CONF" | cut -d ' ' -f 5 | cut -d ';' -f 1) | |
FREQ=$(echo "$CURRENT" | cut -d 'L' -f 4) | |
let FREQ*=8 | |
echo "CURRENT FREQUENCY $FREQ MHz" | |
echo "SELECT DESIRED FREQUENCY :" | |
# original stm led works up to 80MHz, clones up to 104MHz | |
# max crystal swap frequency for original is 24MHz (although the claimed limit is 16MHz) | |
# screen capability is lost for original if more than 72Mhz, but clone can go up to 128MHz | |
# USB should keep up, but may fail for some reasons | |
# UART should be stable in all cases, as well as the rest of the code (float, strings, etc) | |
select f in 16 24 32 40 48 56 64 72 80 88 96 104 112 120 128 | |
do | |
if [[ "$f" ]] | |
then | |
let MUL=REPLY+1 | |
NEW="RCC_PLL_MUL$MUL" | |
sed -i s/$CURRENT/$NEW/g $CONF | |
let FREQ=MUL*8 | |
echo "FREQUENCY SET TO $FREQ MHz" | |
if [[ $MUL -ge 11 ]] | |
then | |
echo "! WARNING ! USB and LED might fail at such frequency" | |
fi | |
break | |
fi | |
echo "PLEASE SELECT A NUMBER" | |
done | |
# external underclock is possible | |
# external overclock isn't stable if more than 10MHz (equivalent to 90MHz on board) | |
# frequency can even be changed without reprogramming and turning off the STM... | |
# note that from now you can compile and upload your Arduino IDE code to your STM, the thicker/time/sleep will adapt to the frequency, so you won't hav | |
e to recompensate the overclock by additional timing | |
# more frequency also means more power consumption and higher temperature |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment