Hi,
I am developing on stm32103/7 controllers.
I would love to initialize the clock/pll of the controller over openocd to achive higher jtag speeds than 8MHz/6 and get much higher download speeds this way.
Sounds simple, but i really got no clue how to do it.
Any help would be nice.
It seems nobody is interested in more speed?
What I got: Its for an STM32F1 with 20kB RAM.
source [find interface/jlink.cfg]
set WORKAREASIZE 0x5000
source [find target/stm32f1x.cfg]
uplevel #0 [list source [find chip/st/stm32/stm32.tcl]]
$_TARGETNAME configure -event reset-init { reset_init }
$_TARGETNAME configure -event gdb-detach { shutdown }
proc reset_init { } {
echo "reset-init..."
global RCC_CR
global FLASH_R_BASE
global RCC_CFGR
# HSE on
memwrite32 $RCC_CR [expr [memread32 $RCC_CR] | 0x00010000]
sleep 100
# Flash prefetch & two waits
memwrite32 $FLASH_R_BASE [expr [memread32 $FLASH_R_BASE] | 0x00000010]
memwrite32 $FLASH_R_BASE [expr [memread32 $FLASH_R_BASE] & 0xFFFFFFFC]
memwrite32 $FLASH_R_BASE [expr [memread32 $FLASH_R_BASE] | 0x00000002]
# PCLK1
memwrite32 $RCC_CFGR [expr [memread32 $RCC_CFGR] | 0x00000400]
# HSE * 9 = 8 * 9 = 72
memwrite32 $RCC_CFGR [expr [memread32 $RCC_CFGR] & 0xFFC0FFFF]
memwrite32 $RCC_CFGR [expr [memread32 $RCC_CFGR] | 0x001D0000]
# PLL on
memwrite32 $RCC_CR [expr [memread32 $RCC_CR] | 0x01000000]
sleep 100
# PLL select
memwrite32 $RCC_CFGR [expr [memread32 $RCC_CFGR] & 0xFFFFFFFC]
memwrite32 $RCC_CFGR [expr [memread32 $RCC_CFGR] | 0x00000002]
sleep 100
# Max 72000/6 = 12000
# 10000 works most of the time
adapter_khz 10000
sleep 100
}
init
reset init
As you see i try to config the FLASH and PLL.
The Flash is erased in eclipse hardware debug with “monitor stm32f1x mass_erase 0” and the .elf is loaded via the eclipse hardware debug.
“Most” of the times it works. But not alway. And if it doesnt, the device gets “bricked” in a way that i need to retry often with low speed (reset-init event commented out).
The J-Link should work up to 12000kHz from what i read on the Segger website. Even 6000kHz is not stable.
Any clues?