Bootloader for S12 on CW 3.1

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bootloader for S12 on CW 3.1

1,116 Views
sebasira
Senior Contributor I

Hello!

 

I've finnish my application, now I want to add a bootloader to it, so firmware can be updated via RS-232.... I've read AN4258, AN3275 and AN2546. Then I choose to go on with AN3275 "S-12 All-Accesss Bootloader for the HCS12 Microcontroller Family"

 

When compiling (with CW 3.1) an error appears: Link error : L1112 The ROUTINESINRAM section has segment type CODE (illegal)

 

I search the web and the only thing I found about that is this post. It says that the error is due to an earlier version of CW (earlier than CW 4.5).

 

First, I try modifing the .prm file so ROUTINESINRAM was READ_ONLY instead of READ_WRITE. It compiles, I can navigate through the menu with HyperTerminal, also I sent a .s19 (as text-file). I could see that the file was entirely transferred, but it never shown the message "ProgrammingComplete".

So I guess something is wrong and as the previous post declare, "if you do the change you mentioned (= change the prm section to Read Only), the code will not work "

 

So then I read the Technical Note 2281, here. But I didn't understand it. I mean, how should I modify the code of the AN3275 in order to be able to use it with CW 3.1? The "Copy to RAM" part is what confused me. Also I don't know why the segment has to be reallocate to address 0x0200. Why 0x0200 and no, let's say, 0x0150?

 

I hope you can help me, so I can finnish with it!

 

Thanks in advance! please excuse my English!

 

Happy New Year!! Feliz Año Nuevo!!:smileyvery-happy:

 

 

 


Labels (1)
0 Kudos
Reply
2 Replies

460 Views
sebasira
Senior Contributor I

I manage to solved it!

 

I just compile the BOOTLOADER project with CW4.6,  "merge" it with my app (build with CW 3.1).

 

Bootloading works well. I can send a .s19 files, and new application runs well.......

 

Steps to merge my app with bootloader.s19: (taken from App Notes mentioned on previous post):

  1- Copy bootloader.s19 to bin folder of my project

  2- At the beggining of the PRM file add HEXFILE bootloader.s19

  3- Modify definition of segment ROM_C000 so it won't overlap with bootloader code. Change it to:

ROM_C000 = READ_ONLY  0xC000 TO 0xEFFD;

  4- If interrupt are used, also modify segment ROM_4000 to:

ROM_4000 = READ_ONLY  0x4000 TO 0x7F0F;

 

[NOTE: here I don't understand if that last change must be done if the Application uses interrupts or if Bootloader uses

interrupt. I assume it's about my application, and as my final app uses interrupts, I've done this change]

  5- Finally, delete reset vector (because it's already implemented on bootloader)

 

 

One thing that is not working is the app that was merged with the bootloader. I'll try to explain in but it's kind of confusing.

 

+ I have a Project called LED.mcp

+ I did the 5 steps listed above, then UNDO steps 1 and 5. So I can load the app with BDM (works fine) and has no bootloader. Then I saved the generated .s19 as LED.s19

+ Now I RE-DO steps 1 and 5, so I add bootloading capability to my app.

+ If I don't enter bootloading my app do nothing (as if it where stuck)

+ But if I enter bootloading, and send LED.s19, then application works

 

What am I missing?

 

I hope the explanation is clear. If you need any more info, please tell me. Also, if wanted, I can post the code.

 

As always, thanks!!

 


0 Kudos
Reply

460 Views
sebasira
Senior Contributor I

I almost got it!!!!

 

Now I leave the dummy application, and I'm working with my full app.


The reason why the programm seems "stuck" is because PC is not at the right address. And I've really not idea why is that happening...

 

Bootloader's startup decide if conitnue executing the bootloader or jump to user application, depending on the state of an input. When it should execute user application, it sets PC = 0x0000... And I don't know how to go on from here. If I manually set PC to 0xC000 program runs perfectly

 

 

Here, I'll put both PRM files: one is of the Bootloader and the other is of the application

Bootloader

NAMES ENDSEGMENTS    RAM = READ_WRITE 0x5000 TO 0x5322;    FLASHROUTINES = READ_WRITE 0x5323 TO 0x53C8;  //157 bytes Flash_Cmd & Unsecure    /* unbanked FLASH ROM */    ROM_UPDATE = READ_ONLY 0xF000 TO 0xF0AF RELOCATE_TO 0xE000;     /*Update Section, 224 bytes*/    ROM_ERASELOADER = READ_ONLY 0xF0B0 TO 0xF0BF;    ROM_C000 = READ_ONLY  0xF0C0 TO 0xFE50;   /* Code may reach only up to 0xFE50 because of limitation on                                                * the amount of Flash that is backed-up                                                 */ENDPLACEMENT    _PRESTART,                   /* Used in HIWARE format: jump to _Startup at the code start */    STARTUP,                     /* startup data structures */    ROM_VAR,                     /* constant variables */    STRINGS,                     /* string literals */    VIRTUAL_TABLE_SEGMENT,       /* C++ virtual table segment */    NON_BANKED,                  /* runtime routines which must not be banked */    DEFAULT_ROM,    COPY,                        /* copy down information: how to initialize variables */                                 /* in case you want to use ROM_4000 here as well, make sure                                    that all files (incl. library files) are compiled with the                                    option: -OnB=b */                                 INTO  ROM_C000/*, ROM_4000*/;    DEFAULT_RAM                  INTO  RAM;    UPDATE_SECTION               INTO  ROM_UPDATE;    ERASELOADER_SECTION          INTO  ROM_ERASELOADER;    ROUTINESINRAM                INTO FLASHROUTINES;ENDENTRIES  vfnpUpdateFn;  gi16FlashSecurity;ENDSTACKTOP 0x53FFVECTOR 0 _Startup /* reset vector: this is the default entry point for a C/C++ application. */

 

 

Application (merged bootloader)

HEXFILE bootloader.s19NAMES ENDSEGMENTS    RAM = READ_WRITE 0x1000 TO 0x3FFF;    /* unbanked FLASH ROM */    ROM_4000 = READ_ONLY  0x4000 TO 0x7FFF;    ROM_C000 = READ_ONLY  0xC000 TO 0xEFFD;    /* banked FLASH ROM */    PAGE_30 = READ_ONLY  0x308000 TO 0x30BFFF;    PAGE_31 = READ_ONLY  0x318000 TO 0x31BFFF;    PAGE_32 = READ_ONLY  0x328000 TO 0x32BFFF;    PAGE_33 = READ_ONLY  0x338000 TO 0x33BFFF;    PAGE_34 = READ_ONLY  0x348000 TO 0x34BFFF;    PAGE_35 = READ_ONLY  0x358000 TO 0x35BFFF;    PAGE_36 = READ_ONLY  0x368000 TO 0x36BFFF;    PAGE_37 = READ_ONLY  0x378000 TO 0x37BFFF;    PAGE_38 = READ_ONLY  0x388000 TO 0x38BFFF;    PAGE_39 = READ_ONLY  0x398000 TO 0x39BFFF;    PAGE_3A = READ_ONLY  0x3A8000 TO 0x3ABFFF;    PAGE_3B = READ_ONLY  0x3B8000 TO 0x3BBFFF;    PAGE_3C = READ_ONLY  0x3C8000 TO 0x3CBFFF;    PAGE_3D = READ_ONLY  0x3D8000 TO 0x3DBFFF;        PAGE_EEPROM = READ_ONLY  0x0400 TO 0x0FFF;ENDPLACEMENT    _PRESTART,                   /* Used in HIWARE format: jump to _Startup at the code start */    STARTUP,                     /* startup data structures */    ROM_VAR,                     /* constant variables */    VIRTUAL_TABLE_SEGMENT,       /* C++ virtual table segment */    NON_BANKED,                  /* runtime routines which must not be banked */    PAGE_IRQs,    COPY                         /* copy down information: how to initialize variables */                                 /* in case you want to use ROM_4000 here as well, make sure                                    that all files (incl. library files) are compiled with the                                    option: -OnB=b */                                 INTO  ROM_C000;                                     DEFAULT_ROM                  INTO  PAGE_30,PAGE_31,PAGE_32,PAGE_33,PAGE_34,PAGE_35,PAGE_36,                                       PAGE_37,PAGE_38,PAGE_39,PAGE_3A,PAGE_3B,PAGE_3C;    DEFAULT_RAM                  INTO  RAM;            FONTS_PAGE        INTO  PAGE_3B;    FLASH_DATA_PAGE   INTO  PAGE_3D;  // Pagina donde voy a guardar datos NO VOLATILES        PAGE_TEXT         INTO  PAGE_3A;        STRINGS           INTO  PAGE_3A;  /* string literals */            EEPROM_DATA_PAGE  INTO  PAGE_EEPROM;ENDSTACKSIZE 0x600/* INTERRUPT VECTOR TABLE *//**************************/ //VECTOR ADDRESS 0xFFFE  _Startup
 /*I commented the Reset Vector because it's allready implemented on the bootloader
    maybe the problem is somewhere here*/ /*here there are all the others vectors, I leave them behind so it won't be too much to read*/

 

 

0 Kudos
Reply