cancel
Showing results for 
Search instead for 
Did you mean: 

Switch from first Flash to second and vice-versa

sbencke3
Associate II
Posted on February 12, 2004 at 11:03

Switch from first Flash to second and vice-versa

11 REPLIES 11
sbencke3
Associate II
Posted on May 17, 2011 at 11:58

Hello,

I’m still trying to jump from one Flash to other, but I can’t do it correctly yet. I write my “Switch� code in assembler in a fixed adress like below:

;*************** MAIN FLASH *****************

ORG 0X1000

_Switch_Flash:

MOV DPTR,#0x90e2 ; Accessing the VM register

MOV A,#0x92 ; ; JUMP TO SECOND FLASH (primary=CODE, sec=DATA)

MOVX @DPTR,A

NOP

NOP

LJMP 0x0000;

;*************** SECOND FLASH *****************

ORG 0X1000

_Switch_Flash:

MOV DPTR,#0x90e2 ; Accessing the VM register

MOV A,#0x0C ; JUMP TO MAIN FLASH (primary=CODE, sec=DATA)

MOVX @DPTR,A

NOP

NOP

LJMP 0x0000;

When I call the function “_Switch_Flash( )�, sometime its works, sometimes not.

Somebody can help me ?

Somebody knows other good way to do this ?

jdaniel
Associate II
Posted on May 17, 2011 at 11:58

Sombra,

I'm not sure if this has anything to do with it, but it looks like in your second routine (the one placed in secondary flash), you disable PIO mode when you make the swap. If you were looking for some verification that you were running out of the other area (on the DK3200's LCD, for instance), this might cause a problem. Perhaps try changing the second VM value to 0x8C instead of 0x0C? Just a thought.

Also, for this method to work without changing the page register, you have to have the primary and secondary flash mapped to overlapping areas. Is this the case?

Best Regards,

pHaze426
sbencke3
Associate II
Posted on May 17, 2011 at 11:58

Thanks Phaze,

I attached two Zip files. The Boot0.zip is the program that I record in the second flash (Boot0) and the other in the main Flash.

Both zip files contain a assembler code Startu32.a51 with the function _Switch_Flash( ) and a C file where I call this functions. A put some marks ( ****** ) to help you to find it.

Thank you,
sbencke3
Associate II
Posted on May 17, 2011 at 11:58

Hi Phaze426

I change the page in my “C code� then a call the function in assembler:

PSD8xx_reg.PAGE = 0;

_Switch_Flash();

I try to change de VM value to 0x8C, but it doesn’t resolve my problem. In the beginning of my code (in the other Flash) I was setting this bit.

My memory map is as follow:

Fs0 = 0x0000~0x3fff – Pag 0;

FS1 = 0x4000 ~0x7FFF - Pag 0;

CSBOOT0 = 0x0000 ~0x1FFF;

CSBOOT1 = 0x2000 ~0x3FFF;

Do you know other way to do this ?

jdaniel
Associate II
Posted on May 17, 2011 at 11:58

Sombra,

Do you have the code that changes the page value to 0 in both primary and secondary flash? I think you have to do so for this method to work. Other than that, I can't think of anything.

If you'd like you could attach the pertinent bits of your code to a message and I could take a look at them for you.

Best Regards,

pHaze426
sbencke3
Associate II
Posted on May 17, 2011 at 11:58

I attached my PSD Soft express configuration. I think that my problem isn’t in the other part of my firmware because it works fine until I call the function Switch_Block, them nothing more works. I can switch just from first flash to second (boot).

I don’t know more what to do! Do you know about a good example for it ? Does ST make a example for it ?

jdaniel
Associate II
Posted on May 17, 2011 at 11:58

Sombra,

I took a look at your code and I don't immediately see anything wrong with the way you're doing the swap. Perhaps the swap is happening correctly, but something about the code in one area or another isn't working quite right. I notice that the files that you gave me only have a ''main'' function for one bank. I know you have to have a main function for the other bank somewhere.

Anyhow... if you still want to try to figure this out, maybe just zipping up the whole project (with the PSDSoft stuff) would be useful. Sorry I haven't been able to help just yet.

Best Regards,

pHaze
jdaniel
Associate II
Posted on May 17, 2011 at 11:58

Sombra,

I think I may have another possible cause of your problem. I think it has something to do with the way you're telling the assembler to locate your code. I think the functions may not actually be located at exactly the same addresses.

The function _Switch_Flash: is located within the segment ?C_C51STARTUP (note the directive ''RSEG ?C_C51STARTUP above it. When you use an ORG directive within a relocatable segment (RSEG), this specifies an offset from the beginning of that segment and not an absolute address. In other words, when you write ORG 0X50 in that particular location, you're telling the compiler / linker to place the code at wherever the ?C_C51STARTUP segment begins plus 0x50. This doesn't mean they end up in the same place in both main and secondary flash.

Take a look at the *.m51 files for each project and search for C_C51STARTUP within the file. This will give you the location of this segment. If they're not the same, this could be where you trouble is coming from.

If you look in the files and they're at different addresses, you can just tell the linker to locate them at the same address. First, find an open space in the memory map that's not used in either program (just to make your life easier). Then, go into your projects and select Project->Options for Target. Then go to the ''BL51 locate'' tab (I'm assuming you're using BL51 and not LX51). In the box for ''code'' enter:

?C_C51STARTUP(0xADDR)

where ADDR is the hex address you've picked. Now recompile the projects and take a look at the *.m51 files. These segments should not be at the same addresses and hopefully things will work better. Let me know if this works.

Best Regards,

PHaze
jdaniel
Associate II
Posted on May 17, 2011 at 11:58

Sombra,

I just wanted to follow up and see if you had any luck with my last suggestion? I finally got a good method for switching flash working on my system, so if you end up having to give up on yours, I can probably help you get stuff working. Just let me know.

Regards,

Phaze426