SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
By mydev
#41801
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:
Code: Select all
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: Select all
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: Select all
#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
By onamatic
#41814
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.
Last edited by onamatic on Wed Jan 30, 2008 10:35 am, edited 1 time in total.
User avatar
By ntfreak
#41818
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
By mydev
#41863
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
User avatar
By ntfreak
#41864
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
By mydev
#41866
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: Select all
# 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: Select all
#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 :)
User avatar
By ntfreak
#41874
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
By mydev
#41949
Hello,

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

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: Select all
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?
User avatar
By ntfreak
#41950
rev 278 from svn

Cheers
Spen
By mydev
#41952
Do you know where I can get a more recent version? Maybe daily/nightly build for windows? :)
User avatar
By ntfreak
#42079
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
By mydev
#42253
I downloaded the newest version from the yagarto homepage - and everything is fine now!
Thanks a lot for being so patient ntfreak :)
By mydev
#42259
Damn, I was lucky too fast...
Sometimes when erasing flash it's hanging and openocd is reporting this problem:
Code: Select all
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]
User avatar
By ntfreak
#42297
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
By mydev
#42365
Hm,

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