OpenOCD flashing STR91x

Hello everybody,

I am working on a STR912 currently, and I already have some working scripts for switching the boot bank as well as programming both banks. Nevertheless, I have now given up understanding what my scripts are doing, so I wanted to ask if somebody could shed some light on this.

In my openocd configuration I setup two flash banks:

flash bank str9x 0x00000000 0x00008000 0 0 0

flash bank str9x 0x00080000 0x00080000 0 0 0

For programming the boot flash, my script looks as follows:

str9x flash_config 0 0 6 0 0x80000

flash protect 0 0 3 off

flash erase_sector 0 0 3

flash write_image 0 main.bin 0x0000

reset

sleep 500

shutdown

The script for programming the main flash looks as follows:

str9x flash_config 0 4 2 0 0x80000

flash protect 0 0 4 off

flash erase_sector 0 0 4

flash write_image 0 main.bin 0x0

mwb 0x52000006 0x00

reset

The output of openocd for both cases tells me that it has written something to bank 0, which can’t really be because I would assume that I am writing to bank 0 as well as bank 1.

Right now, the scripts seem to work, but I am not sure if this configuration is correct at all, or just works by chance?

Any hint is highly appreciated.

Best regards,

Florian

flash bank str9x 0x00000000 0x00008000 0 0 0

flash bank str9x 0x00080000 0x00080000 0 0 0

This just tells openocd the flash configuration.

str9x flash_config 0 4 2 0 0x80000

simply configures the str9 flash controller - see flash guide/ref manual.

This function simply writes to the following registers, enables bank1 and sets the TCM bit - fix a issue with the arm966 core.

BBSR = 4; // boot bank is 256k

NBBSR = 2; // non boot bank is 32k

BBADR = 0; // boot bank starts @ 0x00000000

NBBADR = 0x80000; // non boot bank starts @ 0x00080000

This is as such the same as calling the ST lib fucntion

FMI_BankRemapConfig( 4, 2, 0, 0x80000 );

The rest is standard openocd stuff.

Not to sure what the following is doing

mwb 0x52000006 0x00

this is not a valid address for the str9

Cheers

Spen

Dear Spen,

thanks so much for your answer. There are a few things I still do not get into context.

As I understand, flash write_image 0 main.bin 0x0 would write the contents of main.bin into flash starting at address 0.

Now, the flash configuration is where it gets magic for me.

When you say str9x flash_config 0 4 2 0 0x80000 is equivalent to FMI_BankRemapConfig( 4, 2, 0, 0x80000 ) I understand that the flash space is remapped. But this would only work if the flash is setup so the “small” bank is the boot bank and the “large” bank is the non-boot bank. If we have it setup the other way around (i.e. startup directly into the “large” bank), this setup would not work?

Or is the boot bank selection mechanism in the chip as simple as setting up the registers correctly, and in these terms, the boot bank is ALWAYS the small flash, and the non boot bank is ALWAYS the large flash?

The second question, is it the case that I also could setup the flash with str9x flash_config 0 0 6 0 0x80000 and then do a flash write_image 0 main.bin 0x80000 to achieve the same result?

Thanks again for your patience. I hate it when I get code from a collegue who can’t answer why it works and just says “you needn’t know”…

Best regards,

Florian

I am new to olimex environment…using olimex ARM-USB-Tiny emulator with STR912 board…In the debugging i have many issues.I used the Str912_jtagkey config file …i am not able to debug my application.The error is unable to open FDTI device 1…

I am a CrossWorks user searching for a solution to flash a STR912 with change boot bank bit CSx to 1.

The 64bit configuration register at 0x52000000-0x52000007, setting bit 48 to 0 will cause bank 0 to be the boot bank and setting the bit to 1 will select bank 1.

you are setting bank0 to be the boot bank

mwb 0x52000006 0x00

Maybe you can explain how to setup a ARM-URB-OCD with OpenOCD.