S32K342 CAN bootloader sample code implement problem

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

S32K342 CAN bootloader sample code implement problem

Jump to solution
3,530 Views
HarrySu
Contributor II

Hello NXP, @nxf10035 

Sorry, I have deleted that comment.

I am working on S32K342 CAN bootloader,I have refered the sample code S32K344_CAN_Bootloader_RTD2d0 in

https://community.nxp.com/t5/S32K-Knowledge-Base/Unified-bootloader-Demo/ta-p/1423099

, but I got the complier error below, Mcal.h didn't exist in my project, How can this problem be resolved? My IDE is RTD v2.0.3. Thanks!

HarrySu_0-1686709001698.png

1 Solution
3,488 Views
nxf10035
NXP Employee
NXP Employee

Hi,

     It's might be compatibility problem of RTD2.0 with RTD2.0.3. Suggestion you can

1. create another project over RTD2.0.3

2. Configure peripherals reference bootloader project

3. Copy all bootloader code including link file to new project without RTD and generate code

4. Compare two projects and new project code should the same with old project

5. C40_IP.c should follow old project

BR 

Tomlin

View solution in original post

0 Kudos
32 Replies
655 Views
JonAnder_Amante
Contributor I

Hi, 

I am using the project "S32K344_Can_bootloader_RTD200" in the microprocessor S32K344. I want to download an application with the program of bootloader. I have achieved the jump from program to application but I have different questions.

1. I want to use #define EN_DELAY_TIME but when I uncomment the command in the folder "public_inc", the program has different errors. My target to use "Backdoor", that is to say, I want to check if the program has to enter to bootloader or not. I don´t know the process and the different functions that I have to use to achieve the target. I want to use the function "Boot_CheckReqBootloaderMode(void)" but when I debug the program, it never enters to the "if". Could you explain me the process and the steps to achieve the target. I add different functions that I think are important. 

2. I don´t know if I have to modificate the parameters of "static tJumpAppDelayTimeInfo gs_stJumpAPPDelayTimeInfo = {FALSE, 0u};". I have to change this structure ? You can see all structure in one of the next pictures. 

I need the reply as soon as possible since I have to send a project very soon. 

JonAnder_Amante_0-1712230938279.png

 

 

JonAnder_Amante_1-1712230938258.png

 

 

JonAnder_Amante_2-1712230938289.png

 

 

JonAnder_Amante_3-1712230938305.png

 

 

JonAnder_Amante_4-1712230938269.png

 

 

 

Thank you for all, 

Jon Ander Amante Jorge

0 Kudos
518 Views
nxf10035
NXP Employee
NXP Employee

Hi, @JonAnder_Amante 

   The DELAY_MAX_TIME_MS is used to, enter bootloader mode and have not received any UDS commands, if waiting DELAY_MAX_TIME_MS timeout, then jump to APP if APP is valid. You un-need to modify the global variable or content.

BR

Tomlin

0 Kudos
467 Views
JonAnder_Amante
Contributor I

Hi, 

I have a problem when I try to use "#define EN_DELAY_TIME", if I uncomment this command I have different errors and I don´t know how solve the problem. I don´t the reason of error, could you give solve my question as soon as possible because I have to send the project very soon.

Thank you for all, 

JonAnder_Amante_0-1712908227485.png

JonAnder_Amante_1-1712908296294.png

Jon Ander Amante

0 Kudos
262 Views
nxf10035
NXP Employee
NXP Employee

Hi, @JonAnder_Amante 

    I checked the code. The error maybe we have not used feature in new bootloader version. So, always disable the macro. If you want to enable the feature, suggestion:

1. Create a new function in uds_app_cfg.c

 void  UDS_Cfg_Init(void)

{

#ifdef EN_DELAY_TIME
gs_stJumpAPPDelayTimeInfo.jumpToAPPDelayTime = UdsAppTimeToCount(DELAY_MAX_TIME_MS);
#endif

}

2.  UDS_Init

   -Remove the code  

      #ifdef EN_DELAY_TIME
gs_stJumpAPPDelayTimeInfo.jumpToAPPDelayTime = UdsAppTimeToCount(DELAY_MAX_TIME_MS);
     #endif

 - Call UDS_Cfg_Init(); in UDS_Init

Hope this can help you!

BR

Tomlin

0 Kudos
237 Views
JonAnder_Amante
Contributor I

Hi, 

At now I dont´t receive the error of implementation but I have different questions about this. I don´t know how I can send the request to enter to bootloader. I have looked and I have seen that in my program the function "if(gs_stBootInfo.requestEnterBootloader == *((uint8*)gs_stBootInfo.requestEnterBootloaderAddr))" never is True so I think that I have a problem in this function. I also send you the value of these parameters. Maybe the configuration is done from "ECUBUS" application but I don´t know how send the request of bootloader (I have also sent you the picture of the ECUBUS because perhaps I have to do some configuration in ECUBUS).

I need your reply as soon as possible because I have to send the project very soon. 

Thank you for all,

JonAnder_Amante_10-1713856263602.png

JonAnder_Amante_11-1713856619875.pngJonAnder_Amante_12-1713856701038.pngJonAnder_Amante_13-1713856737649.png

JonAnder_Amante_14-1713856794874.png

 

 

0 Kudos
211 Views
nxf10035
NXP Employee
NXP Employee

Hello,

    ECU-BUS send the UDS command (0x10 0x02) will trigger the APP reset and enter bootloader. If only have bootloader in MCU, then the bootloader will not reset.

BR

Tomlin

0 Kudos
183 Views
JonAnder_Amante
Contributor I

Hi,

1. I don´t understand what you have explained me so could you tell me the steps to achieve that this function to be True "if(gs_stBootInfo.requestEnterBootloader == *((uint8*)gs_stBootInfo.requestEnterBootloaderAddr))".

2. Moreover, coould you tell me how I can send the request of bootloader because I don´t know how to do it.

3. Finally, could you tell me the purpose to send the service "WriteDataByIdentifer". I send you different pictures again. 

Thank you for all, 

JonAnder_Amante_0-1713939442206.pngJonAnder_Amante_1-1713939458569.pngJonAnder_Amante_2-1713939473749.pngJonAnder_Amante_3-1713939493966.pngJonAnder_Amante_4-1713939511231.png

 

0 Kudos
3,489 Views
nxf10035
NXP Employee
NXP Employee

Hi,

     It's might be compatibility problem of RTD2.0 with RTD2.0.3. Suggestion you can

1. create another project over RTD2.0.3

2. Configure peripherals reference bootloader project

3. Copy all bootloader code including link file to new project without RTD and generate code

4. Compare two projects and new project code should the same with old project

5. C40_IP.c should follow old project

BR 

Tomlin

0 Kudos
3,030 Views
HarrySu
Contributor II

Hello nxf10035,

Many thanks for your advice and guidance. It has given me a good direction.

Since I am still a beginner in the field of Bootloaders, I would like to confirm something with you.

Q1. The difference between the sample codes 'project _S32K344_APP_Demo_RTD2d0' and 'project _S32K344_CAN_Bootloader_RTD2d0,' is that the APP code serves as the object to be programmed via CAN, while the Bootloader code is the main code for the MCU, which needs to be programmed using the regular programming method. Am I understanding this correctly?"

 

Q2. In my own Application code do I need to include the 'APP_bootloader_exchange_info' file from the sample code's App src directory? This allows the MCU to update the firmware via CAN while it is running?

 

Best Regards,

Harry

0 Kudos
3,013 Views
nxf10035
NXP Employee
NXP Employee

Hi, Harry,

   Answer as following:

Q1. The difference between the sample codes 'project _S32K344_APP_Demo_RTD2d0' and 'project _S32K344_CAN_Bootloader_RTD2d0,' is that the APP code serves as the object to be programmed via CAN, while the Bootloader code is the main code for the MCU, which needs to be programmed using the regular programming method. Am I understanding this correctly?"

Tomlin: Yes, most of time the APP programed by bootloader.

Q2. In my own Application code do I need to include the 'APP_bootloader_exchange_info' file from the sample code's App src directory? This allows the MCU to update the firmware via CAN while it is running?

Tomlin: No, the APP_bootloader_exchange_info is used to exchange information between APP with bootloader when needed to update APP. APP should integrate UDS stack. Suggestion you can reference OEM spec.

BR

Tomlin

0 Kudos
2,917 Views
HarrySu
Contributor II

Hello Tomlin @nxf10035 ,

Thanks for previous advice, I have already build successfully on S32K342 MCU using S32K344 CAN bootloader sample code, FW could be programmed into MCU too.

HarrySu_1-1687749736068.png

But I encounter another problem now. I have connected PEAK CAN donggle to GUI ECUBus.

I import the ECUBUS_344CAN_uds.json to PCAN UDS schedule from sample file: S32K3xx\S32K344_CAN\

When I click "start" on GUI, there is an error below show : Write from 0xb to 0x16 with RA 0x0,result:undefined

How can i solve this problem? Thanks!

HarrySu_0-1687749582024.png

Best Regards,

Harry

0 Kudos
2,896 Views
nxf10035
NXP Employee
NXP Employee

Hi, @HarrySu ,

   Did you config the CAN info as following?

nxf10035_0-1687832927800.png

BR

Tomlin

0 Kudos
2,860 Views
HarrySu
Contributor II

Hello Tom @nxf10035 ,

Thanks for your reply, my CAN config setting is below, I followed the PDF:ECU-Bus User Guide page4 setting.

HarrySu_0-1687852570264.png

HarrySu_1-1687852570233.png

 

 

About config setting on S32K342, I have an one different setting from S32K344 CAN boot loader.
In below picture, Number Of MB :14, 14 is the maximum value that I can set in S32K342.
But S32K344 set Number Of MB :16, will it cause any error on CAN communication?

HarrySu_2-1687852569864.png

 

 

Best Regards,

Harry

0 Kudos
2,853 Views
nxf10035
NXP Employee
NXP Employee

Hi, @HarrySu 

  We just test on PCAN-USB Pro. What's your hardware type? I think you can send UDS message(0x02 0x10 0x03) to verify the hardware and bootloader working  normally or not in GUI.

 

BR

Tomlin

0 Kudos
2,847 Views
HarrySu
Contributor II

Hello Tom @nxf10035 ,

This is my PEAK CAN Pro HW type:

https://www.microport.com.tw/prod/CAN-Bus-%E6%8E%A7%E5%88%B6%E5%99%A8%E5%8D%80%E5%9F%9F%E7%B6%B2%E8%...

About the UDS Message,

Did you mean use PCAN view directly transmit id:0x784 payload:0x02 0x10 0x03? ( PCAN setting show below)

MCU didn't response anything.

HarrySu_0-1687854275460.png

HarrySu_1-1687854384590.png

BR

Harry

 

0 Kudos
2,842 Views
nxf10035
NXP Employee
NXP Employee

Hi, @HarrySu 

    Looks like the hardware is the same. Yes, PCAN view send the UDS message. If you choose CANFD, please select  nominal bit rate and data bit rate are 500K.

BR

Tomlin

0 Kudos
2,839 Views
HarrySu
Contributor II

Hello Tom @nxf10035 ,

What is the number of CAN ID?, could you please show the PCAN view message window?

I also want to know what the message will MCU bootloader response, Thanks a lot!

 

Best Regards,

Harry

0 Kudos
2,835 Views
nxf10035
NXP Employee
NXP Employee

Hi, @HarrySu 

    The PCAN View send: ID(0x784)  data: 0x02 0x10 0x03. Bootloader response: ID(0x7F0) data: 0x02 0x50 0x03 Please note, the IDs are default IDs, if you are modified. Theses CAN IDs will be changed.

 

BR

Tomlin

0 Kudos
2,794 Views
HarrySu
Contributor II

Hello Tom @nxf10035 ,

I think the problem may be that I didn't include cpu.h and port.h in the includes.h previously,

but now that I have added them, it says that cpu.h and port.h cannot be found. How can I resolve this issue? Thanks!

HarrySu_0-1687931679551.png

 

HarrySu_1-1687931698818.png

Best Regards,

Harry

 

0 Kudos
2,790 Views
nxf10035
NXP Employee
NXP Employee

Hi, @HarrySu 

      The CPU.h and port.h is used other platform. For S32K342, you should follow S32K3x2 bootloader configuration and linkfile. S32K3x4 and S32K3x2 have some different.

BR 

Tomlin