Inconsistant protection status on STR912

Hello,

I am using an STR912 with an Olimex ARM-USB-OCD. I ultimately want to program a bootloader in flash bank 1. I noticed a problem while using OpenOCD and I would like your opinion on this. When I try to change the sector protection, I get inconsistent results (here I’m working on bank 0 but have the same problems with bank 1):

flash protect_check 0

successfully checked protect state

flash info 0

#0: str9x at 0x00080000, size 0x00080000, buswidth 0, chipwidth 0

#0: 0x00000000 (0x10000 64kB) not protected

#1: 0x00010000 (0x10000 64kB) not protected

#2: 0x00020000 (0x10000 64kB) protected

#3: 0x00030000 (0x10000 64kB) protected

#4: 0x00040000 (0x10000 64kB) not protected

#5: 0x00050000 (0x10000 64kB) protected

#6: 0x00060000 (0x10000 64kB) not protected

#7: 0x00070000 (0x10000 64kB) not protected

str9x flash driver info

flash protect 0 0 7 off

cleared protection for sectors 0 through 7 on flash bank 0

flash protect_check 0

successfully checked protect state

flash info 0

#0: str9x at 0x00080000, size 0x00080000, buswidth 0, chipwidth 0

#0: 0x00000000 (0x10000 64kB) not protected

#1: 0x00010000 (0x10000 64kB) not protected

#2: 0x00020000 (0x10000 64kB) protected

#3: 0x00030000 (0x10000 64kB) protected

#4: 0x00040000 (0x10000 64kB) not protected

#5: 0x00050000 (0x10000 64kB) protected

#6: 0x00060000 (0x10000 64kB) not protected

#7: 0x00070000 (0x10000 64kB) not protected

str9x flash driver info

I don’t understand why I cannot unprotect the sectors. Here is what is happening in the debug log when I send the following commands:

flash protect 0 2 2 off

flash protect_check 0

flash info 0

Debug: 2021 266388 command.c:82 script_command(): script_command - protect

Debug: 2022 266388 command.c:99 script_command(): script_command - protect, argv[0]=ocd_flash_protect

Debug: 2023 266388 command.c:99 script_command(): script_command - protect, argv[1]=0

Debug: 2024 266404 command.c:99 script_command(): script_command - protect, argv[2]=2

Debug: 2025 266404 command.c:99 script_command(): script_command - protect, argv[3]=2

Debug: 2026 266419 command.c:99 script_command(): script_command - protect, argv[4]=off

Debug: 2027 266419 target.c:1367 target_write_u16(): address: 0x000a0000, value: 0x00000060

Debug: 2028 266435 embeddedice.c:403 embeddedice_write_reg(): 0: 0x00000004

Debug: 2029 266435 embeddedice.c:403 embeddedice_write_reg(): 0: 0x00000005

Debug: 2030 266435 target.c:1367 target_write_u16(): address: 0x000a0000, value: 0x000000d0

Debug: 2031 266435 embeddedice.c:403 embeddedice_write_reg(): 0: 0x00000004

Debug: 2032 266435 embeddedice.c:403 embeddedice_write_reg(): 0: 0x00000005

Debug: 2033 266435 arm7_9_common.c:1805 arm7_9_read_memory(): address: 0x000a0000, size: 0x00000001, count: 0x00000001

Debug: 2034 266450 target.c:1325 target_read_u8(): address: 0x000a0000, value: 0x80

Debug: 2035 266450 target.c:1367 target_write_u16(): address: 0x000a0000, value: 0x00000050

Debug: 2036 266450 embeddedice.c:403 embeddedice_write_reg(): 0: 0x00000004

Debug: 2037 266466 embeddedice.c:403 embeddedice_write_reg(): 0: 0x00000005

Debug: 2038 266466 target.c:1367 target_write_u16(): address: 0x000a0000, value: 0x000000ff

Debug: 2039 266466 embeddedice.c:403 embeddedice_write_reg(): 0: 0x00000004

Debug: 2040 266466 embeddedice.c:403 embeddedice_write_reg(): 0: 0x00000005

User: 2041 266466 command.c:363 command_print(): cleared protection for sectors 2 through 2 on flash bank 0

Debug: 2043 838446 command.c:82 script_command(): script_command - protect_check

Debug: 2044 838446 command.c:99 script_command(): script_command - protect_check, argv[0]=ocd_flash_protect_check

Debug: 2045 838446 command.c:99 script_command(): script_command - protect_check, argv[1]=0

Debug: 2046 838462 target.c:1367 target_write_u16(): address: 0x00000010, value: 0x00000090

Debug: 2047 838462 embeddedice.c:403 embeddedice_write_reg(): 0: 0x00000004

Debug: 2048 838462 embeddedice.c:403 embeddedice_write_reg(): 0: 0x00000005

Debug: 2049 838462 arm7_9_common.c:1805 arm7_9_read_memory(): address: 0x00000010, size: 0x00000002, count: 0x00000001

Debug: 2050 838462 target.c:1303 target_read_u16(): address: 0x00000010, value: 0xf02c

Debug: 2051 838462 target.c:1367 target_write_u16(): address: 0x00000010, value: 0x000000ff

Debug: 2052 838462 embeddedice.c:403 embeddedice_write_reg(): 0: 0x00000004

Debug: 2053 838477 embeddedice.c:403 embeddedice_write_reg(): 0: 0x00000005

User: 2054 838477 command.c:363 command_print(): successfully checked protect state

Debug: 2056 2708358 command.c:82 script_command(): script_command - info

Debug: 2057 2708358 command.c:99 script_command(): script_command - info, argv[0]=ocd_flash_info

Debug: 2058 2708358 command.c:99 script_command(): script_command - info, argv[1]=0

User: 2059 2708374 command.c:363 command_print(): #0: str9x at 0x00080000, size 0x00080000, buswidth 0, chipwidth 0

User: 2060 2708374 command.c:363 command_print(): #0: 0x00000000 (0x1000064kB) not protected

User: 2061 2708374 command.c:363 command_print(): #1: 0x00010000 (0x1000064kB) not protected

User: 2062 2708390 command.c:363 command_print(): #2: 0x00020000 (0x1000064kB) protected

User: 2063 2708390 command.c:363 command_print(): #3: 0x00030000 (0x1000064kB) protected

User: 2064 2708405 command.c:363 command_print(): #4: 0x00040000 (0x1000064kB) not protected

User: 2065 2708405 command.c:363 command_print(): #5: 0x00050000 (0x1000064kB) protected

User: 2066 2708405 command.c:363 command_print(): #6: 0x00060000 (0x1000064kB) not protected

User: 2067 2708421 command.c:363 command_print(): #7: 0x00070000 (0x1000064kB) not protected

User: 2068 2708421 command.c:363 command_print(): str9x flash driver info

I am interested in line #2050. Why is it reading at address “bank1start + 0x10” ? From datasheet http://www.st.com/stonline/products/lit … /11659.pdf on page 20, table 7, we can see that reading of the protected status should be done at register 0x04 or 0x03. Am I digging too deep ? Is there a simpler explanation ? I have two scripts that I run one after the other to setup and program my chip.

#1:

#daemon configuration

telnet_port 4444

gdb_port 8888

#interface

interface ft2232

#Use following line when using Tiny Olimex

#ft2232_device_desc “Olimex OpenOCD JTAG TINY A”

#Use foloowing line when using full Olimex ft2232_device_desc “Olimex OpenOCD JTAG A”

ft2232_layout “olimex-jtag”

ft2232_vid_pid 0x15BA 0x0004

jtag_speed 3

script for str9

jtag speed. We need to stick to 16kHz until we’ve finished reset.

jtag_rclk 16

jtag_nsrst_delay 100

jtag_ntrst_delay 100

#use combined on interfaces or targets that can’t set TRST/SRST separately reset_config trst_and_srst

#jtag scan chain #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)

jtag_device 8 0x1 0x1 0xfe

jtag_device 4 0x1 0xf 0xe

jtag_device 5 0x1 0x1 0x1e

#target

#target arm7tdmi

target arm966e little 1 arm966e

working_area 0 0x50000000 16384 nobackup

#flsh_bank 0 0 <target#>

flash bank str9xpec 0x00080000 0x00080000 0 0 0

flash bank str9xpec 0x00000000 0x00008000 0 0 0

#switch to normal command mode

init

str9xpec options_lvdsel 0 vdd_vddq

str9xpec options_lvdwarn 0 vdd_vddq

str9xpec options_lvdthd 0 2.7v

str9xpec options_cmap 0 bank1

str9xpec options_write 0

#exit

shutdown

For more information about the configuration files, take a look at:

openocd.texi

#2

#daemon configuration

telnet_port 4444

gdb_port 8888

#interface

interface ft2232

#Use following line when using Tiny Olimex

#ft2232_device_desc “Olimex OpenOCD JTAG TINY A”

#Use foloowing line when using full Olimex

ft2232_device_desc “Olimex OpenOCD JTAG A”

ft2232_layout “olimex-jtag”

ft2232_vid_pid 0x15BA 0x0004

jtag_speed 3

script for str9

jtag speed. We need to stick to 16kHz until we’ve finished reset.

jtag_rclk 16

jtag_nsrst_delay 100

jtag_ntrst_delay 100

#use combined on interfaces or targets that can’t set TRST/SRST separately

reset_config trst_and_srst

#jtag scan chain

#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)

jtag_device 8 0x1 0x1 0xfe

jtag_device 4 0x1 0xf 0xe

jtag_device 5 0x1 0x1 0x1e

#target

#target arm7tdmi

target arm966e little 1 arm966e

working_area 0 0x50000000 16384 nobackup

#flsh_bank 0 0 <target#>

flash bank str9x 0x00080000 0x00080000 0 0 0

flash bank str9x 0x00000000 0x00008000 0 0 0

#switch to normal command mode

init

reset

halt

str9x flash_config 0 0 6 0 0x80000

flash protect 1 0 3 off

flash protect 0 0 7 off

flash write_image erase Calisto-F-bootloader.hex 0 ihex flash

protect_check 0

flash info 0

flash protect_check 1

flash info 1

verify_image Calisto-F-bootloader.hex 0 ihex

#exit

#shutdown

For more information about the configuration files, take a look at:

openocd.texi

Any help would be appreciated,

Thanks,

Guf

Hello,

I noticed that this problem with the sectors is intermittent. When I cycle power on the target, everything seems fine the first few times I run my scripts. However, at some point I get JTAG errors (DEVICE has no ID CODE, 25 devices in chain, etc.) and the erratic behavior occurs. Most of the time I’m still able to program and verify fine but the protection status is not working properly. Note that I’m not always seeing JTAG errors before the problem occurs. I tried slowing down the jtag speed without any success. I tried the Olimex on the STR912-SK dev board from IAR and got a similar result (ruling out hardware design flaws like crosstalk, mismatched impedance, etc).

Could you look at my scripts and tell me if I’m doing something bad that could explain this ?

Did some of you had problems with JTAG that led to similar problems ?

Thanks,

Guf

normally the protection status will not be valid until a target reset.

Cheers

Spen