STM32F10x stdperiph lib 3.1.2 question

Hi everyone,

I’m having trouble running IAR examples from the “STM32F10x stdperiph lib 3.1.2” standard peripheral library on Olimex STM32-P107 development board. I’m using Olimex ARM-USB-OCD-H debugger with OpenOCD GDB server and IAR-EW 6.0. I was able to download code to the uC’s flash, but interrupts won’t work in any given example. Could you please explain to me basic file conifiguration in order for me to be able to run this examples correctly?

Best regards

Srdjan

When debugging, OpenOCD (0.40 version) displays following message:

Warn : Block read error address 0x8fac6890, count 0x4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x8fac68a4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x8fac68a4

Warn : Block read error address 0x8fac68a0, count 0x4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x8fac68b4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x8fac68b4

Warn : Block read error address 0x8fac68b0, count 0x4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x8fac68c4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x8fac68c4

Warn : Block read error address 0x8fac68c0, count 0x4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x8fac68d4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x8fac68d4

Warn : Block read error address 0x8fac68d0, count 0x4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x853977d4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x853977d4

Warn : Block read error address 0x853977d0, count 0x4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x853977e4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x853977e4

Warn : Block read error address 0x853977e0, count 0x4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x853977f4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x853977f4

Warn : Block read error address 0x853977f0, count 0x4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x85397804

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x85397804

Warn : Block read error address 0x85397800, count 0x4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x85397814

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x85397814

Warn : Block read error address 0x85397810, count 0x4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x85397824

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x85397824

Warn : Block read error address 0x85397820, count 0x4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x85397834

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x85397834

Warn : Block read error address 0x85397830, count 0x4

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x85397844

Error: JTAG-DP STICKY ERROR

Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x85397844

etc…

I use stm32.cfg config file. Debugger Clock speed is 1MHz. Any suggestions how to solve this problem?

Thanks

Srdjan

I haven’t used the STM32-P107 or the ARM-USB-OCD-H, so ymmv. When I first tried an ARM-USB-OCD with a LPC-P2148, I got it to work by adding jtag_khz 500 to my .cfg file. You might try a really slow value like jtag_khz 100 in your config to find out whether speed is the problem.

I’m mostly playing with a more “stamp” like (Chinese) STM32 board lately. It works ok at the default jtag clock of 1MHz. I’m not sure if that is because it is a smaller board, with the jtag connector closer to the uC, or what.

You might want to post your openocd.cfg file, and your target and/or interface files if you modified either.

I changed jtag speed to 100kHz (jtag_khz 100), now I’m able to enter interrupt via breakpoint in my simple Timer interrupt project.

While single stepping, when program tries to reenter Timer interrupt routine, OpenOCD shows following error:

Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x23000051, MEM_AP_TAR 0xfffffffa
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x23000051, MEM_AP_TAR 0xfffffffa
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x23000051, MEM_AP_TAR 0xfffffffa.

In my project I’ve got GPIO set/reset commands in if statment which turn diode on and off. When I try to execute program from the flash, one of the diodes blinks with real low intensity.

Is it maybe a power supply problem I’m having?

I tried to bring power externally and via USB_OTG and nothing changes.

Here is olimex-arm-usb-ocd-h.cfg

:

#
# Olimex ARM-USB-OCD-H
#
# http://www.olimex.com/dev/arm-usb-ocd.html
#
interface ft2232
ft2232_device_desc “Olimex OpenOCD JTAG ARM-USB-OCD-H”
ft2232_layout olimex-jtag
ft2232_vid_pid 0x15ba 0x002b,

and stm32.cdg

:

# script for stm32
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME stm32
}
if { [info exists ENDIAN] } {
set _ENDIAN $ENDIAN
} else {
set _ENDIAN little
}
# Work-area is a space in RAM used for flash programming
# By default use 16kB
if { [info exists WORKAREASIZE] } {
set _WORKAREASIZE $WORKAREASIZE
} else {
set _WORKAREASIZE 0x4000
}
# JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
jtag_khz 100
jtag_nsrst_delay 100
jtag_ntrst_delay 100
#jtag scan chain
if { [info exists CPUTAPID ] } {
set _CPUTAPID $CPUTAPID
} else {
# See STM Document RM0008
# Section 26.6.3
set _CPUTAPID 0x3ba00477
}
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
if { [info exists BSTAPID ] } {
# FIXME this never gets used to override defaults…
set _BSTAPID $BSTAPID
} else {
# See STM Document RM0008
# Section 29.6.2
# Low density devices, Rev A
set _BSTAPID1 0x06412041
# Medium density devices, Rev A
set _BSTAPID2 0x06410041
# Medium density devices, Rev B and Rev Z
set _BSTAPID3 0x16410041
# High density devices, Rev A
set _BSTAPID4 0x06414041
# Connectivity line devices, Rev A and Rev Z
set _BSTAPID5 0x06418041
}
jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 *
** -expected-id $_BSTAPID2 -expected-id $_BSTAPID3 *

** -expected-id $_BSTAPID4 -expected-id $_BSTAPID5**
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME stm32x 0 0 0 0 $_TARGETNAME
# For more information about the configuration files, take a look at:
# openocd.texi

.