Topic : Protected and unprotected flash area

Forum : ST7/STM8

Original Post
Post Information Post
October 26, 2009 - 4:10pm
Guest

hi

I used the option bytes to set a 2k UBC area, in this area I put all the boot loader and flash programming procedures (using "at [address] code" directive) so they will not be overwritten.
The aim is of course to use these protected procedures for in field firmware update without having them being deleted by mistake. we do not want to use the built in boot loader option.
my problem is that after putting all the protected procedures with absolute address defined by me in the UBC, the compiler filled the spare room of the UBC with the rest of the code. how do I set the compiler to put the code (which has no specific address assigned to it) in the area starting after the end of the UBC area?

thanks
Igal

Replies
Post Information Post
+1
0
-1
October 27, 2009 - 9:03am
Raisonance Support Team

Hi Igal,

From what I understand you want to limit some of your code to be in the [0x8800-0xFFFF] range (not in the first 2K of flash).

There are many ways to handle this, however I think the best is to share your code into 2 applications. One application will be for the 2KB User Boot Code (UBC), and the other one will be the normal (updateable) code above 0x8800.

The 2 applications should be linked independently.

The first application can be limited through the CODE(0x8000) CODESIZE(0x0800) linker directives, which will ensure that the code is in its proper place.

The second application can be limited through the CODE(0x8800) CODESIZE(0x7800) (whatever fits your processor).

The 2 applications can coexist in a single Ride7 Project, so that flashing/debugging will be easier.

Note that this is just one way to handle the problem. It has the advantages of really splitting the code into identifiable, separated parts. However, you will have to program the 2 applications independently.

Regards,
Bruno

+1
0
-1
October 29, 2009 - 8:45am
Guest

Thank you Bruno for your reply.
Lets say I do 2 applications 1)my_app 2)my_app_boot
Some of the procedures used by boot application are used by both of the applications, is it possible?
is it possible to debug both at the same time? that is, running in debug the 1st application, giving it a command to start boot process (by usart) will it automatically transition to the boot application?
if not this solution is not ideal.
can't I just use the CODE(0x8800) CODESIZE(0x7800) in every non boot C file? and the other in a boot C file?
regards
Igal

+1
0
-1
November 2, 2009 - 10:30am
Guest

Hi

I think when bruno said :

Quote:
The 2 applications can coexist in a single Ride7 Project, so that flashing/debugging will be easier

He meant that it is possible to debug both applications.

Lets that you make two different project and link them.
Then you take one .elf from your application and add it to the other project.
When you start debug it loads the elf of the application from the project and the one that you added to the project.
So you can debug boths.

Regards
Matloub

+1
0
-1
November 24, 2009 - 4:59pm
Guest

ok, I created 2 application but they will not compile since I use a procedure in one application also in the second one (no way around this).
how can I have application #1 recognize procedures from application #2? (the same question relates to variables as well).
regards
Igal

+1
0
-1
November 25, 2009 - 9:57am
Raisonance Support Team

Hi Igal,

You can use an absolute address for your routine, for example in he first application

at 0x9000 void mydualfct(void);

And have an absolute function pointer in the second application:

#define mydualfct (*(void(*)(void))0x9000)  // Just defines the function address
...
mydualfct();

Not very readable, I admit, but it gets the work done!
There will be a call to the absolute address.

Enjoy,
Bruno

+1
0
-1
November 25, 2009 - 3:08pm
Guest

thanks Bruno

The project compiles but when I start debug only the first application is downloaded to the MCU.

+1
0
-1
November 25, 2009 - 5:34pm
Raisonance Support Team

Hello again Igal,

Now you have your 2 applications in your Ride7 Project.
Add the .AOF output file of the first application in the second project (and vice-versa).

You can then debug each of your applications independently.

Note that if you reprogram the flash, Ride will not be able to debug your application though.

Regards,
Bruno

+1
0
-1
November 26, 2009 - 12:06pm
Guest

Thanks
I added yesterday the AOF and Hex file of the second application to the first one and it worked (I didn't add the AOF and Hex of the first to the second) just fine.
Many thanks for your help
Igal