Topic : IAP programming code

Forum : ST7/STM8

Original Post
Post Information Post
July 7, 2010 - 9:30pm
Guest

Hi everyone,

I would like to make an IAP reprogramming code on my SM8S105C6...
For information, devices used:
- RLinkPro
- demo board STM8-Discovery
- Ride7 7.30.10.0159
- Rkit-SM8 2.28.10.0092
- Flash Demo loader (download on STMCU)

With the application note "AN2659", read/write are OK on EEPROM and ROM.

My problem is that I want to put a futur application at the address 0x9000 (name APPLI).
This application just blink a led on the demo board.

With the assistance of the application note, I succeeded to put my code on 0x9000,
but the vectors aren't in the good place ou erased.

In IAP project, I included "redirect_irq_table.c" to redirect IRQs.
In APPLI project, I put "CODE(0x9080)" for linker option.

Before reprograming via IAP, the content of memory is:
Adr content
0x8000 82 00 81 F6 00 00 00 00 82 00 90 08 82 00 90 0C
0x8010 82 00 90 10 82 00 90 14 82 00 90 18 82 00 90 1C
0x8020 .........

After reprograming via IAP, the content of memory is:
Adr content
0x8000 82 00 90 80 82 00 91 C7 82 00 91 C8 82 00 91 C9
0x8010 82 00 91 CA 82 00 91 CB 82 00 91 CC 82 00 91 CD
0x8020 .........

0x9000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x9010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x9020 .........

0x9070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x9080 89 A6 00 6B 02 35 01 50 ...........

0x91C0 53 9F C7 53 02 85 81 80 80 80 80 80 80 80 80 80
0x91D0 80 80 80 80 80 80 80 80 80 80 80 80 00 00 00 00
0x91E0 .........

The code of APPLI is at 0x9080 and vectors at 0x91C7.
After I turn on demo board, the led blink so the APPLI start but it's impossible to reprogram via IAP.

I don't know where is the mistake!
I can post my code if it's necessary.

Regards.

Replies
Post Information Post
+1
0
-1
July 8, 2010 - 9:54am
Raisonance Support Team

Hi Sylvain,

It looks like your reset vector goes into your 0x9000-0xFFFF section after the reprogramming. This is probably because you left a main() function in the upper block.

What you need to do is to place your main() function in the bootloader (in your 0x8000-0x8FFF section).

In the 0x9000-0xFFFF section, place the entry point at an absolute address, such as in 0x9080. Here is the code that will do it:

at 0x9080 void main_high(void)
{
    ...
}

And in your bootloader declare the secondary entry point as absolute, such as:
extern at 0x9080 void main_high(void);

Once the bootloading process needs to jump to the application code, just write:
main_high();

Note: In your bootloaded code the global variables will not be initialized, as there is no startup code for it. So you must ensure that the code does the initializations manually in your code (var = 3; othervar = 7; and the like)...

Let us know if this fixes your problem,
Bruno

+1
0
-1
July 8, 2010 - 10:09pm
Guest

Hi Bruno,

Thank you very much for your explanation, but I don't really understand.
First of all, before reprogramming, the reset vector contains 0x81F6 (main() of IAP program) and after all vectors from 0x9008.

In .HEX file of my application, there is a part with :
:0F4800000000FF00FF00FF00FF00FF00FF00FFB0
:0480000082009080EA
:01808000807F
:01808100807E
:01808200807D
:01808300807C
:........

So when I reprogram with this hex file, an error appears because the page0 and page1 are write-protected.
I think my IAP program is good and this part of file is bad.

What do you feel about that ?
Tomorrow I'll continue on this subject and when I'll know the solution, I'll post a document about this.

Thank you for your remark about global variables.

Regards.