9S12XDP512 Boot Loader

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

9S12XDP512 Boot Loader

1,151 Views
jcdammeyer
Contributor III

I'm trying to figure out how to construct a bootloader for the 9S12XDP512.  Searching through old forum postings and googling the various key words only brings up partially completed threads or applications notes with broken links to code.

 

AN2546.pdf and AN24546SW.ZIP don't provide enough information.  From AN2546SW.ZIP I've taken LRAE_Bootloader.pd and pulled out the source code, reformatted and turned it into a C file.  But the projectglobals.h is missing.  And so is any of the code to actually program the flash memory.

 

What I'm looking for is a Codewarrier Project that has a simple serial port based S file to FLASH boot loader.

 

The project should have:

1. A P&E Multilink prm or TDML.prm file

2. The .ini files for the P&E and TDML

3. The .h files for the boot loader code.

4. The .c files for the boot loader code.

 

Compiling and programming this application should create an S19 file that I can program into the 9S12.  The serial port code needs to be non-interrupt driven and all the interrupt vectors should be mapped to branch into table in a FLASH page that would be programmed via this boot loader.

 

Next I'd like to see a sample "Hello World!" project with interrupt driven serial output that has a the appropriate .prm and .ini files so that the __Startup() and main() are called from the boot loader and the interrupts are vectored appropriately into a table supplied as part of the project.

 

I found this easy enough to do with a PIC18F series where I used CAN bus messages to download the hex file.  The hex file I converted in a Delphi PC application into CAN messages to a Zanthic CAN4USB.  So I'm not a stranger to developing a boot loader.  But somehow I'm missing something in the Freescale/Metroworks Codewarrier world.

 

In my application I won't be using the serial port.  I've got an FTDI USB245R connected with a parallel interface that on the PC side looks like a serial port.  So the PC code will just send a line at a time and I'd like the bootloader to pull the ascii string apart sending back an ACK or NAK if all went well.  The code fragment below shows what I'll be doing.  Easy enough to substitute into a generic bootloader application.

 

 

/* ------------------------------------------------------------------ */// USB 245R interface support routines.// PORT pins as connected to 9S12 are self explanatory in the code.BoolUSBWriteRdy(void) { if (USB_TXE_ == 0)   return(TRUE); else  return(FALSE);}BoolUSBWrite(BYTE d) { if (USBWriteRdy()) {  USB_DATA = d;  // Put data out there for port turnaround  USB_LED = LED_ON;   // Waste some time for signals to settle.  __asm NOP;  __asm NOP;  USB_WR = 1;  // Make Write line high  __asm NOP;  __asm NOP;  USB_DIR = 0xFF; // Make output port. Data now on pins.  __asm NOP;  __asm NOP;  USB_WR = 0;  // Make Write line low latching data into USB   __asm NOP;  __asm NOP;  USB_LED = LED_OFF;   // Waste some time for signals to settle.  USB_DIR = 0x00; // Make an input again.  return(TRUE); } else  return(FALSE);}BoolUSBDataAv(void) { if (USB_RXF_ == 0)    // USB Data Available line.  return(TRUE); else  return(FALSE);}BoolUSBRead(PBYTE pd) { if (USBDataAv()) {  USB_RD_ = 0;    // RD Strobe Low.  USB_LED = LED_ON;   // Waste some time for signals to settle.  __asm NOP;  __asm NOP;  *pd = USB_DATA;  __asm NOP;  USB_LED = LED_OFF;    // And blow some more time.  USB_RD_ = 1;    // RD Strobe High again  return(TRUE); } else  return(FALSE);} 

 Even my Target application isn't overly large with about 0xCDE bytes for the application and 0x290F for the run time library.  Currently the code goes at 0xC000 and the library at FE8000.  The P&E conversion program creates a new S19 file with the library going at 0x7F8000 and my code at 7FC000 while the vectors are mapped to 0x7FFF78 and up.

 

So is there an application note somewhere around that describes how to do this?

Thanks

John

Labels (1)
Tags (1)
0 Kudos
Reply
1 Reply

447 Views
kef
Specialist I

I want to comment this:

 

  • The serial port code needs to be non-interrupt driven and all the interrupt vectors
  • should be mapped to branch into table in a FLASH page that would be programmed via this boot loader.

"To branch into table" is quite odd requirement for S12X and S12 derivatives, that have IVBR register, which allows to change higher order byte of interrupt vector table address at any time. Bootloader may set up IVBR before branching to application code. Alternatively application can chnage IVBR when it wants. Copying bootloader and bootloader vectors table to RAM, switching IVBR to vectors in RAM, and running from RAM, you may keep interrupts enabled during whole reflashing process.

 

0 Kudos
Reply