OpenOCD, STR9, Flash erase problem, status 0xa2

Hello guys,

first of all - thanks for this great forum. Found many hints here already.

Currently I’m working with a STR9 Comstick from Hitex, Yagarto and OpenOCD.

I arrived at the point where I have to flash my hex-file but… the following problem occures - maybe you can figure out what I’m doing wrong. :roll:

Telnet:

Open On-Chip Debugger
> str9x flash_config 0 0 6 0x00000000 0x80000
> flash protect 0 0 3 off
cleared protection for sectors 0 through 3 on flash bank 0
> flash info 0
#0: str9x at 0x00000000, size 0x00008000, buswidth 0, chipwidth 0
        #0: 0x00000000 (0x2000 8kB) erase state unknown, protected
        #1: 0x00002000 (0x2000 8kB) erase state unknown, protected
        #2: 0x00004000 (0x2000 8kB) erase state unknown, protected
        #3: 0x00006000 (0x2000 8kB) erase state unknown, protected
str9x flash driver info
> flash erase
usage: flash erase <bank> <first> <last>
> flash erase 0 0 3
flash erase error
>

OPENOCD-LOG:

Info:    server.c:67 add_connection(): accepted 'telnet' connection from 0
Error:   str9x.c:281 str9x_erase(): error erasing flash bank, status: 0xa2

OPENOCD config:

#daemon configuration
telnet_port 4444
gdb_port 3333

#interface
interface ft2232
ft2232_device_desc "STR9-comStick A"
ft2232_layout comstick 
ft2232_vid_pid 0x0640 0x002c
jtag_speed 0

#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 configuration
daemon_startup reset

#target <type> <endianess> <reset mode>
target arm966e little reset_halt 1 arm966e

#target arm9tdmi little reset_halt 0 arm920t
working_area 0 0x50000000 32768 nobackup
run_and_halt_time 0 30

#flash configuration
#flash bank <driver> <base> <size> <chip_width> <bus_width> [driver_options ...]
flash bank str9x 0x00000000 0x00008000 0 0 0
flash bank str9x 0x00080000 0x00080000 0 0 0

Have you tried :

flash erase 0 0 2

(ie. just erase the first 3 banks rather than all 4)

If this works then you have the same problem as I do with an LPC2119 and that someone else has in this message : viewtopic.php?t=9191

There is definitely something fishy about the erase command parameters; I am currently trying to figure it out as I am certain that in my case the flash bank statement in my config file is correct.

[edit] For LPC processors at least, the top 8k of flash is the boot sector; maybe erasing it would destroy the boot loader? [/edit]

Sorry I can’t be of further help.

The error means the bank is protected, mainly because of the config you are using - normally this would be used if you have remapped Bank0/1.

To get started i would use the default setup - Boot bank is Bank0.

str9x flash_config 0 4 2 0 0x80000

and

flash bank str9x 0x00000000 0x00080000 0 0 0

flash bank str9x 0x00080000 0x00008000 0 0 0

in your config

everything else looks ok.

Cheers

Spen

Hello,

it works!

So the problem was the order I specified the flash banks, right?

How should they be specified - or how do I know which flash bank has to be defined first?

And most interesting question - is this kind of reflecting the content of the STR9 boot bank configuration registers?

Thanks!!

regards,

Daniel

The str9 has a complex flash controller on board, so if have remapped the boot bank you will need a different config.

You have to make sure the flash bans and the flash_config config lines match.

For most people using the default above is ok.

Cheers

Spen

I’m currently coding a bootloader and want to use the flash controller to remap the boot bank (32k) to be the startup bank.

So what I did was…

… configured the flash banks in the order I thought it should be.

# first flash bank (boot bank)
flash bank str9x 0x00000000 0x8000 0 0 0
# second flash bank (app bank)
flash bank str9x 0x00080000 0x00080000 0 0 0

… then I started ocd and set the flash controller

#str9x flash_config <bank> <bbsize> <nbsize> <bbstart> <nbstart>
str9x flash_config        0          0              4            0x0         0x80000

#bbsize register = 0 : means 32kBytes (written in the STR9 flash programming manual)
#nbsize register = 4 : means 512kBytes (written in the STR9 flash programming manual)

Where did I make the failure? I don’t get it :cry:

EDIT I used exactly the configuraiton and flash_config you provided and was able to erase the bank 1 sectors (boot bank). But I got the same error 0xa2 when I tried to erase the bank 0 sectors (appl. bank).

EDIT2 Whenever I use the str9x flash_config command to reassign the memory mapping of the banks… Do I have to disconnect and reconnect the power supply so the new register values are used? Or is it enough to do a reset after the flash_config command?

Help appreciated :slight_smile:

First use str9xpec to configure boot bank:

flash bank str9xpec 0x00000000 0x00080000 0 0 0

str9xpec enable_turbo 0

str9xpec options_read 0

str9xpec options_cmap 0 bank1

str9xpec options_write 0

then cycle board power.

Then configure banks as follows:

flash bank str9x 0x00000000 0x00008000 0 0 0

flash bank str9x 0x00080000 0x00080000 0 0 0

str9x flash_config 0 0 6 0 0x80000

flash protect 0 0 3 off

flash erase 0 0 3

flash write_binary 0 image.bin 0

much easier to use autoerase

flash auto_erase on

flash protect 0 0 3 off

flash write_image image.s19

and to verify write

verify_image image.s19

cheers

Spen

Hello,

I did exactly what you told me to…

This is the log after reconnection of the device:

C:\Program Files\yagarto ide>openocd-ftd2xx.exe -f M:\IAP\Misc\OpenOCD\openocd_b
oot.cfg
Info:    openocd.c:93 main(): Open On-Chip Debugger (2007-12-30 17:00 CET) svn:
247
Info:    openocd.c:94 main(): $URL: http://svn.berlios.de/svnroot/repos/openocd/
trunk/src/openocd.c $
Info:    jtag.c:1291 jtag_examine_chain(): JTAG device found: 0x04570041 (Manufa
cturer: 0x020, Part: 0x4570, Version: 0x0)
Info:    jtag.c:1291 jtag_examine_chain(): JTAG device found: 0x25966041 (Manufa
cturer: 0x020, Part: 0x5966, Version: 0x2)
Info:    jtag.c:1291 jtag_examine_chain(): JTAG device found: 0x1457f041 (Manufa
cturer: 0x020, Part: 0x457f, Version: 0x1)
Info:    server.c:67 add_connection(): accepted 'telnet' connection from 0
Error:   str9x.c:281 str9x_erase(): error erasing flash bank, status: 0xa2
Open On-Chip Debugger
> str9xpec options_read
str9xpec options_read <bank>
> str9xpec options_read 0
CS Map: bank1
OTP Lock: OTP Unlocked
LVD Threshold: 2.7v
LVD Reset Warning: VDD or VDDQ Inputs
LVD Reset Selection: VDD or VDDQ Inputs
>
> str9x flash_
usage: str9x flash_config <bank> <bbsize> <nbsize> <bbstart> <nbstart
> str9x flash_config 0 0 6 0 0x80000
> flash protect 0 0 3 off
cleared protection for sectors 0 through 3 on flash bank 0
> flash erase 0 0 3
flash erase error
> flash info 0
#0: str9x at 0x00000000, size 0x00008000, buswidth 0, chipwidth 0
        #0: 0x00000000 (0x2000 8kB) erase state unknown, protected
        #1: 0x00002000 (0x2000 8kB) erase state unknown, protected
        #2: 0x00004000 (0x2000 8kB) erase state unknown, protected
        #3: 0x00006000 (0x2000 8kB) erase state unknown, protected
str9x flash driver info
> flash info 1
#1: str9x at 0x00080000, size 0x00080000, buswidth 0, chipwidth 0
        #0: 0x00000000 (0x10000 64kB) erase state unknown, protected
        #1: 0x00010000 (0x10000 64kB) erase state unknown, protected
        #2: 0x00020000 (0x10000 64kB) erase state unknown, protected
        #3: 0x00030000 (0x10000 64kB) erase state unknown, protected
        #4: 0x00040000 (0x10000 64kB) erase state unknown, protected
        #5: 0x00050000 (0x10000 64kB) erase state unknown, protected
        #6: 0x00060000 (0x10000 64kB) erase state unknown, protected
        #7: 0x00070000 (0x10000 64kB) erase state unknown, protected
str9x flash driver info

EDIT: Which revision do you use?

rev 278 from svn

Cheers

Spen

Do you know where I can get a more recent version? Maybe daily/nightly build for windows? :slight_smile:

Michael Fischer should be updating the version on his website very soon:

http://www.yagarto.de

The other way is to download the source and build.

Cheers

Spen

I downloaded the newest version from the yagarto homepage - and everything is fine now!

Thanks a lot for being so patient ntfreak :slight_smile:

Damn, I was lucky too fast…

Sometimes when erasing flash it’s hanging and openocd is reporting this problem:

Info:    openocd.c:93 main(): Open On-Chip Debugger (2008-02-02 15:00 CET) svn: 279
Info:    openocd.c:94 main(): $URL: http://svn.berlios.de/svnroot/repos/openocd/trunk/src/openocd.c $
Info:    jtag.c:1261 jtag_examine_chain(): JTAG device found: 0x04570041 (Manufacturer: 0x020, Part: 0x4570, Version: 0x0)
Info:    jtag.c:1261 jtag_examine_chain(): JTAG device found: 0x25966041 (Manufacturer: 0x020, Part: 0x5966, Version: 0x2)
Info:    jtag.c:1261 jtag_examine_chain(): JTAG devi7e found: 0x1457f041 (Manufacturer: 0x020, Part: 0x457f, Version: 0x1)
Info:    server.c:67 add_connection(): accepted 'telnet' connection from 0
Error:   arm7_9_common.c:571 arm7_9_execute_sys_speed(): timeout waiting for SYSCOMP & DBGACK, last DBG_STATUS: 4
Error:   arm7_9_common.c:571 arm7_9_execute_sys_speed(): timeout waiting for SYSCOMP & DBGACK, last DBG_STATUS: 4
Error:   arm7_9_common.c:571 arm7_9_execute_sys_speed(): timeout waiting for SYSCOMP & DBGACK, last DBG_STATUS: 4

[/code]

By default the comstick has a 25MHz osc onboard.

your jtag speed to is high

jtag_speed 1

should fix the problem, try even slower if you still get problems.

Cheers

Spen

Hm,

I think I killed my ComStick somehow. It’s impossible to flash it, even by using Hitop.

Try the following to recover - as a last resort.

Normally you should not get this problem with the str9, we have quite e few people using the comstick.

config script

flash bank str9xpec 0x00000000 0x00080000 0 0 0

then try unlock

str9xpec enable_turbo 0

str9xpec unlock 0

then cycle board power.

Are you sure you have killed it, post the openocd log - openocd -d3

you could even try a lock/unlock sequence.

Cheers

Spen

@ntfreak

I use openocd-r520-20080322 and olimex ARM-USB-OCD

When i try lock i get:

Debug: 96 91189 command.c:375 command_run_line(): str9xpec enable_turbo 0

Debug: 97 106892 command.c:375 command_run_line(): str9xpec lock 0

Debug: 98 106892 str9xpec.c:180 str9xpec_isc_status(): status: 0x2e

Debug: 99 106892 str9xpec.c:209 str9xpec_isc_enable(): ISC_MODE Enabled

and there OpenOCD hangs but str912 is locked.

When i try unlock i get:

Debug: 2764 38998 str9xpec.c:180 str9xpec_isc_status(): status: 0x2a

Debug: 2765 38998 str9xpec.c:180 str9xpec_isc_status(): status: 0x2a

Debug: 2766 39013 str9xpec.c:180 str9xpec_isc_status(): status: 0x2a

and there OpenOCD hangs repeating …, and str912 is still locked.

Maybe you can tell me what is wrong or is there another way to full erase the str9

I have tested the openocd-r657 and i succeeded to erase the STR9 from telnet.

If i try to run unlock from auto load “target script” i get :

User: target.c:435 target_process_reset(): Timed out waiting for halt after reset

and the script don’t execute.

Can someone confirm this?

There has been a few changes with the reset handling, depending on what jtag interface you are using, try the latest from svn.

could you post the full log?

Cheers

Spen

DebugLog:

Debug: 4 0 command.c:425 command_run_line(): script openocd_confUNLOCK.cfg

Debug: 5 0 configuration.c:87 open_file_from_path(): opened openocd_confUNLOCK.cfg

Debug: 6 0 command.c:425 command_run_line(): telnet_port 4444

Debug: 7 0 command.c:425 command_run_line(): gdb_port 3333

Debug: 8 0 command.c:425 command_run_line(): gdb_memory_map enable

Debug: 9 0 command.c:425 command_run_line(): gdb_flash_program enable

Debug: 10 0 command.c:425 command_run_line(): interface ft2232

Debug: 11 0 command.c:425 command_run_line(): ft2232_device_desc “Olimex OpenOCD JTAG A”

Debug: 12 0 command.c:425 command_run_line(): ft2232_layout “olimex-jtag”

Debug: 13 0 command.c:425 command_run_line(): ft2232_vid_pid 0x15BA 0x0003

Debug: 14 0 command.c:425 command_run_line(): jtag_speed 1

Debug: 15 0 jtag.c:1850 handle_jtag_speed_command(): handle jtag speed

Info: 16 0 options.c:50 configuration_output_handler(): jtag_speed: 1, 1

Debug: 17 0 command.c:425 command_run_line(): jtag_nsrst_delay 100

Debug: 18 0 command.c:425 command_run_line(): jtag_ntrst_delay 100

Debug: 19 0 command.c:425 command_run_line(): reset_config trst_and_srst

Debug: 20 0 command.c:425 command_run_line(): jtag_device 8 0x1 0x1 0xfe

Debug: 21 0 command.c:425 command_run_line(): jtag_device 4 0x1 0xf 0xe

Debug: 22 0 command.c:425 command_run_line(): jtag_device 5 0x1 0x1 0x1e

Debug: 23 0 command.c:425 command_run_line(): daemon_startup reset

Info: 24 0 options.c:50 configuration_output_handler(): Open On-Chip Debugger (2008-05-16 20:15) svn: 657

Debug: 25 0 command.c:425 command_run_line(): target arm966e little run_and_init 1 arm966e

Debug: 26 0 arm966e.c:141 arm966e_target_command(): chain_pos: 1, variant: arm966e

Debug: 27 0 command.c:425 command_run_line(): run_and_halt_time 0 30

Debug: 28 0 command.c:425 command_run_line(): target_script 0 reset confUNLOCK.script

Debug: 29 0 command.c:425 command_run_line(): working_area 0 0x50000000 16384 nobackup

Debug: 30 0 command.c:425 command_run_line(): flash bank str9xpec 0x00000000 0x00080000 0 0 0

Debug: 31 0 command.c:425 command_run_line(): init

Debug: 32 0 openocd.c:102 handle_init_command(): target init complete

Debug: 33 0 ft2232.c:1368 ft2232_init_ftd2xx(): ‘ft2232’ interface using FTD2XX with ‘olimex-jtag’ layout (15ba:0003)

Debug: 34 32 ft2232.c:1457 ft2232_init_ftd2xx(): current latency timer: 2

Debug: 35 32 ft2232.c:1804 olimex_jtag_init(): 80 08 1b

Debug: 36 32 ft2232.c:1847 olimex_jtag_init(): 82 09 0f

Debug: 37 32 ft2232.c:253 ft2232_speed(): 86 01 00

Debug: 38 47 openocd.c:109 handle_init_command(): jtag interface init complete

Debug: 39 47 jtag.c:1524 jtag_init_inner(): Init JTAG chain

Debug: 40 47 jtag.c:319 jtag_call_event_callbacks(): jtag event: JTAG controller reset(tms or TRST)

Debug: 41 47 jtag.c:1282 jtag_reset_callback(): -

Debug: 42 47 jtag.c:1282 jtag_reset_callback(): -

Debug: 43 47 jtag.c:1282 jtag_reset_callback(): -

Debug: 44 47 jtag.c:319 jtag_call_event_callbacks(): jtag event: JTAG controller reset(tms or TRST)

Debug: 45 47 jtag.c:1282 jtag_reset_callback(): -

Debug: 46 47 jtag.c:1282 jtag_reset_callback(): -

Debug: 47 47 jtag.c:1282 jtag_reset_callback(): -

Info: 48 47 jtag.c:1376 jtag_examine_chain(): JTAG device found: 0x04570041 (Manufacturer: 0x020, Part: 0x4570, Version: 0x0)

Info: 49 47 jtag.c:1376 jtag_examine_chain(): JTAG device found: 0x25966041 (Manufacturer: 0x020, Part: 0x5966, Version: 0x2)

Info: 50 47 jtag.c:1376 jtag_examine_chain(): JTAG device found: 0x2457f041 (Manufacturer: 0x020, Part: 0x457f, Version: 0x2)

Debug: 51 47 jtag.c:319 jtag_call_event_callbacks(): jtag event: JTAG controller reset(tms or TRST)

Debug: 52 47 jtag.c:1282 jtag_reset_callback(): -

Debug: 53 47 jtag.c:1282 jtag_reset_callback(): -

Debug: 54 47 jtag.c:1282 jtag_reset_callback(): -

Debug: 55 47 openocd.c:116 handle_init_command(): jtag init complete

Debug: 56 47 embeddedice.c:397 embeddedice_write_reg(): 0: 0x00000000

Debug: 57 63 openocd.c:119 handle_init_command(): jtag examine complete

Debug: 58 63 openocd.c:126 handle_init_command(): flash init complete

Debug: 59 63 openocd.c:130 handle_init_command(): NAND init complete

Debug: 60 63 openocd.c:134 handle_init_command(): pld init complete

Debug: 61 63 gdb_server.c:2036 gdb_init(): gdb service for target arm966e at port 3333

Debug: 62 63 command.c:425 command_run_line(): reset

Debug: 63 63 target.c:1830 handle_reset_command(): -

Debug: 64 63 ft2232.c:253 ft2232_speed(): 86 01 00

Debug: 65 63 jtag.c:1568 jtag_init_reset(): Trying to bring the JTAG controller to life by asserting TRST / tms

Debug: 66 63 jtag.c:989 jtag_add_reset(): SRST line released

Debug: 67 63 jtag.c:1008 jtag_add_reset(): TRST line asserted

Debug: 68 63 jtag.c:319 jtag_call_event_callbacks(): jtag event: JTAG controller reset(tms or TRST)

Debug: 69 63 jtag.c:1282 jtag_reset_callback(): -

Debug: 70 63 jtag.c:1282 jtag_reset_callback(): -

Debug: 71 63 jtag.c:1282 jtag_reset_callback(): -

Debug: 72 63 jtag.c:985 jtag_add_reset(): SRST line asserted

Debug: 73 63 jtag.c:1008 jtag_add_reset(): TRST line asserted

Debug: 74 63 jtag.c:319 jtag_call_event_callbacks(): jtag event: JTAG controller reset(tms or TRST)

Debug: 75 63 jtag.c:1282 jtag_reset_callback(): -

Debug: 76 63 jtag.c:1282 jtag_reset_callback(): -

Debug: 77 63 jtag.c:1282 jtag_reset_callback(): -

Debug: 78 63 jtag.c:985 jtag_add_reset(): SRST line asserted

Debug: 79 63 jtag.c:989 jtag_add_reset(): SRST line released

Debug: 80 63 ft2232.c:1031 olimex_jtag_reset(): trst: 1, srst: 0, high_output: 0x08, high_direction: 0x0f

Debug: 81 172 ft2232.c:1031 olimex_jtag_reset(): trst: 1, srst: 1, high_output: 0x0a, high_direction: 0x0f

Debug: 82 172 ft2232.c:1031 olimex_jtag_reset(): trst: 0, srst: 1, high_output: 0x0b, high_direction: 0x0f

Debug: 83 266 ft2232.c:1031 olimex_jtag_reset(): trst: 0, srst: 0, high_output: 0x09, high_direction: 0x0f

Debug: 84 469 jtag.c:1524 jtag_init_inner(): Init JTAG chain

Debug: 85 469 jtag.c:319 jtag_call_event_callbacks(): jtag event: JTAG controller reset(tms or TRST)

Debug: 86 469 jtag.c:1282 jtag_reset_callback(): -

Debug: 87 469 jtag.c:1282 jtag_reset_callback(): -

Debug: 88 469 jtag.c:1282 jtag_reset_callback(): -

Info: 89 469 jtag.c:1376 jtag_examine_chain(): JTAG device found: 0x04570041 (Manufacturer: 0x020, Part: 0x4570, Version: 0x0)

Info: 90 469 jtag.c:1376 jtag_examine_chain(): JTAG device found: 0x25966041 (Manufacturer: 0x020, Part: 0x5966, Version: 0x2)

Info: 91 469 jtag.c:1376 jtag_examine_chain(): JTAG device found: 0x2457f041 (Manufacturer: 0x020, Part: 0x457f, Version: 0x2)

Debug: 92 469 jtag.c:319 jtag_call_event_callbacks(): jtag event: JTAG controller reset(tms or TRST)

Debug: 93 469 jtag.c:1282 jtag_reset_callback(): -

Debug: 94 469 jtag.c:1282 jtag_reset_callback(): -

Debug: 95 469 jtag.c:1282 jtag_reset_callback(): -

Debug: 96 485 embeddedice.c:397 embeddedice_write_reg(): 0: 0x00000000

Debug: 97 485 arm7_9_common.c:736 arm7_9_assert_reset(): target->state: unknown

Debug: 98 485 jtag.c:985 jtag_add_reset(): SRST line asserted

Debug: 99 485 ft2232.c:1031 olimex_jtag_reset(): trst: 0, srst: 1, high_output: 0x03, high_direction: 0x0f

Debug: 100 625 arm7_9_common.c:789 arm7_9_deassert_reset(): target->state: reset

Debug: 101 625 jtag.c:989 jtag_add_reset(): SRST line released

Debug: 102 625 ft2232.c:1031 olimex_jtag_reset(): trst: 0, srst: 0, high_output: 0x01, high_direction: 0x0f

Debug: 103 828 target.c:410 target_process_reset(): Waiting for halted stated as approperiate

Debug: 104 828 arm7_9_common.c:926 arm7_9_halt(): target->state: running

Debug: 105 828 embeddedice.c:397 embeddedice_write_reg(): 0: 0x00000002

Debug: 106 828 target.c:424 target_process_reset(): Polling target

Debug: 108 1328 target.c:424 target_process_reset(): Polling target

Debug: 110 1844 target.c:424 target_process_reset(): Polling target

Debug: 112 2344 target.c:424 target_process_reset(): Polling target

Debug: 114 2844 target.c:424 target_process_reset(): Polling target

Debug: 116 3360 target.c:424 target_process_reset(): Polling target

Debug: 118 3860 target.c:424 target_process_reset(): Polling target

Debug: 120 4360 target.c:424 target_process_reset(): Polling target

Debug: 122 4860 target.c:424 target_process_reset(): Polling target

Debug: 124 5360 target.c:424 target_process_reset(): Polling target

Debug: 126 5860 target.c:424 target_process_reset(): Polling target

User: 127 5875 target.c:435 target_process_reset(): Timed out waiting for halt after reset

Debug: 128 5875 ft2232.c:253 ft2232_speed(): 86 01 00

as you see my script don’t get executed:

My script:

str9xpec options_read 0

str9xpec unlock 0

shutdown