diff --git a/.metadata/.tirex/am243x.content.tirex.json b/.metadata/.tirex/am243x.content.tirex.json index eff71d4..7003713 100644 --- a/.metadata/.tirex/am243x.content.tirex.json +++ b/.metadata/.tirex/am243x.content.tirex.json @@ -255,6 +255,134 @@ ] ] }, + { + "resourceType": "project.ccs", + "resourceClass": [ + "example" + ], + "resourceSubClass": [ + "example.gettingstarted" + ], + "description": "A simple test vector of ClARKE-PARK-IPARK-SVGEN data verification CPU is R5FSS0-0 running NORTOS.", + "name": "transforms_test", + "location": "../../examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/example.projectspec", + "devtools": [ + "AM243x_GP_EVM" + ], + "kernel": [ + "nortos" + ], + "compiler": [ + "ticlang" + ], + "subCategories": [ + "transforms", + "transforms_test", + "r5fss0-0_nortos" + ], + "mainCategories": [ + [ + "Examples", + "Development Tools" + ] + ] + }, + { + "resourceType": "project.ccs", + "resourceClass": [ + "example" + ], + "resourceSubClass": [ + "example.gettingstarted" + ], + "description": "A simple test vector of ClARKE-PARK-IPARK-SVGEN data verification CPU is R5FSS0-0 running FREERTOS.", + "name": "transforms_test", + "location": "../../examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec", + "devtools": [ + "AM243x_GP_EVM" + ], + "kernel": [ + "freertos" + ], + "compiler": [ + "ticlang" + ], + "subCategories": [ + "transforms", + "transforms_test", + "r5fss0-0_freertos" + ], + "mainCategories": [ + [ + "Examples", + "Development Tools" + ] + ] + }, + { + "resourceType": "project.ccs", + "resourceClass": [ + "example" + ], + "resourceSubClass": [ + "example.gettingstarted" + ], + "description": "A simple test vector of ClARKE-PARK-IPARK-SVGEN data verification CPU is R5FSS0-0 running NORTOS.", + "name": "transforms_test", + "location": "../../examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec", + "devtools": [ + "AM243x_LAUNCHPAD" + ], + "kernel": [ + "nortos" + ], + "compiler": [ + "ticlang" + ], + "subCategories": [ + "transforms", + "transforms_test", + "r5fss0-0_nortos" + ], + "mainCategories": [ + [ + "Examples", + "Development Tools" + ] + ] + }, + { + "resourceType": "project.ccs", + "resourceClass": [ + "example" + ], + "resourceSubClass": [ + "example.gettingstarted" + ], + "description": "A simple test vector of ClARKE-PARK-IPARK-SVGEN data verification CPU is R5FSS0-0 running FREERTOS.", + "name": "transforms_test", + "location": "../../examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec", + "devtools": [ + "AM243x_LAUNCHPAD" + ], + "kernel": [ + "freertos" + ], + "compiler": [ + "ticlang" + ], + "subCategories": [ + "transforms", + "transforms_test", + "r5fss0-0_freertos" + ], + "mainCategories": [ + [ + "Examples", + "Development Tools" + ] + ] + }, { "resourceType": "project.ccs", "resourceClass": [ diff --git a/.metadata/.tirex/am263x.content.tirex.json b/.metadata/.tirex/am263x.content.tirex.json index d8a821a..b9f264d 100644 --- a/.metadata/.tirex/am263x.content.tirex.json +++ b/.metadata/.tirex/am263x.content.tirex.json @@ -255,6 +255,134 @@ ] ] }, + { + "resourceType": "project.ccs", + "resourceClass": [ + "example" + ], + "resourceSubClass": [ + "example.gettingstarted" + ], + "description": "A simple test vector of ClARKE-PARK-IPARK-SVGEN data verification CPU is R5FSS0-0 running NORTOS.", + "name": "transforms_test", + "location": "../../examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/example.projectspec", + "devtools": [ + "TMDSCNCD263" + ], + "kernel": [ + "nortos" + ], + "compiler": [ + "ticlang" + ], + "subCategories": [ + "transforms", + "transforms_test", + "r5fss0-0_nortos" + ], + "mainCategories": [ + [ + "Examples", + "Development Tools" + ] + ] + }, + { + "resourceType": "project.ccs", + "resourceClass": [ + "example" + ], + "resourceSubClass": [ + "example.gettingstarted" + ], + "description": "A simple test vector of ClARKE-PARK-IPARK-SVGEN data verification CPU is R5FSS0-0 running FREERTOS.", + "name": "transforms_test", + "location": "../../examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec", + "devtools": [ + "TMDSCNCD263" + ], + "kernel": [ + "freertos" + ], + "compiler": [ + "ticlang" + ], + "subCategories": [ + "transforms", + "transforms_test", + "r5fss0-0_freertos" + ], + "mainCategories": [ + [ + "Examples", + "Development Tools" + ] + ] + }, + { + "resourceType": "project.ccs", + "resourceClass": [ + "example" + ], + "resourceSubClass": [ + "example.gettingstarted" + ], + "description": "A simple test vector of ClARKE-PARK-IPARK-SVGEN data verification CPU is R5FSS0-0 running NORTOS.", + "name": "transforms_test", + "location": "../../examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec", + "devtools": [ + "LP-AM263" + ], + "kernel": [ + "nortos" + ], + "compiler": [ + "ticlang" + ], + "subCategories": [ + "transforms", + "transforms_test", + "r5fss0-0_nortos" + ], + "mainCategories": [ + [ + "Examples", + "Development Tools" + ] + ] + }, + { + "resourceType": "project.ccs", + "resourceClass": [ + "example" + ], + "resourceSubClass": [ + "example.gettingstarted" + ], + "description": "A simple test vector of ClARKE-PARK-IPARK-SVGEN data verification CPU is R5FSS0-0 running FREERTOS.", + "name": "transforms_test", + "location": "../../examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec", + "devtools": [ + "LP-AM263" + ], + "kernel": [ + "freertos" + ], + "compiler": [ + "ticlang" + ], + "subCategories": [ + "transforms", + "transforms_test", + "r5fss0-0_freertos" + ], + "mainCategories": [ + [ + "Examples", + "Development Tools" + ] + ] + }, { "resourceType": "project.ccs", "resourceClass": [ diff --git a/.project/device/project_am243x.js b/.project/device/project_am243x.js index 6a894e7..c4b8345 100644 --- a/.project/device/project_am243x.js +++ b/.project/device/project_am243x.js @@ -18,6 +18,7 @@ const device_defines = { const example_file_list = [ "examples/dcl/dcl_df22/.project/mcsdk_project.js", "examples/dcl/dcl_pi/.project/mcsdk_project.js", + "examples/transforms/transforms_test/.project/mcsdk_project.js", "examples/position_sense/endat_diagnostic/single_channel/.project/project.js", "examples/position_sense/endat_diagnostic/multi_channel_load_share/.project/project.js", "examples/position_sense/endat_diagnostic/multi_channel_single_pru/.project/project.js", diff --git a/.project/device/project_am263x.js b/.project/device/project_am263x.js index 0d39e30..86238c5 100644 --- a/.project/device/project_am263x.js +++ b/.project/device/project_am263x.js @@ -13,6 +13,7 @@ const device_defines = { const example_file_list = [ "examples/dcl/dcl_df22/.project/mcsdk_project.js", "examples/dcl/dcl_pi/.project/mcsdk_project.js", + "examples/transforms/transforms_test/.project/mcsdk_project.js", "examples/position_sense/tamagawa_diagnostic_over_soc_uart/.project/project.js", ]; diff --git a/docs_src/docs/api_guide/components/transforms/transforms.cfg b/docs_src/docs/api_guide/components/transforms/transforms.cfg new file mode 100644 index 0000000..317d80e --- /dev/null +++ b/docs_src/docs/api_guide/components/transforms/transforms.cfg @@ -0,0 +1,5 @@ +INPUT+= $(MOTOR_CONTROL_SDK_PATH)/docs_src/docs/api_guide/components/transforms/transforms.md +INPUT+= $(MOTOR_CONTROL_SDK_PATH)/source/transforms/clarke/clarke.h +INPUT+= $(MOTOR_CONTROL_SDK_PATH)/source/transforms/park/park.h +INPUT+= $(MOTOR_CONTROL_SDK_PATH)/source/transforms/ipark/ipark.h +INPUT+= $(MOTOR_CONTROL_SDK_PATH)/source/transforms/svgen/svgen.h \ No newline at end of file diff --git a/docs_src/docs/api_guide/components/transforms/transforms.md b/docs_src/docs/api_guide/components/transforms/transforms.md new file mode 100644 index 0000000..521698e --- /dev/null +++ b/docs_src/docs/api_guide/components/transforms/transforms.md @@ -0,0 +1,85 @@ +# Transformation Algorithm {#Transforms} + +[TOC] + +## Introduction + +The Transformation module consists of transformation commonly found in motor-control applications. + +## Features Supported + +Transformation module includes: + +- Clarke transformation +- Park transformation +- Inverse Park transformation +- Space Vector Generation (SVGEN) + - Common-mode subtraction approach +- DPWM Generation (Part of SVGEN) + - Maximum Modulation + - Minimum Modulation + +## Features Not Supported + +N/A + +## Benchmark Results + +A benchmark on R5F core has been conducted to observe the following results when running the following functions: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Transform Function + Cpu Cycles +
Clarke Transform
CLARKE_run_twoInput16
CLARKE_run_threeInput18
Park Transform
PARK_run19*
Inverse Park Transform
IPARK_run19*
Space Vector Generation
SVGEN_runCom41
DPWM Generation
SVGEN_runMax36
SVGEN_runMin36
+ + \* Note both PARK and IPARK does not include trigonometric calculations of phasor. For R5F core, it's recommened to leverage the fast ti_arm_sincos() function found in ti_arm_trig/mathlib of MCU+ SDK. +- Ran with TI Clang Compiler v3.2.0.LTS, with -Os flag and functions force-inlined onto the benchmarking function placed in TCM memory. Obtained the average result from 600 consecutive loops of running transform functions with DPL CycleCountP, mimicking the usage of a control loop. +- Actual result may vary depending on provided datasets and memory configuration. For R5F, it is recommended for users to map control loops to TCM for the best performance. +## Provided Examples + +The following examples has been provided to demonstrate transformation module: + +- \ref EXAMPLES_TRANSFORMS_TEST + +## Additional References {#DCL_ADDITIONAL_REFERENCES} + +N/A + +## API + +\ref TRANSFORMS_API_MODULE diff --git a/docs_src/docs/api_guide/device/am243x/examples.cfg b/docs_src/docs/api_guide/device/am243x/examples.cfg index 4c1e872..9f9a643 100644 --- a/docs_src/docs/api_guide/device/am243x/examples.cfg +++ b/docs_src/docs/api_guide/device/am243x/examples.cfg @@ -8,3 +8,4 @@ INPUT+= $(MOTOR_CONTROL_SDK_PATH)/docs_src/docs/api_guide/examples/dcl/dcl_pi/dc INPUT+= $(MOTOR_CONTROL_SDK_PATH)/docs_src/docs/api_guide/examples/dcl/dcl_df22/dcl_df22.md INPUT+= $(MOTOR_CONTROL_SDK_PATH)/docs_src/docs/api_guide/examples/pruicss_pwm_dutycycle.md INPUT+= $(MOTOR_CONTROL_SDK_PATH)/docs_src/docs/api_guide/examples/pruicss_pwm_epwm_sync.md +INPUT+= $(MOTOR_CONTROL_SDK_PATH)/docs_src/docs/api_guide/examples/transforms/transforms_test/transforms_test.md diff --git a/docs_src/docs/api_guide/device/am263x/examples.cfg b/docs_src/docs/api_guide/device/am263x/examples.cfg index 00a46fe..65743af 100644 --- a/docs_src/docs/api_guide/device/am263x/examples.cfg +++ b/docs_src/docs/api_guide/device/am263x/examples.cfg @@ -1,4 +1,5 @@ INPUT+= $(MOTOR_CONTROL_SDK_PATH)/docs_src/docs/api_guide/examples/examples.md INPUT+= $(MOTOR_CONTROL_SDK_PATH)/docs_src/docs/api_guide/examples/tamagawa_uart_example.md INPUT+= $(MOTOR_CONTROL_SDK_PATH)/docs_src/docs/api_guide/examples/dcl/dcl_pi/dcl_pi.md -INPUT+= $(MOTOR_CONTROL_SDK_PATH)/docs_src/docs/api_guide/examples/dcl/dcl_df22/dcl_df22.md \ No newline at end of file +INPUT+= $(MOTOR_CONTROL_SDK_PATH)/docs_src/docs/api_guide/examples/dcl/dcl_df22/dcl_df22.md +INPUT+= $(MOTOR_CONTROL_SDK_PATH)/docs_src/docs/api_guide/examples/transforms/transforms_test/transforms_test.md \ No newline at end of file diff --git a/docs_src/docs/api_guide/examples/examples.md b/docs_src/docs/api_guide/examples/examples.md index a70b6ee..1068225 100644 --- a/docs_src/docs/api_guide/examples/examples.md +++ b/docs_src/docs/api_guide/examples/examples.md @@ -23,6 +23,7 @@ This page lists all the examples and demos supported in this SDK. - RTLibs -# \subpage EXAMPLES_DCL_PI -# \subpage EXAMPLES_DCL_DF22 + -# \subpage EXAMPLES_TRANSFORMS_TEST - PRUICSS PWM -# \subpage EXAMPLE_PRUICSS_PWM_DUTY_CYCLE -# \subpage EXAMPLE_PRUICSS_PWM_EPWM_SYNC @@ -34,4 +35,5 @@ This page lists all the examples and demos supported in this SDK. - RTLibs -# \subpage EXAMPLES_DCL_PI -# \subpage EXAMPLES_DCL_DF22 + -# \subpage EXAMPLES_TRANSFORMS_TEST \endcond diff --git a/docs_src/docs/api_guide/examples/transforms/transforms_test/transforms_test.md b/docs_src/docs/api_guide/examples/transforms/transforms_test/transforms_test.md new file mode 100644 index 0000000..e9c0019 --- /dev/null +++ b/docs_src/docs/api_guide/examples/transforms/transforms_test/transforms_test.md @@ -0,0 +1,109 @@ +# CLAKRE-PARK-ICLARKE-SVGEN Test {#EXAMPLES_TRANSFORMS_TEST} + +[TOC] + +Simple data test incorporating foc-related libraries + +This example runs verifies various transforms libraries used in motor-control application, +specifically as a building block of Field of Control (FOC) motor design. + +It demonstrates how to run clarke, park, inverse park transform and +space-vector generation (svgen). This test trys to mimic a conventional +workflow of passing current values into clarke transform, then park, then +inverse park (PI controllers are neglected here but should exist for both open and close-loop design) +and finally passing to svgen to generate the three-phase ABC value. + +The test used an aribitary phasor angle that feeds into park/ipark, +as opposed to an angle generation module required by an actual FOC design. + +The test vector then compares the PARK, SVGEN results to ensure the integraty of the library. + + + +## Files and directory structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Folder/Files + Description +
${SDK_INSTALL_PATH}/examples/transforms/transforms_test
transforms_test.cMain function for transforms library testing
transforms_test.hContains all initialization of test strctures and variables
${SDK_INSTALL_PATH}/source/transforms
clarke/Folder containing CLARKE library source
park/Folder containing PARK library source
ipark/Folder containing IPARK library source
svgen/Folder containing SVGEN library source
+ +# Supported Combinations {#EXAMPLES_TRANSFORMS_TEST_COMBO} + +\cond SOC_AM64X + + Parameter | Value + ---------------|----------- + CPU + OS | r5fss0-0 nortos + ^ | r5fss0-0 freertos + Toolchain | ti-arm-clang + Board | @VAR_BOARD_NAME_LOWER, @VAR_SK_BOARD_NAME_LOWER + Example folder | examples/transforms/transforms_test + +\endcond + +\cond SOC_AM243X + + Parameter | Value + ---------------|----------- + CPU + OS | r5fss0-0 nortos + ^ | r5fss0-0 freertos + Toolchain | ti-arm-clang + Boards | @VAR_BOARD_NAME_LOWER, @VAR_LP_BOARD_NAME_LOWER + Example folder | examples/transforms/transforms_test + +\endcond + +\cond SOC_AM263X + + Parameter | Value + ---------------|----------- + CPU + OS | r5fss0-0 nortos + ^ | r5fss0-0 freertos + Toolchain | ti-arm-clang + Boards | @VAR_BOARD_NAME_LOWER, @VAR_LP_BOARD_NAME_LOWER + Example folder | examples/transforms/transforms_test + +\endcond + +# Steps to Run the Example + +- **When using CCS projects to build**, import the CCS project for the required combination and build it using the CCS project menu (see Using SDK with CCS Projects ). +- **When using makefiles to build**, note the required combination and build using make command (see Using SDK with Makefiles ). +- Launch a CCS debug session and run the executable, see CCS Launch, Load and Run + +### Sample Output + +Shown below is a sample output when the application is run, assuming when all test passes: + +\code +Transforms test produced 0 error +\endcode diff --git a/examples/dcl/dcl_pi/.project/mcsdk_project_am243x.js b/examples/dcl/dcl_pi/.project/mcsdk_project_am243x.js index 456e789..8985489 100644 --- a/examples/dcl/dcl_pi/.project/mcsdk_project_am243x.js +++ b/examples/dcl/dcl_pi/.project/mcsdk_project_am243x.js @@ -189,8 +189,12 @@ const templates_freertos_m4f = const buildOptionCombos = [ { device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am243x-evm", os: "nortos"}, { device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am243x-evm", os: "freertos"}, + //{ device: device, cpu: "m4fss0-0", cgt: "ti-arm-clang", board: "am243x-evm", os: "nortos"}, + //{ device: device, cpu: "m4fss0-0", cgt: "ti-arm-clang", board: "am243x-evm", os: "freertos"}, { device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am243x-lp", os: "nortos"}, { device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am243x-lp", os: "freertos"}, + //{ device: device, cpu: "m4fss0-0", cgt: "ti-arm-clang", board: "am243x-lp", os: "nortos"}, + //{ device: device, cpu: "m4fss0-0", cgt: "ti-arm-clang", board: "am243x-lp", os: "freertos"}, ]; function getComponentProperty() { diff --git a/examples/dcl/dcl_pi/am243x-lp/r5fss0-0_nortos/example.syscfg b/examples/dcl/dcl_pi/am243x-lp/r5fss0-0_nortos/example.syscfg index da89522..66307ac 100644 --- a/examples/dcl/dcl_pi/am243x-lp/r5fss0-0_nortos/example.syscfg +++ b/examples/dcl/dcl_pi/am243x-lp/r5fss0-0_nortos/example.syscfg @@ -1,7 +1,7 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM243x_ALX_beta" --package "ALX" --part "ALX" --context "r5fss0-0" --product "MOTOR_CONTROL_SDK_AM243X@09.01.00" + * @cliArgs --device "AM243x_ALX_beta" --package "ALX" --part "ALX" --context "r5fss0-0" --product "MOTOR_CONTROL_SDK_AM243x@09.01.00" * @versions {"tool":"1.18.0+3266"} */ diff --git a/examples/dcl/dcl_pi/am263x-lp/r5fss0-0_nortos/example.syscfg b/examples/dcl/dcl_pi/am263x-lp/r5fss0-0_nortos/example.syscfg index 1dbd694..e59fc50 100644 --- a/examples/dcl/dcl_pi/am263x-lp/r5fss0-0_nortos/example.syscfg +++ b/examples/dcl/dcl_pi/am263x-lp/r5fss0-0_nortos/example.syscfg @@ -1,7 +1,7 @@ /** * These arguments were used when this file was generated. They will be automatically applied on subsequent loads * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. - * @cliArgs --device "AM263x_beta" --package "ZCZ" --part "AM263x" --context "r5fss0-0" --product "MOTOR_CONTROL_SDK_AM263X@09.01.00" + * @cliArgs --device "AM263x_beta" --package "ZCZ" --part "AM263x" --context "r5fss0-0" --product "MOTOR_CONTROL_SDK_AM263x@09.01.00" * @versions {"tool":"1.18.0+3266"} */ diff --git a/examples/dcl/dcl_pi/pi_test.h b/examples/dcl/dcl_pi/pi_test.h index 5f6e72a..0be310d 100644 --- a/examples/dcl/dcl_pi/pi_test.h +++ b/examples/dcl/dcl_pi/pi_test.h @@ -64,10 +64,12 @@ int PI_runTest(DCL_PI *ctrl_handle, DCL_PI_FUNC dcl_pi_func); //! DCL_PI *pi_controller = &(DCL_PI) { - .Kp = 2.50000f, - .Ki = 0.01000f, - .Umax = 2.00000f, - .Umin = -2.00000f, + .Kp = 2.5f, + .Ki = 0.01f, + .Umax = 2.0f, + .Umin = -2.0f, + .Imax = 1.0f, + .Imin = -1.0f, PI_INT_DEFAULTS // macro for default values of internal attributes }; diff --git a/examples/transforms/transforms_test/.project/mcsdk_project.js b/examples/transforms/transforms_test/.project/mcsdk_project.js new file mode 100644 index 0000000..4c25148 --- /dev/null +++ b/examples/transforms/transforms_test/.project/mcsdk_project.js @@ -0,0 +1,14 @@ +function getComponentProperty(device) +{ + return require(`./mcsdk_project_${device}`).getComponentProperty(); +}; + +function getComponentBuildProperty(buildOption) +{ + return require(`./mcsdk_project_${buildOption.device}`).getComponentBuildProperty(buildOption); +}; + +module.exports = { + getComponentProperty, + getComponentBuildProperty, +}; diff --git a/examples/transforms/transforms_test/.project/mcsdk_project_am243x.js b/examples/transforms/transforms_test/.project/mcsdk_project_am243x.js new file mode 100644 index 0000000..6a56aea --- /dev/null +++ b/examples/transforms/transforms_test/.project/mcsdk_project_am243x.js @@ -0,0 +1,267 @@ +let path = require('path'); + +let device = "am243x"; + +const files = { + common: [ + /* Project Files */ + "transforms_test.c", + "main.c", + /* Dataset */ + /* Libraries */ + ], +}; + +const projectspec_files = { + common: [ + "../../../transforms_test.h", + ] +} + +/* Relative to where the makefile will be generated + * Typically at /// + */ +const filedirs = { + common: [ + "..", /* core_os_combo base */ + "../../..", /* Example base */ + ], +}; + +const libdirs_nortos = { + common: [ + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/nortos/lib", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib", + ], +}; + +const libdirs_freertos = { + common: [ + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/lib", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib", + ], +}; + +const includes_nortos_r5f = { + common: [ + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/park", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/trig", + ], +}; + +const includes_freertos_r5f = { + common: [ + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/FreeRTOS-Kernel/include", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/config/am243x/r5f", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/park", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/trig", + ], +}; + +const includes_nortos_m4f = { + common: [ + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/park", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen" + ], +}; + +const includes_freertos_m4f = { + common: [ + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/FreeRTOS-Kernel/include", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CM4F", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/config/am243x/m4f", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/park", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen" + ], +}; + +const libs_nortos_r5f = { + common: [ + "nortos.am243x.r5f.ti-arm-clang.${ConfigName}.lib", + "drivers.am243x.r5f.ti-arm-clang.${ConfigName}.lib", + "board.am243x.r5f.ti-arm-clang.${ConfigName}.lib", + "mathlib.am243x.r5f.ti-arm-clang.${ConfigName}.lib", + ], +}; + +const libs_freertos_r5f = { + common: [ + "freertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib", + "drivers.am243x.r5f.ti-arm-clang.${ConfigName}.lib", + "board.am243x.r5f.ti-arm-clang.${ConfigName}.lib", + "mathlib.am243x.r5f.ti-arm-clang.${ConfigName}.lib", + ], +}; + +const libs_nortos_m4f = { + common: [ + "nortos.am243x.m4f.ti-arm-clang.${ConfigName}.lib", + "drivers.am243x.m4f.ti-arm-clang.${ConfigName}.lib", + "board.am243x.m4f.ti-arm-clang.${ConfigName}.lib", + ], +}; + +const libs_freertos_m4f = { + common: [ + "freertos.am243x.m4f.ti-arm-clang.${ConfigName}.lib", + "drivers.am243x.m4f.ti-arm-clang.${ConfigName}.lib", + "board.am243x.m4f.ti-arm-clang.${ConfigName}.lib", + ], +}; + +const lnkfiles = { + common: [ + "linker.cmd", + ] +}; + +const syscfgfile = "../example.syscfg"; + +const readmeDoxygenPageTag = "EXAMPLES_TRANSFORMS_TEST"; + +const templates_nortos_r5f = +[ + { + input: ".project/templates/am243x/common/linker_r5f.cmd.xdt", + output: "linker.cmd", + }, + { + input: ".project/templates/am243x/nortos/main_nortos.c.xdt", + output: "../main.c", + options: { + entryFunction: "transforms_test_main", + }, + } +]; + +const templates_freertos_r5f = +[ + { + input: ".project/templates/am243x/common/linker_r5f.cmd.xdt", + output: "linker.cmd", + }, + { + input: ".project/templates/am243x/freertos/main_freertos.c.xdt", + output: "../main.c", + options: { + entryFunction: "transforms_test_main", + }, + } +]; + + +const templates_nortos_m4f = +[ + { + input: ".project/templates/am243x/common/linker_m4f.cmd.xdt", + output: "linker.cmd", + }, + { + input: ".project/templates/am243x/nortos/main_nortos.c.xdt", + output: "../main.c", + options: { + entryFunction: "transforms_test_main", + }, + } +]; + +const templates_freertos_m4f = +[ + { + input: ".project/templates/am243x/common/linker_m4f.cmd.xdt", + output: "linker.cmd", + }, + { + input: ".project/templates/am243x/freertos/main_freertos.c.xdt", + output: "../main.c", + options: { + entryFunction: "transforms_test_main", + }, + } +]; + +const buildOptionCombos = [ + { device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am243x-evm", os: "nortos"}, + { device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am243x-evm", os: "freertos"}, + { device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am243x-lp", os: "nortos"}, + { device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am243x-lp", os: "freertos"}, +]; + +function getComponentProperty() { + let property = {}; + + property.dirPath = path.resolve(__dirname, ".."); + property.type = "executable"; + property.name = "transforms_test"; + property.isInternal = false; + property.tirexResourceSubClass = [ "example.gettingstarted" ]; + property.description = "A simple test vector of ClARKE-PARK-IPARK-SVGEN data verification" + property.buildOptionCombos = buildOptionCombos; + + return property; +} + +function getComponentBuildProperty(buildOption) { + let build_property = {}; + + build_property.files = files; + build_property.filedirs = filedirs; + build_property.libdirs = libdirs_nortos; + build_property.lnkfiles = lnkfiles; + build_property.syscfgfile = syscfgfile; + build_property.readmeDoxygenPageTag = readmeDoxygenPageTag; + build_property.projectspec_files = projectspec_files; + + if(buildOption.cpu.match(/r5f*/)) { + if(buildOption.os.match(/freertos*/) ) + { + build_property.includes = includes_freertos_r5f; + build_property.libdirs = libdirs_freertos; + build_property.libs = libs_freertos_r5f; + build_property.templates = templates_freertos_r5f; + } + else + { + build_property.includes = includes_nortos_r5f; + build_property.libs = libs_nortos_r5f; + build_property.templates = templates_nortos_r5f; + } + } + if(buildOption.cpu.match(/m4f*/)) { + if(buildOption.os.match(/freertos*/) ) + { + build_property.includes = includes_freertos_m4f; + build_property.libdirs = libdirs_freertos; + build_property.libs = libs_freertos_m4f; + build_property.templates = templates_freertos_m4f; + } + else + { + build_property.includes = includes_nortos_m4f; + build_property.libs = libs_nortos_m4f; + build_property.templates = templates_nortos_m4f; + } + } + + return build_property; +} + +module.exports = { + getComponentProperty, + getComponentBuildProperty, +}; diff --git a/examples/transforms/transforms_test/.project/mcsdk_project_am263x.js b/examples/transforms/transforms_test/.project/mcsdk_project_am263x.js new file mode 100644 index 0000000..c92b5ab --- /dev/null +++ b/examples/transforms/transforms_test/.project/mcsdk_project_am263x.js @@ -0,0 +1,186 @@ +let path = require('path'); + +let device = "am263x"; + +const files = { + common: [ + /* Project Files */ + "transforms_test.c", + "main.c", + /* Dataset */ + /* Libraries */ + ], +}; + +const projectspec_files = { + common: [ + "../../../transforms_test.h", + ] +} + +/* Relative to where the makefile will be generated + * Typically at /// + */ +const filedirs = { + common: [ + "..", /* core_os_combo base */ + "../../..", /* Example base */ + ], +}; + +const libdirs_nortos = { + common: [ + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/nortos/lib", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib", + ], +}; + +const libdirs_freertos = { + common: [ + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/lib", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib", + ], +}; + +const includes_nortos_r5f = { + common: [ + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/park", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/trig", + ], +}; + +const includes_freertos_r5f = { + common: [ + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/FreeRTOS-Kernel/include", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/config/am263x/r5f", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/park", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark", + "${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen", + "${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/trig", + ], +}; + +const libs_nortos_r5f = { + common: [ + "nortos.am263x.r5f.ti-arm-clang.${ConfigName}.lib", + "drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib", + "board.am263x.r5f.ti-arm-clang.${ConfigName}.lib", + "mathlib.am263x.r5f.ti-arm-clang.${ConfigName}.lib", + ], +}; + +const libs_freertos_r5f = { + common: [ + "freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib", + "drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib", + "board.am263x.r5f.ti-arm-clang.${ConfigName}.lib", + "mathlib.am263x.r5f.ti-arm-clang.${ConfigName}.lib", + ], +}; + + +const lnkfiles = { + common: [ + "linker.cmd", + ] +}; + +const syscfgfile = "../example.syscfg"; + +const readmeDoxygenPageTag = "EXAMPLES_TRANSFORMS_TEST"; + +const templates_nortos_r5f = +[ + { + input: ".project/templates/am263x/common/linker_r5f.cmd.xdt", + output: "linker.cmd", + }, + { + input: ".project/templates/am263x/nortos/main_nortos.c.xdt", + output: "../main.c", + options: { + entryFunction: "transforms_test_main", + }, + } +]; + +const templates_freertos_r5f = +[ + { + input: ".project/templates/am263x/common/linker_r5f.cmd.xdt", + output: "linker.cmd", + }, + { + input: ".project/templates/am263x/freertos/main_freertos.c.xdt", + output: "../main.c", + options: { + entryFunction: "transforms_test_main", + }, + } +]; + + +const buildOptionCombos = [ + { device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am263x-cc", os: "nortos"}, + { device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am263x-cc", os: "freertos"}, + { device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am263x-lp", os: "nortos"}, + { device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am263x-lp", os: "freertos"}, +]; + +function getComponentProperty() { + let property = {}; + + property.dirPath = path.resolve(__dirname, ".."); + property.type = "executable"; + property.name = "transforms_test"; + property.isInternal = false; + property.tirexResourceSubClass = [ "example.gettingstarted" ]; + property.description = "A simple test vector of ClARKE-PARK-IPARK-SVGEN data verification" + property.buildOptionCombos = buildOptionCombos; + + return property; +} + +function getComponentBuildProperty(buildOption) { + let build_property = {}; + + build_property.files = files; + build_property.filedirs = filedirs; + build_property.libdirs = libdirs_nortos; + build_property.lnkfiles = lnkfiles; + build_property.syscfgfile = syscfgfile; + build_property.readmeDoxygenPageTag = readmeDoxygenPageTag; + build_property.projectspec_files = projectspec_files; + + if(buildOption.cpu.match(/r5f*/)) { + if(buildOption.os.match(/freertos*/) ) + { + build_property.includes = includes_freertos_r5f; + build_property.libdirs = libdirs_freertos; + build_property.libs = libs_freertos_r5f; + build_property.templates = templates_freertos_r5f; + } + else + { + build_property.includes = includes_nortos_r5f; + build_property.libs = libs_nortos_r5f; + build_property.templates = templates_nortos_r5f; + } + } + + return build_property; +} + +module.exports = { + getComponentProperty, + getComponentBuildProperty, +}; diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/example.syscfg b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/example.syscfg new file mode 100644 index 0000000..53ece92 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/example.syscfg @@ -0,0 +1,62 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM243x_ALV_beta" --package "ALV" --part "ALV" --context "r5fss0-0" --product "MOTOR_CONTROL_SDK_AM243X@07.03.00" + * @versions {"data":"2021012919","timestamp":"2021012919","tool":"1.8.0+1785","templates":null} + */ + +/** + * Import the modules used in this configuration. + */ +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const mpu_armv76 = mpu_armv7.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART_CONSOLE"; +debug_log.uartLog.UART.$assign = "USART0"; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x41010000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x60000000; +mpu_armv75.size = 28; +mpu_armv75.accessPermissions = "Supervisor RD, User RD"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.baseAddr = 0x80000000; +mpu_armv76.size = 31; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +debug_log.uartLog.UART.RXD.$suggestSolution = "UART0_RXD"; +debug_log.uartLog.UART.TXD.$suggestSolution = "UART0_TXD"; diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/main.c b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/main.c new file mode 100644 index 0000000..23423e1 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/main.c @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2018-2021 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" +#include "FreeRTOS.h" +#include "task.h" + +#define MAIN_TASK_PRI (configMAX_PRIORITIES-1) + +#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE)) +StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32))); + +StaticTask_t gMainTaskObj; +TaskHandle_t gMainTask; + +void transforms_test_main(void *args); + +void freertos_main(void *args) +{ + transforms_test_main(NULL); + + vTaskDelete(NULL); +} + + +int main(void) +{ + /* init SOC specific modules */ + System_init(); + Board_init(); + + /* This task is created at highest priority, it should create more tasks and then delete itself */ + gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */ + "freertos_main", /* Text name for the task. This is to facilitate debugging only. */ + MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */ + NULL, /* We are not using the task parameter. */ + MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */ + gMainTaskStack, /* pointer to stack base */ + &gMainTaskObj ); /* pointer to statically allocated task object memory */ + configASSERT(gMainTask != NULL); + + /* Start the scheduler to start the tasks executing. */ + vTaskStartScheduler(); + + /* The following line should never be reached because vTaskStartScheduler() + will only return if there was not enough FreeRTOS heap memory available to + create the Idle and (if configured) Timer tasks. Heap management, and + techniques for trapping heap exhaustion, are described in the book text. */ + DebugP_assertNoLog(0); + + return 0; +} diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/dcl_linker_r5f_am243x_sitara.cmd b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/dcl_linker_r5f_am243x_sitara.cmd new file mode 100644 index 0000000..9eca059 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/dcl_linker_r5f_am243x_sitara.cmd @@ -0,0 +1,19 @@ +/* +* This linker file is optional, it's complementary to the device/core linker file +* Here it specifies the dcl function & data mapping allocated by __attribute__((section(...))) +* and link to a specific memory region for the best performance +*/ + +/* Define core & platform specific variables */ +#define FAST_RAM R5F_TCMB0 /* R5F_TCMA also works */ +#define REG_RAM MSRAM + +SECTIONS +{ + /* dcl functions mapped to on-chip fast ram */ + dclfuncs : {} > FAST_RAM + + /* optional -- map datas & variables to regular ram */ + /* Sitara default linker should already map variables to ram */ + dclDataSection : {} > REG_RAM +} \ No newline at end of file diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec new file mode 100644 index 0000000..49c055b --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/linker.cmd b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/linker.cmd new file mode 100644 index 0000000..69640f4 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/linker.cmd @@ -0,0 +1,148 @@ + +/* This is the stack that is used by code running within main() + * In case of NORTOS, + * - This means all the code outside of ISR uses this stack + * In case of FreeRTOS + * - This means all the code until vTaskStartScheduler() is called in main() + * uses this stack. + * - After vTaskStartScheduler() each task created in FreeRTOS has its own stack + */ +--stack_size=16384 +/* This is the heap size for malloc() API in NORTOS and FreeRTOS + * This is also the heap used by pvPortMalloc in FreeRTOS + */ +--heap_size=32768 +-e_vectors /* This is the entry of the application, _vector MUST be plabed starting address 0x0 */ + +/* This is the size of stack when R5 is in IRQ mode + * In NORTOS, + * - Here interrupt nesting is enabled + * - This is the stack used by ISRs registered as type IRQ + * In FreeRTOS, + * - Here interrupt nesting is disabled + * - This is stack that is used initally when a IRQ is received + * - But then the mode is switched to SVC mode and SVC stack is used for all user ISR callbacks + * - Hence in FreeRTOS, IRQ stack size is less and SVC stack size is more + */ +__IRQ_STACK_SIZE = 256; +/* This is the size of stack when R5 is in IRQ mode + * - In both NORTOS and FreeRTOS nesting is disabled for FIQ + */ +__FIQ_STACK_SIZE = 256; +__SVC_STACK_SIZE = 4096; /* This is the size of stack when R5 is in SVC mode */ +__ABORT_STACK_SIZE = 256; /* This is the size of stack when R5 is in ABORT mode */ +__UNDEFINED_STACK_SIZE = 256; /* This is the size of stack when R5 is in UNDEF mode */ + +SECTIONS +{ + /* This has the R5F entry point and vector table, this MUST be at 0x0 */ + .vectors:{} palign(8) > R5F_VECS + + /* This has the R5F boot code until MPU is enabled, this MUST be at a address < 0x80000000 + * i.e this cannot be placed in DDR + */ + GROUP { + .text.hwi: palign(8) + .text.cache: palign(8) + .text.mpu: palign(8) + .text.boot: palign(8) + .text:abort: palign(8) /* this helps in loading symbols when using XIP mode */ + } > MSRAM + + /* This is rest of code. This can be placed in DDR if DDR is available and needed */ + GROUP { + .text: {} palign(8) /* This is where code resides */ + .rodata: {} palign(8) /* This is where const's go */ + } > MSRAM + + /* This is rest of initialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + .data: {} palign(8) /* This is where initialized globals and static go */ + } > MSRAM + + /* This is rest of uninitialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + .bss: {} palign(8) /* This is where uninitialized globals go */ + RUN_START(__BSS_START) + RUN_END(__BSS_END) + .sysmem: {} palign(8) /* This is where the malloc heap goes */ + .stack: {} palign(8) /* This is where the main() stack goes */ + } > MSRAM + + /* This is where the stacks for different R5F modes go */ + GROUP { + .irqstack: {. = . + __IRQ_STACK_SIZE;} align(8) + RUN_START(__IRQ_STACK_START) + RUN_END(__IRQ_STACK_END) + .fiqstack: {. = . + __FIQ_STACK_SIZE;} align(8) + RUN_START(__FIQ_STACK_START) + RUN_END(__FIQ_STACK_END) + .svcstack: {. = . + __SVC_STACK_SIZE;} align(8) + RUN_START(__SVC_STACK_START) + RUN_END(__SVC_STACK_END) + .abortstack: {. = . + __ABORT_STACK_SIZE;} align(8) + RUN_START(__ABORT_STACK_START) + RUN_END(__ABORT_STACK_END) + .undefinedstack: {. = . + __UNDEFINED_STACK_SIZE;} align(8) + RUN_START(__UNDEFINED_STACK_START) + RUN_END(__UNDEFINED_STACK_END) + } > MSRAM + + /* Sections needed for C++ projects */ + GROUP { + .ARM.exidx: {} palign(8) /* Needed for C++ exception handling */ + .init_array: {} palign(8) /* Contains function pointers called before main */ + .fini_array: {} palign(8) /* Contains function pointers called after main */ + } > MSRAM + + /* General purpose user shared memory, used in some examples */ + .bss.user_shared_mem (NOLOAD) : {} > USER_SHM_MEM + /* this is used when Debug log's to shared memory are enabled, else this is not used */ + .bss.log_shared_mem (NOLOAD) : {} > LOG_SHM_MEM + /* this is used only when IPC RPMessage is enabled, else this is not used */ + .bss.ipc_vring_mem (NOLOAD) : {} > RTOS_NORTOS_IPC_SHM_MEM + /* General purpose non cacheable memory, used in some examples */ + .bss.nocache (NOLOAD) : {} > NON_CACHE_MEM +} + +/* +NOTE: Below memory is reserved for DMSC usage + - During Boot till security handoff is complete + 0x701E0000 - 0x701FFFFF (128KB) + - After "Security Handoff" is complete (i.e at run time) + 0x701F4000 - 0x701FFFFF (48KB) + + Security handoff is complete when this message is sent to the DMSC, + TISCI_MSG_SEC_HANDOVER + + This should be sent once all cores are loaded and all application + specific firewall calls are setup. +*/ + +MEMORY +{ + R5F_VECS : ORIGIN = 0x00000000 , LENGTH = 0x00000040 + R5F_TCMA : ORIGIN = 0x00000040 , LENGTH = 0x00007FC0 + R5F_TCMB0 : ORIGIN = 0x41010000 , LENGTH = 0x00008000 + + /* memory segment used to hold CPU specific non-cached data, MAKE to add a MPU entry to mark this as non-cached */ + NON_CACHE_MEM : ORIGIN = 0x70060000 , LENGTH = 0x8000 + + /* when using multi-core application's i.e more than one R5F/M4F active, make sure + * this memory does not overlap with other R5F's + */ + MSRAM : ORIGIN = 0x70080000 , LENGTH = 0x40000 + + /* This section can be used to put XIP section of the application in flash, make sure this does not overlap with + * other CPUs. Also make sure to add a MPU entry for this section and mark it as cached and code executable + */ + FLASH : ORIGIN = 0x60100000 , LENGTH = 0x80000 + + /* shared memory segments */ + /* On R5F, + * - make sure there is a MPU entry which maps below regions as non-cache + */ + USER_SHM_MEM : ORIGIN = 0x701D0000, LENGTH = 0x180 + LOG_SHM_MEM : ORIGIN = 0x701D0000 + 0x180, LENGTH = 0x00004000 - 0x180 + RTOS_NORTOS_IPC_SHM_MEM : ORIGIN = 0x701D4000, LENGTH = 0x0000C000 +} diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile new file mode 100644 index 0000000..04fa007 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile @@ -0,0 +1,312 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak +include $(MOTOR_CONTROL_SDK_PATH)/devconfig/devconfig.mak + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=transforms_test.$(PROFILE).out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=transforms_test.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=transforms_test.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=transforms_test.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=transforms_test.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=transforms_test.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=transforms_test.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=transforms_test.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=transforms_test.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) +ifeq ($(DEVICE_TYPE), HS) + TARGETS += $(BOOTIMAGE_NAME_HS) +endif + +FILES_common := \ + transforms_test.c \ + main.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source \ + -I${MOTOR_CONTROL_SDK_PATH}/source \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/FreeRTOS-Kernel/include \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/config/am243x/r5f \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/park \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/trig \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM243X \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-deprecated-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lfreertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lboard.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lmathlib.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + + +LIBS_NAME = \ + freertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + board.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + mathlib.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + +all: $(TARGETS) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +$(OUTNAME): syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) + @echo . + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am243x:r5fss0-0:freertos:ti-arm-clang transforms_test ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --context r5fss0-0 --part ALV --package ALV --output generated/ ../example.syscfg + +syscfg-gui: + $(SYSCFG_NWJS) $(SYSCFG_PATH) --product $(SYSCFG_SDKPRODUCT) --device AM243x_ALV_beta --context r5fss0-0 --part ALV --package ALV --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CERT_KEY=$(APP_SIGNING_KEY) + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! + @echo . + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS_FS) Done !!! + @echo . + +$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +ifeq ($(DEVICE_TYPE), HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME)-enc +endif + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo . +endif +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 0000000..8666cfd --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,106 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - MOTOR_CONTROL_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include ${MOTOR_CONTROL_SDK_PATH}/imports.mak +include ${MOTOR_CONTROL_SDK_PATH}/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs_fs +ifeq ($(DEVICE_TYPE),HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME)-enc +endif +endif + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! + @echo . +ifeq ($(DEVICE_TYPE),HS) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs Done !!! + @echo . +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs_fs Done !!! + @echo . +endif +endif diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec new file mode 100644 index 0000000..793b8e7 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(MOTOR_CONTROL_SDK_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 0000000..c2be5da --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "mcu_plus_sdk/kernel/freertos/rov/FreeRTOS.rov.js", +]; diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/example.syscfg b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/example.syscfg new file mode 100644 index 0000000..53ece92 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/example.syscfg @@ -0,0 +1,62 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM243x_ALV_beta" --package "ALV" --part "ALV" --context "r5fss0-0" --product "MOTOR_CONTROL_SDK_AM243X@07.03.00" + * @versions {"data":"2021012919","timestamp":"2021012919","tool":"1.8.0+1785","templates":null} + */ + +/** + * Import the modules used in this configuration. + */ +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const mpu_armv76 = mpu_armv7.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART_CONSOLE"; +debug_log.uartLog.UART.$assign = "USART0"; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x41010000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x60000000; +mpu_armv75.size = 28; +mpu_armv75.accessPermissions = "Supervisor RD, User RD"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.baseAddr = 0x80000000; +mpu_armv76.size = 31; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +debug_log.uartLog.UART.RXD.$suggestSolution = "UART0_RXD"; +debug_log.uartLog.UART.TXD.$suggestSolution = "UART0_TXD"; diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/main.c b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/main.c new file mode 100644 index 0000000..d50c8c2 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/main.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2018-2021 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" + +void transforms_test_main(void *args); + +int main(void) +{ + System_init(); + Board_init(); + + transforms_test_main(NULL); + + Board_deinit(); + System_deinit(); + + return 0; +} diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/example.projectspec b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/example.projectspec new file mode 100644 index 0000000..2fa7604 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/example.projectspec @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/linker.cmd b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/linker.cmd new file mode 100644 index 0000000..69640f4 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/linker.cmd @@ -0,0 +1,148 @@ + +/* This is the stack that is used by code running within main() + * In case of NORTOS, + * - This means all the code outside of ISR uses this stack + * In case of FreeRTOS + * - This means all the code until vTaskStartScheduler() is called in main() + * uses this stack. + * - After vTaskStartScheduler() each task created in FreeRTOS has its own stack + */ +--stack_size=16384 +/* This is the heap size for malloc() API in NORTOS and FreeRTOS + * This is also the heap used by pvPortMalloc in FreeRTOS + */ +--heap_size=32768 +-e_vectors /* This is the entry of the application, _vector MUST be plabed starting address 0x0 */ + +/* This is the size of stack when R5 is in IRQ mode + * In NORTOS, + * - Here interrupt nesting is enabled + * - This is the stack used by ISRs registered as type IRQ + * In FreeRTOS, + * - Here interrupt nesting is disabled + * - This is stack that is used initally when a IRQ is received + * - But then the mode is switched to SVC mode and SVC stack is used for all user ISR callbacks + * - Hence in FreeRTOS, IRQ stack size is less and SVC stack size is more + */ +__IRQ_STACK_SIZE = 256; +/* This is the size of stack when R5 is in IRQ mode + * - In both NORTOS and FreeRTOS nesting is disabled for FIQ + */ +__FIQ_STACK_SIZE = 256; +__SVC_STACK_SIZE = 4096; /* This is the size of stack when R5 is in SVC mode */ +__ABORT_STACK_SIZE = 256; /* This is the size of stack when R5 is in ABORT mode */ +__UNDEFINED_STACK_SIZE = 256; /* This is the size of stack when R5 is in UNDEF mode */ + +SECTIONS +{ + /* This has the R5F entry point and vector table, this MUST be at 0x0 */ + .vectors:{} palign(8) > R5F_VECS + + /* This has the R5F boot code until MPU is enabled, this MUST be at a address < 0x80000000 + * i.e this cannot be placed in DDR + */ + GROUP { + .text.hwi: palign(8) + .text.cache: palign(8) + .text.mpu: palign(8) + .text.boot: palign(8) + .text:abort: palign(8) /* this helps in loading symbols when using XIP mode */ + } > MSRAM + + /* This is rest of code. This can be placed in DDR if DDR is available and needed */ + GROUP { + .text: {} palign(8) /* This is where code resides */ + .rodata: {} palign(8) /* This is where const's go */ + } > MSRAM + + /* This is rest of initialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + .data: {} palign(8) /* This is where initialized globals and static go */ + } > MSRAM + + /* This is rest of uninitialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + .bss: {} palign(8) /* This is where uninitialized globals go */ + RUN_START(__BSS_START) + RUN_END(__BSS_END) + .sysmem: {} palign(8) /* This is where the malloc heap goes */ + .stack: {} palign(8) /* This is where the main() stack goes */ + } > MSRAM + + /* This is where the stacks for different R5F modes go */ + GROUP { + .irqstack: {. = . + __IRQ_STACK_SIZE;} align(8) + RUN_START(__IRQ_STACK_START) + RUN_END(__IRQ_STACK_END) + .fiqstack: {. = . + __FIQ_STACK_SIZE;} align(8) + RUN_START(__FIQ_STACK_START) + RUN_END(__FIQ_STACK_END) + .svcstack: {. = . + __SVC_STACK_SIZE;} align(8) + RUN_START(__SVC_STACK_START) + RUN_END(__SVC_STACK_END) + .abortstack: {. = . + __ABORT_STACK_SIZE;} align(8) + RUN_START(__ABORT_STACK_START) + RUN_END(__ABORT_STACK_END) + .undefinedstack: {. = . + __UNDEFINED_STACK_SIZE;} align(8) + RUN_START(__UNDEFINED_STACK_START) + RUN_END(__UNDEFINED_STACK_END) + } > MSRAM + + /* Sections needed for C++ projects */ + GROUP { + .ARM.exidx: {} palign(8) /* Needed for C++ exception handling */ + .init_array: {} palign(8) /* Contains function pointers called before main */ + .fini_array: {} palign(8) /* Contains function pointers called after main */ + } > MSRAM + + /* General purpose user shared memory, used in some examples */ + .bss.user_shared_mem (NOLOAD) : {} > USER_SHM_MEM + /* this is used when Debug log's to shared memory are enabled, else this is not used */ + .bss.log_shared_mem (NOLOAD) : {} > LOG_SHM_MEM + /* this is used only when IPC RPMessage is enabled, else this is not used */ + .bss.ipc_vring_mem (NOLOAD) : {} > RTOS_NORTOS_IPC_SHM_MEM + /* General purpose non cacheable memory, used in some examples */ + .bss.nocache (NOLOAD) : {} > NON_CACHE_MEM +} + +/* +NOTE: Below memory is reserved for DMSC usage + - During Boot till security handoff is complete + 0x701E0000 - 0x701FFFFF (128KB) + - After "Security Handoff" is complete (i.e at run time) + 0x701F4000 - 0x701FFFFF (48KB) + + Security handoff is complete when this message is sent to the DMSC, + TISCI_MSG_SEC_HANDOVER + + This should be sent once all cores are loaded and all application + specific firewall calls are setup. +*/ + +MEMORY +{ + R5F_VECS : ORIGIN = 0x00000000 , LENGTH = 0x00000040 + R5F_TCMA : ORIGIN = 0x00000040 , LENGTH = 0x00007FC0 + R5F_TCMB0 : ORIGIN = 0x41010000 , LENGTH = 0x00008000 + + /* memory segment used to hold CPU specific non-cached data, MAKE to add a MPU entry to mark this as non-cached */ + NON_CACHE_MEM : ORIGIN = 0x70060000 , LENGTH = 0x8000 + + /* when using multi-core application's i.e more than one R5F/M4F active, make sure + * this memory does not overlap with other R5F's + */ + MSRAM : ORIGIN = 0x70080000 , LENGTH = 0x40000 + + /* This section can be used to put XIP section of the application in flash, make sure this does not overlap with + * other CPUs. Also make sure to add a MPU entry for this section and mark it as cached and code executable + */ + FLASH : ORIGIN = 0x60100000 , LENGTH = 0x80000 + + /* shared memory segments */ + /* On R5F, + * - make sure there is a MPU entry which maps below regions as non-cache + */ + USER_SHM_MEM : ORIGIN = 0x701D0000, LENGTH = 0x180 + LOG_SHM_MEM : ORIGIN = 0x701D0000 + 0x180, LENGTH = 0x00004000 - 0x180 + RTOS_NORTOS_IPC_SHM_MEM : ORIGIN = 0x701D4000, LENGTH = 0x0000C000 +} diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/makefile b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/makefile new file mode 100644 index 0000000..5b1260b --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/makefile @@ -0,0 +1,309 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak +include $(MOTOR_CONTROL_SDK_PATH)/devconfig/devconfig.mak + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=transforms_test.$(PROFILE).out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=transforms_test.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=transforms_test.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=transforms_test.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=transforms_test.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=transforms_test.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=transforms_test.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=transforms_test.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=transforms_test.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) +ifeq ($(DEVICE_TYPE), HS) + TARGETS += $(BOOTIMAGE_NAME_HS) +endif + +FILES_common := \ + transforms_test.c \ + main.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source \ + -I${MOTOR_CONTROL_SDK_PATH}/source \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/park \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/trig \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM243X \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-deprecated-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/nortos/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lnortos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lboard.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lmathlib.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + + +LIBS_NAME = \ + nortos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + board.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + mathlib.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/nortos/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am243x:r5fss0-0:nortos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am243x:r5fss0-0:nortos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + +all: $(TARGETS) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +$(OUTNAME): syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) + @echo . + @echo Linking: am243x:r5fss0-0:nortos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + @echo Linking: am243x:r5fss0-0:nortos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am243x:r5fss0-0:nortos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am243x:r5fss0-0:nortos:ti-arm-clang transforms_test ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --context r5fss0-0 --part ALV --package ALV --output generated/ ../example.syscfg + +syscfg-gui: + $(SYSCFG_NWJS) $(SYSCFG_PATH) --product $(SYSCFG_SDKPRODUCT) --device AM243x_ALV_beta --context r5fss0-0 --part ALV --package ALV --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CERT_KEY=$(APP_SIGNING_KEY) + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! + @echo . + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS_FS) Done !!! + @echo . + +$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +ifeq ($(DEVICE_TYPE), HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME)-enc +endif + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo . +endif +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 0000000..81886bf --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,106 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - MOTOR_CONTROL_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include ${MOTOR_CONTROL_SDK_PATH}/imports.mak +include ${MOTOR_CONTROL_SDK_PATH}/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs_fs +ifeq ($(DEVICE_TYPE),HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME)-enc +endif +endif + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! + @echo . +ifeq ($(DEVICE_TYPE),HS) + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME).hs Done !!! + @echo . +else + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME).hs_fs Done !!! + @echo . +endif +endif diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec new file mode 100644 index 0000000..810fb35 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(MOTOR_CONTROL_SDK_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 0000000..c2be5da --- /dev/null +++ b/examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "mcu_plus_sdk/kernel/freertos/rov/FreeRTOS.rov.js", +]; diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/example.syscfg b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/example.syscfg new file mode 100644 index 0000000..19cbe82 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/example.syscfg @@ -0,0 +1,57 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM243x_ALX_beta" --package "ALX" --part "ALX" --context "r5fss0-0" --product "MOTOR_CONTROL_SDK_AM243X@07.03.00" + * @versions {"data":"2021040816","timestamp":"2021040816","tool":"1.8.1+1900","templates":null} + */ + +/** + * Import the modules used in this configuration. + */ +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART_CONSOLE"; +debug_log.uartLog.UART.$assign = "USART0"; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x41010000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x60000000; +mpu_armv75.size = 28; +mpu_armv75.accessPermissions = "Supervisor RD, User RD"; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +debug_log.uartLog.UART.RXD.$suggestSolution = "B10"; +debug_log.uartLog.UART.TXD.$suggestSolution = "B11"; diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/main.c b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/main.c new file mode 100644 index 0000000..23423e1 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/main.c @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2018-2021 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" +#include "FreeRTOS.h" +#include "task.h" + +#define MAIN_TASK_PRI (configMAX_PRIORITIES-1) + +#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE)) +StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32))); + +StaticTask_t gMainTaskObj; +TaskHandle_t gMainTask; + +void transforms_test_main(void *args); + +void freertos_main(void *args) +{ + transforms_test_main(NULL); + + vTaskDelete(NULL); +} + + +int main(void) +{ + /* init SOC specific modules */ + System_init(); + Board_init(); + + /* This task is created at highest priority, it should create more tasks and then delete itself */ + gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */ + "freertos_main", /* Text name for the task. This is to facilitate debugging only. */ + MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */ + NULL, /* We are not using the task parameter. */ + MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */ + gMainTaskStack, /* pointer to stack base */ + &gMainTaskObj ); /* pointer to statically allocated task object memory */ + configASSERT(gMainTask != NULL); + + /* Start the scheduler to start the tasks executing. */ + vTaskStartScheduler(); + + /* The following line should never be reached because vTaskStartScheduler() + will only return if there was not enough FreeRTOS heap memory available to + create the Idle and (if configured) Timer tasks. Heap management, and + techniques for trapping heap exhaustion, are described in the book text. */ + DebugP_assertNoLog(0); + + return 0; +} diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec new file mode 100644 index 0000000..d8c05ed --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/linker.cmd b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/linker.cmd new file mode 100644 index 0000000..69640f4 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/linker.cmd @@ -0,0 +1,148 @@ + +/* This is the stack that is used by code running within main() + * In case of NORTOS, + * - This means all the code outside of ISR uses this stack + * In case of FreeRTOS + * - This means all the code until vTaskStartScheduler() is called in main() + * uses this stack. + * - After vTaskStartScheduler() each task created in FreeRTOS has its own stack + */ +--stack_size=16384 +/* This is the heap size for malloc() API in NORTOS and FreeRTOS + * This is also the heap used by pvPortMalloc in FreeRTOS + */ +--heap_size=32768 +-e_vectors /* This is the entry of the application, _vector MUST be plabed starting address 0x0 */ + +/* This is the size of stack when R5 is in IRQ mode + * In NORTOS, + * - Here interrupt nesting is enabled + * - This is the stack used by ISRs registered as type IRQ + * In FreeRTOS, + * - Here interrupt nesting is disabled + * - This is stack that is used initally when a IRQ is received + * - But then the mode is switched to SVC mode and SVC stack is used for all user ISR callbacks + * - Hence in FreeRTOS, IRQ stack size is less and SVC stack size is more + */ +__IRQ_STACK_SIZE = 256; +/* This is the size of stack when R5 is in IRQ mode + * - In both NORTOS and FreeRTOS nesting is disabled for FIQ + */ +__FIQ_STACK_SIZE = 256; +__SVC_STACK_SIZE = 4096; /* This is the size of stack when R5 is in SVC mode */ +__ABORT_STACK_SIZE = 256; /* This is the size of stack when R5 is in ABORT mode */ +__UNDEFINED_STACK_SIZE = 256; /* This is the size of stack when R5 is in UNDEF mode */ + +SECTIONS +{ + /* This has the R5F entry point and vector table, this MUST be at 0x0 */ + .vectors:{} palign(8) > R5F_VECS + + /* This has the R5F boot code until MPU is enabled, this MUST be at a address < 0x80000000 + * i.e this cannot be placed in DDR + */ + GROUP { + .text.hwi: palign(8) + .text.cache: palign(8) + .text.mpu: palign(8) + .text.boot: palign(8) + .text:abort: palign(8) /* this helps in loading symbols when using XIP mode */ + } > MSRAM + + /* This is rest of code. This can be placed in DDR if DDR is available and needed */ + GROUP { + .text: {} palign(8) /* This is where code resides */ + .rodata: {} palign(8) /* This is where const's go */ + } > MSRAM + + /* This is rest of initialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + .data: {} palign(8) /* This is where initialized globals and static go */ + } > MSRAM + + /* This is rest of uninitialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + .bss: {} palign(8) /* This is where uninitialized globals go */ + RUN_START(__BSS_START) + RUN_END(__BSS_END) + .sysmem: {} palign(8) /* This is where the malloc heap goes */ + .stack: {} palign(8) /* This is where the main() stack goes */ + } > MSRAM + + /* This is where the stacks for different R5F modes go */ + GROUP { + .irqstack: {. = . + __IRQ_STACK_SIZE;} align(8) + RUN_START(__IRQ_STACK_START) + RUN_END(__IRQ_STACK_END) + .fiqstack: {. = . + __FIQ_STACK_SIZE;} align(8) + RUN_START(__FIQ_STACK_START) + RUN_END(__FIQ_STACK_END) + .svcstack: {. = . + __SVC_STACK_SIZE;} align(8) + RUN_START(__SVC_STACK_START) + RUN_END(__SVC_STACK_END) + .abortstack: {. = . + __ABORT_STACK_SIZE;} align(8) + RUN_START(__ABORT_STACK_START) + RUN_END(__ABORT_STACK_END) + .undefinedstack: {. = . + __UNDEFINED_STACK_SIZE;} align(8) + RUN_START(__UNDEFINED_STACK_START) + RUN_END(__UNDEFINED_STACK_END) + } > MSRAM + + /* Sections needed for C++ projects */ + GROUP { + .ARM.exidx: {} palign(8) /* Needed for C++ exception handling */ + .init_array: {} palign(8) /* Contains function pointers called before main */ + .fini_array: {} palign(8) /* Contains function pointers called after main */ + } > MSRAM + + /* General purpose user shared memory, used in some examples */ + .bss.user_shared_mem (NOLOAD) : {} > USER_SHM_MEM + /* this is used when Debug log's to shared memory are enabled, else this is not used */ + .bss.log_shared_mem (NOLOAD) : {} > LOG_SHM_MEM + /* this is used only when IPC RPMessage is enabled, else this is not used */ + .bss.ipc_vring_mem (NOLOAD) : {} > RTOS_NORTOS_IPC_SHM_MEM + /* General purpose non cacheable memory, used in some examples */ + .bss.nocache (NOLOAD) : {} > NON_CACHE_MEM +} + +/* +NOTE: Below memory is reserved for DMSC usage + - During Boot till security handoff is complete + 0x701E0000 - 0x701FFFFF (128KB) + - After "Security Handoff" is complete (i.e at run time) + 0x701F4000 - 0x701FFFFF (48KB) + + Security handoff is complete when this message is sent to the DMSC, + TISCI_MSG_SEC_HANDOVER + + This should be sent once all cores are loaded and all application + specific firewall calls are setup. +*/ + +MEMORY +{ + R5F_VECS : ORIGIN = 0x00000000 , LENGTH = 0x00000040 + R5F_TCMA : ORIGIN = 0x00000040 , LENGTH = 0x00007FC0 + R5F_TCMB0 : ORIGIN = 0x41010000 , LENGTH = 0x00008000 + + /* memory segment used to hold CPU specific non-cached data, MAKE to add a MPU entry to mark this as non-cached */ + NON_CACHE_MEM : ORIGIN = 0x70060000 , LENGTH = 0x8000 + + /* when using multi-core application's i.e more than one R5F/M4F active, make sure + * this memory does not overlap with other R5F's + */ + MSRAM : ORIGIN = 0x70080000 , LENGTH = 0x40000 + + /* This section can be used to put XIP section of the application in flash, make sure this does not overlap with + * other CPUs. Also make sure to add a MPU entry for this section and mark it as cached and code executable + */ + FLASH : ORIGIN = 0x60100000 , LENGTH = 0x80000 + + /* shared memory segments */ + /* On R5F, + * - make sure there is a MPU entry which maps below regions as non-cache + */ + USER_SHM_MEM : ORIGIN = 0x701D0000, LENGTH = 0x180 + LOG_SHM_MEM : ORIGIN = 0x701D0000 + 0x180, LENGTH = 0x00004000 - 0x180 + RTOS_NORTOS_IPC_SHM_MEM : ORIGIN = 0x701D4000, LENGTH = 0x0000C000 +} diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile new file mode 100644 index 0000000..16ddf4e --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -0,0 +1,312 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak +include $(MOTOR_CONTROL_SDK_PATH)/devconfig/devconfig.mak + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=transforms_test.$(PROFILE).out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=transforms_test.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=transforms_test.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=transforms_test.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=transforms_test.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=transforms_test.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=transforms_test.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=transforms_test.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=transforms_test.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) +ifeq ($(DEVICE_TYPE), HS) + TARGETS += $(BOOTIMAGE_NAME_HS) +endif + +FILES_common := \ + transforms_test.c \ + main.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source \ + -I${MOTOR_CONTROL_SDK_PATH}/source \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/FreeRTOS-Kernel/include \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/config/am243x/r5f \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/park \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/trig \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM243X \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-deprecated-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lfreertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lboard.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lmathlib.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + + +LIBS_NAME = \ + freertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + board.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + mathlib.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + +all: $(TARGETS) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +$(OUTNAME): syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) + @echo . + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am243x:r5fss0-0:freertos:ti-arm-clang transforms_test ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --context r5fss0-0 --part ALX --package ALX --output generated/ ../example.syscfg + +syscfg-gui: + $(SYSCFG_NWJS) $(SYSCFG_PATH) --product $(SYSCFG_SDKPRODUCT) --device AM243x_ALX_beta --context r5fss0-0 --part ALX --package ALX --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CERT_KEY=$(APP_SIGNING_KEY) + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! + @echo . + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS_FS) Done !!! + @echo . + +$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +ifeq ($(DEVICE_TYPE), HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME)-enc +endif + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo . +endif +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 0000000..8666cfd --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,106 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - MOTOR_CONTROL_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include ${MOTOR_CONTROL_SDK_PATH}/imports.mak +include ${MOTOR_CONTROL_SDK_PATH}/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs_fs +ifeq ($(DEVICE_TYPE),HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME)-enc +endif +endif + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! + @echo . +ifeq ($(DEVICE_TYPE),HS) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs Done !!! + @echo . +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs_fs Done !!! + @echo . +endif +endif diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec new file mode 100644 index 0000000..c170366 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(MOTOR_CONTROL_SDK_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 0000000..c2be5da --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "mcu_plus_sdk/kernel/freertos/rov/FreeRTOS.rov.js", +]; diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/example.syscfg b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/example.syscfg new file mode 100644 index 0000000..19cbe82 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/example.syscfg @@ -0,0 +1,57 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM243x_ALX_beta" --package "ALX" --part "ALX" --context "r5fss0-0" --product "MOTOR_CONTROL_SDK_AM243X@07.03.00" + * @versions {"data":"2021040816","timestamp":"2021040816","tool":"1.8.1+1900","templates":null} + */ + +/** + * Import the modules used in this configuration. + */ +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART_CONSOLE"; +debug_log.uartLog.UART.$assign = "USART0"; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x41010000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x60000000; +mpu_armv75.size = 28; +mpu_armv75.accessPermissions = "Supervisor RD, User RD"; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +debug_log.uartLog.UART.RXD.$suggestSolution = "B10"; +debug_log.uartLog.UART.TXD.$suggestSolution = "B11"; diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/main.c b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/main.c new file mode 100644 index 0000000..d50c8c2 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/main.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2018-2021 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" + +void transforms_test_main(void *args); + +int main(void) +{ + System_init(); + Board_init(); + + transforms_test_main(NULL); + + Board_deinit(); + System_deinit(); + + return 0; +} diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec new file mode 100644 index 0000000..11646df --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/linker.cmd b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/linker.cmd new file mode 100644 index 0000000..69640f4 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/linker.cmd @@ -0,0 +1,148 @@ + +/* This is the stack that is used by code running within main() + * In case of NORTOS, + * - This means all the code outside of ISR uses this stack + * In case of FreeRTOS + * - This means all the code until vTaskStartScheduler() is called in main() + * uses this stack. + * - After vTaskStartScheduler() each task created in FreeRTOS has its own stack + */ +--stack_size=16384 +/* This is the heap size for malloc() API in NORTOS and FreeRTOS + * This is also the heap used by pvPortMalloc in FreeRTOS + */ +--heap_size=32768 +-e_vectors /* This is the entry of the application, _vector MUST be plabed starting address 0x0 */ + +/* This is the size of stack when R5 is in IRQ mode + * In NORTOS, + * - Here interrupt nesting is enabled + * - This is the stack used by ISRs registered as type IRQ + * In FreeRTOS, + * - Here interrupt nesting is disabled + * - This is stack that is used initally when a IRQ is received + * - But then the mode is switched to SVC mode and SVC stack is used for all user ISR callbacks + * - Hence in FreeRTOS, IRQ stack size is less and SVC stack size is more + */ +__IRQ_STACK_SIZE = 256; +/* This is the size of stack when R5 is in IRQ mode + * - In both NORTOS and FreeRTOS nesting is disabled for FIQ + */ +__FIQ_STACK_SIZE = 256; +__SVC_STACK_SIZE = 4096; /* This is the size of stack when R5 is in SVC mode */ +__ABORT_STACK_SIZE = 256; /* This is the size of stack when R5 is in ABORT mode */ +__UNDEFINED_STACK_SIZE = 256; /* This is the size of stack when R5 is in UNDEF mode */ + +SECTIONS +{ + /* This has the R5F entry point and vector table, this MUST be at 0x0 */ + .vectors:{} palign(8) > R5F_VECS + + /* This has the R5F boot code until MPU is enabled, this MUST be at a address < 0x80000000 + * i.e this cannot be placed in DDR + */ + GROUP { + .text.hwi: palign(8) + .text.cache: palign(8) + .text.mpu: palign(8) + .text.boot: palign(8) + .text:abort: palign(8) /* this helps in loading symbols when using XIP mode */ + } > MSRAM + + /* This is rest of code. This can be placed in DDR if DDR is available and needed */ + GROUP { + .text: {} palign(8) /* This is where code resides */ + .rodata: {} palign(8) /* This is where const's go */ + } > MSRAM + + /* This is rest of initialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + .data: {} palign(8) /* This is where initialized globals and static go */ + } > MSRAM + + /* This is rest of uninitialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + .bss: {} palign(8) /* This is where uninitialized globals go */ + RUN_START(__BSS_START) + RUN_END(__BSS_END) + .sysmem: {} palign(8) /* This is where the malloc heap goes */ + .stack: {} palign(8) /* This is where the main() stack goes */ + } > MSRAM + + /* This is where the stacks for different R5F modes go */ + GROUP { + .irqstack: {. = . + __IRQ_STACK_SIZE;} align(8) + RUN_START(__IRQ_STACK_START) + RUN_END(__IRQ_STACK_END) + .fiqstack: {. = . + __FIQ_STACK_SIZE;} align(8) + RUN_START(__FIQ_STACK_START) + RUN_END(__FIQ_STACK_END) + .svcstack: {. = . + __SVC_STACK_SIZE;} align(8) + RUN_START(__SVC_STACK_START) + RUN_END(__SVC_STACK_END) + .abortstack: {. = . + __ABORT_STACK_SIZE;} align(8) + RUN_START(__ABORT_STACK_START) + RUN_END(__ABORT_STACK_END) + .undefinedstack: {. = . + __UNDEFINED_STACK_SIZE;} align(8) + RUN_START(__UNDEFINED_STACK_START) + RUN_END(__UNDEFINED_STACK_END) + } > MSRAM + + /* Sections needed for C++ projects */ + GROUP { + .ARM.exidx: {} palign(8) /* Needed for C++ exception handling */ + .init_array: {} palign(8) /* Contains function pointers called before main */ + .fini_array: {} palign(8) /* Contains function pointers called after main */ + } > MSRAM + + /* General purpose user shared memory, used in some examples */ + .bss.user_shared_mem (NOLOAD) : {} > USER_SHM_MEM + /* this is used when Debug log's to shared memory are enabled, else this is not used */ + .bss.log_shared_mem (NOLOAD) : {} > LOG_SHM_MEM + /* this is used only when IPC RPMessage is enabled, else this is not used */ + .bss.ipc_vring_mem (NOLOAD) : {} > RTOS_NORTOS_IPC_SHM_MEM + /* General purpose non cacheable memory, used in some examples */ + .bss.nocache (NOLOAD) : {} > NON_CACHE_MEM +} + +/* +NOTE: Below memory is reserved for DMSC usage + - During Boot till security handoff is complete + 0x701E0000 - 0x701FFFFF (128KB) + - After "Security Handoff" is complete (i.e at run time) + 0x701F4000 - 0x701FFFFF (48KB) + + Security handoff is complete when this message is sent to the DMSC, + TISCI_MSG_SEC_HANDOVER + + This should be sent once all cores are loaded and all application + specific firewall calls are setup. +*/ + +MEMORY +{ + R5F_VECS : ORIGIN = 0x00000000 , LENGTH = 0x00000040 + R5F_TCMA : ORIGIN = 0x00000040 , LENGTH = 0x00007FC0 + R5F_TCMB0 : ORIGIN = 0x41010000 , LENGTH = 0x00008000 + + /* memory segment used to hold CPU specific non-cached data, MAKE to add a MPU entry to mark this as non-cached */ + NON_CACHE_MEM : ORIGIN = 0x70060000 , LENGTH = 0x8000 + + /* when using multi-core application's i.e more than one R5F/M4F active, make sure + * this memory does not overlap with other R5F's + */ + MSRAM : ORIGIN = 0x70080000 , LENGTH = 0x40000 + + /* This section can be used to put XIP section of the application in flash, make sure this does not overlap with + * other CPUs. Also make sure to add a MPU entry for this section and mark it as cached and code executable + */ + FLASH : ORIGIN = 0x60100000 , LENGTH = 0x80000 + + /* shared memory segments */ + /* On R5F, + * - make sure there is a MPU entry which maps below regions as non-cache + */ + USER_SHM_MEM : ORIGIN = 0x701D0000, LENGTH = 0x180 + LOG_SHM_MEM : ORIGIN = 0x701D0000 + 0x180, LENGTH = 0x00004000 - 0x180 + RTOS_NORTOS_IPC_SHM_MEM : ORIGIN = 0x701D4000, LENGTH = 0x0000C000 +} diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/makefile b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/makefile new file mode 100644 index 0000000..39f6d73 --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/makefile @@ -0,0 +1,309 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak +include $(MOTOR_CONTROL_SDK_PATH)/devconfig/devconfig.mak + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=transforms_test.$(PROFILE).out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=transforms_test.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=transforms_test.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=transforms_test.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=transforms_test.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=transforms_test.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=transforms_test.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=transforms_test.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=transforms_test.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) +ifeq ($(DEVICE_TYPE), HS) + TARGETS += $(BOOTIMAGE_NAME_HS) +endif + +FILES_common := \ + transforms_test.c \ + main.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source \ + -I${MOTOR_CONTROL_SDK_PATH}/source \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/park \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/trig \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM243X \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-deprecated-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/nortos/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lnortos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lboard.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lmathlib.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + + +LIBS_NAME = \ + nortos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + board.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + mathlib.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/nortos/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am243x:r5fss0-0:nortos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am243x:r5fss0-0:nortos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + +all: $(TARGETS) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +$(OUTNAME): syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) + @echo . + @echo Linking: am243x:r5fss0-0:nortos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + @echo Linking: am243x:r5fss0-0:nortos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am243x:r5fss0-0:nortos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am243x:r5fss0-0:nortos:ti-arm-clang transforms_test ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --context r5fss0-0 --part ALX --package ALX --output generated/ ../example.syscfg + +syscfg-gui: + $(SYSCFG_NWJS) $(SYSCFG_PATH) --product $(SYSCFG_SDKPRODUCT) --device AM243x_ALX_beta --context r5fss0-0 --part ALX --package ALX --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CERT_KEY=$(APP_SIGNING_KEY) + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! + @echo . + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS_FS) Done !!! + @echo . + +$(BOOTIMAGE_NAME_HS): $(BOOTIMAGE_NAME) +ifeq ($(DEVICE_TYPE), HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME)-enc +endif + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo . +endif +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 0000000..81886bf --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,106 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - MOTOR_CONTROL_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include ${MOTOR_CONTROL_SDK_PATH}/imports.mak +include ${MOTOR_CONTROL_SDK_PATH}/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs_fs +ifeq ($(DEVICE_TYPE),HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME)-enc +endif +endif + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! + @echo . +ifeq ($(DEVICE_TYPE),HS) + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME).hs Done !!! + @echo . +else + @echo Boot image: am243x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME).hs_fs Done !!! + @echo . +endif +endif diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec new file mode 100644 index 0000000..0f8f5ce --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(MOTOR_CONTROL_SDK_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 0000000..c2be5da --- /dev/null +++ b/examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "mcu_plus_sdk/kernel/freertos/rov/FreeRTOS.rov.js", +]; diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/example.syscfg b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/example.syscfg new file mode 100644 index 0000000..62a0408 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/example.syscfg @@ -0,0 +1,59 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM263x_beta" --package "ZCZ" --part "AM263x" --context "r5fss0-0" --product "MOTOR_CONTROL_SDK_AM263x@09.01.00" + * @versions {"tool":"1.14.0+2667"} + */ + +/** + * Import the modules used in this configuration. + */ +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const mpu_armv76 = mpu_armv7.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART0"; +debug_log.uartLog.UART.$assign = "UART0"; +debug_log.uartLog.UART.RXD.$assign = "ball.A7"; +debug_log.uartLog.UART.TXD.$assign = "ball.A6"; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x80000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x50D00000; +mpu_armv75.size = 14; +mpu_armv75.allowExecute = false; +mpu_armv75.attributes = "Device"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.baseAddr = 0x72000000; +mpu_armv76.size = 14; +mpu_armv76.allowExecute = false; +mpu_armv76.attributes = "NonCached"; diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/main.c b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/main.c new file mode 100644 index 0000000..9786873 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/main.c @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2018-2022 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" +#include "FreeRTOS.h" +#include "task.h" + +#define MAIN_TASK_PRI (configMAX_PRIORITIES-1) + +#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE)) +StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32))); + +StaticTask_t gMainTaskObj; +TaskHandle_t gMainTask; + +void transforms_test_main(void *args); + +void freertos_main(void *args) +{ + transforms_test_main(NULL); + + vTaskDelete(NULL); +} + + +int main(void) +{ + /* init SOC specific modules */ + System_init(); + Board_init(); + + /* This task is created at highest priority, it should create more tasks and then delete itself */ + gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */ + "freertos_main", /* Text name for the task. This is to facilitate debugging only. */ + MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */ + NULL, /* We are not using the task parameter. */ + MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */ + gMainTaskStack, /* pointer to stack base */ + &gMainTaskObj ); /* pointer to statically allocated task object memory */ + configASSERT(gMainTask != NULL); + + /* Start the scheduler to start the tasks executing. */ + vTaskStartScheduler(); + + /* The following line should never be reached because vTaskStartScheduler() + will only return if there was not enough FreeRTOS heap memory available to + create the Idle and (if configured) Timer tasks. Heap management, and + techniques for trapping heap exhaustion, are described in the book text. */ + DebugP_assertNoLog(0); + + return 0; +} diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec new file mode 100644 index 0000000..3ed29ed --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/linker.cmd b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/linker.cmd new file mode 100644 index 0000000..7a34f5e --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/linker.cmd @@ -0,0 +1,137 @@ + +/* This is the stack that is used by code running within main() + * In case of NORTOS, + * - This means all the code outside of ISR uses this stack + * In case of FreeRTOS + * - This means all the code until vTaskStartScheduler() is called in main() + * uses this stack. + * - After vTaskStartScheduler() each task created in FreeRTOS has its own stack + */ +--stack_size=16384 +/* This is the heap size for malloc() API in NORTOS and FreeRTOS + * This is also the heap used by pvPortMalloc in FreeRTOS + */ +--heap_size=32768 +-e_vectors /* This is the entry of the application, _vector MUST be plabed starting address 0x0 */ + +/* This is the size of stack when R5 is in IRQ mode + * In NORTOS, + * - Here interrupt nesting is enabled + * - This is the stack used by ISRs registered as type IRQ + * In FreeRTOS, + * - Here interrupt nesting is enabled + * - This is stack that is used initally when a IRQ is received + * - But then the mode is switched to SVC mode and SVC stack is used for all user ISR callbacks + * - Hence in FreeRTOS, IRQ stack size is less and SVC stack size is more + */ +__IRQ_STACK_SIZE = 256; +/* This is the size of stack when R5 is in IRQ mode + * - In both NORTOS and FreeRTOS nesting is disabled for FIQ + */ +__FIQ_STACK_SIZE = 256; +__SVC_STACK_SIZE = 4096; /* This is the size of stack when R5 is in SVC mode */ +__ABORT_STACK_SIZE = 256; /* This is the size of stack when R5 is in ABORT mode */ +__UNDEFINED_STACK_SIZE = 256; /* This is the size of stack when R5 is in UNDEF mode */ + +SECTIONS +{ + /* This has the R5F entry point and vector table, this MUST be at 0x0 */ + .vectors:{} palign(8) > R5F_VECS + + /* This has the R5F boot code until MPU is enabled, this MUST be at a address < 0x80000000 + * i.e this cannot be placed in DDR + */ + GROUP { + .text.hwi: palign(8) + .text.cache: palign(8) + .text.mpu: palign(8) + .text.boot: palign(8) + .text:abort: palign(8) /* this helps in loading symbols when using XIP mode */ + } > OCRAM + + /* This is rest of code. This can be placed in DDR if DDR is available and needed */ + GROUP { + .text: {} palign(8) /* This is where code resides */ + .rodata: {} palign(8) /* This is where const's go */ + } > OCRAM + + /* This is rest of initialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + + .data: {} palign(8) /* This is where initialized globals and static go */ + } > OCRAM + + /* This is rest of uninitialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + .bss: {} palign(8) /* This is where uninitialized globals go */ + RUN_START(__BSS_START) + RUN_END(__BSS_END) + .sysmem: {} palign(8) /* This is where the malloc heap goes */ + .stack: {} palign(8) /* This is where the main() stack goes */ + } > OCRAM + + /* This is where the stacks for different R5F modes go */ + GROUP { + .irqstack: {. = . + __IRQ_STACK_SIZE;} align(8) + RUN_START(__IRQ_STACK_START) + RUN_END(__IRQ_STACK_END) + .fiqstack: {. = . + __FIQ_STACK_SIZE;} align(8) + RUN_START(__FIQ_STACK_START) + RUN_END(__FIQ_STACK_END) + .svcstack: {. = . + __SVC_STACK_SIZE;} align(8) + RUN_START(__SVC_STACK_START) + RUN_END(__SVC_STACK_END) + .abortstack: {. = . + __ABORT_STACK_SIZE;} align(8) + RUN_START(__ABORT_STACK_START) + RUN_END(__ABORT_STACK_END) + .undefinedstack: {. = . + __UNDEFINED_STACK_SIZE;} align(8) + RUN_START(__UNDEFINED_STACK_START) + RUN_END(__UNDEFINED_STACK_END) + } > OCRAM + + /* Sections needed for C++ projects */ + GROUP { + .ARM.exidx: {} palign(8) /* Needed for C++ exception handling */ + .init_array: {} palign(8) /* Contains function pointers called before main */ + .fini_array: {} palign(8) /* Contains function pointers called after main */ + } > OCRAM + + /* General purpose user shared memory, used in some examples */ + .bss.user_shared_mem (NOLOAD) : {} > USER_SHM_MEM + /* this is used when Debug log's to shared memory are enabled, else this is not used */ + .bss.log_shared_mem (NOLOAD) : {} > LOG_SHM_MEM + /* this is used only when IPC RPMessage is enabled, else this is not used */ + .bss.ipc_vring_mem (NOLOAD) : {} > RTOS_NORTOS_IPC_SHM_MEM + /* this is used only when Secure IPC is enabled */ + .bss.sipc_hsm_queue_mem (NOLOAD) : {} > MAILBOX_HSM + .bss.sipc_r5f_queue_mem (NOLOAD) : {} > MAILBOX_R5F +} + +MEMORY +{ + R5F_VECS : ORIGIN = 0x00000000 , LENGTH = 0x00000040 + R5F_TCMA : ORIGIN = 0x00000040 , LENGTH = 0x00007FC0 + R5F_TCMB : ORIGIN = 0x00080000 , LENGTH = 0x00008000 + + /* when using multi-core application's i.e more than one R5F/M4F active, make sure + * this memory does not overlap with other R5F's + */ + OCRAM : ORIGIN = 0x70040000 , LENGTH = 0x40000 + + /* This section can be used to put XIP section of the application in flash, make sure this does not overlap with + * other CPUs. Also make sure to add a MPU entry for this section and mark it as cached and code executable + */ + FLASH : ORIGIN = 0x60100000 , LENGTH = 0x80000 + + + /* shared memories that are used by RTOS/NORTOS cores */ + /* On R5F, + * - make sure there is a MPU entry which maps below regions as non-cache + */ + USER_SHM_MEM : ORIGIN = 0x701D0000, LENGTH = 0x00004000 + LOG_SHM_MEM : ORIGIN = 0x701D4000, LENGTH = 0x00004000 + /* MSS mailbox memory is used as shared memory, we dont use bottom 32*12 bytes, since its used as SW queue by ipc_notify */ + RTOS_NORTOS_IPC_SHM_MEM : ORIGIN = 0x72000000, LENGTH = 0x3E80 + MAILBOX_HSM: ORIGIN = 0x44000000 , LENGTH = 0x000003CE + MAILBOX_R5F: ORIGIN = 0x44000400 , LENGTH = 0x000003CE + } diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile new file mode 100644 index 0000000..1647041 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile @@ -0,0 +1,283 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak +include $(MOTOR_CONTROL_SDK_PATH)/devconfig/devconfig.mak + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=transforms_test.$(PROFILE).out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=transforms_test.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=transforms_test.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=transforms_test.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=transforms_test.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=transforms_test.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=transforms_test.$(PROFILE).rprc_tmp + +FILES_common := \ + transforms_test.c \ + main.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source \ + -I${MOTOR_CONTROL_SDK_PATH}/source \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/FreeRTOS-Kernel/include \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/config/am263x/r5f \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/park \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/trig \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM263X \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-deprecated-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lmathlib.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + + +LIBS_NAME = \ + freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + mathlib.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + +all: $(BOOTIMAGE_NAME) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +$(OUTNAME): syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) + @echo . + @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am263x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am263x:r5fss0-0:freertos:ti-arm-clang transforms_test ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --context r5fss0-0 --part AM263x --package ZCZ --output generated/ ../example.syscfg + +syscfg-gui: + $(SYSCFG_NWJS) $(SYSCFG_PATH) --product $(SYSCFG_SDKPRODUCT) --device AM263x_beta --context r5fss0-0 --part AM263x --package ZCZ --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + + +BOOTIMAGE_CORE_ID_r5fss0-0 = 0 +BOOTIMAGE_CORE_ID_r5fss0-1 = 1 +BOOTIMAGE_CORE_ID_r5fss1-0 = 2 +BOOTIMAGE_CORE_ID_r5fss1-1 = 3 +SBL_RUN_ADDRESS=0x70002000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) + @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! + @echo . + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 0000000..e0799fb --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,84 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - MOTOR_CONTROL_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include ${MOTOR_CONTROL_SDK_PATH}/imports.mak +include ${MOTOR_CONTROL_SDK_PATH}/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 0 +BOOTIMAGE_CORE_ID_r5fss0-1 = 1 +BOOTIMAGE_CORE_ID_r5fss1-0 = 2 +BOOTIMAGE_CORE_ID_r5fss1-1 = 3 +SBL_RUN_ADDRESS=0x70002000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! + @echo . +endif diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec new file mode 100644 index 0000000..858ea47 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(MOTOR_CONTROL_SDK_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 0000000..c2be5da --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "mcu_plus_sdk/kernel/freertos/rov/FreeRTOS.rov.js", +]; diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/example.syscfg b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/example.syscfg new file mode 100644 index 0000000..62a0408 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/example.syscfg @@ -0,0 +1,59 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM263x_beta" --package "ZCZ" --part "AM263x" --context "r5fss0-0" --product "MOTOR_CONTROL_SDK_AM263x@09.01.00" + * @versions {"tool":"1.14.0+2667"} + */ + +/** + * Import the modules used in this configuration. + */ +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const mpu_armv76 = mpu_armv7.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART0"; +debug_log.uartLog.UART.$assign = "UART0"; +debug_log.uartLog.UART.RXD.$assign = "ball.A7"; +debug_log.uartLog.UART.TXD.$assign = "ball.A6"; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x80000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x50D00000; +mpu_armv75.size = 14; +mpu_armv75.allowExecute = false; +mpu_armv75.attributes = "Device"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.baseAddr = 0x72000000; +mpu_armv76.size = 14; +mpu_armv76.allowExecute = false; +mpu_armv76.attributes = "NonCached"; diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/main.c b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/main.c new file mode 100644 index 0000000..a2defb6 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/main.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2018-2022 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" + +void transforms_test_main(void *args); + +int main(void) +{ + System_init(); + Board_init(); + + transforms_test_main(NULL); + + Board_deinit(); + System_deinit(); + + return 0; +} diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/example.projectspec b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/example.projectspec new file mode 100644 index 0000000..9c2056a --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/example.projectspec @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/linker.cmd b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/linker.cmd new file mode 100644 index 0000000..7a34f5e --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/linker.cmd @@ -0,0 +1,137 @@ + +/* This is the stack that is used by code running within main() + * In case of NORTOS, + * - This means all the code outside of ISR uses this stack + * In case of FreeRTOS + * - This means all the code until vTaskStartScheduler() is called in main() + * uses this stack. + * - After vTaskStartScheduler() each task created in FreeRTOS has its own stack + */ +--stack_size=16384 +/* This is the heap size for malloc() API in NORTOS and FreeRTOS + * This is also the heap used by pvPortMalloc in FreeRTOS + */ +--heap_size=32768 +-e_vectors /* This is the entry of the application, _vector MUST be plabed starting address 0x0 */ + +/* This is the size of stack when R5 is in IRQ mode + * In NORTOS, + * - Here interrupt nesting is enabled + * - This is the stack used by ISRs registered as type IRQ + * In FreeRTOS, + * - Here interrupt nesting is enabled + * - This is stack that is used initally when a IRQ is received + * - But then the mode is switched to SVC mode and SVC stack is used for all user ISR callbacks + * - Hence in FreeRTOS, IRQ stack size is less and SVC stack size is more + */ +__IRQ_STACK_SIZE = 256; +/* This is the size of stack when R5 is in IRQ mode + * - In both NORTOS and FreeRTOS nesting is disabled for FIQ + */ +__FIQ_STACK_SIZE = 256; +__SVC_STACK_SIZE = 4096; /* This is the size of stack when R5 is in SVC mode */ +__ABORT_STACK_SIZE = 256; /* This is the size of stack when R5 is in ABORT mode */ +__UNDEFINED_STACK_SIZE = 256; /* This is the size of stack when R5 is in UNDEF mode */ + +SECTIONS +{ + /* This has the R5F entry point and vector table, this MUST be at 0x0 */ + .vectors:{} palign(8) > R5F_VECS + + /* This has the R5F boot code until MPU is enabled, this MUST be at a address < 0x80000000 + * i.e this cannot be placed in DDR + */ + GROUP { + .text.hwi: palign(8) + .text.cache: palign(8) + .text.mpu: palign(8) + .text.boot: palign(8) + .text:abort: palign(8) /* this helps in loading symbols when using XIP mode */ + } > OCRAM + + /* This is rest of code. This can be placed in DDR if DDR is available and needed */ + GROUP { + .text: {} palign(8) /* This is where code resides */ + .rodata: {} palign(8) /* This is where const's go */ + } > OCRAM + + /* This is rest of initialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + + .data: {} palign(8) /* This is where initialized globals and static go */ + } > OCRAM + + /* This is rest of uninitialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + .bss: {} palign(8) /* This is where uninitialized globals go */ + RUN_START(__BSS_START) + RUN_END(__BSS_END) + .sysmem: {} palign(8) /* This is where the malloc heap goes */ + .stack: {} palign(8) /* This is where the main() stack goes */ + } > OCRAM + + /* This is where the stacks for different R5F modes go */ + GROUP { + .irqstack: {. = . + __IRQ_STACK_SIZE;} align(8) + RUN_START(__IRQ_STACK_START) + RUN_END(__IRQ_STACK_END) + .fiqstack: {. = . + __FIQ_STACK_SIZE;} align(8) + RUN_START(__FIQ_STACK_START) + RUN_END(__FIQ_STACK_END) + .svcstack: {. = . + __SVC_STACK_SIZE;} align(8) + RUN_START(__SVC_STACK_START) + RUN_END(__SVC_STACK_END) + .abortstack: {. = . + __ABORT_STACK_SIZE;} align(8) + RUN_START(__ABORT_STACK_START) + RUN_END(__ABORT_STACK_END) + .undefinedstack: {. = . + __UNDEFINED_STACK_SIZE;} align(8) + RUN_START(__UNDEFINED_STACK_START) + RUN_END(__UNDEFINED_STACK_END) + } > OCRAM + + /* Sections needed for C++ projects */ + GROUP { + .ARM.exidx: {} palign(8) /* Needed for C++ exception handling */ + .init_array: {} palign(8) /* Contains function pointers called before main */ + .fini_array: {} palign(8) /* Contains function pointers called after main */ + } > OCRAM + + /* General purpose user shared memory, used in some examples */ + .bss.user_shared_mem (NOLOAD) : {} > USER_SHM_MEM + /* this is used when Debug log's to shared memory are enabled, else this is not used */ + .bss.log_shared_mem (NOLOAD) : {} > LOG_SHM_MEM + /* this is used only when IPC RPMessage is enabled, else this is not used */ + .bss.ipc_vring_mem (NOLOAD) : {} > RTOS_NORTOS_IPC_SHM_MEM + /* this is used only when Secure IPC is enabled */ + .bss.sipc_hsm_queue_mem (NOLOAD) : {} > MAILBOX_HSM + .bss.sipc_r5f_queue_mem (NOLOAD) : {} > MAILBOX_R5F +} + +MEMORY +{ + R5F_VECS : ORIGIN = 0x00000000 , LENGTH = 0x00000040 + R5F_TCMA : ORIGIN = 0x00000040 , LENGTH = 0x00007FC0 + R5F_TCMB : ORIGIN = 0x00080000 , LENGTH = 0x00008000 + + /* when using multi-core application's i.e more than one R5F/M4F active, make sure + * this memory does not overlap with other R5F's + */ + OCRAM : ORIGIN = 0x70040000 , LENGTH = 0x40000 + + /* This section can be used to put XIP section of the application in flash, make sure this does not overlap with + * other CPUs. Also make sure to add a MPU entry for this section and mark it as cached and code executable + */ + FLASH : ORIGIN = 0x60100000 , LENGTH = 0x80000 + + + /* shared memories that are used by RTOS/NORTOS cores */ + /* On R5F, + * - make sure there is a MPU entry which maps below regions as non-cache + */ + USER_SHM_MEM : ORIGIN = 0x701D0000, LENGTH = 0x00004000 + LOG_SHM_MEM : ORIGIN = 0x701D4000, LENGTH = 0x00004000 + /* MSS mailbox memory is used as shared memory, we dont use bottom 32*12 bytes, since its used as SW queue by ipc_notify */ + RTOS_NORTOS_IPC_SHM_MEM : ORIGIN = 0x72000000, LENGTH = 0x3E80 + MAILBOX_HSM: ORIGIN = 0x44000000 , LENGTH = 0x000003CE + MAILBOX_R5F: ORIGIN = 0x44000400 , LENGTH = 0x000003CE + } diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/makefile b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/makefile new file mode 100644 index 0000000..4facccd --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/makefile @@ -0,0 +1,280 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak +include $(MOTOR_CONTROL_SDK_PATH)/devconfig/devconfig.mak + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=transforms_test.$(PROFILE).out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=transforms_test.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=transforms_test.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=transforms_test.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=transforms_test.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=transforms_test.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=transforms_test.$(PROFILE).rprc_tmp + +FILES_common := \ + transforms_test.c \ + main.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source \ + -I${MOTOR_CONTROL_SDK_PATH}/source \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/park \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/trig \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM263X \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-deprecated-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/nortos/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lnortos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lmathlib.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + + +LIBS_NAME = \ + nortos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + mathlib.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/nortos/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am263x:r5fss0-0:nortos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am263x:r5fss0-0:nortos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + +all: $(BOOTIMAGE_NAME) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +$(OUTNAME): syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) + @echo . + @echo Linking: am263x:r5fss0-0:nortos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + @echo Linking: am263x:r5fss0-0:nortos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am263x:r5fss0-0:nortos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am263x:r5fss0-0:nortos:ti-arm-clang transforms_test ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --context r5fss0-0 --part AM263x --package ZCZ --output generated/ ../example.syscfg + +syscfg-gui: + $(SYSCFG_NWJS) $(SYSCFG_PATH) --product $(SYSCFG_SDKPRODUCT) --device AM263x_beta --context r5fss0-0 --part AM263x --package ZCZ --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + + +BOOTIMAGE_CORE_ID_r5fss0-0 = 0 +BOOTIMAGE_CORE_ID_r5fss0-1 = 1 +BOOTIMAGE_CORE_ID_r5fss1-0 = 2 +BOOTIMAGE_CORE_ID_r5fss1-1 = 3 +SBL_RUN_ADDRESS=0x70002000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am263x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) + @echo Boot image: am263x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! + @echo . + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 0000000..d790183 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,84 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - MOTOR_CONTROL_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include ${MOTOR_CONTROL_SDK_PATH}/imports.mak +include ${MOTOR_CONTROL_SDK_PATH}/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 0 +BOOTIMAGE_CORE_ID_r5fss0-1 = 1 +BOOTIMAGE_CORE_ID_r5fss1-0 = 2 +BOOTIMAGE_CORE_ID_r5fss1-1 = 3 +SBL_RUN_ADDRESS=0x70002000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am263x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + @echo Boot image: am263x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! + @echo . +endif diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec new file mode 100644 index 0000000..2ed7238 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(MOTOR_CONTROL_SDK_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 0000000..c2be5da --- /dev/null +++ b/examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "mcu_plus_sdk/kernel/freertos/rov/FreeRTOS.rov.js", +]; diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/example.syscfg b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/example.syscfg new file mode 100644 index 0000000..62a0408 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/example.syscfg @@ -0,0 +1,59 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM263x_beta" --package "ZCZ" --part "AM263x" --context "r5fss0-0" --product "MOTOR_CONTROL_SDK_AM263x@09.01.00" + * @versions {"tool":"1.14.0+2667"} + */ + +/** + * Import the modules used in this configuration. + */ +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const mpu_armv76 = mpu_armv7.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART0"; +debug_log.uartLog.UART.$assign = "UART0"; +debug_log.uartLog.UART.RXD.$assign = "ball.A7"; +debug_log.uartLog.UART.TXD.$assign = "ball.A6"; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x80000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x50D00000; +mpu_armv75.size = 14; +mpu_armv75.allowExecute = false; +mpu_armv75.attributes = "Device"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.baseAddr = 0x72000000; +mpu_armv76.size = 14; +mpu_armv76.allowExecute = false; +mpu_armv76.attributes = "NonCached"; diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/main.c b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/main.c new file mode 100644 index 0000000..9786873 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/main.c @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2018-2022 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" +#include "FreeRTOS.h" +#include "task.h" + +#define MAIN_TASK_PRI (configMAX_PRIORITIES-1) + +#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE)) +StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32))); + +StaticTask_t gMainTaskObj; +TaskHandle_t gMainTask; + +void transforms_test_main(void *args); + +void freertos_main(void *args) +{ + transforms_test_main(NULL); + + vTaskDelete(NULL); +} + + +int main(void) +{ + /* init SOC specific modules */ + System_init(); + Board_init(); + + /* This task is created at highest priority, it should create more tasks and then delete itself */ + gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */ + "freertos_main", /* Text name for the task. This is to facilitate debugging only. */ + MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */ + NULL, /* We are not using the task parameter. */ + MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */ + gMainTaskStack, /* pointer to stack base */ + &gMainTaskObj ); /* pointer to statically allocated task object memory */ + configASSERT(gMainTask != NULL); + + /* Start the scheduler to start the tasks executing. */ + vTaskStartScheduler(); + + /* The following line should never be reached because vTaskStartScheduler() + will only return if there was not enough FreeRTOS heap memory available to + create the Idle and (if configured) Timer tasks. Heap management, and + techniques for trapping heap exhaustion, are described in the book text. */ + DebugP_assertNoLog(0); + + return 0; +} diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec new file mode 100644 index 0000000..bcf351b --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/linker.cmd b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/linker.cmd new file mode 100644 index 0000000..7a34f5e --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/linker.cmd @@ -0,0 +1,137 @@ + +/* This is the stack that is used by code running within main() + * In case of NORTOS, + * - This means all the code outside of ISR uses this stack + * In case of FreeRTOS + * - This means all the code until vTaskStartScheduler() is called in main() + * uses this stack. + * - After vTaskStartScheduler() each task created in FreeRTOS has its own stack + */ +--stack_size=16384 +/* This is the heap size for malloc() API in NORTOS and FreeRTOS + * This is also the heap used by pvPortMalloc in FreeRTOS + */ +--heap_size=32768 +-e_vectors /* This is the entry of the application, _vector MUST be plabed starting address 0x0 */ + +/* This is the size of stack when R5 is in IRQ mode + * In NORTOS, + * - Here interrupt nesting is enabled + * - This is the stack used by ISRs registered as type IRQ + * In FreeRTOS, + * - Here interrupt nesting is enabled + * - This is stack that is used initally when a IRQ is received + * - But then the mode is switched to SVC mode and SVC stack is used for all user ISR callbacks + * - Hence in FreeRTOS, IRQ stack size is less and SVC stack size is more + */ +__IRQ_STACK_SIZE = 256; +/* This is the size of stack when R5 is in IRQ mode + * - In both NORTOS and FreeRTOS nesting is disabled for FIQ + */ +__FIQ_STACK_SIZE = 256; +__SVC_STACK_SIZE = 4096; /* This is the size of stack when R5 is in SVC mode */ +__ABORT_STACK_SIZE = 256; /* This is the size of stack when R5 is in ABORT mode */ +__UNDEFINED_STACK_SIZE = 256; /* This is the size of stack when R5 is in UNDEF mode */ + +SECTIONS +{ + /* This has the R5F entry point and vector table, this MUST be at 0x0 */ + .vectors:{} palign(8) > R5F_VECS + + /* This has the R5F boot code until MPU is enabled, this MUST be at a address < 0x80000000 + * i.e this cannot be placed in DDR + */ + GROUP { + .text.hwi: palign(8) + .text.cache: palign(8) + .text.mpu: palign(8) + .text.boot: palign(8) + .text:abort: palign(8) /* this helps in loading symbols when using XIP mode */ + } > OCRAM + + /* This is rest of code. This can be placed in DDR if DDR is available and needed */ + GROUP { + .text: {} palign(8) /* This is where code resides */ + .rodata: {} palign(8) /* This is where const's go */ + } > OCRAM + + /* This is rest of initialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + + .data: {} palign(8) /* This is where initialized globals and static go */ + } > OCRAM + + /* This is rest of uninitialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + .bss: {} palign(8) /* This is where uninitialized globals go */ + RUN_START(__BSS_START) + RUN_END(__BSS_END) + .sysmem: {} palign(8) /* This is where the malloc heap goes */ + .stack: {} palign(8) /* This is where the main() stack goes */ + } > OCRAM + + /* This is where the stacks for different R5F modes go */ + GROUP { + .irqstack: {. = . + __IRQ_STACK_SIZE;} align(8) + RUN_START(__IRQ_STACK_START) + RUN_END(__IRQ_STACK_END) + .fiqstack: {. = . + __FIQ_STACK_SIZE;} align(8) + RUN_START(__FIQ_STACK_START) + RUN_END(__FIQ_STACK_END) + .svcstack: {. = . + __SVC_STACK_SIZE;} align(8) + RUN_START(__SVC_STACK_START) + RUN_END(__SVC_STACK_END) + .abortstack: {. = . + __ABORT_STACK_SIZE;} align(8) + RUN_START(__ABORT_STACK_START) + RUN_END(__ABORT_STACK_END) + .undefinedstack: {. = . + __UNDEFINED_STACK_SIZE;} align(8) + RUN_START(__UNDEFINED_STACK_START) + RUN_END(__UNDEFINED_STACK_END) + } > OCRAM + + /* Sections needed for C++ projects */ + GROUP { + .ARM.exidx: {} palign(8) /* Needed for C++ exception handling */ + .init_array: {} palign(8) /* Contains function pointers called before main */ + .fini_array: {} palign(8) /* Contains function pointers called after main */ + } > OCRAM + + /* General purpose user shared memory, used in some examples */ + .bss.user_shared_mem (NOLOAD) : {} > USER_SHM_MEM + /* this is used when Debug log's to shared memory are enabled, else this is not used */ + .bss.log_shared_mem (NOLOAD) : {} > LOG_SHM_MEM + /* this is used only when IPC RPMessage is enabled, else this is not used */ + .bss.ipc_vring_mem (NOLOAD) : {} > RTOS_NORTOS_IPC_SHM_MEM + /* this is used only when Secure IPC is enabled */ + .bss.sipc_hsm_queue_mem (NOLOAD) : {} > MAILBOX_HSM + .bss.sipc_r5f_queue_mem (NOLOAD) : {} > MAILBOX_R5F +} + +MEMORY +{ + R5F_VECS : ORIGIN = 0x00000000 , LENGTH = 0x00000040 + R5F_TCMA : ORIGIN = 0x00000040 , LENGTH = 0x00007FC0 + R5F_TCMB : ORIGIN = 0x00080000 , LENGTH = 0x00008000 + + /* when using multi-core application's i.e more than one R5F/M4F active, make sure + * this memory does not overlap with other R5F's + */ + OCRAM : ORIGIN = 0x70040000 , LENGTH = 0x40000 + + /* This section can be used to put XIP section of the application in flash, make sure this does not overlap with + * other CPUs. Also make sure to add a MPU entry for this section and mark it as cached and code executable + */ + FLASH : ORIGIN = 0x60100000 , LENGTH = 0x80000 + + + /* shared memories that are used by RTOS/NORTOS cores */ + /* On R5F, + * - make sure there is a MPU entry which maps below regions as non-cache + */ + USER_SHM_MEM : ORIGIN = 0x701D0000, LENGTH = 0x00004000 + LOG_SHM_MEM : ORIGIN = 0x701D4000, LENGTH = 0x00004000 + /* MSS mailbox memory is used as shared memory, we dont use bottom 32*12 bytes, since its used as SW queue by ipc_notify */ + RTOS_NORTOS_IPC_SHM_MEM : ORIGIN = 0x72000000, LENGTH = 0x3E80 + MAILBOX_HSM: ORIGIN = 0x44000000 , LENGTH = 0x000003CE + MAILBOX_R5F: ORIGIN = 0x44000400 , LENGTH = 0x000003CE + } diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile new file mode 100644 index 0000000..1647041 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -0,0 +1,283 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak +include $(MOTOR_CONTROL_SDK_PATH)/devconfig/devconfig.mak + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=transforms_test.$(PROFILE).out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=transforms_test.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=transforms_test.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=transforms_test.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=transforms_test.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=transforms_test.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=transforms_test.$(PROFILE).rprc_tmp + +FILES_common := \ + transforms_test.c \ + main.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source \ + -I${MOTOR_CONTROL_SDK_PATH}/source \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/FreeRTOS-Kernel/include \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/config/am263x/r5f \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/park \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/trig \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM263X \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-deprecated-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lfreertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lmathlib.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + + +LIBS_NAME = \ + freertos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + mathlib.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/freertos/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am263x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + +all: $(BOOTIMAGE_NAME) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +$(OUTNAME): syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) + @echo . + @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + @echo Linking: am263x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am263x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am263x:r5fss0-0:freertos:ti-arm-clang transforms_test ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --context r5fss0-0 --part AM263x --package ZCZ --output generated/ ../example.syscfg + +syscfg-gui: + $(SYSCFG_NWJS) $(SYSCFG_PATH) --product $(SYSCFG_SDKPRODUCT) --device AM263x_beta --context r5fss0-0 --part AM263x --package ZCZ --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + + +BOOTIMAGE_CORE_ID_r5fss0-0 = 0 +BOOTIMAGE_CORE_ID_r5fss0-1 = 1 +BOOTIMAGE_CORE_ID_r5fss1-0 = 2 +BOOTIMAGE_CORE_ID_r5fss1-1 = 3 +SBL_RUN_ADDRESS=0x70002000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) + @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! + @echo . + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 0000000..e0799fb --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,84 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - MOTOR_CONTROL_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include ${MOTOR_CONTROL_SDK_PATH}/imports.mak +include ${MOTOR_CONTROL_SDK_PATH}/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 0 +BOOTIMAGE_CORE_ID_r5fss0-1 = 1 +BOOTIMAGE_CORE_ID_r5fss1-0 = 2 +BOOTIMAGE_CORE_ID_r5fss1-1 = 3 +SBL_RUN_ADDRESS=0x70002000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + @echo Boot image: am263x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! + @echo . +endif diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec new file mode 100644 index 0000000..bd49a81 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(MOTOR_CONTROL_SDK_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 0000000..c2be5da --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "mcu_plus_sdk/kernel/freertos/rov/FreeRTOS.rov.js", +]; diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/example.syscfg b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/example.syscfg new file mode 100644 index 0000000..62a0408 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/example.syscfg @@ -0,0 +1,59 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM263x_beta" --package "ZCZ" --part "AM263x" --context "r5fss0-0" --product "MOTOR_CONTROL_SDK_AM263x@09.01.00" + * @versions {"tool":"1.14.0+2667"} + */ + +/** + * Import the modules used in this configuration. + */ +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const mpu_armv76 = mpu_armv7.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART0"; +debug_log.uartLog.UART.$assign = "UART0"; +debug_log.uartLog.UART.RXD.$assign = "ball.A7"; +debug_log.uartLog.UART.TXD.$assign = "ball.A6"; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x80000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x50D00000; +mpu_armv75.size = 14; +mpu_armv75.allowExecute = false; +mpu_armv75.attributes = "Device"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.baseAddr = 0x72000000; +mpu_armv76.size = 14; +mpu_armv76.allowExecute = false; +mpu_armv76.attributes = "NonCached"; diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/main.c b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/main.c new file mode 100644 index 0000000..a2defb6 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/main.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2018-2022 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" + +void transforms_test_main(void *args); + +int main(void) +{ + System_init(); + Board_init(); + + transforms_test_main(NULL); + + Board_deinit(); + System_deinit(); + + return 0; +} diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec new file mode 100644 index 0000000..02ca37c --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/linker.cmd b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/linker.cmd new file mode 100644 index 0000000..7a34f5e --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/linker.cmd @@ -0,0 +1,137 @@ + +/* This is the stack that is used by code running within main() + * In case of NORTOS, + * - This means all the code outside of ISR uses this stack + * In case of FreeRTOS + * - This means all the code until vTaskStartScheduler() is called in main() + * uses this stack. + * - After vTaskStartScheduler() each task created in FreeRTOS has its own stack + */ +--stack_size=16384 +/* This is the heap size for malloc() API in NORTOS and FreeRTOS + * This is also the heap used by pvPortMalloc in FreeRTOS + */ +--heap_size=32768 +-e_vectors /* This is the entry of the application, _vector MUST be plabed starting address 0x0 */ + +/* This is the size of stack when R5 is in IRQ mode + * In NORTOS, + * - Here interrupt nesting is enabled + * - This is the stack used by ISRs registered as type IRQ + * In FreeRTOS, + * - Here interrupt nesting is enabled + * - This is stack that is used initally when a IRQ is received + * - But then the mode is switched to SVC mode and SVC stack is used for all user ISR callbacks + * - Hence in FreeRTOS, IRQ stack size is less and SVC stack size is more + */ +__IRQ_STACK_SIZE = 256; +/* This is the size of stack when R5 is in IRQ mode + * - In both NORTOS and FreeRTOS nesting is disabled for FIQ + */ +__FIQ_STACK_SIZE = 256; +__SVC_STACK_SIZE = 4096; /* This is the size of stack when R5 is in SVC mode */ +__ABORT_STACK_SIZE = 256; /* This is the size of stack when R5 is in ABORT mode */ +__UNDEFINED_STACK_SIZE = 256; /* This is the size of stack when R5 is in UNDEF mode */ + +SECTIONS +{ + /* This has the R5F entry point and vector table, this MUST be at 0x0 */ + .vectors:{} palign(8) > R5F_VECS + + /* This has the R5F boot code until MPU is enabled, this MUST be at a address < 0x80000000 + * i.e this cannot be placed in DDR + */ + GROUP { + .text.hwi: palign(8) + .text.cache: palign(8) + .text.mpu: palign(8) + .text.boot: palign(8) + .text:abort: palign(8) /* this helps in loading symbols when using XIP mode */ + } > OCRAM + + /* This is rest of code. This can be placed in DDR if DDR is available and needed */ + GROUP { + .text: {} palign(8) /* This is where code resides */ + .rodata: {} palign(8) /* This is where const's go */ + } > OCRAM + + /* This is rest of initialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + + .data: {} palign(8) /* This is where initialized globals and static go */ + } > OCRAM + + /* This is rest of uninitialized data. This can be placed in DDR if DDR is available and needed */ + GROUP { + .bss: {} palign(8) /* This is where uninitialized globals go */ + RUN_START(__BSS_START) + RUN_END(__BSS_END) + .sysmem: {} palign(8) /* This is where the malloc heap goes */ + .stack: {} palign(8) /* This is where the main() stack goes */ + } > OCRAM + + /* This is where the stacks for different R5F modes go */ + GROUP { + .irqstack: {. = . + __IRQ_STACK_SIZE;} align(8) + RUN_START(__IRQ_STACK_START) + RUN_END(__IRQ_STACK_END) + .fiqstack: {. = . + __FIQ_STACK_SIZE;} align(8) + RUN_START(__FIQ_STACK_START) + RUN_END(__FIQ_STACK_END) + .svcstack: {. = . + __SVC_STACK_SIZE;} align(8) + RUN_START(__SVC_STACK_START) + RUN_END(__SVC_STACK_END) + .abortstack: {. = . + __ABORT_STACK_SIZE;} align(8) + RUN_START(__ABORT_STACK_START) + RUN_END(__ABORT_STACK_END) + .undefinedstack: {. = . + __UNDEFINED_STACK_SIZE;} align(8) + RUN_START(__UNDEFINED_STACK_START) + RUN_END(__UNDEFINED_STACK_END) + } > OCRAM + + /* Sections needed for C++ projects */ + GROUP { + .ARM.exidx: {} palign(8) /* Needed for C++ exception handling */ + .init_array: {} palign(8) /* Contains function pointers called before main */ + .fini_array: {} palign(8) /* Contains function pointers called after main */ + } > OCRAM + + /* General purpose user shared memory, used in some examples */ + .bss.user_shared_mem (NOLOAD) : {} > USER_SHM_MEM + /* this is used when Debug log's to shared memory are enabled, else this is not used */ + .bss.log_shared_mem (NOLOAD) : {} > LOG_SHM_MEM + /* this is used only when IPC RPMessage is enabled, else this is not used */ + .bss.ipc_vring_mem (NOLOAD) : {} > RTOS_NORTOS_IPC_SHM_MEM + /* this is used only when Secure IPC is enabled */ + .bss.sipc_hsm_queue_mem (NOLOAD) : {} > MAILBOX_HSM + .bss.sipc_r5f_queue_mem (NOLOAD) : {} > MAILBOX_R5F +} + +MEMORY +{ + R5F_VECS : ORIGIN = 0x00000000 , LENGTH = 0x00000040 + R5F_TCMA : ORIGIN = 0x00000040 , LENGTH = 0x00007FC0 + R5F_TCMB : ORIGIN = 0x00080000 , LENGTH = 0x00008000 + + /* when using multi-core application's i.e more than one R5F/M4F active, make sure + * this memory does not overlap with other R5F's + */ + OCRAM : ORIGIN = 0x70040000 , LENGTH = 0x40000 + + /* This section can be used to put XIP section of the application in flash, make sure this does not overlap with + * other CPUs. Also make sure to add a MPU entry for this section and mark it as cached and code executable + */ + FLASH : ORIGIN = 0x60100000 , LENGTH = 0x80000 + + + /* shared memories that are used by RTOS/NORTOS cores */ + /* On R5F, + * - make sure there is a MPU entry which maps below regions as non-cache + */ + USER_SHM_MEM : ORIGIN = 0x701D0000, LENGTH = 0x00004000 + LOG_SHM_MEM : ORIGIN = 0x701D4000, LENGTH = 0x00004000 + /* MSS mailbox memory is used as shared memory, we dont use bottom 32*12 bytes, since its used as SW queue by ipc_notify */ + RTOS_NORTOS_IPC_SHM_MEM : ORIGIN = 0x72000000, LENGTH = 0x3E80 + MAILBOX_HSM: ORIGIN = 0x44000000 , LENGTH = 0x000003CE + MAILBOX_R5F: ORIGIN = 0x44000400 , LENGTH = 0x000003CE + } diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/makefile b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/makefile new file mode 100644 index 0000000..4facccd --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/makefile @@ -0,0 +1,280 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak +include $(MOTOR_CONTROL_SDK_PATH)/devconfig/devconfig.mak + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=transforms_test.$(PROFILE).out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=transforms_test.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=transforms_test.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=transforms_test.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=transforms_test.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=transforms_test.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=transforms_test.$(PROFILE).rprc_tmp + +FILES_common := \ + transforms_test.c \ + main.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source \ + -I${MOTOR_CONTROL_SDK_PATH}/source \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/clarke \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/park \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/ipark \ + -I${MOTOR_CONTROL_SDK_PATH}/source/transforms/svgen \ + -I${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/trig \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM263X \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-deprecated-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/nortos/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + -Wl,-i${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lnortos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lboard.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -lmathlib.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + + +LIBS_NAME = \ + nortos.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + board.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + mathlib.am263x.r5f.ti-arm-clang.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/kernel/nortos/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/drivers/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/board/lib \ + ${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/source/mathlib/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am263x:r5fss0-0:nortos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am263x:r5fss0-0:nortos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $< + +all: $(BOOTIMAGE_NAME) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +$(OUTNAME): syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) + @echo . + @echo Linking: am263x:r5fss0-0:nortos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) + @echo Linking: am263x:r5fss0-0:nortos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am263x:r5fss0-0:nortos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am263x:r5fss0-0:nortos:ti-arm-clang transforms_test ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --context r5fss0-0 --part AM263x --package ZCZ --output generated/ ../example.syscfg + +syscfg-gui: + $(SYSCFG_NWJS) $(SYSCFG_PATH) --product $(SYSCFG_SDKPRODUCT) --device AM263x_beta --context r5fss0-0 --part AM263x --package ZCZ --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + + +BOOTIMAGE_CORE_ID_r5fss0-0 = 0 +BOOTIMAGE_CORE_ID_r5fss0-1 = 1 +BOOTIMAGE_CORE_ID_r5fss1-0 = 2 +BOOTIMAGE_CORE_ID_r5fss1-1 = 3 +SBL_RUN_ADDRESS=0x70002000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am263x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) + @echo Boot image: am263x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ Done !!! + @echo . + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 0000000..d790183 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,84 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - MOTOR_CONTROL_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include ${MOTOR_CONTROL_SDK_PATH}/imports.mak +include ${MOTOR_CONTROL_SDK_PATH}/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 0 +BOOTIMAGE_CORE_ID_r5fss0-1 = 1 +BOOTIMAGE_CORE_ID_r5fss1-0 = 2 +BOOTIMAGE_CORE_ID_r5fss1-1 = 3 +SBL_RUN_ADDRESS=0x70002000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/out2rprc/elf2rprc.js + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.exe +else + XIPGEN_CMD=$(MOTOR_CONTROL_SDK_PATH)/mcu_plus_sdk/tools/boot/xipGen/xipGen.out +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am263x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + @echo Boot image: am263x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_NAME) Done !!! + @echo . +endif diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec new file mode 100644 index 0000000..a448d69 --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,20 @@ +# +# Auto generated makefile +# + +export MOTOR_CONTROL_SDK_PATH?=$(abspath ../../../../../..) +include $(MOTOR_CONTROL_SDK_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(MOTOR_CONTROL_SDK_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(MOTOR_CONTROL_SDK_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 0000000..c2be5da --- /dev/null +++ b/examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,8 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "mcu_plus_sdk/kernel/freertos/rov/FreeRTOS.rov.js", +]; diff --git a/examples/transforms/transforms_test/transforms_test.c b/examples/transforms/transforms_test/transforms_test.c new file mode 100644 index 0000000..828550d --- /dev/null +++ b/examples/transforms/transforms_test/transforms_test.c @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "transforms_test.h" + +int verify_output(int test_num,\ +float32_t* alphaBetaCurrent, float32_t* dqCurrent, float32_t* alphaBetaVoltage, float32_t* abcOutput) +{ + // Compares park output with expected park output + bool is_park_erroneous = is_different(testParams[test_num].refAlpha, dqCurrent[0]) || is_different(testParams[test_num].refBeta, dqCurrent[1]); + + // Compares svgen output with expected svgen output + bool is_svgen_erroneous = is_different(testParams[test_num].refA, abcOutput[0]) || is_different(testParams[test_num].refB, abcOutput[1]) || is_different(testParams[test_num].refC, abcOutput[2]); + + // Compares output make sure that running park then ipark would revert all the changes + bool is_park_ipark_erroneous = is_different(alphaBetaCurrent[0], alphaBetaVoltage[0]) || is_different(alphaBetaCurrent[1], alphaBetaVoltage[1]); + + if (is_park_erroneous || is_svgen_erroneous || is_park_ipark_erroneous) + { + DebugP_log("Test case %d (zero-indexed) produced error:\n",test_num); + if(is_park_erroneous)\ + DebugP_log("Incorrect park value, the resultant is %f %f, but the expected is %f %f\n",dqCurrent[0],dqCurrent[1], testParams[test_num].refAlpha, testParams[test_num].refBeta); + if(is_svgen_erroneous)\ + DebugP_log("Incorrect svgen value, the resultant is %f %f %f, but the expected is %f %f %f\n", abcOutput[0], abcOutput[1], abcOutput[2], testParams[test_num].refA, testParams[test_num].refB, testParams[test_num].refC); + if(is_park_ipark_erroneous)\ + DebugP_log("Incorrect value, the original clarke value is %f %f, but the value after park-ipark is %f %f, before and after value should be the same\n", alphaBetaCurrent[0], alphaBetaCurrent[1], alphaBetaVoltage[0], alphaBetaVoltage[1]); + return 1; + } + return 0; +} + +void transforms_test_main() +{ + int testSize = sizeof(testParams)/sizeof(*testParams); + int error = 0; + + + for (int idx = 0; idx < testSize; idx++) + { + float32_t abcOutput[3], abcInput[3] = {testParams[idx].inA,testParams[idx].inB,testParams[idx].inC}; + float32_t alphaBetaI[2], dqI[2], alphaBetaV[2]; + + float32_t sincosVal[2]; + ti_arm_sincos(phasorOffset, &sincosVal[0]); + + CLARKE_run_threeInput(abcInput[0], abcInput[1], abcInput[2], &alphaBetaI[0], &alphaBetaI[1]); + PARK_run(sincosVal[0], sincosVal[1], alphaBetaI[0], alphaBetaI[1], &dqI[0], &dqI[1]); + IPARK_run(sincosVal[0], sincosVal[1], dqI[0], dqI[1], &alphaBetaV[0], &alphaBetaV[1]); + + // + // Using common mode for SVM modulation, functions for DPWM min/max modulation are also provided + // + SVGEN_runCom(1.0f, alphaBetaV[0], alphaBetaV[1], &abcOutput[0], &abcOutput[1], &abcOutput[2]); + + error += verify_output(idx, &alphaBetaI[0], &dqI[0], &alphaBetaV[0], &abcOutput[0]); + } + + DebugP_log("Transforms test produced %d error",error); + +} diff --git a/examples/transforms/transforms_test/transforms_test.h b/examples/transforms/transforms_test/transforms_test.h new file mode 100644 index 0000000..9696407 --- /dev/null +++ b/examples/transforms/transforms_test/transforms_test.h @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TRANSFORMS_TEST +#define TRANSFORMS_TEST + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "ti_drivers_config.h" +#include "ti_drivers_open_close.h" +#include "ti_board_open_close.h" + +#include "ti_arm_trig.h" +#include "clarke.h" +#include "park.h" +#include "ipark.h" +#include "svgen.h" + +#include +#include + + +typedef struct { + /* Provided Input */ + float32_t inA; + float32_t inB; + float32_t inC; + /* Reference Output */ + float32_t refAlpha; // expected value for PARK output + float32_t refBeta; // expected value for PARK output + float32_t refA; // expected value for SVGEN output + float32_t refB; // expected value for SVGEN output + float32_t refC; // expected value for SVGEN output +} transform_test_t; + +#define ERROR_TOL 1e-05f +#define exceeds_tolerance(x) x > ERROR_TOL +#define is_different(x,y) exceeds_tolerance(fabsf(x - y)) + +static float32_t phasorOffset = M_PI_2; + +static transform_test_t testParams[] = +{ + { + 1.0f, -0.5f,-0.5f, + -0.0f, -1.0f, + 0.75f, -0.75f, -0.75f + }, + { + 0.75f, -0.158494f, -0.591506f, + 0.250000f, -0.750000f, + 0.670753f, -0.237741f, -0.670753f + }, + { + 0.5f, 0.183013,-0.683013, + 0.5f, -0.5f, + 0.591506f, 0.274520f, -0.591506f + }, + { + 0.25f,0.524519f,-0.774519f, + 0.75f, -0.25f, + 0.375f, 0.649519f, -0.649519f + }, + { + 0.0f,0.866025f,-0.866025f, + 1.0f, 0.0f, + 0.0f, 0.866025f, -0.866025f + }, + { + -0.25f,0.774519f,-0.524519f, + 0.75f, 0.25f, + -0.375000f, 0.649519f, -0.649519f + }, + { + -0.5f,0.683013f,-0.183013f, + 0.5f, 0.5f, + -0.591506f, 0.591506f, -0.274519f + }, + { + -0.75f,0.591506f,0.158494f, + 0.25f, 0.75f, + -0.670753f, 0.670753f, 0.237741f + }, + { + -1.0f,0.5f,0.5f, + 0.0f, 1.0f, + -0.75f, 0.75f, 0.75f + }, + { + -0.75f,0.591506f,0.158494f, + 0.25f,0.75f, + -0.670753f, 0.670753f, 0.237741f + }, + { + -0.500000f, 0.683013f, -0.183013f, + 0.5f,0.5f, + -0.591506f, 0.591506f, -0.274519f + }, + { + -0.250000f, -0.524519f, 0.774519f, + -0.75f,0.25f, + -0.375000f, -0.649519f, 0.649519f + }, + { + 0.000000f, -0.866025f, 0.866025f, + -1.0f,0.0f, + 0.0f, -0.866025f, 0.866025f + }, + { + 0.250000f, -0.774519f, 0.524519f, + -0.75f,-0.25f, + 0.375f, -0.649519, 0.649519f + }, + { + 0.500000f, -0.683013f, 0.183013f, + -0.5f,-0.5f, + 0.591506f, -0.591506f, 0.274519f + }, + { + 0.750000f, -0.591506f, -0.158494f, + -0.25f,-0.75f, + 0.670753f, -0.670753f, -0.237741f + }, +}; + + +#ifdef __cplusplus +} +#endif // extern "C" + +#endif diff --git a/makefile.am243x b/makefile.am243x index 1c9820e..7f97749 100644 --- a/makefile.am243x +++ b/makefile.am243x @@ -58,6 +58,10 @@ help: @echo $(MAKE) -s -C examples/dcl/dcl_pi/am243x-evm/r5fss0-0_freertos/ti-arm-clang [all clean syscfg-gui syscfg] @echo $(MAKE) -s -C examples/dcl/dcl_pi/am243x-lp/r5fss0-0_nortos/ti-arm-clang [all clean syscfg-gui syscfg] @echo $(MAKE) -s -C examples/dcl/dcl_pi/am243x-lp/r5fss0-0_freertos/ti-arm-clang [all clean syscfg-gui syscfg] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang [all clean syscfg-gui syscfg] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang [all clean syscfg-gui syscfg] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang [all clean syscfg-gui syscfg] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang [all clean syscfg-gui syscfg] @echo $(MAKE) -s -C examples/position_sense/endat_diagnostic/single_channel/am243x-evm/r5fss0-0_freertos/ti-arm-clang [all clean syscfg-gui syscfg] @echo $(MAKE) -s -C examples/position_sense/endat_diagnostic/single_channel/am243x-lp/r5fss0-0_freertos/ti-arm-clang [all clean syscfg-gui syscfg] @echo $(MAKE) -s -C examples/position_sense/endat_diagnostic/multi_channel_load_share/am243x-evm/r5fss0-0_freertos/ti-arm-clang [all clean syscfg-gui syscfg] @@ -229,6 +233,10 @@ BUILD_COMBO_EXAMPLE_ALL += dcl_pi_am243x-evm_r5fss0-0_nortos_ti-arm-clang BUILD_COMBO_EXAMPLE_ALL += dcl_pi_am243x-evm_r5fss0-0_freertos_ti-arm-clang BUILD_COMBO_EXAMPLE_ALL += dcl_pi_am243x-lp_r5fss0-0_nortos_ti-arm-clang BUILD_COMBO_EXAMPLE_ALL += dcl_pi_am243x-lp_r5fss0-0_freertos_ti-arm-clang +BUILD_COMBO_EXAMPLE_ALL += transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang +BUILD_COMBO_EXAMPLE_ALL += transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang +BUILD_COMBO_EXAMPLE_ALL += transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang +BUILD_COMBO_EXAMPLE_ALL += transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang BUILD_COMBO_EXAMPLE_ALL += endat_diagnostic_single_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang BUILD_COMBO_EXAMPLE_ALL += endat_diagnostic_single_channel_am243x-lp_r5fss0-0_freertos_ti-arm-clang BUILD_COMBO_EXAMPLE_ALL += endat_diagnostic_multi_channel_load_share_am243x-evm_r5fss0-0_freertos_ti-arm-clang @@ -303,6 +311,18 @@ examples-private: $(BUILD_COMBO_EXAMPLE_PRIVATE_ALL) dcl_pi_am243x-lp_r5fss0-0_freertos_ti-arm-clang: $(MAKE) -C examples/dcl/dcl_pi/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile all + transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang: + $(MAKE) -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang -f makefile all + + transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang: + $(MAKE) -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile all + + transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang: + $(MAKE) -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile all + + transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang: + $(MAKE) -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile all + endat_diagnostic_single_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang: $(MAKE) -C examples/position_sense/endat_diagnostic/single_channel/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile all @@ -434,6 +454,10 @@ BUILD_COMBO_EXAMPLE_CLEAN_ALL += dcl_pi_am243x-evm_r5fss0-0_nortos_ti-arm-clang_ BUILD_COMBO_EXAMPLE_CLEAN_ALL += dcl_pi_am243x-evm_r5fss0-0_freertos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_CLEAN_ALL += dcl_pi_am243x-lp_r5fss0-0_nortos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_CLEAN_ALL += dcl_pi_am243x-lp_r5fss0-0_freertos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_CLEAN_ALL += transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_CLEAN_ALL += transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_CLEAN_ALL += transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_CLEAN_ALL += transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_CLEAN_ALL += endat_diagnostic_single_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_CLEAN_ALL += endat_diagnostic_single_channel_am243x-lp_r5fss0-0_freertos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_CLEAN_ALL += endat_diagnostic_multi_channel_load_share_am243x-evm_r5fss0-0_freertos_ti-arm-clang_clean @@ -508,6 +532,18 @@ examples-private-clean: $(BUILD_COMBO_EXAMPLE_PRIVATE_CLEAN_ALL) dcl_pi_am243x-lp_r5fss0-0_freertos_ti-arm-clang_clean: $(MAKE) -C examples/dcl/dcl_pi/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile clean + transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang -f makefile clean + + transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile clean + + transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile clean + + transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile clean + endat_diagnostic_single_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang_clean: $(MAKE) -C examples/position_sense/endat_diagnostic/single_channel/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile clean @@ -639,6 +675,10 @@ BUILD_COMBO_EXAMPLE_SCRUB_ALL += dcl_pi_am243x-evm_r5fss0-0_nortos_ti-arm-clang_ BUILD_COMBO_EXAMPLE_SCRUB_ALL += dcl_pi_am243x-evm_r5fss0-0_freertos_ti-arm-clang_scrub BUILD_COMBO_EXAMPLE_SCRUB_ALL += dcl_pi_am243x-lp_r5fss0-0_nortos_ti-arm-clang_scrub BUILD_COMBO_EXAMPLE_SCRUB_ALL += dcl_pi_am243x-lp_r5fss0-0_freertos_ti-arm-clang_scrub +BUILD_COMBO_EXAMPLE_SCRUB_ALL += transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang_scrub +BUILD_COMBO_EXAMPLE_SCRUB_ALL += transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang_scrub +BUILD_COMBO_EXAMPLE_SCRUB_ALL += transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang_scrub +BUILD_COMBO_EXAMPLE_SCRUB_ALL += transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang_scrub BUILD_COMBO_EXAMPLE_SCRUB_ALL += endat_diagnostic_single_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang_scrub BUILD_COMBO_EXAMPLE_SCRUB_ALL += endat_diagnostic_single_channel_am243x-lp_r5fss0-0_freertos_ti-arm-clang_scrub BUILD_COMBO_EXAMPLE_SCRUB_ALL += endat_diagnostic_multi_channel_load_share_am243x-evm_r5fss0-0_freertos_ti-arm-clang_scrub @@ -713,6 +753,18 @@ examples-scrub-private: $(BUILD_COMBO_EXAMPLE_PRIVATE_SCRUB_ALL) dcl_pi_am243x-lp_r5fss0-0_freertos_ti-arm-clang_scrub: $(MAKE) -C examples/dcl/dcl_pi/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile scrub + transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang_scrub: + $(MAKE) -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang -f makefile scrub + + transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang_scrub: + $(MAKE) -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile scrub + + transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang_scrub: + $(MAKE) -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile scrub + + transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang_scrub: + $(MAKE) -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile scrub + endat_diagnostic_single_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang_scrub: $(MAKE) -C examples/position_sense/endat_diagnostic/single_channel/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile scrub diff --git a/makefile.am263x b/makefile.am263x index 8a874ec..22a32d7 100644 --- a/makefile.am263x +++ b/makefile.am263x @@ -48,6 +48,10 @@ help: @echo $(MAKE) -s -C examples/dcl/dcl_pi/am263x-cc/r5fss0-0_freertos/ti-arm-clang [all clean syscfg-gui syscfg] @echo $(MAKE) -s -C examples/dcl/dcl_pi/am263x-lp/r5fss0-0_nortos/ti-arm-clang [all clean syscfg-gui syscfg] @echo $(MAKE) -s -C examples/dcl/dcl_pi/am263x-lp/r5fss0-0_freertos/ti-arm-clang [all clean syscfg-gui syscfg] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang [all clean syscfg-gui syscfg] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang [all clean syscfg-gui syscfg] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang [all clean syscfg-gui syscfg] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang [all clean syscfg-gui syscfg] @echo $(MAKE) -s -C examples/position_sense/tamagawa_diagnostic_over_soc_uart/am263x-lp/r5fss0-0_freertos/ti-arm-clang [all clean syscfg-gui syscfg] @echo . @echo System Example build targets, @@ -120,6 +124,10 @@ BUILD_COMBO_EXAMPLE_ALL += dcl_pi_am263x-cc_r5fss0-0_nortos_ti-arm-clang BUILD_COMBO_EXAMPLE_ALL += dcl_pi_am263x-cc_r5fss0-0_freertos_ti-arm-clang BUILD_COMBO_EXAMPLE_ALL += dcl_pi_am263x-lp_r5fss0-0_nortos_ti-arm-clang BUILD_COMBO_EXAMPLE_ALL += dcl_pi_am263x-lp_r5fss0-0_freertos_ti-arm-clang +BUILD_COMBO_EXAMPLE_ALL += transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang +BUILD_COMBO_EXAMPLE_ALL += transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang +BUILD_COMBO_EXAMPLE_ALL += transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang +BUILD_COMBO_EXAMPLE_ALL += transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang BUILD_COMBO_EXAMPLE_ALL += tamagawa_diagnostic_soc_uart_am263x-lp_r5fss0-0_freertos_ti-arm-clang # Various System Example Targets @@ -155,6 +163,18 @@ examples-private: $(BUILD_COMBO_EXAMPLE_PRIVATE_ALL) dcl_pi_am263x-lp_r5fss0-0_freertos_ti-arm-clang: $(MAKE) -C examples/dcl/dcl_pi/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile all + transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang: + $(MAKE) -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang -f makefile all + + transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang: + $(MAKE) -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang -f makefile all + + transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang: + $(MAKE) -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile all + + transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang: + $(MAKE) -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile all + tamagawa_diagnostic_soc_uart_am263x-lp_r5fss0-0_freertos_ti-arm-clang: $(MAKE) -C examples/position_sense/tamagawa_diagnostic_over_soc_uart/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile all @@ -169,6 +189,10 @@ BUILD_COMBO_EXAMPLE_CLEAN_ALL += dcl_pi_am263x-cc_r5fss0-0_nortos_ti-arm-clang_c BUILD_COMBO_EXAMPLE_CLEAN_ALL += dcl_pi_am263x-cc_r5fss0-0_freertos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_CLEAN_ALL += dcl_pi_am263x-lp_r5fss0-0_nortos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_CLEAN_ALL += dcl_pi_am263x-lp_r5fss0-0_freertos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_CLEAN_ALL += transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_CLEAN_ALL += transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_CLEAN_ALL += transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_CLEAN_ALL += transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_CLEAN_ALL += tamagawa_diagnostic_soc_uart_am263x-lp_r5fss0-0_freertos_ti-arm-clang_clean # Various System Example Clean Targets @@ -204,6 +228,18 @@ examples-private-clean: $(BUILD_COMBO_EXAMPLE_PRIVATE_CLEAN_ALL) dcl_pi_am263x-lp_r5fss0-0_freertos_ti-arm-clang_clean: $(MAKE) -C examples/dcl/dcl_pi/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile clean + transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang -f makefile clean + + transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang -f makefile clean + + transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile clean + + transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile clean + tamagawa_diagnostic_soc_uart_am263x-lp_r5fss0-0_freertos_ti-arm-clang_clean: $(MAKE) -C examples/position_sense/tamagawa_diagnostic_over_soc_uart/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile clean @@ -218,6 +254,10 @@ BUILD_COMBO_EXAMPLE_SCRUB_ALL += dcl_pi_am263x-cc_r5fss0-0_nortos_ti-arm-clang_s BUILD_COMBO_EXAMPLE_SCRUB_ALL += dcl_pi_am263x-cc_r5fss0-0_freertos_ti-arm-clang_scrub BUILD_COMBO_EXAMPLE_SCRUB_ALL += dcl_pi_am263x-lp_r5fss0-0_nortos_ti-arm-clang_scrub BUILD_COMBO_EXAMPLE_SCRUB_ALL += dcl_pi_am263x-lp_r5fss0-0_freertos_ti-arm-clang_scrub +BUILD_COMBO_EXAMPLE_SCRUB_ALL += transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang_scrub +BUILD_COMBO_EXAMPLE_SCRUB_ALL += transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang_scrub +BUILD_COMBO_EXAMPLE_SCRUB_ALL += transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang_scrub +BUILD_COMBO_EXAMPLE_SCRUB_ALL += transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang_scrub BUILD_COMBO_EXAMPLE_SCRUB_ALL += tamagawa_diagnostic_soc_uart_am263x-lp_r5fss0-0_freertos_ti-arm-clang_scrub # Various System Example Scrub Targets @@ -253,6 +293,18 @@ examples-scrub-private: $(BUILD_COMBO_EXAMPLE_PRIVATE_SCRUB_ALL) dcl_pi_am263x-lp_r5fss0-0_freertos_ti-arm-clang_scrub: $(MAKE) -C examples/dcl/dcl_pi/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile scrub + transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang_scrub: + $(MAKE) -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang -f makefile scrub + + transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang_scrub: + $(MAKE) -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang -f makefile scrub + + transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang_scrub: + $(MAKE) -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile scrub + + transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang_scrub: + $(MAKE) -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile scrub + tamagawa_diagnostic_soc_uart_am263x-lp_r5fss0-0_freertos_ti-arm-clang_scrub: $(MAKE) -C examples/position_sense/tamagawa_diagnostic_over_soc_uart/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile scrub diff --git a/makefile_projectspec.am243x b/makefile_projectspec.am243x index f4cdbfd..4004c81 100644 --- a/makefile_projectspec.am243x +++ b/makefile_projectspec.am243x @@ -15,6 +15,10 @@ BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += dcl_pi_am243x-evm_r5fss0-0_nortos_t BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += dcl_pi_am243x-evm_r5fss0-0_freertos_ti-arm-clang_build BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += dcl_pi_am243x-lp_r5fss0-0_nortos_ti-arm-clang_build BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += dcl_pi_am243x-lp_r5fss0-0_freertos_ti-arm-clang_build +BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang_build +BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang_build +BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang_build +BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang_build BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += endat_diagnostic_single_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang_build BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += endat_diagnostic_single_channel_am243x-lp_r5fss0-0_freertos_ti-arm-clang_build BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += endat_diagnostic_multi_channel_load_share_am243x-evm_r5fss0-0_freertos_ti-arm-clang_build @@ -89,6 +93,18 @@ all-private: $(BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_PRIVATE_ALL) dcl_pi_am243x-lp_r5fss0-0_freertos_ti-arm-clang_build: $(MAKE) -C examples/dcl/dcl_pi/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec all + transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang_build: + $(MAKE) -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec all + + transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang_build: + $(MAKE) -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec all + + transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang_build: + $(MAKE) -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec all + + transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang_build: + $(MAKE) -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec all + endat_diagnostic_single_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang_build: $(MAKE) -C examples/position_sense/endat_diagnostic/single_channel/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec all @@ -221,6 +237,10 @@ BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += dcl_pi_am243x-evm_r5fss0-0_nortos_t BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += dcl_pi_am243x-evm_r5fss0-0_freertos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += dcl_pi_am243x-lp_r5fss0-0_nortos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += dcl_pi_am243x-lp_r5fss0-0_freertos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += endat_diagnostic_single_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += endat_diagnostic_single_channel_am243x-lp_r5fss0-0_freertos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += endat_diagnostic_multi_channel_load_share_am243x-evm_r5fss0-0_freertos_ti-arm-clang_clean @@ -295,6 +315,18 @@ clean-private: $(BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_PRIVATE_ALL) dcl_pi_am243x-lp_r5fss0-0_freertos_ti-arm-clang_clean: $(MAKE) -C examples/dcl/dcl_pi/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec clean + transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec clean + + transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec clean + + transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec clean + + transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec clean + endat_diagnostic_single_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang_clean: $(MAKE) -C examples/position_sense/endat_diagnostic/single_channel/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec clean @@ -427,6 +459,10 @@ BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += dcl_pi_am243x-evm_r5fss0-0_nortos_ BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += dcl_pi_am243x-evm_r5fss0-0_freertos_ti-arm-clang_export BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += dcl_pi_am243x-lp_r5fss0-0_nortos_ti-arm-clang_export BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += dcl_pi_am243x-lp_r5fss0-0_freertos_ti-arm-clang_export +BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang_export +BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang_export +BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang_export +BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang_export BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += endat_diagnostic_single_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang_export BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += endat_diagnostic_single_channel_am243x-lp_r5fss0-0_freertos_ti-arm-clang_export BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += endat_diagnostic_multi_channel_load_share_am243x-evm_r5fss0-0_freertos_ti-arm-clang_export @@ -501,6 +537,18 @@ export-private: $(BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_PRIVATE_ALL) dcl_pi_am243x-lp_r5fss0-0_freertos_ti-arm-clang_export: $(MAKE) -C examples/dcl/dcl_pi/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec export + transforms_test_am243x-evm_r5fss0-0_nortos_ti-arm-clang_export: + $(MAKE) -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec export + + transforms_test_am243x-evm_r5fss0-0_freertos_ti-arm-clang_export: + $(MAKE) -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec export + + transforms_test_am243x-lp_r5fss0-0_nortos_ti-arm-clang_export: + $(MAKE) -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec export + + transforms_test_am243x-lp_r5fss0-0_freertos_ti-arm-clang_export: + $(MAKE) -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec export + endat_diagnostic_single_channel_am243x-evm_r5fss0-0_freertos_ti-arm-clang_export: $(MAKE) -C examples/position_sense/endat_diagnostic/single_channel/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec export @@ -658,6 +706,10 @@ help: @echo $(MAKE) -s -C examples/dcl/dcl_pi/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec [export all clean] @echo $(MAKE) -s -C examples/dcl/dcl_pi/am243x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec [export all clean] @echo $(MAKE) -s -C examples/dcl/dcl_pi/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec [export all clean] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec [export all clean] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec [export all clean] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec [export all clean] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec [export all clean] @echo $(MAKE) -s -C examples/position_sense/endat_diagnostic/single_channel/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec [export all clean] @echo $(MAKE) -s -C examples/position_sense/endat_diagnostic/single_channel/am243x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec [export all clean] @echo $(MAKE) -s -C examples/position_sense/endat_diagnostic/multi_channel_load_share/am243x-evm/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec [export all clean] diff --git a/makefile_projectspec.am263x b/makefile_projectspec.am263x index 9130f64..4399d5c 100644 --- a/makefile_projectspec.am263x +++ b/makefile_projectspec.am263x @@ -12,6 +12,10 @@ BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += dcl_pi_am263x-cc_r5fss0-0_nortos_ti BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += dcl_pi_am263x-cc_r5fss0-0_freertos_ti-arm-clang_build BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += dcl_pi_am263x-lp_r5fss0-0_nortos_ti-arm-clang_build BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += dcl_pi_am263x-lp_r5fss0-0_freertos_ti-arm-clang_build +BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang_build +BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang_build +BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang_build +BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang_build BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_ALL += tamagawa_diagnostic_soc_uart_am263x-lp_r5fss0-0_freertos_ti-arm-clang_build # Various System Example Projectspec Build Targets @@ -47,6 +51,18 @@ all-private: $(BUILD_COMBO_EXAMPLE_PROJECTSPEC_BUILD_PRIVATE_ALL) dcl_pi_am263x-lp_r5fss0-0_freertos_ti-arm-clang_build: $(MAKE) -C examples/dcl/dcl_pi/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec all + transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang_build: + $(MAKE) -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec all + + transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang_build: + $(MAKE) -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec all + + transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang_build: + $(MAKE) -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec all + + transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang_build: + $(MAKE) -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec all + tamagawa_diagnostic_soc_uart_am263x-lp_r5fss0-0_freertos_ti-arm-clang_build: $(MAKE) -C examples/position_sense/tamagawa_diagnostic_over_soc_uart/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec all @@ -62,6 +78,10 @@ BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += dcl_pi_am263x-cc_r5fss0-0_nortos_ti BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += dcl_pi_am263x-cc_r5fss0-0_freertos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += dcl_pi_am263x-lp_r5fss0-0_nortos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += dcl_pi_am263x-lp_r5fss0-0_freertos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang_clean +BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang_clean BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_ALL += tamagawa_diagnostic_soc_uart_am263x-lp_r5fss0-0_freertos_ti-arm-clang_clean # Various System Example Projectspec Clean Targets @@ -97,6 +117,18 @@ clean-private: $(BUILD_COMBO_EXAMPLE_PROJECTSPEC_CLEAN_PRIVATE_ALL) dcl_pi_am263x-lp_r5fss0-0_freertos_ti-arm-clang_clean: $(MAKE) -C examples/dcl/dcl_pi/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec clean + transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec clean + + transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec clean + + transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec clean + + transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang_clean: + $(MAKE) -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec clean + tamagawa_diagnostic_soc_uart_am263x-lp_r5fss0-0_freertos_ti-arm-clang_clean: $(MAKE) -C examples/position_sense/tamagawa_diagnostic_over_soc_uart/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec clean @@ -112,6 +144,10 @@ BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += dcl_pi_am263x-cc_r5fss0-0_nortos_t BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += dcl_pi_am263x-cc_r5fss0-0_freertos_ti-arm-clang_export BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += dcl_pi_am263x-lp_r5fss0-0_nortos_ti-arm-clang_export BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += dcl_pi_am263x-lp_r5fss0-0_freertos_ti-arm-clang_export +BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang_export +BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang_export +BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang_export +BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang_export BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_ALL += tamagawa_diagnostic_soc_uart_am263x-lp_r5fss0-0_freertos_ti-arm-clang_export # Various System Example Projectspec Export Targets @@ -147,6 +183,18 @@ export-private: $(BUILD_COMBO_EXAMPLE_PROJECTSPEC_EXPORT_PRIVATE_ALL) dcl_pi_am263x-lp_r5fss0-0_freertos_ti-arm-clang_export: $(MAKE) -C examples/dcl/dcl_pi/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec export + transforms_test_am263x-cc_r5fss0-0_nortos_ti-arm-clang_export: + $(MAKE) -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec export + + transforms_test_am263x-cc_r5fss0-0_freertos_ti-arm-clang_export: + $(MAKE) -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec export + + transforms_test_am263x-lp_r5fss0-0_nortos_ti-arm-clang_export: + $(MAKE) -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec export + + transforms_test_am263x-lp_r5fss0-0_freertos_ti-arm-clang_export: + $(MAKE) -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec export + tamagawa_diagnostic_soc_uart_am263x-lp_r5fss0-0_freertos_ti-arm-clang_export: $(MAKE) -C examples/position_sense/tamagawa_diagnostic_over_soc_uart/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec export @@ -178,6 +226,10 @@ help: @echo $(MAKE) -s -C examples/dcl/dcl_pi/am263x-cc/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec [export all clean] @echo $(MAKE) -s -C examples/dcl/dcl_pi/am263x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec [export all clean] @echo $(MAKE) -s -C examples/dcl/dcl_pi/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec [export all clean] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec [export all clean] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am263x-cc/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec [export all clean] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_nortos/ti-arm-clang -f makefile_projectspec [export all clean] + @echo $(MAKE) -s -C examples/transforms/transforms_test/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec [export all clean] @echo $(MAKE) -s -C examples/position_sense/tamagawa_diagnostic_over_soc_uart/am263x-lp/r5fss0-0_freertos/ti-arm-clang -f makefile_projectspec [export all clean] @echo . @echo System Example ProjectSpec build targets, diff --git a/source/dcl/common/dcl_aux.h b/source/dcl/common/dcl_aux.h index 7203fe5..d75d29a 100644 --- a/source/dcl/common/dcl_aux.h +++ b/source/dcl/common/dcl_aux.h @@ -99,4 +99,4 @@ extern "C" { } #endif // extern "C" -#endif // _DCL_AUX_H_ \ No newline at end of file +#endif // _DCL_AUX_H_ diff --git a/source/dcl/common/dcl_css.h b/source/dcl/common/dcl_css.h index 6ddad69..d2ff25e 100644 --- a/source/dcl/common/dcl_css.h +++ b/source/dcl/common/dcl_css.h @@ -56,7 +56,7 @@ extern "C" { //! typedef struct dcl_css { float32_t tpt; //!< Test point - float32_t t_sec; //!< Controller period in seconds + float32_t T; //!< Controller period in seconds volatile uint32_t sts; //!< Status word uint32_t err_line; //!< Error location line (errno) uint32_t err; //!< Error status code @@ -71,7 +71,7 @@ typedef struct dcl_css { //! typedef struct dcl_css64 { float64_t tpt; //!< Test point - float64_t t_sec; //!< Controller period in seconds + float64_t T; //!< Controller period in seconds volatile uint32_t sts; //!< Status word uint32_t err_line; //!< Error location line (errno) uint32_t err; //!< Error status code @@ -85,11 +85,11 @@ typedef struct dcl_css64 { //! \brief Loads the controller period in the CSS //! CSS pointer must be configured first //! -//! \param[in] p Pointer to the controller structure -//! \param[in] T Sample period in seconds -//! \return None +//! \param[in] p Pointer to the controller structure +//! \param[in] t_sec Controller period in seconds +//! \return None //! -#define DCL_setControllerPeriod(p,T) ((p)->css->t_sec = T) +#define DCL_setControllerPeriod(p,t_sec) ((p)->css->T = t_sec) //--- Status word ------------------------------------------------------------ @@ -107,7 +107,6 @@ typedef enum { dcl_sts_none = 0U, //!< Status empty dcl_sts_param_update = (1U << 0), //!< Parameter update-in-progress flag, high if ongoing parameter update - dcl_sts_param_pending = (1U << 2), //!< Parameter pending-for-update flag, high if parameter needs to be updated dcl_sts_ctrl_running = (1U << 1) //!< Controller operation-in-progress flag, high if operation is in progress } dcl_status_bits; @@ -123,11 +122,6 @@ typedef enum #define DCL_getUpdateStatus(p) (0U != ((p)->css->sts & dcl_sts_param_update)) -//! \brief Macros to set and clear the pending-for-update flag -//! -#define DCL_setPendingStatus(p) ((p)->css->sts |= dcl_sts_param_pending) -#define DCL_clearPendingStatus(p) ((p)->css->sts &= ~dcl_sts_param_pending) - //! \brief Determine whether a parameter pending-for-update flag is set //! //! \return 'true' if pending status is set, otherwise false diff --git a/source/dcl/dcl.h b/source/dcl/dcl.h index fc32970..2389fa7 100644 --- a/source/dcl/dcl.h +++ b/source/dcl/dcl.h @@ -18,7 +18,7 @@ * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPgResS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, @@ -49,8 +49,8 @@ extern "C" { */ //! \brief Library version number formatted for numerical comparison -//! v4.00.00.00 -#define DCL_VERSION 4000000 +//! v4.00.01.00 +#define DCL_VERSION 4000100 //! \brief Enable voltaile flag for dcl strcutures //! Only enable the flag if the controller can @@ -73,7 +73,7 @@ extern "C" { #include "misc/dcl_fdlog.h" #include "misc/dcl_error.h" -/* 32bit arthmetic */ +/* 32bit arithmetic */ #include "pi/dcl_pi.h" #include "pi/dcl_pi2.h" #include "pid/dcl_pid.h" @@ -83,7 +83,7 @@ extern "C" { #include "df/dcl_df22.h" #include "df/dcl_df23.h" -/* 64bit arthmetic */ +/* 64bit arithmetic */ #include "pid/dcl_pidf64.h" /** @} */ diff --git a/source/dcl/dcl_common.h b/source/dcl/dcl_common.h index 4ed4f85..a1c0aed 100644 --- a/source/dcl/dcl_common.h +++ b/source/dcl/dcl_common.h @@ -18,7 +18,7 @@ * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPgResS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, @@ -45,6 +45,9 @@ extern "C" { * \brief Top level header that contains all DCL common strctures and functions */ +#include +#include + //! \brief Defines single,double precision data type. //! Note: Assumes ABI to be __TI_EABI__, //! does not support legacy __TI_COFF__. @@ -56,7 +59,7 @@ typedef double float64_t; //! \brief Defines dcl function section that users can specify in the linker file(.cmd) //! and to accelerate performance by mapping to faster memory -//! Note: only DCL_runXXX and DCL_updateXXX/pendingUpdateXXX are included by default +//! Note: only DCL_run and DCL_update are included by default #define _DCL_CODE_SECTION __attribute__((section("dclfuncs"))) //! \brief Defines volatile for DCL strctures @@ -97,8 +100,6 @@ typedef double float64_t; #warning "DCL currently doesn't support interrupt operations for this architecture" #endif -#include -#include #include "common/dcl_aux.h" #include "common/dcl_css.h" #include "common/dcl_zpk3.h" diff --git a/source/dcl/df/dcl_df11.h b/source/dcl/df/dcl_df11.h index fc168fb..714d55f 100644 --- a/source/dcl/df/dcl_df11.h +++ b/source/dcl/df/dcl_df11.h @@ -140,77 +140,59 @@ typedef _DCL_VOLATILE struct dcl_df11 _DCL_CODE_ACCESS void DCL_resetDF11(DCL_DF11 *df) { - dcl_interrupt_t ints = DCL_disableInts(); + dcl_interrupt_t ints; + ints = DCL_disableInts(); df->d1 = df->d2 = 0.0f; DCL_restoreInts(ints); } -//! \brief Loads DF11 tuning parameter from its SPS parameter +//! \brief Loads DF11 tuning parameter from its SPS parameter without interrupt protection //! //! \param[in] df Pointer to the active DCL_DF11 controller structure //! _DCL_CODE_ACCESS -void DCL_fupdateDF11(DCL_DF11 *df) +void DCL_forceUpdateDF11(DCL_DF11 *df) { df->b0 = df->sps->b0; df->b1 = df->sps->b1; df->a1 = df->sps->a1; } -//! \brief Updates DF11 parameter from its SPS parameter with interrupt protection +//! \brief Loads DF11 tuning parameter from its SPS parameter with interrupt protection //! //! \param[in] df Pointer to the DCL_DF11 controller structure -//! \return 'true' if update is successful, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_updateDF11(DCL_DF11 *df) +void DCL_updateDF11NoCheck(DCL_DF11 *df) { - if (!DCL_getUpdateStatus(df)) - { - dcl_interrupt_t ints = DCL_disableInts(); - DCL_setUpdateStatus(df); - df->b0 = df->sps->b0; - df->b1 = df->sps->b1; - df->a1 = df->sps->a1; - DCL_clearUpdateStatus(df); - DCL_restoreInts(ints); - return true; - } - return false; + dcl_interrupt_t ints; + ints = DCL_disableInts(); + df->b0 = df->sps->b0; + df->b1 = df->sps->b1; + df->a1 = df->sps->a1; + DCL_restoreInts(ints); } -//! \brief A conditional update based on the pending-for-update flag. -//! If the pending status is set, the function will update DF11 +//! \brief A conditional update based on the update flag. +//! If the update status is set, the function will update DF11 //! parameter from its SPS parameter and clear the status flag on completion. -//! Note: Use DCL_setPendingStatus(df) to set the pending status. +//! Note: Use DCL_setUpdateStatus(df) to set the update status. //! //! \param[in] df Pointer to the DCL_DF11 controller structure //! \return 'true' if an update is applied, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_pendingUpdateDF11(DCL_DF11 *df) +bool DCL_updateDF11(DCL_DF11 *df) { - if (DCL_getPendingStatus(df) && DCL_updateDF11(df)) + if (DCL_getUpdateStatus(df)) { - DCL_clearPendingStatus(df); + DCL_updateDF11NoCheck(df); + DCL_clearUpdateStatus(df); return true; } return false; } -//! \brief Update SPS parameter with active param, userful when needing -//! to update only few active param from SPS and keep rest the same -//! -//! \param[in] df Pointer to the active DCL_DF11 controller structure -//! -_DCL_CODE_ACCESS -void DCL_updateDF11SPS(DCL_DF11 *df) -{ - df->sps->b0 = df->b0; - df->sps->b1 = df->b1; - df->sps->a1 = df->a1; -} - //! \brief Determines stability of the shadow DF11 compensator //! //! \param[in] df Pointer to the DCL_DF11 controller structure @@ -223,7 +205,7 @@ bool DCL_isStableDF11(DCL_DF11 *df) } //! \brief Loads the DF11 shadow coefficients from a ZPK3 description -//! Note: Sampling period df->css->t_sec are used in the calculation. +//! Note: Sampling period df->css->T are used in the calculation. //! New settings take effect after DCL_updateDF11(). //! Only real z1 & p1 considered, all other roots ignored. //! @@ -245,15 +227,15 @@ void DCL_loadDF11asZPK(DCL_DF11 *df, DCL_ZPK3 *zpk) } #endif - float32_t t_sec = df->css->t_sec; - float32_t a0p = 2.0f - (float32_t) crealf(zpk->p1) * t_sec; - df->sps->b0 = zpk->K * (2.0f - (float32_t) crealf(zpk->z1) * t_sec) / a0p; - df->sps->b1 = zpk->K * (-2.0f - (float32_t) crealf(zpk->z1) * t_sec) / a0p; - df->sps->a1 = (-2.0f - (float32_t) crealf(zpk->p1) * t_sec) / a0p; + float32_t T = df->css->T; + float32_t a0p = 2.0f - (float32_t) crealf(zpk->p1) * T; + df->sps->b0 = zpk->K * (2.0f - (float32_t) crealf(zpk->z1) * T) / a0p; + df->sps->b1 = zpk->K * (-2.0f - (float32_t) crealf(zpk->z1) * T) / a0p; + df->sps->a1 = (-2.0f - (float32_t) crealf(zpk->p1) * T) / a0p; } //! \brief Loads compensator coefficients to emulate series form PI -//! Note: Sampling period df->css->t_sec are used in the calculation. +//! Note: Sampling period df->css->T are used in the calculation. //! New settings take effect after DCL_updateDF11(). //! //! \param[in] df Pointer to the DCL_DF11 controller structure @@ -275,9 +257,9 @@ void DCL_loadDF11asPI(DCL_DF11 *df, float32_t Kp, float32_t Ki) } #endif - float32_t t_sec = df->css->t_sec; - df->sps->b0 = Kp * ((Ki * t_sec) + 2.0f) / 2.0f; - df->sps->b1 = Kp * ((Ki * t_sec) - 2.0f) / 2.0f; + float32_t T = df->css->T; + df->sps->b0 = Kp * ((Ki * T) + 2.0f) / 2.0f; + df->sps->b1 = Kp * ((Ki * T) - 2.0f) / 2.0f; df->sps->a1 = -1.0f; } diff --git a/source/dcl/df/dcl_df13.h b/source/dcl/df/dcl_df13.h index c71817b..d432fe9 100644 --- a/source/dcl/df/dcl_df13.h +++ b/source/dcl/df/dcl_df13.h @@ -45,7 +45,33 @@ extern "C" { * \file dcl_df13.h * \brief Contains direct form 1 3rd order DF13 compensator * with its related structures and functions - */ + * + * \details Due to compatibility reason, this file maintains a copy + * of legacy function DCL_runDF13_C5(), DCL_runDF13_C6(). + * It is advised to not use these legacy functions for new development. + * + * \code Previously, C28 version of DCL did not implement a function + * to run DF13 with clamp. Instead, user had to implement a routine + * similar to the following: + * + * extern DCL_DF13 df; + * extern float32_t ek, uk; + * float32_t vk = 0; + * + * float32_t uk = DCL_runDF13_C2/C5(df, ek, vk); + * bool is_clamped = DCL_runClamp_C1/C2(&uk, Umax, Umin) + * if (!is_clamped) + * { + * vk = DCL_runDF13_C3/C6(df, ek, uk); + * } + * + * A new function DCL_runDF13Clamp() was implemented to replace it, + * therefore, user may change the aformentioned routine to just: + * + * uk = DCL_runDF13Clamp(df, ek, Umax, Umin); + * \endcode + * + */ #include "../dcl_common.h" @@ -62,9 +88,10 @@ typedef struct dcl_df13_sps { float32_t a1; //!< neg. coefficient to u(k-1) float32_t a2; //!< neg. coefficient to u(k-2) float32_t a3; //!< neg. coefficient to u(k-3) + float32_t a0; //!< No Longer Needed } DCL_DF13_SPS; -#define DF13_SPS_DEFAULTS { 0.25f, 0.25f, 0.25f, 0.25f, 0.0f, 0.0f, 0.0f } +#define DF13_SPS_DEFAULTS { 0.25f, 0.25f, 0.25f, 0.25f, 0.0f, 0.0f, 0.0f, 0.0f } //! \brief DCL_DF13 object for storing df13 specific parameters //! @@ -87,6 +114,10 @@ typedef _DCL_VOLATILE struct dcl_df13 float32_t d5; //!< u(k-2) float32_t d6; //!< u(k-3) + float32_t a0; //!< No Longer Needed + float32_t d0; //!< No Longer Needed + float32_t d7; //!< No Longer Needed + /* miscellaneous */ DCL_DF13_SPS *sps; //!< updates compensator parameter DCL_CSS *css; //!< configuration & debugging @@ -95,7 +126,7 @@ typedef _DCL_VOLATILE struct dcl_df13 //! \brief Defines default values to initialize DCL_DF13 //! #define DF13_DEFAULTS { 0.25f, 0.25f, 0.25f, 0.25f, 0.0f, 0.0f, 0.0f, \ - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, \ + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, \ &(DCL_DF13_SPS)DF13_SPS_DEFAULTS, &(DCL_CSS)DCL_CSS_DEFAULTS } //! \brief Macro for internal default values to initialize DCL_DF13 @@ -107,8 +138,8 @@ typedef _DCL_VOLATILE struct dcl_df13 //! DF13_INT_DEFAULTS //! }; #define DF13_INT_DEFAULTS .d1=0.0f, .d2=0.0f, .d3=0.0f, .d4=0.0f, .d5=0.0f, \ - .d6=0.0f, .sps=&(DCL_DF13_SPS)DF13_SPS_DEFAULTS, \ - .css=&(DCL_CSS)DCL_CSS_DEFAULTS + .d6=0.0f, .a0=0.0f, .d0=0.0f, .d7=0.0f, \ + .sps=&(DCL_DF13_SPS)DF13_SPS_DEFAULTS, .css=&(DCL_CSS)DCL_CSS_DEFAULTS //! \brief Initialize DCL_DF13 struct with default parameters //! Example: DCL_DF13* df13_ctrl = DCL_initDF13(); @@ -143,8 +174,8 @@ typedef _DCL_VOLATILE struct dcl_df13 if(sps_ptr) \ { \ *new_df =(DCL_DF13){ (new_sps)->b0, (new_sps)->b1, (new_sps)->b2, (new_sps)->b3, \ - (new_sps)->a1, (new_sps)->a2, (new_sps)->a3, 0.0f, 0.0f, 0.0f, 0.0f, \ - 0.0f, 0.0f, (DCL_DF13_SPS*)new_sps, &(DCL_CSS)DCL_CSS_DEFAULTS }; \ + (new_sps)->a1, (new_sps)->a2, (new_sps)->a3, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, \ + 0.0f, 0.0f, 0.0f, (DCL_DF13_SPS*)new_sps, &(DCL_CSS)DCL_CSS_DEFAULTS }; \ } \ new_df; \ }) @@ -157,17 +188,18 @@ typedef _DCL_VOLATILE struct dcl_df13 _DCL_CODE_ACCESS void DCL_resetDF13(DCL_DF13 *df) { - dcl_interrupt_t ints = DCL_disableInts(); + dcl_interrupt_t ints; + ints = DCL_disableInts(); df->d1 = df->d2 = df->d3 = df->d4 = df->d5 = df->d6 = 0.0f; DCL_restoreInts(ints); } -//! \brief Loads DF13 tuning parameter from its SPS parameter +//! \brief Loads DF13 tuning parameter from its SPS parameter without interrupt protection //! //! \param[in] df Pointer to the active DCL_DF13 controller structure //! _DCL_CODE_ACCESS -void DCL_fupdateDF13(DCL_DF13 *df) +void DCL_forceUpdateDF13(DCL_DF13 *df) { df->b0 = df->sps->b0; df->b1 = df->sps->b1; @@ -178,68 +210,45 @@ void DCL_fupdateDF13(DCL_DF13 *df) df->a3 = df->sps->a3; } -//! \brief Updates DF13 parameter from its SPS parameter with interrupt protection +//! \brief Loads DF13 tuning parameter from its SPS parameter with interrupt protection //! //! \param[in] df Pointer to the DCL_DF13 controller structure -//! \return 'true' if update is successful, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_updateDF13(DCL_DF13 *df) +void DCL_updateDF13NoCheck(DCL_DF13 *df) { - if (!DCL_getUpdateStatus(df)) - { - dcl_interrupt_t ints = DCL_disableInts(); - DCL_setUpdateStatus(df); - df->b0 = df->sps->b0; - df->b1 = df->sps->b1; - df->b2 = df->sps->b2; - df->b3 = df->sps->b3; - df->a1 = df->sps->a1; - df->a2 = df->sps->a2; - df->a3 = df->sps->a3; - DCL_clearUpdateStatus(df); - DCL_restoreInts(ints); - return true; - } - return false; + dcl_interrupt_t ints; + ints = DCL_disableInts(); + df->b0 = df->sps->b0; + df->b1 = df->sps->b1; + df->b2 = df->sps->b2; + df->b3 = df->sps->b3; + df->a1 = df->sps->a1; + df->a2 = df->sps->a2; + df->a3 = df->sps->a3; + DCL_restoreInts(ints); } -//! \brief A conditional update based on the pending-for-update flag. -//! If the pending status is set, the function will update DF13 +//! \brief A conditional update based on the update flag. +//! If the update status is set, the function will update DF13 //! parameter from its SPS parameter and clear the status flag on completion.. -//! Note: Use DCL_setPendingStatus(df) to set the pending status. +//! Note: Use DCL_setUpdateStatus(df) to set the update status. //! //! \param[in] df Pointer to the DCL_DF13 controller structure //! \return 'true' if an update is applied, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_pendingUpdateDF13(DCL_DF13 *df) +bool DCL_updateDF13(DCL_DF13 *df) { - if (DCL_getPendingStatus(df) && DCL_updateDF13(df)) + if (DCL_getUpdateStatus(df)) { - DCL_clearPendingStatus(df); + DCL_updateDF13NoCheck(df); + DCL_clearUpdateStatus(df); return true; } return false; } -//! \brief Update SPS parameter with active param, userful when needing -//! to update only few active param from SPS and keep rest the same -//! -//! \param[in] df Pointer to the active DCL_DF13 controller structure -//! -_DCL_CODE_ACCESS -void DCL_updateDF13SPS(DCL_DF13 *df) -{ - df->sps->b0 = df->b0; - df->sps->b1 = df->b1; - df->sps->b2 = df->b2; - df->sps->b3 = df->b3; - df->sps->a1 = df->a1; - df->sps->a2 = df->a2; - df->sps->a3 = df->a3; -} - //! \brief Determines stability of the shadow compensator //! //! \param[in] df Pointer to the DCL_DF13 controller structure @@ -252,7 +261,7 @@ bool DCL_isStableDF13(DCL_DF13 *df) } //! \brief Loads the DF13 shadow coefficients from a ZPK3 description. -//! Note: Sampling period df->css->t_sec are used in the calculation. +//! Note: Sampling period df->css->T are used in the calculation. //! New settings take effect after DCL_updateDF13(). //! //! \param[in] df Pointer to the DCL_DF13 controller structure @@ -281,18 +290,18 @@ void DCL_loadDF13asZPK(DCL_DF13 *df, DCL_ZPK3 *zpk) float32_t alpha1 = (float32_t) crealf((zpk->p1 * zpk->p2) + (zpk->p2 * zpk->p3) + (zpk->p1 * zpk->p3)); float32_t alpha0 = -(float32_t) crealf(zpk->p1 * zpk->p2 * zpk->p3); - float32_t t_sec = df->css->t_sec; + float32_t T = df->css->T; - float32_t a0p = 8.0f + (alpha2 * 4.0f * t_sec) + (alpha1 * 2.0f * t_sec * t_sec) + (alpha0 * t_sec * t_sec * t_sec); + float32_t a0p = 8.0f + (alpha2 * 4.0f * T) + (alpha1 * 2.0f * T * T) + (alpha0 * T * T * T); - df->sps->b0 = zpk->K * (8.0f + (beta2 * 4.0f * t_sec) + (beta1 * 2.0f * t_sec * t_sec) + (beta0 * t_sec * t_sec * t_sec)) / a0p; - df->sps->b1 = zpk->K * (-24.0f - (beta2 * 4.0f * t_sec) + (beta1 * 2.0f * t_sec * t_sec) + (3.0f * beta0 * t_sec * t_sec * t_sec)) / a0p; - df->sps->b2 = zpk->K * (24.0f - (beta2 * 4.0f * t_sec) - (beta1 * 2.0f * t_sec * t_sec) + (3.0f * beta0 * t_sec * t_sec * t_sec)) / a0p; - df->sps->b3 = zpk->K * (-8.0f + (beta2 * 4.0f * t_sec) - (beta1 * 2.0f * t_sec * t_sec) + (beta0 * t_sec * t_sec * t_sec)) / a0p; + df->sps->b0 = zpk->K * (8.0f + (beta2 * 4.0f * T) + (beta1 * 2.0f * T * T) + (beta0 * T * T * T)) / a0p; + df->sps->b1 = zpk->K * (-24.0f - (beta2 * 4.0f * T) + (beta1 * 2.0f * T * T) + (3.0f * beta0 * T * T * T)) / a0p; + df->sps->b2 = zpk->K * (24.0f - (beta2 * 4.0f * T) - (beta1 * 2.0f * T * T) + (3.0f * beta0 * T * T * T)) / a0p; + df->sps->b3 = zpk->K * (-8.0f + (beta2 * 4.0f * T) - (beta1 * 2.0f * T * T) + (beta0 * T * T * T)) / a0p; - df->sps->a1 = (-24.0f - (alpha2 * 4.0f * t_sec) + (alpha1 * 2.0f * t_sec * t_sec) + (3.0f * alpha0 * t_sec * t_sec * t_sec)) / a0p; - df->sps->a2 = (24.0f - (alpha2 * 4.0f * t_sec) - (alpha1 * 2.0f * t_sec * t_sec) + (3.0f * alpha0 * t_sec * t_sec * t_sec)) / a0p; - df->sps->a3 = (-8.0f + (alpha2 * 4.0f * t_sec) - (alpha1 * 2.0f * t_sec * t_sec) + (alpha0 * t_sec * t_sec * t_sec)) / a0p; + df->sps->a1 = (-24.0f - (alpha2 * 4.0f * T) + (alpha1 * 2.0f * T * T) + (3.0f * alpha0 * T * T * T)) / a0p; + df->sps->a2 = (24.0f - (alpha2 * 4.0f * T) - (alpha1 * 2.0f * T * T) + (3.0f * alpha0 * T * T * T)) / a0p; + df->sps->a3 = (-8.0f + (alpha2 * 4.0f * T) - (alpha1 * 2.0f * T * T) + (alpha0 * T * T * T)) / a0p; } //! \brief Executes a 3rd order Direct Form 1 controller @@ -363,6 +372,44 @@ float32_t DCL_runDF13Clamp(DCL_DF13 *df, float32_t ek, float32_t Umax, float32_t return(uk); } +//! \brief Legacy C28 Function for maintaining backwards compatibility. +//! It Executes an immediate 3rd order Direct Form 1 controller +//! +//! \param[in] p Pointer to the DCL_DF13 controller structure +//! \param[in] ek The servo error +//! \param[in] vk The partial pre-computed control effort +//! \return uk The control effort +//! +_DCL_CODE_ACCESS +float32_t DCL_runDF13_C5(DCL_DF13 *p, float32_t ek, float32_t vk) +{ + p->d4 = (ek * p->b0) + vk; + + return(p->d4); +} + +//! \brief Legacy C28 Function for maintaining backwards compatibility. +//! It executes a partial pre-computed 3rd order Direct Form 1 controller +//! +//! \param[in] p Pointer to the DCL_DF13 controller structure +//! \param[in] ek The servo error +//! \param[in] uk The controller output in the previous sample interval +//! \return vk The control effort +//! +_DCL_CODE_ACCESS +float32_t DCL_runDF13_C6(DCL_DF13 *p, float32_t ek, float32_t uk) +{ + float32_t v9; + + v9 = (ek * p->b1) + (p->d1 * p->b2) + (p->d2 * p->b3) - (uk * p->a1) - (p->d5 * p->a2) - (p->d6 * p->a3); + p->d2 = p->d1; + p->d1 = ek; + p->d6 = p->d5; + p->d5 = uk; + + return(v9); +} + /** @} */ #ifdef __cplusplus diff --git a/source/dcl/df/dcl_df22.h b/source/dcl/df/dcl_df22.h index 976e1b8..3f9f4d2 100644 --- a/source/dcl/df/dcl_df22.h +++ b/source/dcl/df/dcl_df22.h @@ -146,17 +146,18 @@ typedef _DCL_VOLATILE struct dcl_df22 _DCL_CODE_ACCESS void DCL_resetDF22(DCL_DF22 *df) { - dcl_interrupt_t ints = DCL_disableInts(); + dcl_interrupt_t ints; + ints = DCL_disableInts(); df->x1 = df->x2 = 0.0f; DCL_restoreInts(ints); } -//! \brief Loads DF22 tuning parameter from its SPS parameter +//! \brief Loads DF22 tuning parameter from its SPS parameter without interrupt protection //! //! \param[in] df Pointer to the active DCL_DF22 controller structure //! _DCL_CODE_ACCESS -void DCL_fupdateDF22(DCL_DF22 *df) +void DCL_forceUpdateDF22(DCL_DF22 *df) { df->b0 = df->sps->b0; df->b1 = df->sps->b1; @@ -165,65 +166,43 @@ void DCL_fupdateDF22(DCL_DF22 *df) df->a2 = df->sps->a2; } -//! \brief Updates DF22 parameter from its SPS parameter with interrupt protection +//! \brief Loads DF22 tuning parameter from its SPS parameter with interrupt protection //! //! \param[in] df Pointer to the DCL_DF22 controller structure -//! \return 'true' if update is successful, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_updateDF22(DCL_DF22 *df) +void DCL_updateDF22NoCheck(DCL_DF22 *df) { - if (!DCL_getUpdateStatus(df)) - { - dcl_interrupt_t ints = DCL_disableInts(); - DCL_setUpdateStatus(df); - df->b0 = df->sps->b0; - df->b1 = df->sps->b1; - df->b2 = df->sps->b2; - df->a1 = df->sps->a1; - df->a2 = df->sps->a2; - DCL_clearUpdateStatus(df); - DCL_restoreInts(ints); - return true; - } - return false; + dcl_interrupt_t ints; + ints = DCL_disableInts(); + df->b0 = df->sps->b0; + df->b1 = df->sps->b1; + df->b2 = df->sps->b2; + df->a1 = df->sps->a1; + df->a2 = df->sps->a2; + DCL_restoreInts(ints); } -//! \brief A conditional update based on the pending-for-update flag. -//! If the pending status is set, the function will update DF22 +//! \brief A conditional update based on the update flag. +//! If the update status is set, the function will update DF22 //! parameter from its SPS parameter and clear the status flag on completion. -//! Note: Use DCL_setPendingStatus(df) to set the pending status. +//! Note: Use DCL_setUpdateStatus(df) to set the update status. //! //! \param[in] df Pointer to the DCL_DF22 controller structure //! \return 'true' if an update is applied, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_pendingUpdateDF22(DCL_DF22 *df) +bool DCL_updateDF22(DCL_DF22 *df) { - if (DCL_getPendingStatus(df) && DCL_updateDF22(df)) + if (DCL_setUpdateStatus(df)) { - DCL_clearPendingStatus(df); + DCL_updateDF22NoCheck(df); + DCL_clearUpdateStatus(df); return true; } return false; } -//! \brief Update SPS parameter with active param, userful when needing -//! to update only few active param from SPS and keep rest the same -//! -//! \param[in] df Pointer to the active DCL_DF22 controller structure -//! -_DCL_CODE_ACCESS -void DCL_updateDF22SPS(DCL_DF22 *df) -{ - df->sps->b0 = df->b0; - df->sps->b1 = df->b1; - df->sps->b2 = df->b2; - df->sps->a1 = df->a1; - df->sps->a2 = df->a2; -} - - //! \brief Determines stability of the shadow compensator //! //! \param[in] df Pointer to the DCL_DF22 controller structure @@ -236,7 +215,7 @@ bool DCL_isStableDF22(DCL_DF22 *df) } //! \brief Loads the DF22 shadow coefficients from a ZPK3 description -//! Note: Sampling period df->css->t_sec are used in the calculation. +//! Note: Sampling period df->css->T are used in the calculation. //! New settings take effect after DCL_updateDF22(). //! Only z1, z2, p1 & p2 are considered, z3 & p3 are ignored. //! @@ -264,19 +243,19 @@ void DCL_loadDF22asZPK(DCL_DF22 *df, DCL_ZPK3 *zpk) float32_t alpha1 = -(float32_t) crealf(zpk->p1 + zpk->p2); float32_t alpha0 = (float32_t) crealf(zpk->p1 * zpk->p2); - float32_t t_sec = df->css->t_sec; - float32_t a0p = 4.0f + (alpha1 * 2.0f * t_sec) + (alpha0 * t_sec * t_sec); + float32_t T = df->css->T; + float32_t a0p = 4.0f + (alpha1 * 2.0f * T) + (alpha0 * T * T); - df->sps->b0 = zpk->K * (4.0f + (beta1 * 2.0f * t_sec) + (beta0 * t_sec * t_sec)) / a0p; - df->sps->b1 = zpk->K * (-8.0f + (2.0f * beta0 * t_sec * t_sec)) / a0p; - df->sps->b2 = zpk->K * (4.0f - (beta1 * 2.0f * t_sec) + (beta0 * t_sec * t_sec)) / a0p; - df->sps->a1 = (-8.0f + (2.0f * alpha0 * t_sec * t_sec)) / a0p; - df->sps->a2 = (4.0f - (alpha1 * 2.0f * t_sec) + (alpha0 * t_sec * t_sec)) / a0p; + df->sps->b0 = zpk->K * (4.0f + (beta1 * 2.0f * T) + (beta0 * T * T)) / a0p; + df->sps->b1 = zpk->K * (-8.0f + (2.0f * beta0 * T * T)) / a0p; + df->sps->b2 = zpk->K * (4.0f - (beta1 * 2.0f * T) + (beta0 * T * T)) / a0p; + df->sps->a1 = (-8.0f + (2.0f * alpha0 * T * T)) / a0p; + df->sps->a2 = (4.0f - (alpha1 * 2.0f * T) + (alpha0 * T * T)) / a0p; } //! \brief Loads the DF22 shadow coefficients from damping ratio and un-damped //! natural frequency using sample rate in CSS. -//! Note: Sampling period df->css->t_sec are used in the calculation. +//! Note: Sampling period df->css->T are used in the calculation. //! New settings take effect after DCL_updateDF22(). //! //! \param[in] df Pointer to the DCL_DF22 controller structure @@ -299,18 +278,18 @@ void DCL_loadDF22asZwn(DCL_DF22 *df, float32_t z, float32_t wn) } #endif - float32_t t_sec = df->css->t_sec; - float32_t v1 = wn * wn * t_sec * t_sec; - float32_t a2p = 1.0f / (4.0f + (4.0f * z * wn * t_sec) + v1); + float32_t T = df->css->T; + float32_t v1 = wn * wn * T * T; + float32_t a2p = 1.0f / (4.0f + (4.0f * z * wn * T) + v1); df->sps->b0 = v1 * a2p; df->sps->b1 = 2.0f * df->sps->b0; df->sps->b2 = df->sps->b0; df->sps->a1 = ((2.0f * v1) - 8.0f) * a2p; - df->sps->a2 = (4.0f - (4.0f * z * wn * t_sec) + v1) * a2p; + df->sps->a2 = (4.0f - (4.0f * z * wn * T) + v1) * a2p; } //! \brief Loads the shadow DF22 compensator coefficients to emulate a series form PID. -//! Note: Sampling period df->css->t_sec are used in the calculation. +//! Note: Sampling period df->css->T are used in the calculation. //! New settings take effect after DCL_updateDF22(). //! //! \param[in] df Pointer to the DCL_DF22 controller structure @@ -337,10 +316,10 @@ void DCL_loadDF22asSeriesPID(DCL_DF22 *df, float32_t Kp, float32_t Ki, float32_t } #endif - float32_t t_sec = df->css->t_sec; + float32_t T = df->css->T; float32_t tau = 1 / (2.0f * CONST_PI * fc); - float32_t c1 = 2.0f / (t_sec + (2.0f * tau)); - float32_t c2 = c1 * (t_sec - (2.0f * tau)) / 2.0f; + float32_t c1 = 2.0f / (T + (2.0f * tau)); + float32_t c2 = c1 * (T - (2.0f * tau)) / 2.0f; float32_t Kdp = Kd * c1; df->sps->b0 = Kp * (1 + Ki + Kdp); df->sps->b1 = Kp * (c2 - 1 + Ki*c2 - 2*Kdp); @@ -350,7 +329,7 @@ void DCL_loadDF22asSeriesPID(DCL_DF22 *df, float32_t Kp, float32_t Ki, float32_t } //! \brief Loads the shadow DF22 compensator coefficients to emulate a parallel form PID. -//! Note: Sampling period df->css->t_sec are used in the calculation. +//! Note: Sampling period df->css->T are used in the calculation. //! New settings take effect after DCL_updateDF22(). //! //! \param[in] df Pointer to the DCL_DF22 controller structure @@ -369,7 +348,7 @@ void DCL_loadDF22asParallelPID(DCL_DF22 *df, float32_t Kp, float32_t Ki, float32 err_code |= (Ki < 0.0f) ? dcl_param_range_err : dcl_none; err_code |= (Kd < 0.0f) ? dcl_param_range_err : dcl_none; err_code |= (fc < 0.0f) ? dcl_param_range_err : dcl_none; - err_code |= (fc > (1.0f / (2.0f * df->css->t_sec))) ? dcl_param_warn_err : dcl_none; + err_code |= (fc > (1.0f / (2.0f * df->css->T))) ? dcl_param_warn_err : dcl_none; if (err_code) { DCL_setError(df,err_code); @@ -378,10 +357,10 @@ void DCL_loadDF22asParallelPID(DCL_DF22 *df, float32_t Kp, float32_t Ki, float32 } #endif - float32_t t_sec = df->css->t_sec; + float32_t T = df->css->T; float32_t tau = 1.0f / (2.0f * CONST_PI * fc); - float32_t c1 = 2.0f / (t_sec + (2.0f * tau)); - float32_t c2 = c1 * (t_sec - (2.0f * tau)) / 2.0f; + float32_t c1 = 2.0f / (T + (2.0f * tau)); + float32_t c2 = c1 * (T - (2.0f * tau)) / 2.0f; float32_t Kdp = Kd * c1; df->sps->b0 = Kp + Ki + Kdp; df->sps->b1 = (Kp * (c2 - 1)) + (Ki * c2) - (2.0f * Kdp); diff --git a/source/dcl/df/dcl_df23.h b/source/dcl/df/dcl_df23.h index 2891374..816959c 100644 --- a/source/dcl/df/dcl_df23.h +++ b/source/dcl/df/dcl_df23.h @@ -153,17 +153,18 @@ typedef _DCL_VOLATILE struct dcl_df23 _DCL_CODE_ACCESS void DCL_resetDF23(DCL_DF23 *df) { - dcl_interrupt_t ints = DCL_disableInts(); + dcl_interrupt_t ints; + ints = DCL_disableInts(); df->x1 = df->x2 = df->x3 = 0.0f; DCL_restoreInts(ints); } -//! \brief Loads DF23 tuning parameter from its SPS parameter +//! \brief Loads DF23 tuning parameter from its SPS parameter without interrupt protection //! //! \param[in] df Pointer to the active DCL_DF23 controller structure //! _DCL_CODE_ACCESS -void DCL_fupdateDF23(DCL_DF23 *df) +void DCL_forceUpdateDF23(DCL_DF23 *df) { df->b0 = df->sps->b0; df->b1 = df->sps->b1; @@ -177,65 +178,42 @@ void DCL_fupdateDF23(DCL_DF23 *df) //! \brief Updates DF23 parameter from its SPS parameter with interrupt protection //! //! \param[in] df Pointer to the DCL_DF23 controller structure -//! \return 'true' if update is successful, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_updateDF23(DCL_DF23 *df) +void DCL_updateDF23NoCheck(DCL_DF23 *df) { - if (!DCL_getUpdateStatus(df)) - { - dcl_interrupt_t ints = DCL_disableInts(); - DCL_setUpdateStatus(df); - df->b0 = df->sps->b0; - df->b1 = df->sps->b1; - df->b2 = df->sps->b2; - df->b3 = df->sps->b3; - df->a1 = df->sps->a1; - df->a2 = df->sps->a2; - df->a3 = df->sps->a3; - DCL_clearUpdateStatus(df); - DCL_restoreInts(ints); - return true; - } - return false; + dcl_interrupt_t ints; + ints = DCL_disableInts(); + df->b0 = df->sps->b0; + df->b1 = df->sps->b1; + df->b2 = df->sps->b2; + df->b3 = df->sps->b3; + df->a1 = df->sps->a1; + df->a2 = df->sps->a2; + df->a3 = df->sps->a3; + DCL_restoreInts(ints); } -//! \brief A conditional update based on the pending-for-update flag. -//! If the pending status is set, the function will update DF23 +//! \brief A conditional update based on the update flag. +//! If the update status is set, the function will update DF23 //! parameter from its SPS parameter and clear the status flag on completion. -//! Note: Use DCL_setPendingStatus(df) to set the pending status. +//! Note: Use DCL_setUpdateStatus(df) to set the update status. //! //! \param[in] df Pointer to the DCL_DF23 controller structure //! \return 'true' if an update is applied, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_pendingUpdateDF23(DCL_DF23 *df) +bool DCL_updateDF23(DCL_DF23 *df) { - if (DCL_getPendingStatus(df) && DCL_updateDF23(df)) + if (DCL_setUpdateStatus(df)) { - DCL_clearPendingStatus(df); + DCL_updateDF23NoCheck(df); + DCL_clearUpdateStatus(df); return true; } return false; } -//! \brief Update SPS parameter with active param, userful when needing -//! to update only few active param from SPS and keep rest the same -//! -//! \param[in] df Pointer to the active DCL_DF23 controller structure -//! -_DCL_CODE_ACCESS -void DCL_updateDF23SPS(DCL_DF23 *df) -{ - df->sps->b0 = df->b0; - df->sps->b1 = df->b1; - df->sps->b2 = df->b2; - df->sps->b3 = df->b3; - df->sps->a1 = df->a1; - df->sps->a2 = df->a2; - df->sps->a3 = df->a3; -} - //! \brief Determines stability of the shadow compensator //! //! \param[in] df Pointer to the DCL_DF23 controller structure @@ -248,7 +226,7 @@ bool DCL_isStableDF23(DCL_DF23 *df) } //! \brief Loads the DF23 shadow coefficients from a ZPK3 description -//! Note: Sampling period df->css->t_sec are used in the calculation. +//! Note: Sampling period df->css->T are used in the calculation. //! New settings take effect after DCL_updateDF23(). //! //! \param[in] df Pointer to the DCL_DF23 controller structure @@ -277,17 +255,17 @@ void DCL_loadDF23asZPK(DCL_DF23 *df, DCL_ZPK3 *zpk) float32_t alpha1 = (float32_t) crealf((zpk->p1 * zpk->p2) + (zpk->p2 * zpk->p3) + (zpk->p1 * zpk->p3)); float32_t alpha0 = -(float32_t) crealf(zpk->p1 * zpk->p2 * zpk->p3); - float32_t t_sec = df->css->t_sec; - float32_t a0p = 8.0f + (alpha2 * 4.0f * t_sec) + (alpha1 * 2.0f * t_sec * t_sec) + (alpha0 * t_sec * t_sec * t_sec); + float32_t T = df->css->T; + float32_t a0p = 8.0f + (alpha2 * 4.0f * T) + (alpha1 * 2.0f * T * T) + (alpha0 * T * T * T); - df->sps->b0 = zpk->K * (8.0f + (beta2 * 4.0f * t_sec) + (beta1 * 2.0f * t_sec * t_sec) + (beta0 * t_sec * t_sec * t_sec)) / a0p; - df->sps->b1 = zpk->K * (-24.0f - (beta2 * 4.0f * t_sec) + (beta1 * 2.0f * t_sec * t_sec) + (3.0f * beta0 * t_sec * t_sec * t_sec)) / a0p; - df->sps->b2 = zpk->K * (24.0f - (beta2 * 4.0f * t_sec) - (beta1 * 2.0f * t_sec * t_sec) + (3.0f * beta0 * t_sec * t_sec * t_sec)) / a0p; - df->sps->b3 = zpk->K * (-8.0f + (beta2 * 4.0f * t_sec) - (beta1 * 2.0f * t_sec * t_sec) + (beta0 * t_sec * t_sec * t_sec)) / a0p; + df->sps->b0 = zpk->K * (8.0f + (beta2 * 4.0f * T) + (beta1 * 2.0f * T * T) + (beta0 * T * T * T)) / a0p; + df->sps->b1 = zpk->K * (-24.0f - (beta2 * 4.0f * T) + (beta1 * 2.0f * T * T) + (3.0f * beta0 * T * T * T)) / a0p; + df->sps->b2 = zpk->K * (24.0f - (beta2 * 4.0f * T) - (beta1 * 2.0f * T * T) + (3.0f * beta0 * T * T * T)) / a0p; + df->sps->b3 = zpk->K * (-8.0f + (beta2 * 4.0f * T) - (beta1 * 2.0f * T * T) + (beta0 * T * T * T)) / a0p; - df->sps->a1 = (-24.0f - (alpha2 * 4.0f * t_sec) + (alpha1 * 2.0f * t_sec * t_sec) + (3.0f * alpha0 * t_sec * t_sec * t_sec)) / a0p; - df->sps->a2 = (24.0f - (alpha2 * 4.0f * t_sec) - (alpha1 * 2.0f * t_sec * t_sec) + (3.0f * alpha0 * t_sec * t_sec * t_sec)) / a0p; - df->sps->a3 = (-8.0f + (alpha2 * 4.0f * t_sec) - (alpha1 * 2.0f * t_sec * t_sec) + (alpha0 * t_sec * t_sec * t_sec)) / a0p; + df->sps->a1 = (-24.0f - (alpha2 * 4.0f * T) + (alpha1 * 2.0f * T * T) + (3.0f * alpha0 * T * T * T)) / a0p; + df->sps->a2 = (24.0f - (alpha2 * 4.0f * T) - (alpha1 * 2.0f * T * T) + (3.0f * alpha0 * T * T * T)) / a0p; + df->sps->a3 = (-8.0f + (alpha2 * 4.0f * T) - (alpha1 * 2.0f * T * T) + (alpha0 * T * T * T)) / a0p; } //! \brief Executes a 3rd order Direct Form 2 controller diff --git a/source/dcl/misc/dcl_c28_compatibility.h b/source/dcl/misc/dcl_c28_compatibility.h index 601d6bb..0a24e4d 100644 --- a/source/dcl/misc/dcl_c28_compatibility.h +++ b/source/dcl/misc/dcl_c28_compatibility.h @@ -18,7 +18,7 @@ * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPgResS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, @@ -33,14 +33,19 @@ #ifndef _DCL_C28_COMPATIBILITY_H_ #define _DCL_C28_COMPATIBILITY_H_ -//! \file dcl_c28_compatibility.h -//! \brief C28 compatibility macro -//! Contains backward compatbility mapping to C28 DCL's naming scheme -//! -//! Note: -//! CLA functions are not compatible, nonetheless its -//! direct equivalent are listed in comments -//! ASM functions will be alias into inline C code +/** + * + * @{ + * + * \file dcl_c28_compatibility.h + * \brief Contains backward compatbility mapping to C28 DCL's naming scheme + * Not included in dcl.h by default, be sure to include this file seperately when using. + * + * Note: + * All C28 ASM functions will be alias into its equivalent C functions + * + * CLA functions are not compatible, nonetheless its direct equivalent are listed in comments below + */ #ifdef __cplusplus extern "C" { @@ -49,13 +54,14 @@ extern "C" { //***************************************************************************** // PI //***************************************************************************** -#define DCL_runPI_C1 DCL_runPISeries -#define DCL_runPI_C2 DCL_runPISeries +#define DCL_runPI_C1 DCL_runPISeries // C28 ASM function +#define DCL_runPI_C2 DCL_runPISeries #define DCL_runPI_C3 DCL_runPIParallel -#define DCL_runPI_C4 DCL_runPIParallel +#define DCL_runPI_C4 DCL_runPIParallel // C28 ASM function #define DCL_runPI_C5 DCL_runPIParallelEnhanced #define DCL_runPI_C6 DCL_runPISeriesTustin -#define DCL_runPI_C7 DCL_runPISeriesTustin +#define DCL_runPI_C7 DCL_runPISeriesTustin // C28 ASM function +#define DCL_fupdatePI DCL_updatePI // C28 ASM function /* // C28 CLA Functions #define DCL_runPI_L1 DCL_runPISeries @@ -69,15 +75,17 @@ extern "C" { // PI2 //***************************************************************************** #define DCL_runPI2_C1 DCL_runPI2Series -#define DCL_runPI2_C2 DCL_runPI2Series +#define DCL_runPI2_C2 DCL_runPI2Series // C28 ASM function +#define DCL_fupdatePI2 DCL_updatePI2 // C28 ASM function //***************************************************************************** // PID //***************************************************************************** -#define DCL_runPID_C1 DCL_runPIDSeries -#define DCL_runPID_C2 DCL_runPIDSeries +#define DCL_runPID_C1 DCL_runPIDSeries // C28 ASM function +#define DCL_runPID_C2 DCL_runPIDSeries #define DCL_runPID_C3 DCL_runPIDParallel -#define DCL_runPID_C4 DCL_runPIDParallel +#define DCL_runPID_C4 DCL_runPIDParallel // C28 ASM function +#define DCL_fupdatePID DCL_updatePID // C28 ASM function /* // C28 CLA Functions #define DCL_runPID_L1 DCL_runPIDSeries @@ -89,8 +97,9 @@ extern "C" { //***************************************************************************** // DF11 //***************************************************************************** -#define DCL_runDF11_C1 DCL_runDF11 +#define DCL_runDF11_C1 DCL_runDF11 // C28 ASM function #define DCL_runDF11_C2 DCL_runDF11 +#define DCL_fupdateDF11 DCL_updateDF11 // C28 ASM function /* // C28 CLA Functions #define DCL_runDF11_L1 DCL_runDF11 @@ -99,31 +108,38 @@ extern "C" { //***************************************************************************** // DF13 //***************************************************************************** -#define DCL_runDF13_C1 DCL_runDF13 -#define DCL_runDF13_C2 DCL_runDF13PartialCompute -#define DCL_runDF13_C3 DCL_runDF13PartialUpdate +/* + * Note that due to incompatible changes with running DF13 w/ Clamp, the legacy + * implementation for both DCL_runDF13_C5 and DCL_runDF13_C6 are still included. + * + * It is advised to use the new function DCL_runDF13Clamp() for running DF13 w/ Clamp. + * For more info, refer to \details section of dcl_df13.h +*/ +#define DCL_runDF13_C1 DCL_runDF13 // C28 ASM function +#define DCL_runDF13_C2 DCL_runDF13_C5 // Alias into local implementation of legacy function C5 +#define DCL_runDF13_C3 DCL_runDF13_C6 // Alias into local implementation of legacy function C6 #define DCL_runDF13_C4 DCL_runDF13 -#define DCL_runDF13_C5 DCL_runDF13PartialCompute -#define DCL_runDF13_C6 DCL_runDF13PartialUpdate +#define DCL_fupdateDF13 DCL_updateDF13 // C28 ASM function /* // C28 CLA Functions #define DCL_runDF13_L1 DCL_runDF13 -#define DCL_runDF13_L2 DCL_runDF13PartialCompute -#define DCL_runDF13_L3 DCL_runDF13PartialUpdate +#define DCL_runDF13_L2 DCL_runDF13_C5 +#define DCL_runDF13_L3 DCL_runDF13_C6 #define DCL_runDF13_L4 DCL_runDF13 -#define DCL_runDF13_L5 DCL_runDF13PartialCompute -#define DCL_runDF13_L6 DCL_runDF13PartialUpdate +#define DCL_runDF13_L5 DCL_runDF13_C5 +#define DCL_runDF13_L6 DCL_runDF13_C6 */ //***************************************************************************** // DF22 //***************************************************************************** -#define DCL_runDF22_C1 DCL_runDF22 -#define DCL_runDF22_C2 DCL_runDF22PartialCompute -#define DCL_runDF22_C3 DCL_runDF22PartialUpdate -#define DCL_runDF22_C4 DCL_runDF22 +#define DCL_runDF22_C1 DCL_runDF22 // C28 ASM function +#define DCL_runDF22_C2 DCL_runDF22PartialCompute // C28 ASM function +#define DCL_runDF22_C3 DCL_runDF22PartialUpdate // C28 ASM function +#define DCL_runDF22_C4 DCL_runDF22 #define DCL_runDF22_C5 DCL_runDF22PartialCompute -#define DCL_runDF22_C6 DCL_runDF22PartialUpdate +#define DCL_runDF22_C6 DCL_runDF22PartialUpdate +#define DCL_fupdateDF22 DCL_updateDF22 // C28 ASM function /* // C28 CLA Functions #define DCL_runDF22_L1 DCL_runDF22 @@ -135,12 +151,13 @@ extern "C" { //***************************************************************************** // DF23 //***************************************************************************** -#define DCL_runDF23_C1 DCL_runDF23 -#define DCL_runDF23_C2 DCL_runDF23PartialCompute -#define DCL_runDF23_C3 DCL_runDF23PartialUpdate +#define DCL_runDF23_C1 DCL_runDF23 // C28 ASM function +#define DCL_runDF23_C2 DCL_runDF23PartialCompute // C28 ASM function +#define DCL_runDF23_C3 DCL_runDF23PartialUpdate // C28 ASM function #define DCL_runDF23_C4 DCL_runDF23 #define DCL_runDF23_C5 DCL_runDF23PartialCompute #define DCL_runDF23_C6 DCL_runDF23PartialUpdate +#define DCL_fupdateDF23 DCL_updateDF23 // C28 ASM function /* // C28 CLA Functions #define DCL_runDF23_L1 DCL_runDF23 @@ -151,7 +168,7 @@ extern "C" { //***************************************************************************** // Clamp //***************************************************************************** -#define DCL_runClamp_C1 DCL_runClamp +#define DCL_runClamp_C1 DCL_runClamp // C28 ASM function #define DCL_runClamp_C2 DCL_runClamp #define DCL_runClamp_S1 DCL_runClampF64 /* @@ -175,9 +192,9 @@ extern "C" { #define DCL_RESTORE_INTS DCL_restoreInts #define DCL_SET_CONTROLLER_PERIOD DCL_setControllerPeriod #define DCL_SET_SAMPLE_RATE DCL_setControllerPeriod -#define DCL_REQUEST_UPDATE DCL_setPendingStatus -#define DCL_CLEAR_UPDATE_REQUEST DCL_clearPendingStatus -#define DCL_UPDATE_WAITING DCL_getPendingStatus +#define DCL_REQUEST_UPDATE DCL_setUpdateStatus +#define DCL_CLEAR_UPDATE_REQUEST DCL_clearUpdateStatus +#define DCL_UPDATE_WAITING DCL_getUpdateStatus #define DCL_CONTROLLER_BEGIN DCL_setControllerStatus #define DCL_CONTROLLER_END DCL_clearControllerStatus #define DCL_CONTROLLER_IN_PROGRESS DCL_getControllerStatus @@ -215,6 +232,8 @@ extern "C" { //***************************************************************************** #define DCL_runPIDF64_S1 DCL_runPIDF64Series +/** @} */ + #ifdef __cplusplus } #endif // extern "C" diff --git a/source/dcl/misc/dcl_error.h b/source/dcl/misc/dcl_error.h index b01c53d..9b88fb4 100644 --- a/source/dcl/misc/dcl_error.h +++ b/source/dcl/misc/dcl_error.h @@ -18,7 +18,7 @@ * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPgResS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, diff --git a/source/dcl/misc/dcl_fdlog.h b/source/dcl/misc/dcl_fdlog.h index 57e61e0..1f0964a 100644 --- a/source/dcl/misc/dcl_fdlog.h +++ b/source/dcl/misc/dcl_fdlog.h @@ -18,7 +18,7 @@ * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPgResS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, diff --git a/source/dcl/pi/dcl_pi.h b/source/dcl/pi/dcl_pi.h index 91d6704..f611fb3 100644 --- a/source/dcl/pi/dcl_pi.h +++ b/source/dcl/pi/dcl_pi.h @@ -18,7 +18,7 @@ * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPgResS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, @@ -58,11 +58,13 @@ typedef struct dcl_pi_sps float32_t Ki; //!< Integral gain float32_t Umax; //!< Upper saturation limit float32_t Umin; //!< Lower saturation limit + float32_t Imax; //!< Upper integrator saturation limit, only used in DCL_runPIParallelEnhanced() + float32_t Imin; //!< Lower integrator saturation limit, only used in DCL_runPIParallelEnhanced() } DCL_PI_SPS; //! \brief Defines default values to initialize DCL_PI_SPS //! -#define PI_SPS_DEFAULTS { 1.0f, 0.0f, 1.0f, -1.0f } +#define PI_SPS_DEFAULTS { 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, -1.0f } //! \brief DCL_PI object for storing PI specific parameters //! @@ -73,6 +75,8 @@ typedef _DCL_VOLATILE struct dcl_pi float32_t Ki; //!< Integral gain float32_t Umax; //!< Upper control saturation limit float32_t Umin; //!< Lower control saturation limit + float32_t Imax; //!< Upper integrator saturation limit, only used in DCL_runPIParallelEnhanced() + float32_t Imin; //!< Lower integrator saturation limit, only used in DCL_runPIParallelEnhanced() /* internal storage */ float32_t i6; //!< Saturation storage @@ -86,7 +90,7 @@ typedef _DCL_VOLATILE struct dcl_pi //! \brief Defines default values to initialize DCL_PI //! -#define PI_DEFAULTS { 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, \ +#define PI_DEFAULTS { 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, \ &(DCL_PI_SPS)PI_SPS_DEFAULTS, &(DCL_CSS)DCL_CSS_DEFAULTS } //! \brief Macro for internal default values to initialize DCL_PI @@ -95,6 +99,8 @@ typedef _DCL_VOLATILE struct dcl_pi //! .Ki = 0.0f, //! .Umax = 1.0f, //! .Umin = -1.0f, +//! .Imax = 0.0f, +//! .Imin = 0.0f, //! PI_INT_DEFAULTS //! }; #define PI_INT_DEFAULTS .i6=1.0f, .i10=0.0f, .i11=0.0f, \ @@ -133,7 +139,8 @@ typedef _DCL_VOLATILE struct dcl_pi if(sps_ptr) \ { \ *new_pi = (DCL_PI){ (new_sps)->Kp, (new_sps)->Ki, (new_sps)->Umax, (new_sps)->Umin,\ - 1.0f, 0.0f, 0.0f, (DCL_PI_SPS*)new_sps, &(DCL_CSS)DCL_CSS_DEFAULTS }; \ + (new_sps)->Imax, (new_sps)->Imin, 1.0f, 0.0f, 0.0f, \ + (DCL_PI_SPS*)new_sps, &(DCL_CSS)DCL_CSS_DEFAULTS }; \ } \ new_pi; \ }) @@ -145,24 +152,25 @@ typedef _DCL_VOLATILE struct dcl_pi _DCL_CODE_ACCESS void DCL_resetPI(DCL_PI *pi) { - dcl_interrupt_t ints = DCL_disableInts(); + dcl_interrupt_t ints; + ints = DCL_disableInts(); pi->i6 = 1.0f; pi->i10 = pi->i11 = 0.0f; DCL_restoreInts(ints); } -//! \brief Loads PI tuning parameter from its SPS parameter +//! \brief Loads PI tuning parameter from its SPS parameter without interrupt protection //! //! \param[in] pi Pointer to the DCL_PI controller structure //! _DCL_CODE_ACCESS -void DCL_fupdatePI(DCL_PI *pi) +void DCL_forceUpdatePI(DCL_PI *pi) { #ifdef DCL_ERROR_HANDLING_ENABLED uint32_t err_code = dcl_none; err_code |= (pi->sps->Umax <= pi->sps->Umin) ? dcl_param_invalid_err : dcl_none; - err_code |= (pi->css->t_sec <= 0.0f) ? dcl_param_range_err : dcl_none; + err_code |= (pi->css->T <= 0.0f) ? dcl_param_range_err : dcl_none; err_code |= (pi->sps->Kp < 0.0f) ? dcl_param_range_err : dcl_none; err_code |= (pi->sps->Ki < 0.0f) ? dcl_param_range_err : dcl_none; if (err_code) @@ -177,21 +185,22 @@ void DCL_fupdatePI(DCL_PI *pi) pi->Ki = pi->sps->Ki; pi->Umax = pi->sps->Umax; pi->Umin = pi->sps->Umin; + pi->Imax = pi->sps->Imax; + pi->Imin = pi->sps->Imin; } -//! \brief Updates PI parameter from its SPS parameter with interrupt protection +//! \brief Loads PI tuning parameter from its SPS parameter with interrupt protection //! //! \param[in] pi Pointer to the DCL_PI controller structure -//! \return 'true' if update is successful, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_updatePI(DCL_PI *pi) +void DCL_updatePINoCheck(DCL_PI *pi) { #ifdef DCL_ERROR_HANDLING_ENABLED uint32_t err_code = dcl_none; err_code |= (pi->sps->Umax <= pi->sps->Umin) ? dcl_param_invalid_err : dcl_none; - err_code |= (pi->css->t_sec <= 0.0f) ? dcl_param_range_err : dcl_none; + err_code |= (pi->css->T <= 0.0f) ? dcl_param_range_err : dcl_none; err_code |= (pi->sps->Kp < 0.0f) ? dcl_param_range_err : dcl_none; err_code |= (pi->sps->Ki < 0.0f) ? dcl_param_range_err : dcl_none; if (err_code) @@ -202,56 +211,39 @@ bool DCL_updatePI(DCL_PI *pi) } #endif - if (!DCL_getUpdateStatus(pi)) - { - dcl_interrupt_t ints = DCL_disableInts(); - DCL_setUpdateStatus(pi); - pi->Kp = pi->sps->Kp; - pi->Ki = pi->sps->Ki; - pi->Umax = pi->sps->Umax; - pi->Umin = pi->sps->Umin; - DCL_clearUpdateStatus(pi); - DCL_restoreInts(ints); - return true; - } - return false; + dcl_interrupt_t ints; + ints = DCL_disableInts(); + pi->Kp = pi->sps->Kp; + pi->Ki = pi->sps->Ki; + pi->Umax = pi->sps->Umax; + pi->Umin = pi->sps->Umin; + pi->Imax = pi->sps->Imax; + pi->Imin = pi->sps->Imin; + DCL_restoreInts(ints); } -//! \brief A conditional update based on the pending-for-update flag. -//! If the pending status is set, the function will update PI +//! \brief A conditional update based on the update flag. +//! If the update status is set, the function will update PI //! parameter from its SPS parameter and clear the status flag on completion. -//! Note: Use DCL_setPendingStatus(pi) to set the pending status. +//! Note: Use DCL_setUpdateStatus(pi) to set the update status. //! //! \param[in] pi Pointer to the DCL_PI controller structure //! \return 'true' if an update is applied, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_pendingUpdatePI(DCL_PI *pi) +bool DCL_updatePI(DCL_PI *pi) { - if (DCL_getPendingStatus(pi) && DCL_updatePI(pi)) + if (DCL_getUpdateStatus(pi)) { - DCL_clearPendingStatus(pi); + DCL_updatePINoCheck(pi); + DCL_clearUpdateStatus(pi); return true; } return false; } -//! \brief Update SPS parameter with active param, userful when needing -//! to update only few active param from SPS and keep rest the same -//! -//! \param[in] pi Pointer to the active DCL_PI controller structure -//! -_DCL_CODE_ACCESS -void DCL_updatePISPS(DCL_PI *pi) -{ - pi->sps->Kp = pi->Kp; - pi->sps->Ki = pi->Ki; - pi->sps->Umax = pi->Umax; - pi->sps->Umin = pi->Umin; -} - //! \brief Configures a series PI controller in "zero-pole-gain" form -//! Note: Sampling period pi->css->t_sec are used in the calculation. +//! Note: Sampling period pi->css->T are used in the calculation. //! New settings take effect after DCL_updatePI(). //! Only z1 considered in DCL_ZPK3, other poles & zeros ignored. //! Zero frequency assumed to be in radians/sec. @@ -265,7 +257,7 @@ void DCL_loadSeriesPIasZPK(DCL_PI *pi, DCL_ZPK3 *zpk) #ifdef DCL_ERROR_HANDLING_ENABLED uint32_t err_code = dcl_none; err_code |= (zpk->K < 0.0f) ? dcl_param_range_err : dcl_none; - err_code |= (crealf(zpk->z1) > (1.0f / (2.0f * pi->css->t_sec))) ? dcl_param_warn_err : dcl_none; + err_code |= (crealf(zpk->z1) > (1.0f / (2.0f * pi->css->T))) ? dcl_param_warn_err : dcl_none; if (err_code) { DCL_setError(pi,err_code); @@ -274,15 +266,15 @@ void DCL_loadSeriesPIasZPK(DCL_PI *pi, DCL_ZPK3 *zpk) } #endif - float32_t t_sec = pi->css->t_sec; + float32_t T = pi->css->T; float32_t z1 = (float32_t) crealf(zpk->z1); - pi->sps->Kp = zpk->K * (1.0f + (t_sec * z1) / 2.0f); - pi->sps->Ki = (-2.0f * t_sec * z1) / (2.0f + (t_sec * z1)); + pi->sps->Kp = zpk->K * (1.0f + (T * z1) / 2.0f); + pi->sps->Ki = (-2.0f * T * z1) / (2.0f + (T * z1)); } //! \brief Configures a parallel PI controller in "zero-pole-gain" form -//! Note: Sampling period pi->css->t_sec are used in the calculation. +//! Note: Sampling period pi->css->T are used in the calculation. //! New settings take effect after DCL_updatePI(). //! Zero frequency assumed to be in radians/sec. //! @@ -295,7 +287,7 @@ void DCL_loadParallelPIasZPK(DCL_PI *pi, DCL_ZPK3 *zpk) #ifdef DCL_ERROR_HANDLING_ENABLED uint32_t err_code = dcl_none; err_code |= (zpk->K < 0.0f) ? dcl_param_range_err : dcl_none; - err_code |= (crealf(zpk->z1) > (1.0f / (2.0f * pi->css->t_sec))) ? dcl_param_warn_err : dcl_none; + err_code |= (crealf(zpk->z1) > (1.0f / (2.0f * pi->css->T))) ? dcl_param_warn_err : dcl_none; if (err_code) { DCL_setError(pi,err_code); @@ -304,10 +296,10 @@ void DCL_loadParallelPIasZPK(DCL_PI *pi, DCL_ZPK3 *zpk) } #endif - float32_t t_sec = pi->css->t_sec; + float32_t T = pi->css->T; float32_t z1 = (float32_t) crealf(zpk->z1); - pi->sps->Kp = zpk->K * (1.0f + (t_sec * z1) / 2.0f); - pi->sps->Ki = -zpk->K * t_sec * z1; + pi->sps->Kp = zpk->K * (1.0f + (T * z1) / 2.0f); + pi->sps->Ki = -zpk->K * T * z1; } //! \brief Executes an inline series form PI controller @@ -371,12 +363,10 @@ float32_t DCL_runPIParallel(DCL_PI *pi, float32_t rk, float32_t yk) //! \param[in] pi Pointer to the DCL_PI structure //! \param[in] rk The controller set-point reference //! \param[in] yk The measured feedback value -//! \param[in] Imax Upper integrator saturation limit -//! \param[in] Imin Lower integrator saturation limit //! \return The control effort //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -float32_t DCL_runPIParallelEnhanced(DCL_PI *pi, float32_t rk, float32_t yk, float32_t Imax, float32_t Imin) +float32_t DCL_runPIParallelEnhanced(DCL_PI *pi, float32_t rk, float32_t yk) { float32_t v1, v5, v7, v8; bool l11, l14, l17, l18, l19; @@ -387,7 +377,7 @@ float32_t DCL_runPIParallelEnhanced(DCL_PI *pi, float32_t rk, float32_t yk, floa v7 = (v1 * pi->Kp) + v5; v8 = DCL_runSat(v7, pi->Umax, pi->Umin); l17 = (v7 == v8) ? true : false; - l11 = (DCL_runSat(v5,Imax,Imin) == v5) ? true : false; + l11 = (DCL_runSat(v5, pi->Imax, pi->Imin) == v5) ? true : false; l19 = (v5 > 0) ? true : false; l14 = (v1 > 0) ? true : false; l18 = l17 && (!l11 || (l19 ^ l14)); diff --git a/source/dcl/pi/dcl_pi2.h b/source/dcl/pi/dcl_pi2.h index 13b6b5e..ed0e326 100644 --- a/source/dcl/pi/dcl_pi2.h +++ b/source/dcl/pi/dcl_pi2.h @@ -18,7 +18,7 @@ * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPgResS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, @@ -147,24 +147,25 @@ typedef _DCL_VOLATILE struct dcl_pi2 _DCL_CODE_ACCESS void DCL_resetPI2(DCL_PI2 *pi2) { - dcl_interrupt_t ints = DCL_disableInts(); + dcl_interrupt_t ints; + ints = DCL_disableInts(); pi2->i6 = pi2->i9 = 0.0f; pi2->i12 = pi2->i13 = 1.0f; DCL_restoreInts(ints); } -//! \brief Loads PI2 tuning parameter from its SPS parameter +//! \brief Loads PI2 tuning parameter from its SPS parameter without interrupt protection //! //! \param[in] pi2 Pointer to the DCL_PI2 controller structure //! _DCL_CODE_ACCESS -void DCL_fupdatePI2(DCL_PI2 *pi2) +void DCL_forceUpdatePI2(DCL_PI2 *pi2) { #ifdef DCL_ERROR_HANDLING_ENABLED uint32_t err_code = dcl_none; err_code |= (pi2->sps->Umax <= pi2->sps->Umin) ? dcl_param_invalid_err : dcl_none; - err_code |= (pi2->css->t_sec <= 0.0f) ? dcl_param_range_err : dcl_none; + err_code |= (pi2->css->T <= 0.0f) ? dcl_param_range_err : dcl_none; err_code |= (pi2->sps->Kp < 0.0f) ? dcl_param_range_err : dcl_none; err_code |= (pi2->sps->Ki < 0.0f) ? dcl_param_range_err : dcl_none; if (err_code) @@ -181,19 +182,18 @@ void DCL_fupdatePI2(DCL_PI2 *pi2) pi2->Umin = pi2->sps->Umin; } -//! \brief Updates PI2 parameter from its SPS parameter with interrupt protection +//! \brief Loads PI2 tuning parameter from its SPS parameter with interrupt protection //! //! \param[in] pi2 Pointer to the DCL_PI2 controller structure -//! \return 'true' if update is successful, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_updatePI2(DCL_PI2 *pi2) +void DCL_updatePI2NoCheck(DCL_PI2 *pi2) { #ifdef DCL_ERROR_HANDLING_ENABLED uint32_t err_code = dcl_none; err_code |= (pi2->sps->Umax <= pi2->sps->Umin) ? dcl_param_invalid_err : dcl_none; - err_code |= (pi2->css->t_sec <= 0.0f) ? dcl_param_range_err : dcl_none; + err_code |= (pi2->css->T <= 0.0f) ? dcl_param_range_err : dcl_none; err_code |= (pi2->sps->Kp < 0.0f) ? dcl_param_range_err : dcl_none; err_code |= (pi2->sps->Ki < 0.0f) ? dcl_param_range_err : dcl_none; if (err_code) @@ -204,54 +204,35 @@ bool DCL_updatePI2(DCL_PI2 *pi2) } #endif - if (!DCL_getUpdateStatus(pi2)) - { - dcl_interrupt_t ints = DCL_disableInts(); - DCL_setUpdateStatus(pi2); - pi2->Ki = pi2->sps->Ki; - pi2->Kp = pi2->sps->Kp; - pi2->Umax = pi2->sps->Umax; - pi2->Umin = pi2->sps->Umin; - DCL_clearUpdateStatus(pi2); - DCL_restoreInts(ints); - return true; - } - return false; + dcl_interrupt_t ints; + ints = DCL_disableInts(); + pi2->Ki = pi2->sps->Ki; + pi2->Kp = pi2->sps->Kp; + pi2->Umax = pi2->sps->Umax; + pi2->Umin = pi2->sps->Umin; + DCL_restoreInts(ints); } -//! \brief A conditional update based on the pending-for-update flag. -//! If the pending status is set, the function will update PI2 +//! \brief A conditional update based on the update flag. +//! If the update status is set, the function will update PI2 //! parameter from its SPS parameter and clear the status flag on completion. -//! Note: Use DCL_setPendingStatus(pi2) to set the pending status. +//! Note: Use DCL_setUpdateStatus(pi2) to set the update status. //! //! \param[in] pi2 Pointer to the DCL_PI2 controller structure //! \return 'true' if an update is applied, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_pendingUpdatePI2(DCL_PI2 *pi2) +bool DCL_updatePI2(DCL_PI2 *pi2) { - if (DCL_getPendingStatus(pi2) && DCL_updatePI2(pi2)) + if (DCL_getUpdateStatus(pi2)) { - DCL_clearPendingStatus(pi2); + DCL_updatePI2NoCheck(pi2); + DCL_clearUpdateStatus(pi2); return true; } return false; } -//! \brief Update SPS parameter with active param, userful when needing -//! to update only few active param from SPS and keep rest the same -//! -//! \param[in] pi2 Pointer to the active DCL_PI controller structure -//! -_DCL_CODE_ACCESS -void DCL_updatePI2SPS(DCL_PI2 *pi2) -{ - pi2->sps->Kp = pi2->Kp; - pi2->sps->Ki = pi2->Ki; - pi2->sps->Umax = pi2->Umax; - pi2->sps->Umin = pi2->Umin; -} - //! \brief Executes an inline series form PI2 controller on the FPU32 //! //! \param[in] pi2 Pointer to the DCL_PI2 structure diff --git a/source/dcl/pid/dcl_pid.h b/source/dcl/pid/dcl_pid.h index 7a234eb..9332645 100644 --- a/source/dcl/pid/dcl_pid.h +++ b/source/dcl/pid/dcl_pid.h @@ -18,7 +18,7 @@ * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPgResS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, @@ -157,27 +157,28 @@ typedef _DCL_VOLATILE struct dcl_pid _DCL_CODE_ACCESS void DCL_resetPID(DCL_PID *pid) { - dcl_interrupt_t ints = DCL_disableInts(); + dcl_interrupt_t ints; + ints = DCL_disableInts(); pid->d2 = pid->d3 = pid->i10 = 0.0f; pid->i14 = 1.0f; DCL_restoreInts(ints); } -//! \brief Loads PID tuning parameter from its SPS parameter +//! \brief Loads PID tuning parameter from its SPS parameter without interrupt protection //! //! \param[in] pid Pointer to the active DCL_PID controller structure //! _DCL_CODE_ACCESS -void DCL_fupdatePID(DCL_PID *pid) +void DCL_forceUpdatePID(DCL_PID *pid) { #ifdef DCL_ERROR_HANDLING_ENABLED - float32_t tau = (2.0f - pid->sps->c1 * pid->css->t_sec) / (2.0f * pid->sps->c1); - float32_t ec2 = pid->sps->c1 * (pid->css->t_sec - 2.0f * tau) / 2.0f; + float32_t tau = (2.0f - pid->sps->c1 * pid->css->T) / (2.0f * pid->sps->c1); + float32_t ec2 = pid->sps->c1 * (pid->css->T - 2.0f * tau) / 2.0f; uint32_t err_code = dcl_none; err_code |= DCL_isValue(pid->sps->c2, ec2) ? dcl_none : dcl_param_invalid_err; err_code |= (pid->sps->Umax > pid->sps->Umin) ? dcl_none : dcl_param_invalid_err; - err_code |= (pid->css->t_sec > 0.0f) ? dcl_none : dcl_param_range_err; + err_code |= (pid->css->T > 0.0f) ? dcl_none : dcl_param_range_err; err_code |= ((pid->sps->Kp > 0.0f) && (pid->sps->Ki > 0.0f) && (pid->sps->Kd > 0.0f) && (pid->sps->Kr > 0.0f)) ? dcl_none : dcl_param_range_err ; if (err_code) { @@ -197,22 +198,21 @@ void DCL_fupdatePID(DCL_PID *pid) pid->Umin = pid->sps->Umin; } -//! \brief Updates PID parameter from its SPS parameter with interrupt protection +//! \brief Loads PID tuning parameter from its SPS parameter with interrupt protection //! //! \param[in] pid Pointer to the active DCL_PID controller structure -//! \return 'true' if update is successful, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_updatePID(DCL_PID *pid) +void DCL_updatePIDNoCheck(DCL_PID *pid) { #ifdef DCL_ERROR_HANDLING_ENABLED - float32_t tau = (2.0f - pid->sps->c1 * pid->css->t_sec) / (2.0f * pid->sps->c1); - float32_t ec2 = pid->sps->c1 * (pid->css->t_sec - 2.0f * tau) / 2.0f; + float32_t tau = (2.0f - pid->sps->c1 * pid->css->T) / (2.0f * pid->sps->c1); + float32_t ec2 = pid->sps->c1 * (pid->css->T - 2.0f * tau) / 2.0f; uint32_t err_code = dcl_none; err_code |= DCL_isValue(pid->sps->c2, ec2) ? dcl_none : dcl_param_invalid_err; err_code |= (pid->sps->Umax > pid->sps->Umin) ? dcl_none : dcl_param_invalid_err; - err_code |= (pid->css->t_sec > 0.0f) ? dcl_none : dcl_param_range_err; + err_code |= (pid->css->T > 0.0f) ? dcl_none : dcl_param_range_err; err_code |= ((pid->sps->Kp > 0.0f) && (pid->sps->Ki > 0.0f) && (pid->sps->Kd > 0.0f) && (pid->sps->Kr > 0.0f)) ? dcl_none : dcl_param_range_err ; if (err_code) { @@ -222,64 +222,41 @@ bool DCL_updatePID(DCL_PID *pid) } #endif - if (!DCL_getUpdateStatus(pid)) - { - dcl_interrupt_t ints = DCL_disableInts(); - DCL_setUpdateStatus(pid); - pid->Kp = pid->sps->Kp; - pid->Ki = pid->sps->Ki; - pid->Kd = pid->sps->Kd; - pid->Kr = pid->sps->Kr; - pid->c1 = pid->sps->c1; - pid->c2 = pid->sps->c2; - pid->Umax = pid->sps->Umax; - pid->Umin = pid->sps->Umin; - DCL_clearUpdateStatus(pid); - DCL_restoreInts(ints); - return true; - } - return false; + dcl_interrupt_t ints; + ints = DCL_disableInts(); + pid->Kp = pid->sps->Kp; + pid->Ki = pid->sps->Ki; + pid->Kd = pid->sps->Kd; + pid->Kr = pid->sps->Kr; + pid->c1 = pid->sps->c1; + pid->c2 = pid->sps->c2; + pid->Umax = pid->sps->Umax; + pid->Umin = pid->sps->Umin; + DCL_restoreInts(ints); } -//! \brief A conditional update based on the pending-for-update flag. -//! If the pending status is set, the function will update PID +//! \brief A conditional update based on the update flag. +//! If the update status is set, the function will update PID //! parameter from its SPS parameter and clear the status flag on completion. -//! Note: Use DCL_setPendingStatus(pid) to set the pending status. +//! Note: Use DCL_getUpdateStatus(pid) to set the update status. //! //! \param[in] pid Pointer to the DCL_PID controller structure //! \return 'true' if an update is applied, otherwise 'false' //! _DCL_CODE_ACCESS _DCL_CODE_SECTION -bool DCL_pendingUpdatePID(DCL_PID *pid) +bool DCL_updatePID(DCL_PID *pid) { - if (DCL_getPendingStatus(pid) && DCL_updatePID(pid)) + if (DCL_getUpdateStatus(pid)) { - DCL_clearPendingStatus(pid); + DCL_updatePIDNoCheck(pid); + DCL_clearUpdateStatus(pid); return true; } return false; } -//! \brief Update SPS parameter with active param, userful when needing -//! to update only few active param from SPS and keep rest the same -//! -//! \param[in] pid Pointer to the active DCL_PID controller structure -//! -_DCL_CODE_ACCESS -void DCL_updatePIDSPS(DCL_PID *pid) -{ - pid->sps->Kp = pid->Kp; - pid->sps->Ki = pid->Ki; - pid->sps->Kd = pid->Kd; - pid->sps->Kr = pid->Kr; - pid->sps->c1 = pid->c1; - pid->sps->c2 = pid->c2; - pid->sps->Umax = pid->Umax; - pid->sps->Umin = pid->Umin; -} - //! \brief Loads the derivative path filter shadow coefficients. -//! Note: Sampling period pid->css->t_sec are used in the calculation. +//! Note: Sampling period pid->css->T are used in the calculation. //! New coefficients take effect when DCL_updatePID() is called. //! //! \param[in] pid Pointer to the DCL_PID structure @@ -291,7 +268,7 @@ void DCL_setPIDfilterBW(DCL_PID *pid, float32_t fc) #ifdef DCL_ERROR_HANDLING_ENABLED uint32_t err_code = dcl_none; - err_code |= ((fc >= 1.0f / (2.0f * pid->css->t_sec)) || (fc <= 0.0f)) ? dcl_param_range_err : dcl_none; + err_code |= ((fc >= 1.0f / (2.0f * pid->css->T)) || (fc <= 0.0f)) ? dcl_param_range_err : dcl_none; if (err_code) { DCL_setError(pid,err_code); @@ -300,27 +277,27 @@ void DCL_setPIDfilterBW(DCL_PID *pid, float32_t fc) } #endif - float32_t t_sec = pid->css->t_sec; + float32_t T = pid->css->T; float32_t tau = 1.0f / (2.0f * CONST_PI * fc); - pid->sps->c1 = 2.0f / (t_sec + (2.0f * tau)); - pid->sps->c2 = (t_sec - (2.0f * tau)) / (t_sec + (2.0f * tau)); + pid->sps->c1 = 2.0f / (T + (2.0f * tau)); + pid->sps->c2 = (T - (2.0f * tau)) / (T + (2.0f * tau)); } //! \brief Loads the PID derivative path filter active coefficients -//! Note: Sampling period pid->css->t_sec are used in the calculation. +//! Note: Sampling period pid->css->T are used in the calculation. //! New coefficients take effect immediately. SPS & CSS contents are unaffected. //! //! \param[in] pid Pointer to the DCL_PID structure //! \param[in] fc The desired filter bandwidth in Hz -//! \param[in] t_sec The controller update rate in seconds +//! \param[in] T The controller update rate in seconds //! _DCL_CODE_ACCESS -void DCL_setActivePIDfilterBW(DCL_PID *pid, float32_t fc, float32_t t_sec) +void DCL_setActivePIDfilterBW(DCL_PID *pid, float32_t fc, float32_t T) { #ifdef DCL_ERROR_HANDLING_ENABLED uint32_t err_code = dcl_none; - err_code |= ((fc >= 1.0f / (2.0f * t_sec)) || (fc <= 0.0f)) ? dcl_param_range_err : dcl_none; + err_code |= ((fc >= 1.0f / (2.0f * T)) || (fc <= 0.0f)) ? dcl_param_range_err : dcl_none; if (err_code) { DCL_setError(pid,err_code); @@ -330,24 +307,24 @@ void DCL_setActivePIDfilterBW(DCL_PID *pid, float32_t fc, float32_t t_sec) #endif float32_t tau = 1.0f / (2.0f * CONST_PI * fc); - pid->c1 = 2.0f / (t_sec + (2.0f * tau)); - pid->c2 = (t_sec - (2.0f * tau)) / (t_sec + (2.0f * tau)); + pid->c1 = 2.0f / (T + (2.0f * tau)); + pid->c2 = (T - (2.0f * tau)) / (T + (2.0f * tau)); } //! \brief Calculates the active derivative path filter bandwidth in Hz. -//! Note: Sampling period pid->css->t_sec are used in the calculation. +//! Note: Sampling period pid->css->T are used in the calculation. //! \param[in] pid Pointer to the DCL_PID structure //! \return The filter bandwidth in Hz //! _DCL_CODE_ACCESS float32_t DCL_getPIDfilterBW(DCL_PID *pid) { - float32_t tau = ((2.0f - pid->c1 * pid->css->t_sec) / (2.0f * pid->c1)); + float32_t tau = ((2.0f - pid->c1 * pid->css->T) / (2.0f * pid->c1)); return(1.0f / (2.0f * CONST_PI * tau)); } //! \brief Configures a series PID controller parameter in ZPK form. -//! Note: Sampling period pid->css->t_sec are used in the calculation. +//! Note: Sampling period pid->css->T are used in the calculation. //! Parameters take effect after call to DCL_updatePID(). //! Only z1, z2 & p2 considered, p1 = 0 assumed. //! @@ -376,15 +353,15 @@ void DCL_loadSeriesPIDasZPK(DCL_PID *pid, DCL_ZPK3 *zpk) float32_t beta0 = (float32_t) crealf(zpk->z1 * zpk->z2); float32_t alpha1 = -(float32_t) crealf(zpk->p1 + zpk->p2); float32_t alpha0 = (float32_t) crealf(zpk->p1 * zpk->p2); - float32_t t_sec = pid->css->t_sec; - float32_t a0p = 4.0f + (alpha1 * 2.0f * t_sec) + (alpha0 * t_sec * t_sec); - float32_t b0 = zpk->K * (4.0f + (beta1 * 2.0f * t_sec) + (beta0 * t_sec *t_sec)) / a0p; - float32_t b1 = zpk->K * (-8.0f + (2.0f * beta0 * t_sec * t_sec)) / a0p; - float32_t b2 = zpk->K * (4.0f - (beta1 * 2.0f * t_sec) + (beta0 * t_sec * t_sec)) / a0p; - float32_t a2 = (4.0f - (alpha1 * 2.0f * t_sec) + (alpha0 * t_sec * t_sec)) / a0p; + float32_t T = pid->css->T; + float32_t a0p = 4.0f + (alpha1 * 2.0f * T) + (alpha0 * T * T); + float32_t b0 = zpk->K * (4.0f + (beta1 * 2.0f * T) + (beta0 * T *T)) / a0p; + float32_t b1 = zpk->K * (-8.0f + (2.0f * beta0 * T * T)) / a0p; + float32_t b2 = zpk->K * (4.0f - (beta1 * 2.0f * T) + (beta0 * T * T)) / a0p; + float32_t a2 = (4.0f - (alpha1 * 2.0f * T) + (alpha0 * T * T)) / a0p; float32_t c2 = -a2; - float32_t tau = (t_sec / 2.0f) * (1.0f - c2) / (1.0f + c2); - pid->sps->c1 = 2.0f / (t_sec + 2.0f * tau); + float32_t tau = (T / 2.0f) * (1.0f - c2) / (1.0f + c2); + pid->sps->c1 = 2.0f / (T + 2.0f * tau); pid->sps->c2 = c2; float32_t det = (c2 + 1.0f); det *= det; @@ -414,7 +391,7 @@ void DCL_loadSeriesPIDasZPK(DCL_PID *pid, DCL_ZPK3 *zpk) } //! \brief Configures a parallel PID controller in ZPK form. -//! Note: Sampling period pid->css->t_sec are used in the calculation. +//! Note: Sampling period pid->css->T are used in the calculation. //! Parameters take effect after call to DCL_updatePID(). //! Only z1, z2 & p2 considered, p1 = 0 assumed. //! @@ -442,15 +419,15 @@ void DCL_loadParallelPIDasZPK(DCL_PID *pid, DCL_ZPK3 *zpk) float32_t beta0 = (float32_t) crealf(zpk->z1 * zpk->z2); float32_t alpha1 = -(float32_t) crealf(zpk->p1 + zpk->p2); float32_t alpha0 = (float32_t) crealf(zpk->p1 * zpk->p2); - float32_t t_sec = pid->css->t_sec; - float32_t a0p = 4.0f + (alpha1 * 2.0f * t_sec) + (alpha0 * t_sec * t_sec); - float32_t b0 = zpk->K * (4.0f + (beta1 * 2.0f * t_sec) + (beta0 * t_sec * t_sec)) / a0p; - float32_t b1 = zpk->K * (-8.0f + (2.0f * beta0 * t_sec * t_sec)) / a0p; - float32_t b2 = zpk->K * (4.0f - (beta1 * 2.0f * t_sec) + (beta0 * t_sec * t_sec)) / a0p; - float32_t a2 = (4.0f - (alpha1 * 2.0f * t_sec) + (alpha0 * t_sec * t_sec)) / a0p; + float32_t T = pid->css->T; + float32_t a0p = 4.0f + (alpha1 * 2.0f * T) + (alpha0 * T * T); + float32_t b0 = zpk->K * (4.0f + (beta1 * 2.0f * T) + (beta0 * T * T)) / a0p; + float32_t b1 = zpk->K * (-8.0f + (2.0f * beta0 * T * T)) / a0p; + float32_t b2 = zpk->K * (4.0f - (beta1 * 2.0f * T) + (beta0 * T * T)) / a0p; + float32_t a2 = (4.0f - (alpha1 * 2.0f * T) + (alpha0 * T * T)) / a0p; float32_t c2 = -a2; - float32_t tau = (t_sec / 2.0f) * (1.0f - c2) / (1.0f + c2); - pid->sps->c1 = 2.0f / (t_sec + 2.0f * tau); + float32_t tau = (T / 2.0f) * (1.0f - c2) / (1.0f + c2); + pid->sps->c1 = 2.0f / (T + 2.0f * tau); pid->sps->c2 = c2; float32_t det = (c2 + 1.0f); det *= det; diff --git a/source/dcl/pid/dcl_pidf64.h b/source/dcl/pid/dcl_pidf64.h index 9f0fb88..01cb226 100644 --- a/source/dcl/pid/dcl_pidf64.h +++ b/source/dcl/pid/dcl_pidf64.h @@ -154,27 +154,28 @@ typedef _DCL_VOLATILE struct dcl_pidf64 { _DCL_CODE_ACCESS void DCL_resetPIDF64(DCL_PIDF64 *pid) { - dcl_interrupt_t ints = DCL_disableInts(); + dcl_interrupt_t ints; + ints = DCL_disableInts(); pid->d2 = pid->d3 = pid->i10 = 0.0L; pid->i14 = 1.0L; DCL_restoreInts(ints); } -//! \brief Loads PIDF64 tuning parameter from its SPS parameter +//! \brief Loads PIDF64 tuning parameter from its SPS parameter without interrupt protection //! //! \param[in] pid Pointer to the active DCL_PID64 controller structure //! _DCL_CODE_ACCESS -void DCL_fupdatePIDF64(DCL_PIDF64 *pid) +void DCL_forceUpdatePIDF64(DCL_PIDF64 *pid) { #ifdef DCL_ERROR_HANDLING_ENABLED - float64_t tau = (2.0L - pid->sps->c1 * p->css->t_sec) / (2.0L * pid->sps->c1); - float64_t ec2 = pid->sps->c1 * (pid->css->t_sec - 2.0L * tau) / 2.0L; + float64_t tau = (2.0L - pid->sps->c1 * p->css->T) / (2.0L * pid->sps->c1); + float64_t ec2 = pid->sps->c1 * (pid->css->T - 2.0L * tau) / 2.0L; uint32_t err_code = dcl_none; err_code |= DCL_isValue(pid->sps->c2, ec2) ? dcl_none : dcl_param_invalid_err; err_code |= (pid->sps->Umax > pid->sps->Umin) ? dcl_none : dcl_param_invalid_err; - err_code |= (pid->css->t_sec > 0.0L) ? dcl_none : dcl_param_range_err; + err_code |= (pid->css->T > 0.0L) ? dcl_none : dcl_param_range_err; err_code |= ((pid->sps->Kp > 0.0L) && (pid->sps->Ki > 0.0L) && (pid->sps->Kd > 0.0L) && (pid->sps->Kr > 0.0L)) ? dcl_none : dcl_param_range_err ; if (err_code) { @@ -198,19 +199,18 @@ void DCL_fupdatePIDF64(DCL_PIDF64 *pid) //! \brief Updates PID parameter from its SPS parameter with interrupt protection //! //! \param[in] pid Pointer to the DCL_PID64 controller structure -//! \return 'true' if update is successful, otherwise 'false' //! _DCL_CODE_ACCESS -bool DCL_updatePIDF64(DCL_PIDF64 *pid) +void DCL_updatePIDF64NoCheck(DCL_PIDF64 *pid) { #ifdef DCL_ERROR_HANDLING_ENABLED - float64_t tau = (2.0L - pid->sps->c1 * pid->css->t_sec) / (2.0L * pid->sps->c1); - float64_t ec2 = pid->sps->c1 * (pid->css->t_sec - 2.0L * tau) / 2.0L; + float64_t tau = (2.0L - pid->sps->c1 * pid->css->T) / (2.0L * pid->sps->c1); + float64_t ec2 = pid->sps->c1 * (pid->css->T - 2.0L * tau) / 2.0L; uint32_t err_code = dcl_none; err_code |= DCL_isValue(pid->sps->c2, ec2) ? dcl_none : dcl_param_invalid_err; err_code |= (pid->sps->Umax > pid->sps->Umin) ? dcl_none : dcl_param_invalid_err; - err_code |= (pid->css->t_sec > 0.0L) ? dcl_none : dcl_param_range_err; + err_code |= (pid->css->T > 0.0L) ? dcl_none : dcl_param_range_err; err_code |= ((pid->sps->Kp > 0.0L) && (pid->sps->Ki > 0.0L) && (pid->sps->Kd > 0.0L) && (pid->sps->Kr > 0.0L)) ? dcl_none : dcl_param_range_err ; if (err_code) { @@ -220,64 +220,41 @@ bool DCL_updatePIDF64(DCL_PIDF64 *pid) } #endif - if (!DCL_getUpdateStatus(pid)) - { - dcl_interrupt_t ints = DCL_disableInts(); - DCL_setUpdateStatus(pid); - pid->Kp = pid->sps->Kp; - pid->Ki = pid->sps->Ki; - pid->Kd = pid->sps->Kd; - pid->Kr = pid->sps->Kr; - pid->c1 = pid->sps->c1; - pid->c2 = pid->sps->c2; - pid->Umax = pid->sps->Umax; - pid->Umin = pid->sps->Umin; - DCL_clearUpdateStatus(pid); - DCL_restoreInts(ints); - return true; - } - return false; + dcl_interrupt_t ints; + ints = DCL_disableInts(); + pid->Kp = pid->sps->Kp; + pid->Ki = pid->sps->Ki; + pid->Kd = pid->sps->Kd; + pid->Kr = pid->sps->Kr; + pid->c1 = pid->sps->c1; + pid->c2 = pid->sps->c2; + pid->Umax = pid->sps->Umax; + pid->Umin = pid->sps->Umin; + DCL_restoreInts(ints); } -//! \brief A conditional update based on the pending-for-update flag. -//! If the pending status is set, the function will update PIDF64 +//! \brief A conditional update based on the update flag. +//! If the update status is set, the function will update PIDF64 //! parameter from its SPS parameter and clear the status flag on completion. -//! Note: Use DCL_setPendingStatus(pid) to set the pending status. +//! Note: Use DCL_setUpdateStatus(pid) to set the pending status. //! //! \param[in] pid Pointer to the DCL_PIDF64 controller structure //! \return 'true' if an update is applied, otherwise 'false' //! _DCL_CODE_ACCESS -bool DCL_pendingUpdatePIDF64(DCL_PIDF64 *pid) +bool DCL_updatePIDF64(DCL_PIDF64 *pid) { - if (DCL_getPendingStatus(pid) && DCL_updatePIDF64(pid)) + if (DCL_getUpdateStatus(pid)) { - DCL_clearPendingStatus(pid); + DCL_updatePIDF64NoCheck(pid); + DCL_clearUpdateStatus(pid); return true; } return false; } -//! \brief Update SPS parameter with active param, userful when needing -//! to update only few active param from SPS and keep rest the same -//! -//! \param[in] pid Pointer to the active DCL_PIDF64 controller structure -//! -_DCL_CODE_ACCESS -void DCL_updatePIDF64SPS(DCL_PIDF64 *pid) -{ - pid->sps->Kp = pid->Kp; - pid->sps->Ki = pid->Ki; - pid->sps->Kd = pid->Kd; - pid->sps->Kr = pid->Kr; - pid->sps->c1 = pid->c1; - pid->sps->c2 = pid->c2; - pid->sps->Umax = pid->Umax; - pid->sps->Umin = pid->Umin; -} - //! \brief Loads the derivative path filter shadow coefficients -//! Note: Sampling period pid->css->t_sec are used in the calculation +//! Note: Sampling period pid->css->T are used in the calculation //! Note: new coefficients take effect when DCL_updatePID64() is called //! //! \param[in] pid Pointer to the DCL_PID64 structure @@ -289,7 +266,7 @@ void DCL_setPIDF64filterBW(DCL_PIDF64 *pid, float64_t fc) #ifdef DCL_ERROR_HANDLING_ENABLED uint32_t err_code; - err_code = ((fc >= 1.0L / (2.0L * pid->css->t_sec)) || (fc <= 0.0L)) ? dcl_param_range_err : dcl_none; + err_code = ((fc >= 1.0L / (2.0L * pid->css->T)) || (fc <= 0.0L)) ? dcl_param_range_err : dcl_none; if (err_code) { DCL_setError(pid,err_code); @@ -298,28 +275,27 @@ void DCL_setPIDF64filterBW(DCL_PIDF64 *pid, float64_t fc) } #endif - float64_t t_sec = pid->css->t_sec; + float64_t T = pid->css->T; float64_t tau = 1.0L / (2.0L * CONST_PI_F64 * fc); - pid->sps->c1 = 2.0L / (t_sec + (2.0L * tau)); - pid->sps->c2 = (t_sec - (2.0L * tau)) / (t_sec + (2.0L * tau)); + pid->sps->c1 = 2.0L / (T + (2.0L * tau)); + pid->sps->c2 = (T - (2.0L * tau)) / (T + (2.0L * tau)); } //! \brief Loads the PID64 derivative path filter active coefficients -//! Note: Sampling period pid->css->t_sec are used in the calculation //! Note: new coefficients take effect immediately. SPS & //! CSS contents are unaffected. //! //! \param[in] pid Pointer to the DCL_PID64 structure //! \param[in] fc The desired filter bandwidth in Hz -//! \param[in] t_sec The controller update rate in seconds +//! \param[in] T The controller period in seconds //! _DCL_CODE_ACCESS -void DCL_setActivePIDF64filterBW(DCL_PIDF64 *pid, float64_t fc, float64_t t_sec) +void DCL_setActivePIDF64filterBW(DCL_PIDF64 *pid, float64_t fc, float64_t T) { #ifdef DCL_ERROR_HANDLING_ENABLED uint32_t err_code; - err_code = ((fc >= 1.0L / (2.0L * t_sec)) || (fc <= 0.0L)) ? dcl_param_range_err : dcl_none; + err_code = ((fc >= 1.0L / (2.0L * T)) || (fc <= 0.0L)) ? dcl_param_range_err : dcl_none; if (err_code) { DCL_setError(pid,err_code); @@ -329,12 +305,12 @@ void DCL_setActivePIDF64filterBW(DCL_PIDF64 *pid, float64_t fc, float64_t t_sec) #endif float64_t tau = 1.0L / (2.0L * CONST_PI_F64 * fc); - pid->c1 = 2.0L / (t_sec + (2.0L * tau)); - pid->c2 = (t_sec - (2.0L * tau)) / (t_sec + (2.0L * tau)); + pid->c1 = 2.0L / (T + (2.0L * tau)); + pid->c2 = (T - (2.0L * tau)) / (T + (2.0L * tau)); } //! \brief Returns the active derivative path filter bandwidth in Hz -//! Note: Sampling period pid->css->t_sec are used in the calculation +//! Note: Sampling period pid->css->T are used in the calculation //! //! \param[in] pid Pointer to the DCL_PID64 structure //! \return The filter bandwidth in Hz @@ -342,7 +318,7 @@ void DCL_setActivePIDF64filterBW(DCL_PIDF64 *pid, float64_t fc, float64_t t_sec) _DCL_CODE_ACCESS float64_t DCL_getPIDF64filterBW(DCL_PIDF64 *pid) { - float64_t tau = ((2.0L - pid->c1 * pid->css->t_sec) / (2.0L * pid->c1)); + float64_t tau = ((2.0L - pid->c1 * pid->css->T) / (2.0L * pid->c1)); return(1.0L / (2.0L * CONST_PI_F64 * tau)); } diff --git a/source/transforms/clarke/clarke.h b/source/transforms/clarke/clarke.h new file mode 100644 index 0000000..49eea71 --- /dev/null +++ b/source/transforms/clarke/clarke.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2023 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _CLARKE_H_ +#define _CLARKE_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * \defgroup TRANSFORMS_API_MODULE APIs for motor transformations + * \ingroup MOTOR_CONTROL_API + * + * Here is the list of transform function APIs + * @{ + * + * \file clarke.h + * \brief Contains abc to alpha/beta/0 transform implementation + */ + +#include + +typedef float float32_t; + +#define ONE_OVER_THREE 0.33333333333333f +#define ONE_OVER_SQRT_THREE 0.57735026918963f + +//! \brief Runs the Clarke transform module for three inputs +//! +//! \param[in] inIa Input current value in a-axis +//! \param[in] inIb Input current value in b-axis +//! \param[in] inIc Input current value in c-axis +//! \param[in] pIalpha Output pointer to current value in alpha-axis +//! \param[in] pIbeta Output pointer to current value in beta-axis +//! +static __attribute__((always_inline)) +void CLARKE_run_threeInput(const float32_t inIa, const float32_t inIb, const float32_t inIc, \ + float32_t* pIalpha, float32_t* pIbeta) +{ + *pIalpha = ((2.0f * inIa) - (inIb + inIc)) * ONE_OVER_THREE; + *pIbeta = (inIb - inIc) * ONE_OVER_SQRT_THREE; +} + +//! \brief Runs the Clarke transform module for two inputs +//! +//! \param[in] inIa Input current value in a-axis +//! \param[in] inIb Input current value in b-axis +//! \param[in] pIalpha Output pointer to current value in alpha-axis +//! \param[in] pIbeta Output pointer to current value in beta-axis +//! +static __attribute__((always_inline)) +void CLARKE_run_twoInput(const float32_t inIa, const float32_t inIb, \ + float32_t* pIalpha, float32_t* pIbeta) +{ + *pIalpha = inIa; + *pIbeta = (inIa + (2.0f * inIb)) * ONE_OVER_SQRT_THREE; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // _CLARKE_H_ + diff --git a/source/transforms/ipark/ipark.h b/source/transforms/ipark/ipark.h new file mode 100644 index 0000000..e6e9dd8 --- /dev/null +++ b/source/transforms/ipark/ipark.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2023 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _IPARK_H_ +#define _IPARK_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * \addtogroup TRANSFORMS_API_MODULE APIs for motor transformations + * @{ + * + * \file ipark.h + * \brief Contains d/q/0 to alpha/beta/0 transform implementation + */ + +#include + +typedef float float32_t; + +//! \brief Runs the inverse Park transform module +//! \param[in] sinTh Sine value in radian +//! \param[in] cosTh Cosine value in radian +//! \param[in] inVd Input voltage value in d-axis +//! \param[in] inVq Input voltage value in q-axis +//! \param[in] pValpha Output pointer to voltage value in alpha-axis +//! \param[in] pVbeta Output pointer to voltage value in beta-axis +//! +static __attribute__((always_inline)) +void IPARK_run(const float32_t sinTh, const float32_t cosTh, const float32_t inVd, const float32_t inVq, \ + float32_t* pValpha, float32_t* pVbeta) +{ + *pValpha = (inVd * cosTh) - (inVq * sinTh); + *pVbeta = (inVq * cosTh) + (inVd * sinTh); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // _IPARK_H_ diff --git a/source/transforms/park/park.h b/source/transforms/park/park.h new file mode 100644 index 0000000..5368fdd --- /dev/null +++ b/source/transforms/park/park.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2023 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _PARK_H_ +#define _PARK_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * \addtogroup TRANSFORMS_API_MODULE APIs for motor transformations + * @{ + * + * \file park.h + * \brief Contains alpha/beta/0 to d/q/0 transform implementation + */ + +#include + +typedef float float32_t; + +//! \brief Runs the Park transform module +//! \param[in] sinTh Sine value in radians +//! \param[in] cosTh Cosine value in radians +//! \param[in] inIalpha Input current value in alpha-axis +//! \param[in] inIbeta Input current value in beta-axis +//! \param[in] pId Output pointer to voltage value in d-axis +//! \param[in] pIq Output pointer to voltage value in q-axis +//! +static __attribute__((always_inline)) +void PARK_run(const float32_t sinTh, const float32_t cosTh, const float32_t inIalpha, const float32_t inIbeta, \ + float32_t* pId, float32_t* pIq) +{ + *pId = (inIalpha * cosTh) + (inIbeta * sinTh); + *pIq = (inIbeta * cosTh) - (inIalpha * sinTh); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // _PARK_H_ diff --git a/source/transforms/svgen/svgen.h b/source/transforms/svgen/svgen.h new file mode 100644 index 0000000..55c9bb1 --- /dev/null +++ b/source/transforms/svgen/svgen.h @@ -0,0 +1,255 @@ +/* + * Copyright (C) 2023 Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVGEN_H_ +#define _SVGEN_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * \addtogroup TRANSFORMS_API_MODULE APIs for motor transformations + * \@{ + * + * \file svgen.h + * \brief Contains svpwm generation implementation + */ + +#include + +typedef float float32_t; + +#define SQRT_THREE_OVER_TWO 0.8660254037844f +#define TWO_OVER_SQRT_THREE 1.15470053837926f + + +//! \brief Implements a SVM that subtracts common-mode term to achieve SV modulation. +//! \param[in] oneOverDcBUS_invV The inverse dc bus voltage scale factor, used to convert inputs to pu, use 1 if units are already in pu. +//! \param[in] inValpha Input voltage value in alpha-axis, V or pu +//! \param[in] inVbeta Input voltage value in beta-axis, V or pu +//! \param[in] pVa Output pointer to voltage value in a-axis, pu +//! \param[in] pVb Output pointer to voltage value in b-axis, pu +//! \param[in] pVc Output pointer to voltage value in c-axis, pu +//! +static __attribute__((always_inline)) +void SVGEN_runCom(const float32_t oneOverDcBus_invV, const float32_t inValpha, const float32_t inVbeta, \ + float32_t* pVa, float32_t* pVb, float32_t* pVc) +{ + float32_t vmax_pu, vmin_pu, vcom_pu = 0; + + float32_t va_pu = inValpha * oneOverDcBus_invV; + float32_t vbeta_pu = inVbeta * oneOverDcBus_invV; + + float32_t va_tmp = -0.5f * va_pu; + float32_t vb_tmp = SQRT_THREE_OVER_TWO * vbeta_pu; + + // + // -0.5*Valpha + sqrt(3)/2 * Vbeta + // + float32_t vb_pu = va_tmp + vb_tmp; + + // + // -0.5*Valpha - sqrt(3)/2 * Vbeta + // + float32_t vc_pu = va_tmp - vb_tmp; + + // + // Find Vmax and Vmin + // + if(va_pu > vb_pu) + { + vmax_pu = va_pu; + vmin_pu = vb_pu; + } + else + { + vmax_pu = vb_pu; + vmin_pu = va_pu; + } + if(vc_pu > vmax_pu) + { + vmax_pu = vc_pu; + } + else if(vc_pu < vmin_pu) + { + vmin_pu = vc_pu; + } + + // + // Compute Vcom = 0.5*(Vmax+Vmin) + // + vcom_pu = 0.5f * (vmax_pu + vmin_pu); + + // + // Subtract common-mode term to achieve SV modulation + // + *pVa = (va_pu - vcom_pu); + *pVb = (vb_pu - vcom_pu); + *pVc = (vc_pu - vcom_pu); + +} + +//! \brief Implements a DPWM that uses maximum modulation. +//! \param[in] oneOverDcBUS_invV The inverse dc bus voltage scale factor, used to convert inputs to pu, use 1 if units are already in pu. +//! \param[in] inValpha Input voltage value in alpha-axis, V or pu +//! \param[in] inVbeta Input voltage value in beta-axis, V or pu +//! \param[in] pVa Output pointer to voltage value in a-axis, pu +//! \param[in] pVb Output pointer to voltage value in b-axis, pu +//! \param[in] pVc Output pointer to voltage value in c-axis, pu +//! +static __attribute__((always_inline)) +void SVGEN_runMax(const float32_t oneOverDcBus_invV, const float32_t inValpha, const float32_t inVbeta, \ + float32_t* pVa, float32_t* pVb, float32_t* pVc) +{ + float32_t vmax_pu = 0; + + float32_t va_pu = inValpha * oneOverDcBus_invV; + float32_t vbeta_pu = inVbeta * oneOverDcBus_invV; + + float32_t va_tmp = -0.5f * va_pu; + float32_t vb_tmp = SQRT_THREE_OVER_TWO * vbeta_pu; + + // + // -0.5*Valpha + sqrt(3)/2 * Vbeta + // + float32_t vb_pu = va_tmp + vb_tmp; + + // + // -0.5*Valpha - sqrt(3)/2 * Vbeta + // + float32_t vc_pu = va_tmp - vb_tmp; + + // + // Find Vmax + // + if(va_pu > vb_pu) + { + vmax_pu = va_pu; + } + else + { + vmax_pu = vb_pu; + } + + if(vc_pu > vmax_pu) + { + vmax_pu = vc_pu; + } + + // + // DPWM maximum modulation + // + *pVa = (va_pu - vmax_pu) + 0.5f; + *pVb = (vb_pu - vmax_pu) + 0.5f; + *pVc = (vc_pu - vmax_pu) + 0.5f; +} + +//! \brief Implements a DPWM that uses minimum modulation. +//! \param[in] oneOverDcBUS_invV The inverse dc bus voltage scale factor, used to convert inputs to pu, use 1 if units are already in pu. +//! \param[in] inValpha Input voltage value in alpha-axis, V or pu +//! \param[in] inVbeta Input voltage value in beta-axis, V or pu +//! \param[in] pVa Output pointer to voltage value in a-axis, pu +//! \param[in] pVb Output pointer to voltage value in b-axis, pu +//! \param[in] pVc Output pointer to voltage value in c-axis, pu +//! +static __attribute__((always_inline)) +void SVGEN_runMin(const float32_t oneOverDcBus_invV, const float32_t inValpha, const float32_t inVbeta, \ + float32_t* pVa, float32_t* pVb, float32_t* pVc) +{ + float32_t vmin_pu = 0; + + float32_t va_pu = inValpha * oneOverDcBus_invV; + float32_t vbeta_pu = inVbeta * oneOverDcBus_invV; + + float32_t va_tmp = -0.5f * va_pu; + float32_t vb_tmp = SQRT_THREE_OVER_TWO * vbeta_pu; + + // + // -0.5*Valpha + sqrt(3)/2 * Vbeta + // + float32_t vb_pu = va_tmp + vb_tmp; + + // + // -0.5*Valpha - sqrt(3)/2 * Vbeta + // + float32_t vc_pu = va_tmp - vb_tmp; + + // + // Find Vmin + // + if(va_pu < vb_pu) + { + vmin_pu = va_pu; + } + else + { + vmin_pu = vb_pu; + } + + if(vc_pu < vmin_pu) + { + vmin_pu = vc_pu; + } + + // + // DPWM minimum modulation + // + *pVa = (va_pu - vmin_pu) - 0.5f; + *pVb = (vb_pu - vmin_pu) - 0.5f; + *pVc = (vc_pu - vmin_pu) - 0.5f; +} + +//! \brief Saturates the SVM variable base on modulation limits +//! \param[in] Umax Maximum modulation limit +//! \param[in] Umin Minimum modulation limit +//! \param[in] pVa pointer to voltage value in a-axis +//! \param[in] pVb pointer to voltage value in b-axis +//! \param[in] pVc pointer to voltage value in c-axis +//! +static __attribute__((always_inline)) +void SVGEN_clamp(const float32_t Umax, const float32_t Umin, \ + float32_t* pVa, float32_t* pVb, float32_t* pVc) +{ + *pVa = (*pVa > Umax) ? Umax : (*pVa < Umin) ? Umin : *pVa; + *pVb = (*pVb > Umax) ? Umax : (*pVb < Umin) ? Umin : *pVb; + *pVc = (*pVc > Umax) ? Umax : (*pVc < Umin) ? Umin : *pVc; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // _SVGEN_H_