Serial Bootloader for S12GA240MLL micro controller

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

Serial Bootloader for S12GA240MLL micro controller

646 Views
bhavanraibagi
Contributor I

Hello Sir,

 

I'm working on bootloader application. For this i got some sample codes of S12X,S12G128. I gone through this codes. When system will enter into the bootloader mode through the serial communication. Then according to the option 'b' selecting then need to send the .s19 converted user application code through the serial communication. Then by selecting PP0 pin to low then i have to send the file then it should execute my user application.

 

This procedure where told in the which is explained this attached one pdf file(AN4258.pdf).

 

According to I gone through the procedure. But i'm facing problem that the bootloader code is not entering into the bootloader mode. So can you please tell me steps or links for serial bootloader for this S12GA240MLL micro controller. 

 

May be i'm facing some problem at initiliazation time in bootloader code. It's not flashing the code to the MCU. Here I sent my .prm file. Can you what mistakes I made here and what I need do steps to complete this serial bootloader task for this S12GA240 micro controller

 

.prm file->

/***********************************START OF .prm FILE ***********************************/

 

INIT _BootStart

 

/* This is a linker parameter file for the MC9S12GA240 */
NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */

SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */

/* Register space */
/* IO_SEG = PAGED 0x0000 TO 0x03FF; intentionally not defined */

 

/* RAM */
RAM = READ_WRITE 0x1400 TO 0x3CFF;


// RAM_CODE_SEG = READ_ONLY 0xFD00 TO 0xFEFF RELOCATE_TO 0x3D00;

 

/* D-Flash */
DFLASH = READ_ONLY 0x0400 TO 0x13FF;

 

/* non-paged FLASHs */

//ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF;//0x7F0F; //0x7FFF;

 

ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF;
ROM_C000 = READ_ONLY 0xC000 TO 0xFCFF;//0xEFDF; //0xFEFF;

// RAM_CODE_SEG = READ_ONLY 0xFD00 TO 0xFEFF RELOCATE_TO 0x3D00;

// ROM_F000 = READ_ONLY 0xF000 TO 0xFCFF;

VECTORS = READ_ONLY 0xFF00 TO 0xFFFF;/* intentionally not defined: used for VECTOR commands below */
OSVECTORS = READ_ONLY 0xFF80 TO 0xFFFF; /* OSEK interrupt vectors (use your vector.o) */

/* paged FLASH: 0x8000 TO 0xBFFF; addressed through PPAGE */
PAGE_01 = READ_ONLY 0x018000 TO 0x01BFFF;
PAGE_02 = READ_ONLY 0x028000 TO 0x02BFFF;
PAGE_03 = READ_ONLY 0x038000 TO 0x03BFFF;
PAGE_04 = READ_ONLY 0x048000 TO 0x04BFFF;
PAGE_05 = READ_ONLY 0x058000 TO 0x05BFFF;
PAGE_06 = READ_ONLY 0x068000 TO 0x06BFFF;
PAGE_07 = READ_ONLY 0x078000 TO 0x07BFFF;
PAGE_08 = READ_ONLY 0x088000 TO 0x08BFFF;
PAGE_09 = READ_ONLY 0x098000 TO 0x09BFFF;
PAGE_0A = READ_ONLY 0x0A8000 TO 0x0ABFFF;
PAGE_0B = READ_ONLY 0x0B8000 TO 0x0BBFFF;
PAGE_0C = READ_ONLY 0x0C8000 TO 0x0CBFFF;
PAGE_0E = READ_ONLY 0x0E8000 TO 0x0EBFFF;
// PAGE_0D = READ_ONLY 0x0D8000 TO 0x0DBFFF;// not used: equivalent to ROM_4000 */
// PAGE_0F = READ_ONLY 0x0F8000 TO 0x0FBEFF;// not used: equivalent to ROM_C000 */

 

END

 

PLACEMENT /* here all predefined and user segments are placed into the SEGMENTS defined above. */

 

_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 */

 

.ostext, /* OSEK */

 

NON_BANKED, /* runtime routines which must not be banked */

 

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_4000/*, ROM_4000*/;

 

DEFAULT_ROM INTO PAGE_01, PAGE_02, PAGE_03, PAGE_04, PAGE_05, PAGE_06, PAGE_07, PAGE_08,
PAGE_09, PAGE_0A, PAGE_0B, PAGE_0C, PAGE_0E;//, PAGE_0D, PAGE_0F;

 

.stackstart, /* eventually used for OSEK kernel awareness: Main-Stack Start */

 

SSTACK, /* allocate stack first to avoid overwriting variables on overflow */

 

.stackend, /* eventually used for OSEK kernel awareness: Main-Stack End */

 

DEFAULT_RAM INTO RAM;

 

RAM_CODE INTO RAM_CODE_SEG;


.vectors INTO OSVECTORS; /* OSEK */
END

 

ENTRIES /* keep the following unreferenced variables */

 

flash_array /* OSEK: always allocate the vector table and all dependent objects */
//_vectab OsBuildNumber _OsOrtiStackStart _OsOrtiStart
END

 

STACKSIZE 0x100

//VECTOR 0 _Startup

 

VECTOR 0 _BootStart
VECTOR 1 _BootStart
VECTOR 2 _BootStart

 

//VECTOR 0 Entry /* reset vector: this is the default entry point for an Assembly application. */
//INIT Entry /* for assembly applications: that this is as well the initialization entry point */

 

 /************************************* END ***********************************/

 

Regards,

Bhavan

Labels (1)
1 Reply

476 Views
RadekS
NXP Employee
NXP Employee

Hi Bhavan,

The entering into AN4258 bootloader is trough MCU reset.

So, the simplest method how to enter into bootloader mode is press some button (e.g. PTP0) and reset MCU by RESET button. The code in StartS12.s will be executed as first and it will check PP0 button state. If this pin is active (low) or when the application is not loaded, it will jump to bootloader, otherwise, it will jump to application.

 

Note: the default code in StartS12.s file (Bootloader_S12) is for S12P demo board, however, it should work also on TWR-S12G240 board.

Note: the buttons on TWR-S12G240 board are connected to port AD. If you want to use these pins, you have to also enable digital input buffer pin at the appropriate pin. For example:

movb  #$80, $007D     ; enable digital buffer on pin PAD7

;…

movb  #$00, $007D     ; disable digital buffer on pin PAD7 - restore default state

 

 

If you want to enter into bootloader mode on the base of application request, you have to implement some code for rising a flag (e.g in EEPROM) and reset routine (typically COP reset) into your application.

The bootloader may check that flag instead of PP0 button after reset.

 

 

Note: there is known hardware issue with bootloader and TWR-S12Gxxx boards. These boards use MAX3387E as UART transceiver where the FORCEOFF pin is connected to port AD pin. You should enable pull-up at PAD15 pin (or drive high this pin) for disable power save features of this transceiver.

 

 

I am not sure with your prm file. Is it prm file for your application or for the S12 bootloader?

It does not fit any of these purposes.

 

For your information, please look at prm file of the S12 bootloader and at prm file of Demo application in AN4258SW.zip file.

The basic idea is that bootloader occupied the smallest possible area at last page together with reset vectors while the main application may use the rest of non-volatile memory (the application do not have access to reset vectors and application interrupt vectors has to be targeted by IVBR register out of the default area 0xFF80~0xFFF9).

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------