[S32K3 Tools Part] How to port RTD's existing MCAL demo to other K3 chips

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

[S32K3 Tools Part] How to port RTD's existing MCAL demo to other K3 chips

[S32K3 Tools Part] How to port RTD's existing MCAL demo to other K3 chips

[S32K3 Tools Part] How to port RTD's existing MCAL demo to other K3 chips

 1. Abstract

    From the release notes of NXP's RTD4.0.0, we can see that the supported chip models are very complete:


1.png

Fig 1

From this point, we can know that RTD4.0.0 can cover all S32K3 series chips. But if you want a ready-made demo, such as MCAL demo, you can see it under the ready-made demo path, for example:

C:\NXP\SW32K3_S32M27x_RTD_R21-11_4.0.0\eclipse\plugins\Dio_TS_T40D34M40I0R0\examples\EBT

Just S32K344,S32K358,S32K388,S32K396,S32M276。

Therefore, if you use other S32 chips, such as K312, in actual use, although it is within the range supported by RTD, but there is no ready-made demo to use, you need to do the porting by yourself. This article will explain how to port the RTD4.0.0 K344 MCAL demo to S32K312 and configure the corresponding EB project. First, implement the execution in the command line. After success, port the working MCAL code EB project to S32DS.

2. Platform and migration steps

2.1 Platform Description

This article is based on RTD4.0.0: SW32K3_S32M27x_RTD_R21-11_4.0.0

For other versions with patch or HF, the operation process is the same!

Hardware platform: S32K312 mini EVB or S32K312EVB

Other official EVBs, such as S32K31XEVB, or the customer's own S32K3 hardware board also have the same steps.

Due to the lack of official EVB boards, this article is based on S32K312 mini EVB, combined with P&E Multilink simulator download simulation. The platform situation is as follows:


2.png

Fig 2

2.2 Migration steps

The reference demo can be any existing demo in RTD4.0.0. In order to simplify the process, this article takes DIO as an example:

C:\NXP\SW32K3_S32M27x_RTD_R21-11_4.0.0\eclipse\plugins\Dio_TS_T40D34M40I0R0\examples\EBT\S32K3XX\Dio_Example_S32K344

2.2.1 Copy the project and configure

2.2.1.1 Copy the project

In order not to affect the original RTD default demo, here we directly copy a Dio_TS_T40D34M40I0R0 and open the path:

C:\NXP\SW32K3_S32M27x_RTD_R21-11_4.0.0\eclipse\plugins

Copy Dio_TS_T40D34M40I0R0 and save it in a folder named: Dio_TS_T40D34M40I0R0_miniK312_doc

The process for other chips is similar. You only need to change the chip name and related configuration to the required chip.

Open folder:

C:\NXP\SW32K3_S32M27x_RTD_R21-11_4.0.0\eclipse\plugins\Dio_TS_T40D34M40I0R0_miniK312_doc\examples\EBT\S32K3XX

Copy Dio_Example_S32K344 to Dio_Example_S32K312


3.png

Fig 3

   Open path:

C:\NXP\SW32K3_S32M27x_RTD_R21-11_4.0.0\eclipse\plugins\Dio_TS_T40D34M40I0R0_miniK312_doc\examples\EBT\S32K3XX\Dio_Example_S32K312\TresosProject

 Modify the EB project Dio_Example_S32K344 to Dio_Example_S32K312


4.png

Fig 4

2.2.1.2 Configure the project

Enter the newly created Dio_Example_S32K312, open the path with VScode, and save the VScode workspace to this path.

Modify project_parameters.mk:

GCC_DIR = C:/NXP/S32DS.3.5_RTD400/S32DS/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi
TRESOS_DIR = C:/EB/tresos_29_0_0
PLUGINS_DIR = C:/NXP/SW32K3_S32M27x_RTD_R21-11_4.0.0/eclipse/plugins
EXAMPLE_DERIVATIVE = S32K312
TRESO_PROJECT_NAME = Dio_Example_S32K312

​

5.png

Fig 5


6.png

Fig 6

Check_build_params.mk, delete the following code:

ifeq ("$(wildcard $(T32_DIR)/bin/windows/t32marm.exe)","")
    $(error Invalid path set to Trace32. \
    The provided path: from project_parameters.mk T32_DIR=$(T32_DIR) is invalid!)
endif

This part is used for lauterbach trace32. If it is not deleted, an error will be reported.

2.2.2 EB project configuration

The following is the configuration of the EB project. Open the EB tresos Studio 29.0 software and import the project.

File->Import->General->Existing Projects into Workspace, add the EB project path:

C:\NXP\SW32K3_S32M27x_RTD_R21-11_4.0.0\eclipse\plugins\Dio_TS_T40D34M40I0R0_miniK312_doc\examples\EBT\S32K3XX\Dio_Example_S32K312\TresosProject\Dio_Example_S32K312

Note, do not click copy projects into workspace!!!

Select the project Dio_Example_S32K344, right-click the mouse, and rename it to: Dio_Example_S32K312


7.png

Fig 7

Double-click someId to open the configuration module.

Open the Resource module, General->ResourceSubderivative select the target chip partbumber, here select: s32k312_hdqfp172

8.png

Fig 8

After saving, you will find many errors reported as follows:

9.png

Fig 9

There is no need to worry too much here, because if you analyze it carefully, you will find that it is actually because there are many modules on K344 that K312 does not have. So enter the error prompt location and delete the missing K312 module.

Mcu->McuModeSettingConf->McuPeripheral

If you click in, you can find that if the K312 does not have a module, there is a red cross in front of the peripheral Name.

10.png

Fig 10

The direct method is to delete all the error items, a total of 41.

After deleting, you can find that all the problems are gone:

11.png

Fig 11

Select someId in the project, right-click, and click Generate Code. You can see that the project can be generated without any errors.

12.png

Fig12

Don't take it lightly here. Although the code can be generated without error, there is still a place that needs to be modified.

Here, we can firstly close the EB tresos tool, then open terminal->new terminal in VScode and enter:

13.png

Fig13

We can see the error content is : mcucgm0_clockMux0/McuClockMux0Divider5, McuClockMux0Divider6, McuClkMux0Div5_En, McuClkMux0Div6_En.

Open S32KRM here, and you can see that K312 actually does not have MUX_0_5,6.

14.png

Fig 14

At this time, when I opened the EB tresos software again, there was indeed such an error on the interface, and there was no divider 5,6 option in mcucgmClockMux0.

15.png

Fig 15

Don't worry at this time, there is a way to fix this problem.

Close the EB tresos tool and open the text:

C:\NXP\SW32K3_S32M27x_RTD_R21-11_4.0.0\eclipse\plugins\Dio_TS_T40D34M40I0R0_miniK312_doc\examples\EBT\S32K3XX\Dio_Example_S32K312\TresosProject\Dio_Example_S32K312\config\ Mcu.xdm

file.

Directly turn off the enablement and value configuration of divider 5 and 6 in the file.

Modify the following code:Modified to:The main thing is to change the enable and frequency value of Mux0Divider5,6 hidden in the file.

Reopen it and you can see that the error disappears. Right-click on the EB project someId, generate project, and the code can be generated normally without error.

Here is a little trick: In order to prevent the mismatch between the previously generated code and the latest EB project, you can also change:

C:\NXP\SW32K3_S32M27x_RTD_R21-11_4.0.0\eclipse\plugins\Dio_TS_T40D34M40I0R0_miniK312_doc\examples\EBT\S32K3XX\Dio_Example_S32K312\generate

Folder:src,include clean it,then regenerate in EB tresos when generating a project.

Close the EB software and enter make generate again in the terminal of the Vscode project

You can see that there are no problems at this time:

16.png

Fig 16

 3.Command line compilation and result testing

From the above steps, the code and EB configuration migration of an existing RTD K344 project to a K312 MCAL project has been completed. Now, through VScode, command line form, generate main.elf, and then download and test.

Command:

make generate
make build

the main.elf can be found in the following folder path:

C:\NXP\SW32K3_S32M27x_RTD_R21-11_4.0.0\eclipse\plugins\Dio_TS_T40D34M40I0R0_miniK312_doc\examples\EBT\S32K3XX\Dio_Example_S32K312\out

Regarding testing, because there is a main.elf file and PE Multilink, you can create a new K312 project in S32DS. The debug interface is PE Multilink. After compiling and generating the code, copy main.elf to the Debug_FLASH folder of the new project. In the S32DS debug configuration, directly replace the C/C++ application with main.elf and download it for testing. 

17.png

Fig 17

As you can see, you can enter the debug interface, and the LED light on the actual test board can flash successfully.

This means that the MCAL code has been successfully ported to K312.

4. S32DS project migration and testing

      In the previous document:

https://community.nxp.com/t5/S32K-Knowledge-Base/S32K3-Tools-Part-How-to-import-RTD-EB-project-into-...

Previously, the RTD MCAL EB project was transplanted to the K344 project of S32DS. Simply modify the project name, project chip model, ld file, driver file inclusion, etc., then clean the project and compile the project.

     It is assumed here that you already have an RTD MCAL project imported into the S32DS project, and then modify it based on this.

4.1 S32DS Project Configuration

    Because the folder was copied under the original RTD folder, there is a newly created folder in the S32DS project Mcal_Plugins->Link_Source. This folder needs to be excluded from compilation:

Select Dio_TS_T40D34M40I0R0_minik312_doc, right-click Build path->remove from->Debug_FLASH.     

18.png

Fig 18

Rename the project from Mcal_Dio_S32K344_RTD400 to Mcal_Dio_S32K312_RTD400.

Modify the following project configuration, project->properties:

(1)preprocessor

S32K344->S32K312

19.png

Fig 19

  (2) Sstandard S32DS C Linker->General

Modify

"${MCAL_PLUGIN_PATH}/Platform${MCAL_MODULE_NAME_SUFFIX}/build_files/gcc/linker_flash_s32k344.ld"

To

"${MCAL_PLUGIN_PATH}/Platform${MCAL_MODULE_NAME_SUFFIX}/build_files/gcc/linker_flash_s32k312.ld"

After modification, click apply and close

Now, change the main.c content to the content in path: 

C:\NXP\SW32K3_S32M27x_RTD_R21-11_4.0.0\eclipse\plugins\Dio_TS_T40D34M40I0R0_miniK312_doc\examples\EBT\S32K3XX\Dio_Example_S32K312\src\main.c

Add header file:

#include "Port_Cfg.h"

Comment code:

// #include "check_example.h"
//    Exit_Example(TRUE);

 

4.2 EB project replacement

Copy:

C:\NXP\SW32K3_S32M27x_RTD_R21-11_4.0.0\eclipse\plugins\Dio_TS_T40D34M40I0R0_miniK312_doc\examples\EBT\S32K3XX\Dio_Example_S32K312\TresosProject\Dio_Example_S32K312\config

All the .xdm file to the S32DS EB folder, replace the old file:

Mcal_Dio_S32K312_RTD400\Tresos_Project\Mcal_Dio_S32K344_RTD400\config

Use the EB tresos open the above project, then Generate project,after the code is generated, close the EB project, back to the S32DS side.

4.3 MCAL S32DS project testing

clean project:project->clean project,  then build the project

20.png

Fig 20

You can see that it can be compiled successfully, then RUN->debug configuration selects the downloaded code xxx_Debug_FLASH_PNE. Note that you need to change the Device from S32K344 to S32K312

21.png

Fig 21

After successful configuration, click debug, download the code and simulate. The results are as follows:

22.png

Fig 22

As you can see, we can successfully enter debug, and the light on the board is actually blinking, which means that the RTD MCAL project demo can be successfully ported to S32K312 S32DS.

 

 

 

 

 

添付
評価なし
バージョン履歴
最終更新日:
‎10-03-2024 02:21 AM
更新者: