S12GN32 Bootloader

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

S12GN32 Bootloader

Jump to solution
3,223 Views
jixiangli
Contributor III

Hello, our company is a large number of USES freescale S12GN32 the chip, 32 pins, used in automobile motor control, products sold throughout the country, but often need to update the underlying drivers, if each product are burning program, it's such a waste of resources, the company decided to use SCI Bootloader mode to update the program!

I never contact before Bootloader, rarely freescale's official website on this introduction, ask everybody to help me solve about S12GN32 Bootloader program of serial communication, how to write, had better have routines and to illustrate, recommend some useful information, thank you!Thank you very much!

Labels (1)
1 Solution
2,477 Views
jixiangli
Contributor III

Dear Radek,

   Thank you for your reply, I would like to study, do not understand the need to ask you again, thank you!

View solution in original post

0 Kudos
Reply
17 Replies
2,475 Views
RadekS
NXP Employee
NXP Employee

Hi jixiang,

I would like to recommend our application note AN4258 Serial Bootloader for S12(X) Microcontrollers Based on 180 nm Technology

http://www.nxp.com/files/microcontrollers/doc/app_note/AN4258.pdf

http://www.nxp.com/files/microcontrollers/doc/app_note/AN4258SW.zip

 

Since, the S12GN32 derivative is slightly newer than AN4258, the S12GN32 target missing in AN4258 S12 Bootloader project.

You may add them yourself, or use attached bootloader project where S12GN32 target was already added by me.

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
2,475 Views
jixiangli
Contributor III

Dear Radek,

    Thank you very much for taking the time to answer my questions! 

     I would like to ask you, you give me the attachment procedures‘AN4258-Bootloader_S12-updatedS12GN’, I can download directly after the use of it? I mean, you give me this program is a BOOTLOADER program, I don't need to make any changes, direct download it to the S12GN32 chip, then I built an application, you can directly through the serial communication to update the application? Is it necessary to change the contents of the.Prm file in my new application, and if so, how should I change it? Can you give me a detailed description of the document, from the new project to be able to use the instructions, I really need it, including specific steps, each step needs to be done, thank you!
    Thank you very much for your answer to my question! Wish you happy every day!

0 Kudos
Reply
2,475 Views
RadekS
NXP Employee
NXP Employee

Hi Jixiang,

The complete AN4258 software is located at:

http://www.nxp.com/files/microcontrollers/doc/app_note/AN4258SW.zip

The AN4258-Bootloader_S12-updatedS12GN file contains just slightly updated bootloader project from the AN4258SW package.

The documentation is still in the above-mentioned pdf file and AN4258SW package contains also example demo applications, Bootloader for S12X and tools for PLL and S-record file conversion.

The AN4258 Bootloader is designed as demo software. You may use it as it is, modify it or use it just as inspiration. Unfortunately, there is no guarantee or production certification for that code.

 

The bootloader typically needs modification in case of using different Clock (main.c), SCI module (Regdef.h),… or when we use a different signal for entering into bootloader mode (in the StartS12.s file)… The default AN4258-Bootloader_S12-updatedS12GN project use SCI0 and simple detection of PP0 pin level right after reset.

 

The S12 Bootloader occupies part of flash include default vector location (0xF000~0xFFFF). So, application linker file must be trimmed for that and application should use own vector table. See demo application in the AN4258SW package.

 

The generated application s19 file should be simply converted prior sending it through SCI. Using converted s19 file significantly simplifies bootloader logic.

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
2,475 Views
jixiangli
Contributor III

Dear Radek,

   Hello, I would like to add that.I direct the contents of the file“.s19” copy and paste into the PC serial communication assistant to send, interface display download success, but I run the program, the function is not normal, however I use BDM to download files“.s19”, run the program function is normal, I wonder whether my ".PRM" partition error? Or need to parse the file“.s19” and then send? What do I need to do, help me see, thank you very much!

pastedImage_1.png

0 Kudos
Reply
2,475 Views
RadekS
NXP Employee
NXP Employee

Hi Jixiang,

1. There is a problem with interrupt vectors in your application.

The PE generated vector table at default vectors position 0xFF80~0xFFFF. This area is already used by Bootloader. You have to create vector table somewhere else in Flash or RAM.

Please switch PE CPU inspector into the Advanced or Expert mode and set addresses for Reset vector table (for example 0xEEFA) and Interrupt vector table (for example 0xEE80).

S12GN32-relocated_vectors.png

2. The s19 file must be converted by SRecCvt utility prior loading into MCU. That will manage that S records will have correct address format and that S-record size is exactly 32B (it simplifies parser in bootloader code – in Srec.c file).

3. The flow control of your PC terminal must be set for XON/XOFF mode. Unfortunately, I do not know PC terminal from your picture. You should select “b” and send s19 file content as a text file. Since programming needs some time, we must use flow control. Otherwise, receive buffer will overflow.

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
2,475 Views
jixiangli
Contributor III

Dear Radek,

     Thank you for your patience!

      I basically understand the process, thank you very much! But when I use the software "SRecCvt-GUI", found that there is no S12GN32 driver, I need to manually add this driver, in order to convert ".S19" this file, how do I need to add it? How do you fill out the address? Thank you very much. Here's my screenshot:

pastedImage_1.png

pastedImage_2.png

pastedImage_3.png

The following figure is my "PE" tool to configure the memory after the screenshot:

pastedImage_4.png

0 Kudos
Reply
2,475 Views
RadekS
NXP Employee
NXP Employee

Hi Jixiang,

Thank you for more details. Now is clear what you mean by the S12GN32 driver.

 

I am sorry, that I forget to mention that.

Please select S12G128 for converting your s19 file.

Optionally you may add S12GN32 configuration by Add Device window or by simply adding a line into the DeviceInfo.Dat text file.

 

# Device          FlashStart  FlashEnd  PPAGEBase  NumPages  EEStart  EEEnd  FErasedState  SRecSize  Device Type

S12GN32,          8000,      BFFF,      E,         2,        0400,    07FF,  FF,             32,         s1218

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
2,475 Views
jixiangli
Contributor III

Dear Radek,

    Thank you very much indeed! 

    I've been able to convert the file“.S19” now!But my serial debugging assistant does not support sending text files,Do you have similar to send text file serial assistant software? FREESCALE is best for their own dedicated serial communication BOOTLOADER PC software for S12GN32, can you give me one? Thank you very much!

   You are the best and most experienced engineer I have ever met!

0 Kudos
Reply
2,475 Views
RadekS
NXP Employee
NXP Employee

Hi Jixiang,

You are welcome.

There should be plenty of serial terminals available on the web.

If fact, I still use Hyperterminal from WinXP (I just copy hypertrm.dll and hypertrm.exe into my Win7 x64 system) in most of the cases.

But, quite powerful replacement may be for example widely used TeraTerm or RealTerm tool.

I am not sure now whether NXP offers such tool (I never need it).

The sending ASCII file is simply just more comfortable that sending file content through the clipboard. It should not have any influence on the result.

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
2,475 Views
jixiangli
Contributor III

Dear Radek,

     Hello, forgive me ignorance!

     I am still working BOOTLOADER a little problem, I would like to set up my own APP procedures and BOOTLOADER procedures for you, you help me analyze the problem where? Okay? Esteem it a favor!Attachment is my own establishment of the APP program and BootLoader program.

    Happy everyday!

0 Kudos
Reply
2,475 Views
RadekS
NXP Employee
NXP Employee

Hi Jixiang,
The ROM area for Application and Bootloader must be separated. The meeting point between Application and Bootloader typically just Application start vector. So, Application does not know anything about the bootloader and vice versa.
From this point of view, the ROM_BOOTLOADER segment and ROM_F000 section in App linker file are quite useless information. Your App cannot operate at that part of flash used by Bootloader. But, this should not have any influence on functionality.

I can see the problem in App vectors:
The vector table in your APP (vectors.c) is defined at address 0xFF80U. That area is already occupied by the bootloader. Please configure proper address in PE per my previous recommendation:
https://community.nxp.com/thread/447344#comment-890099
If you already made that, you probably just forget to generate PE code.

Unfortunately, I made mistake in my recommendation. The Application start vector is defined in bootloader at address 0xEFFE. So, we have to either configure Reset vector table at address 0xEFFA or modify Start12.s file in bootloader and change line per your application settings:
AppResetVect:   equ     $effe ; here is stored reset vector of user application

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
2,475 Views
jixiangli
Contributor III

Dear Radek,

    Add a little more,I just directly modify the APP source code compiled through the BDM download to the microcontroller, can be successfully downloaded, but the program can not run, can not achieve the function, is it my ROM partition error? Thank you!

  But when I put the "reset vactor address" to 0xFFFA, "interrupt vactor address" to 0xFF80, and then re compiled, downloaded to the microcontroller through the BDM, to be able to run normally, the function is normal, table, table. 

Figure:

pastedImage_1.png

pastedImage_2.png

Here's a bit of my personal understanding, is that right?

pastedImage_3.png

You can see the address 0XFF80, 0XFFFA no problem, they do not overlap!Do not know how to understand, thank you! Do you need any changes?
This is just my point of view, you follow your instructions to me, thank you very much! Best illustrated!

0 Kudos
Reply
2,475 Views
RadekS
NXP Employee
NXP Employee

Hi Jixiang,

Note: doesn’t matter whether you select "effe" instead of "effa" in the bootloader. The S12(X) devices have three reset vectors (COP, CM, POR/LVR/Ext/…). The PE will create reset vector table at address 0xEFFA and fill it by three reset vector which all of them will point to the Application EntryPoint.

So, all 0xEFFA, 0xEFFC and 0xEFFE vectors have the same content (EntryPoint address).

 

It is OK when your application does not run when it is prepared for bootloader use and you load it by the debugger.

When you will load your application by the debugger, the default reset vectors (0xFFFA, 0xFFFC, and 0xFFFE) are erased and CPU will start to execute code from a wrong place.

When you load application by the bootloader, the default reset vectors (0xFFFA, 0xFFFC, and 0xFFFE) are filled by the bootloader and they point to Start12.s code. There is programmed rule for next execution of Bootloader or Application code.

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
2,478 Views
jixiangli
Contributor III

Dear Radek,

   Thank you for your reply, I would like to study, do not understand the need to ask you again, thank you!

0 Kudos
Reply
2,475 Views
jixiangli
Contributor III

Dear Radek,

   Thank you very much!According to your suggestion I revised the BOOTLOADER and APP program.

   This is a screenshot of the BOOTLOADER program changes:

pastedImage_1.png

    In the BOOTLOADER program only in this place will "effe" instead of "effa", other places remain unchanged.

   Here is a screenshot of the APP program:

pastedImage_1.png

pastedImage_2.png

pastedImage_3.png

pastedImage_4.png

Attachment is my revised "BOOTLOADER" and "APP" source, you help me look at this right? If you have the wrong place, please take your screenshot to help me analyze the show, thanks!

    

0 Kudos
Reply
2,475 Views
jixiangli
Contributor III

Dear Radek,

    Hello! I looked at the document, using the serial port to connect the circuit board and the computer, download the BOOTLOADER program has been able to communicate, the host computer can receive information, but also to erase success,As shown in the following figure:

pastedImage_1.png

pastedImage_1.png

Then I used the "ProcessorExpert" tool to create a new project "GN32App", and then modified the memory address in the ".PRM" file, as shown in the documentation:

pastedImage_2.png

pastedImage_3.png

This is a compiled file“.s19”

pastedImage_4.png

I still do not understand a bit, the compiled file “.s19”,downloaded to the microcontroller through the BOOTLOADER, how to parse the file“.s19”,You gave me a software"SRecCvt-GUI", there is no driver on the S12GN32, I tried to add a, no success, can you help me add one?The main task is to compile the new project files “.s19”downloaded to the microcontroller through the BOOTLOADER, how to do, how to parse the file“.s19”, what is it? Thank you

0 Kudos
Reply
2,475 Views
jixiangli
Contributor III

Dear Radek,

       Thank you very much for your reply, I first look at the document and routine, have not understand place to ask you again, thank you very much!

0 Kudos
Reply