SparkFun Electronics Forum Index SparkFun Electronics
MicroController Ideas and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

OpenOCD, STR9, Flash erase problem, status 0xa2
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    SparkFun Electronics Forum Index -> OpenOCD
View previous topic :: View next topic  
Author Message
mydev



Joined: 30 Jan 2008
Posts: 11

PostPosted: Wed Jan 30, 2008 3:14 am    Post subject: OpenOCD, STR9, Flash erase problem, status 0xa2 Reply with quote

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. Rolling Eyes

Telnet:
Code:
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:
Code:
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:
Code:

#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
Back to top
View user's profile Send private message
onamatic



Joined: 30 Nov 2007
Posts: 13
Location: West Sussex, UK

PostPosted: Wed Jan 30, 2008 9:15 am    Post subject: Reply with quote

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 : http://forum.sparkfun.com/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.


Last edited by onamatic on Wed Jan 30, 2008 10:35 am; edited 1 time in total
Back to top
View user's profile Send private message
ntfreak



Joined: 17 Jun 2006
Posts: 289
Location: UK

PostPosted: Wed Jan 30, 2008 10:27 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
mydev



Joined: 30 Jan 2008
Posts: 11

PostPosted: Thu Jan 31, 2008 3:10 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
ntfreak



Joined: 17 Jun 2006
Posts: 289
Location: UK

PostPosted: Thu Jan 31, 2008 3:13 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
mydev



Joined: 30 Jan 2008
Posts: 11

PostPosted: Thu Jan 31, 2008 3:43 am    Post subject: Reply with quote

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.

Code:
# 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

Code:
#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 Crying or Very sad

*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 Smile
Back to top
View user's profile Send private message
ntfreak



Joined: 17 Jun 2006
Posts: 289
Location: UK

PostPosted: Thu Jan 31, 2008 7:43 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
mydev



Joined: 30 Jan 2008
Posts: 11

PostPosted: Fri Feb 01, 2008 1:22 am    Post subject: Reply with quote

Hello,

I did exactly what you told me to...
This is the log after reconnection of the device:

Code:


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


Code:

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?
Back to top
View user's profile Send private message
ntfreak



Joined: 17 Jun 2006
Posts: 289
Location: UK

PostPosted: Fri Feb 01, 2008 1:31 am    Post subject: Reply with quote

rev 278 from svn

Cheers
Spen
Back to top
View user's profile Send private message
mydev



Joined: 30 Jan 2008
Posts: 11

PostPosted: Fri Feb 01, 2008 1:58 am    Post subject: Reply with quote

Do you know where I can get a more recent version? Maybe daily/nightly build for windows? Smile
Back to top
View user's profile Send private message
ntfreak



Joined: 17 Jun 2006
Posts: 289
Location: UK

PostPosted: Sat Feb 02, 2008 7:09 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
mydev



Joined: 30 Jan 2008
Posts: 11

PostPosted: Tue Feb 05, 2008 1:08 am    Post subject: Reply with quote

I downloaded the newest version from the yagarto homepage - and everything is fine now!
Thanks a lot for being so patient ntfreak Smile
Back to top
View user's profile Send private message
mydev



Joined: 30 Jan 2008
Posts: 11

PostPosted: Tue Feb 05, 2008 2:38 am    Post subject: Reply with quote

Damn, I was lucky too fast...
Sometimes when erasing flash it's hanging and openocd is reporting this problem:

Code:

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]
Back to top
View user's profile Send private message
ntfreak



Joined: 17 Jun 2006
Posts: 289
Location: UK

PostPosted: Tue Feb 05, 2008 1:18 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
mydev



Joined: 30 Jan 2008
Posts: 11

PostPosted: Wed Feb 06, 2008 11:07 am    Post subject: Reply with quote

Hm,

I think I killed my ComStick somehow. It's impossible to flash it, even by using Hitop.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SparkFun Electronics Forum Index -> OpenOCD All times are GMT - 7 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group