Forum : ST7/STM8
Post Information | Post |
---|---|
July 7, 2010 - 9:30pm
|
Hi everyone, I would like to make an IAP reprogramming code on my SM8S105C6... 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). With the assistance of the application note, I succeeded to put my code on 0x9000, In IAP project, I included "redirect_irq_table.c" to redirect IRQs. Before reprograming via IAP, the content of memory is: After reprograming via IAP, the content of memory is: 0x9000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x9070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x91C0 53 9F C7 53 02 85 81 80 80 80 80 80 80 80 80 80 The code of APPLI is at 0x9080 and vectors at 0x91C7. I don't know where is the mistake! Regards. |
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:
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
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.