From 9c9fea4cd4873f0e525edcb88086a18a13c5aff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20BRIDAY?= Date: Thu, 15 Feb 2024 17:23:24 +0100 Subject: [PATCH] build option for CortexM4 or M7 --- goil/templates/build/build_py.goilTemplate | 4 ++-- goil/templates/build/make_py.goilTemplate | 12 ++++++------ .../config/cortex-m/armv7em/buildOptions.oil | 16 +++++----------- .../armv7em/mk20dx256/buildOptionsTarget.oil | 17 +++++++++++++++++ .../armv7em/stm32f303/buildOptionsTarget.oil | 17 +++++++++++++++++ .../armv7em/stm32f407/buildOptionsTarget.oil | 17 +++++++++++++++++ .../armv7em/stm32h743/buildOptionsTarget.oil | 17 +++++++++++++++++ .../armv7em/stm32l432/buildOptionsTarget.oil | 17 +++++++++++++++++ 8 files changed, 98 insertions(+), 19 deletions(-) create mode 100755 goil/templates/config/cortex-m/armv7em/mk20dx256/buildOptionsTarget.oil create mode 100755 goil/templates/config/cortex-m/armv7em/stm32f303/buildOptionsTarget.oil create mode 100755 goil/templates/config/cortex-m/armv7em/stm32f407/buildOptionsTarget.oil create mode 100755 goil/templates/config/cortex-m/armv7em/stm32h743/buildOptionsTarget.oil create mode 100644 goil/templates/config/cortex-m/armv7em/stm32l432/buildOptionsTarget.oil diff --git a/goil/templates/build/build_py.goilTemplate b/goil/templates/build/build_py.goilTemplate index 8380b279a..107bdb390 100755 --- a/goil/templates/build/build_py.goilTemplate +++ b/goil/templates/build/build_py.goilTemplate @@ -42,7 +42,7 @@ if exists POSTBUILD then let postgoals := mapof exists POSTBUILD default ( @() ) by NAME end if -%#! /usr/bin/env python +%#! /usr/bin/env python3 # -*- coding: UTF-8 -*- #---------------------------------------------------------------------- #--- Python Build file for application % !CPUNAME % @@ -61,7 +61,7 @@ end if #--- build.py is generated each time goil is called by make.py #---------------------------------------------------------------------- -import sys, os, subprocess, string, distutils.spawn +import sys, os, subprocess, string from string import Template #--- Add some function for Python3 support diff --git a/goil/templates/build/make_py.goilTemplate b/goil/templates/build/make_py.goilTemplate index 5f15d4713..5529f9000 100755 --- a/goil/templates/build/make_py.goilTemplate +++ b/goil/templates/build/make_py.goilTemplate @@ -41,7 +41,7 @@ foreach pb in exists POSTBUILD default( @() ) do end foreach end foreach -%#! /usr/bin/env python +%#! /usr/bin/env python3 # -*- coding: UTF-8 -*- #---------------------------------------------------------------------- #--- Python Make file for application % !CPUNAME % @@ -179,11 +179,11 @@ os.chdir (scriptDir) #--- Launch build.py # is there the 'python' executable? -import distutils.spawn -if distutils.spawn.find_executable("python"): - childProcess = subprocess.Popen (["python", "build.py", askedGoal, str(maxParallelJobs)]) -else: #no python executable, maybe python3 - childProcess = subprocess.Popen (["python3", "build.py", askedGoal, str(maxParallelJobs)]) +import shutil +cmd = shutil.which('python') +if not cmd: + cmd = shutil.which('python3') +childProcess = subprocess.Popen ([cmd, "build.py", askedGoal, str(maxParallelJobs)]) #--- Wait for subprocess termination if childProcess.poll () == None : diff --git a/goil/templates/config/cortex-m/armv7em/buildOptions.oil b/goil/templates/config/cortex-m/armv7em/buildOptions.oil index 6641b38b3..bead04461 100755 --- a/goil/templates/config/cortex-m/armv7em/buildOptions.oil +++ b/goil/templates/config/cortex-m/armv7em/buildOptions.oil @@ -13,10 +13,6 @@ CPU buildOptions { //COMMONFLAGS = "-Wall"; COMMONFLAGS = "-Wno-unused-but-set-variable"; // Except unused variables COMMONFLAGS = "-Wmissing-field-initializers"; // Struct initialized with incorrect number of fiels - COMMONFLAGS = "-mcpu=cortex-m4"; // Compile for cortex-m4 - COMMONFLAGS = "-mthumb"; // Thumb instruction set - COMMONFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software - COMMONFLAGS = "-mfpu=fpv4-sp-d16"; // Truly obscure option to set. Check http://stackoverflow.com/questions/19464556/how-to-link-gcc-options-to-the-arm-mcu-fpu-datasheet COMMONFLAGS = "-nostartfiles"; // Default startfiles (crt0.c) are not used COMMONFLAGS = "-fno-builtin"; // Do not used built in gcc functions CFLAGS = "--specs=nosys.specs"; // @@ -41,14 +37,8 @@ CPU buildOptions { */ ASFLAGS = "-g"; // Produce debugging information ASFLAGS = "-Wall"; // All warnings on - ASFLAGS = "-mcpu=cortex-m4"; // Assemble for cortex-m4 - ASFLAGS = "-mthumb"; // Thumb instruction set ASFLAGS = "--fatal-warnings"; // A warning is an error - ASFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software - ASFLAGS = "-mfpu=fpv4-sp-d16"; // Truly obscure option to set. - // Check http://stackoverflow.com/questions/19464556/how-to-link-gcc-options-to-the-arm-mcu-fpu-datasheet - - + // LDFLAGS = "--no-warn-rwx-segment"; // fix gnu-ld 2.39 snafu LDFLAGS = "--fatal-warnings"; // A warning is an error LDFLAGS = "--warn-common"; // Warn when a common symbol is combined with another common symbol @@ -56,3 +46,7 @@ CPU buildOptions { LDFLAGS = "--gc-sections"; // Remove unused sections. Works with -ffunction-sections and -fdata-sections, see above }; }; + +//one should include target specific flags for CortexM4 or CortexM7 +#includeifexists + diff --git a/goil/templates/config/cortex-m/armv7em/mk20dx256/buildOptionsTarget.oil b/goil/templates/config/cortex-m/armv7em/mk20dx256/buildOptionsTarget.oil new file mode 100755 index 000000000..558e5a892 --- /dev/null +++ b/goil/templates/config/cortex-m/armv7em/mk20dx256/buildOptionsTarget.oil @@ -0,0 +1,17 @@ +rm /* + * ARMv7 build options for gcc - CortexM4 + * TODO: we use only soft FPU for now! + */ +CPU buildOptions { + BUILDOPTIONS buildForCortexM4 { + COMMONFLAGS = "-mcpu=cortex-m4"; // Compile for cortex-m4 + COMMONFLAGS = "-mthumb"; // Thumb instruction set + COMMONFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software + COMMONFLAGS = "-mfpu=fpv4-sp-d16"; // FPU version for CortexM4 + + ASFLAGS = "-mcpu=cortex-m4"; // Assemble for cortex-m4 + ASFLAGS = "-mthumb"; // Thumb instruction set + ASFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software + ASFLAGS = "-mfpu=fpv4-sp-d16"; // FPU version for CortexM4 + }; +}; diff --git a/goil/templates/config/cortex-m/armv7em/stm32f303/buildOptionsTarget.oil b/goil/templates/config/cortex-m/armv7em/stm32f303/buildOptionsTarget.oil new file mode 100755 index 000000000..558e5a892 --- /dev/null +++ b/goil/templates/config/cortex-m/armv7em/stm32f303/buildOptionsTarget.oil @@ -0,0 +1,17 @@ +rm /* + * ARMv7 build options for gcc - CortexM4 + * TODO: we use only soft FPU for now! + */ +CPU buildOptions { + BUILDOPTIONS buildForCortexM4 { + COMMONFLAGS = "-mcpu=cortex-m4"; // Compile for cortex-m4 + COMMONFLAGS = "-mthumb"; // Thumb instruction set + COMMONFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software + COMMONFLAGS = "-mfpu=fpv4-sp-d16"; // FPU version for CortexM4 + + ASFLAGS = "-mcpu=cortex-m4"; // Assemble for cortex-m4 + ASFLAGS = "-mthumb"; // Thumb instruction set + ASFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software + ASFLAGS = "-mfpu=fpv4-sp-d16"; // FPU version for CortexM4 + }; +}; diff --git a/goil/templates/config/cortex-m/armv7em/stm32f407/buildOptionsTarget.oil b/goil/templates/config/cortex-m/armv7em/stm32f407/buildOptionsTarget.oil new file mode 100755 index 000000000..558e5a892 --- /dev/null +++ b/goil/templates/config/cortex-m/armv7em/stm32f407/buildOptionsTarget.oil @@ -0,0 +1,17 @@ +rm /* + * ARMv7 build options for gcc - CortexM4 + * TODO: we use only soft FPU for now! + */ +CPU buildOptions { + BUILDOPTIONS buildForCortexM4 { + COMMONFLAGS = "-mcpu=cortex-m4"; // Compile for cortex-m4 + COMMONFLAGS = "-mthumb"; // Thumb instruction set + COMMONFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software + COMMONFLAGS = "-mfpu=fpv4-sp-d16"; // FPU version for CortexM4 + + ASFLAGS = "-mcpu=cortex-m4"; // Assemble for cortex-m4 + ASFLAGS = "-mthumb"; // Thumb instruction set + ASFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software + ASFLAGS = "-mfpu=fpv4-sp-d16"; // FPU version for CortexM4 + }; +}; diff --git a/goil/templates/config/cortex-m/armv7em/stm32h743/buildOptionsTarget.oil b/goil/templates/config/cortex-m/armv7em/stm32h743/buildOptionsTarget.oil new file mode 100755 index 000000000..8f6a7d827 --- /dev/null +++ b/goil/templates/config/cortex-m/armv7em/stm32h743/buildOptionsTarget.oil @@ -0,0 +1,17 @@ +rm /* + * ARMv7 build options for gcc - CortexM7 + * TODO: we use only soft FPU for now! + */ +CPU buildOptions { + BUILDOPTIONS buildForCortexM4 { + COMMONFLAGS = "-mcpu=cortex-m7"; // Compile for cortex-m7 + COMMONFLAGS = "-mthumb"; // Thumb instruction set + COMMONFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software + COMMONFLAGS = "-mfpu=fpv5-d16"; // FPU version for CortexM7 + + ASFLAGS = "-mcpu=cortex-m7"; // Assemble for cortex-m7 + ASFLAGS = "-mthumb"; // Thumb instruction set + ASFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software + ASFLAGS = "-mfpu=fpv5-d16"; // FPU version for CortexM7 + }; +}; diff --git a/goil/templates/config/cortex-m/armv7em/stm32l432/buildOptionsTarget.oil b/goil/templates/config/cortex-m/armv7em/stm32l432/buildOptionsTarget.oil new file mode 100644 index 000000000..558e5a892 --- /dev/null +++ b/goil/templates/config/cortex-m/armv7em/stm32l432/buildOptionsTarget.oil @@ -0,0 +1,17 @@ +rm /* + * ARMv7 build options for gcc - CortexM4 + * TODO: we use only soft FPU for now! + */ +CPU buildOptions { + BUILDOPTIONS buildForCortexM4 { + COMMONFLAGS = "-mcpu=cortex-m4"; // Compile for cortex-m4 + COMMONFLAGS = "-mthumb"; // Thumb instruction set + COMMONFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software + COMMONFLAGS = "-mfpu=fpv4-sp-d16"; // FPU version for CortexM4 + + ASFLAGS = "-mcpu=cortex-m4"; // Assemble for cortex-m4 + ASFLAGS = "-mthumb"; // Thumb instruction set + ASFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software + ASFLAGS = "-mfpu=fpv4-sp-d16"; // FPU version for CortexM4 + }; +};