[Openocd-development] Clock setup script for STM32F107

2011-10-09 Thread Simon Barner
Dear list,

I have already posted the attached script some weeks ago.

It enables the PLL of the STM32F107 and thus configures
the MCU to run at 72 MHz which allows for higher JTAG speeds.

Since this should be useful for everybody, I would like to
contribute it to OpenOCD. However, I am not sure how to integrate
it. One idea is to conditionally call it from scripts/target
/stm32f1x.cfg. Comments and alternative suggestions are highly
appreciated.

Regards,
 Simon
# Enable PLL2 and PLL (as in CMSIS system_stm32f10x.c)
# and clock system with 72 Mhz
#
# Set JTAG clock to 6 MHz   
$_TARGETNAME configure -event reset-init {
# RCC_CR reset value: 0x??83
# RCC_CR - RCC_CR_HSEON
mww 0x40021000 0x10083
sleep 10

# FLASH_ACR reset value: 0x30
# FLASH_ACR - FLASH_ACR_PRFTBE, FLASH_ACR_LATENCY_2
mww 0x40022000 0x32

# RCC_CFGR reset value: 0x0
# RCC_CFGR - RCC_CFGR_HPRE_DIV1, RCC_CFGR_PPRE2_DIV1, 
RCC_CFGR_PPRE1_DIV2
mww 0x40021004 0x400

# RCC_CFGR2 reset value: 0x0
# RCC_CFGR2 - RCC_CFGR2_PREDIV2_DIV5, RCC_CFGR2_PLL2MUL8,
#  RCC_CFGR2_PREDIV1SRC_PLL2, RCC_CFGR2_PREDIV1_DIV5
mww 0x4002102c 0x10644

# RCC_CR - RCC_CR_PLL2ON
mww 0x40021000 0x4010083
sleep 10

# RCC_CFGR - PLLCLK = PREDIV1 * 9 = 72 MHz
mww 0x40021004 0x1d0400

# RCC_CR - RCC_CR_PLLON
mww 0x40021000 0x5010083
sleep 10

# RCC_CR - RCC_CFGR_SW_PLL
mww 0x40021004 0x1d0402
sleep 10

adapter_khz 6000
}
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] Clock setup script for STM32F107

2011-10-09 Thread Michael Schwingen
Am 10/09/2011 12:37 PM, schrieb Simon Barner:
 Dear list,

 I have already posted the attached script some weeks ago.

 It enables the PLL of the STM32F107 and thus configures
 the MCU to run at 72 MHz which allows for higher JTAG speeds.

 Since this should be useful for everybody, I would like to
 contribute it to OpenOCD. However, I am not sure how to integrate
 it. One idea is to conditionally call it from scripts/target
 /stm32f1x.cfg. Comments and alternative suggestions are highly
 appreciated.
How about moving this to a function that can be called from the board
config file?

cu
Michael

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] Clock setup script for STM32F107

2011-10-09 Thread Andreas Fritiofson
On Sun, Oct 9, 2011 at 12:37 PM, Simon Barner bar...@gmx.de wrote:

 Dear list,

 I have already posted the attached script some weeks ago.

 It enables the PLL of the STM32F107 and thus configures
 the MCU to run at 72 MHz which allows for higher JTAG speeds.

 Since this should be useful for everybody, I would like to
 contribute it to OpenOCD. However, I am not sure how to integrate
 it. One idea is to conditionally call it from scripts/target
 /stm32f1x.cfg. Comments and alternative suggestions are highly
 appreciated.


First of all, it's better to run off of the HSI instead. Not everyone has a
crystal attached, or it could be another frequency.

For example, I have this in my config files (for STM32F103, I don't know
what differs):

$_TARGETNAME configure -event reset-init {
 mww 0x40022000 0x32
 mww 0x40021004 0x3c0400
 mww 0x40021000 0x01000883
 sleep 10
 mww 0x40021004 0x3c0402
 sleep 10
 adapter_khz 3000
}

As Michael said, it's probably best to put in in a tcl procedure that the
user can choose to call from the reset-init hook. Don't put the adapter_khz
in that procedure. If the settings are the same for all devices in the
family, the procedure probably belongs in target/stm32f1x.cfg.

/Andreas
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development