S32G2 MCAL sample code building and import into S32DS

[S32G2 MCAL sample building and import into S32DS by using Serdes sample]

安裝環境:

  1. S32 design studio Version 3.5
  2. S32 Design Studio Platform Package 3.5.2
  3. S32 Design Studio Platform Tool Package 3.5.2
  4. 4_4.0.0 (SW32_RTD_4.4_4.0.0_D2210.exe)
  5. Cygwin64 (需增加make package)
  6. EB Tresos tool (27.1.0)

此篇文章是假設都已經安裝好相對應的軟體。

一、MCAL sample building

這裡介紹2種MCAL sample generate & build的做法:

第一種: (透過command line generate code)

1.打開cygwin64 terminal

並進入/cygdrive/c/NXP/SW32_RTD_4.4_4.0.0/eclipse/plugins/Serdes_TS_T40D11M40I0R0/examples/EBT/S32G2/Serdes_Example_EBT_S32G274A_M7_SGMII 的目錄。(依使用者安裝的目錄為主)

2.編輯project_parameters.mk 內的路徑

GCC_DIR = c:/NXP/S32DS.3.5/S32DS/build_tools/gcc_v9.2/gcc-9.2-arm32-eabi

TRESOS_DIR = C:/EB/tresos

ADDITIONAL_INCLUDE_DIRS = C:/NXP/SW32G_RTD_4.4_3.0.2/eclipse/plugins/Mcl_TS_T40D11M30I2R0/include/ C:/NXP/SW32G_RTD_4.4_3.0.2/eclipse/plugins/Eth_43_PFE_TS_T40D11M09I7R0/include/ C:/NXP/SW32G_RTD_4.4_3.0.2/eclipse/plugins/Gpt_TS_T40D11M30I2R0/include/        

3.編譯程式

$ make generate

$ make build

======================================================================

Creating directory for object files

Compiling ../../../../..//Platform_TS_T40D11M40I0R0/startup/src/m7/gcc/Vector_Table.s

Compiling ../../../../..//Platform_TS_T40D11M40I0R0/startup/src/m7/gcc/startup_cm7.s

Linking main.elf

若看到main.elf 代表已經build ok.

第二種: 透過EB tresos generate code. (可透過EB tresos IDE變更configuration)

1.選擇Menu File > Import , 在General tab 中選Existing Projects into workspace.

Figure1

2.按下Browse…選擇Serdes sample的位置,並勾選Projects及Copy projects into workspace. 之後再按下Finish.

Figure2

3.Project import 進來後,展開Serdes_example,在someld上按右鍵選Load Configuration.

Figure3

4. 在Generate code之前,可以更改generate code的位置,在Serdes_example project上按右鍵選Resources 可以看到Project Location.

Figure4

5. 在Code Generator tab可以看到Default Generation path. 建議改成 .\generate 。

執行Generate project時,輸出會產生在C:\EB\tresos\workspace\Serdes_Example_EBT_S32G274A_M7_SGMII\generate 目錄。

Figure5

6.在Serdes_example project上按右鍵選Generate Project.

Figure6

7.打開File explorer 在generate目錄下可以看到include/output/src 目錄。

Figure7

8.並把這三個目錄直接copy &paste 至C:/NXP/SW32_RTD_4.4_4.0.0/eclipse/plugins/Serdes_TS_T40D11M40I0R0/examples/EBT/S32G2/Serdes_Example_EBT_S32G274A_M7_SGMII

9. 編輯 project_parameters.mk 檔案內的路徑

GCC_DIR = c:/NXP/S32DS.3.5/S32DS/build_tools/gcc_v9.2/gcc-9.2-arm32-eabi

TRESOS_DIR = C:/EB/tresos

ADDITIONAL_INCLUDE_DIRS = C:/NXP/SW32G_RTD_4.4_3.0.2/eclipse/plugins/Mcl_TS_T40D11M30I2R0/include/ C:/NXP/SW32G_RTD_4.4_3.0.2/eclipse/plugins/Eth_43_PFE_TS_T40D11M09I7R0/include/ C:/NXP/SW32G_RTD_4.4_3.0.2/eclipse/plugins/Gpt_TS_T40D11M30I2R0/include/        

10.編譯程式

$ make build

======================================================================

Creating directory for object files

Compiling ../../../../..//Platform_TS_T40D11M40I0R0/startup/src/m7/gcc/Vector_Table.s

Compiling ../../../../..//Platform_TS_T40D11M40I0R0/startup/src/m7/gcc/startup_cm7.s

Linking main.elf

若看到main.elf 代表已經build ok.

二、MCAL project import into S32DS


EBT generate 出來的project 並無法直接給S32DS使用. 需要手動把code拉進S32DS中,以下就一步步介紹如何加入S32DS 中。
加入S32DS的好處就是可以透過S32G debugger probe 做source level debug

1. Menu File > New > S32DS Application project

Figure 2-1

2. 填寫Project name ,選擇platform S32G234M, 再按Next

Figure2-2

3. 若用不到Core M7_1, M7_2 ,不勾選這2個 I/O support 可以選Debugger console, Debugger 包留S32 Debugger, 再按Finish完成。

Figure2-3

4. Startup_code/Liner_files/ include/ src 目錄都用不到,要將之刪除。

Figure2-4

5.解壓MCAL.zip 至Serdes_demo project中。(因MCAL.zip可能有版權,不能分享; 請自行從C:\NXP\SW32_RTD_4.4_4.0.0\eclipse\plugins copy至MCAL folder)

6. 把之前Generate 出來的code (include/src/output) 拷貝至Serdes_demo project中。

Figure2-6

Figure2-7

7.在Serdes_demo project上按右鍵,並選Refresh。就會把新增的Folder/Files 加入S32DS project exploer中。

Figure2-8

8. 在S32DS Serdes_sample project上按右鍵選Properties, 在C compiler includes tab中加入MCAL folder各子目錄(module)的include path.

Figure2-9

9. 在EB tresos IDE中可以看出來Serdes_example 使用了 base/dem/EcuC/Eth/ Mcu/Platform/Port/Resources/Serdes module.

figure2-10

10. 在Serdes_demo project 上按右鍵並選用Build configuration explorer

figure2-11

11. 選擇base/dem/EcuC/Eth/ Mcu/Platform/Port/Resources/Serdes module加入building, 並包含最後的include /src folder也要加入。

figure2-12

12. 這時候就可以Build project, 但會遇到下面的問題.

問題1: Serdes_demo_2023_M7_0/include/OsIf_Cfg.h:47:10: fatal error: S32G274A_SYSTICK.h: No such file or directory

解決方法:加入 include path: "${ProjDirPath}/MCAL/Base_TS_T40D11M40I0R0/header"

問題2: Serdes_demo_2023_M7_0/include/check_example.h:82:43: error: 'VV_RESULT_ADDRESS' undeclared (first use in this function)

解決方法: 打開src/main.c mark //#include "check_example.h"

問題3:../MCAL/Platform_TS_T40D11M40I0R0/startup/src/sys_init.c:35:10: fatal error: sys_init.h: No such file or directory

解決方法: 加入 include path: "${ProjDirPath}/MCAL/Platform_TS_T40D11M40I0R0/startup/include"

問題4:make: *** No rule to make target 'C:/Users/Chenyu.Wang/workspaceS32DS.3.5/Serdes_demo_2023/Serdes_demo_2023_M7_0/Project_Settings/Linker_Files/S32G_M7_RAM.ld', needed by 'Serdes_demo_2023_M7_0.elf'.  Stop.

解決方法: 將S32G_M7_RAM.ld 改成"${ProjDirPath}/MCAL/Platform_TS_T40D11M40I0R0/build_files/gcc/linker_ram.ld"

Figure2-13

問題5:../MCAL/Eth_TS_T40D11M40I0R0/src/Eth.c:359: undefined reference to `Det_ReportError'

解決方法: 在Build configuration explorer 中加入Det module.

之後還會有其他的undefined reference,以相同的做法陸續加入Rte_TS / EthTrcv / EthSwt/ EthIf_TS

Figure2-14

問題6: ../MCAL/Platform_TS_T40D11M40I0R0/startup/src/m7/gcc/startup_cm7.s:134: multiple definition of `_start';

解決方法: 在Standard S32DS C Linker > General tab 勾選Do not use standard start files(-nostartfiles)

figure2-15

問題7: C:\Users\Chenyu.Wang\workspaceS32DS.3.5\Serdes_demo_2023\Serdes_demo_2023_M7_0\Debug_RAM/../src/main.c:107: undefined reference to `Exit_Example'

解決方法: 在src/main.c mark掉Exit_Example

13. Build 成功,有產生 elf files

Figure2-16

★博文內容均由個人提供,與平台無關,如有違法或侵權,請與網站管理員聯繫。

★文明上網,請理性發言。內容一周內被舉報5次,發文人進小黑屋喔~

評論