From a5811b34b04ec8257e0f313019d1d643c3b361a6 Mon Sep 17 00:00:00 2001 From: Johannes Kliemann Date: Fri, 14 Apr 2023 20:35:38 +0200 Subject: [PATCH 1/4] Add FreeRTOS light runtime ref eng/toolchain/bb-runtimes#8 --- build_rts.py | 5 ++++ freertos/__init__.py | 47 ++++++++++++++++++++++++++++++++++ gen_rts_sources.py | 2 +- support/rts_sources/sources.py | 36 ++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 freertos/__init__.py diff --git a/build_rts.py b/build_rts.py index f14579b0..0f6ea32b 100755 --- a/build_rts.py +++ b/build_rts.py @@ -103,6 +103,8 @@ from qnx import Aarch64QNX, ARMQNX +from freertos import ArmV7AFP_FreeRTOS + import argparse import os import subprocess @@ -121,6 +123,9 @@ def build_configs(target): t = ArmPikeOS5() elif target == "ppc-pikeos5": t = PPCPikeOS5() + # FreeRTOS + elif target == "arm-freertos-v7a-fp": + t = ArmV7AFP_FreeRTOS() # AArch64 elf elif target == "morello": t = Morello(uart_io=True) diff --git a/freertos/__init__.py b/freertos/__init__.py new file mode 100644 index 00000000..0bcd98b2 --- /dev/null +++ b/freertos/__init__.py @@ -0,0 +1,47 @@ +from support.bsp_sources.target import Target +from support.bsp_sources.archsupport import ArchSupport + + +class ArmFreeRTOS(Target): + def __init__(self): + super().__init__() + self.add_gnat_sources("src/s-macres__zynq.adb") + self.add_linker_switch("-Wl,-r", loader=None) + self.add_linker_switch("-nostdlib", loader=None) + + @property + def target(self): + return "arm-eabi" + + @property + def system_ads(self): + return { + "light": "system-xi-arm.ads", + } + + +class ArmV7AFP_FreeRTOS(ArmFreeRTOS): + @property + def has_timer_64(self): + return True + + @property + def has_single_precision_fpu(self): + return True + + @property + def has_double_precision_fpu(self): + return True + + @property + def name(self): + return "v7a-fp" + + @property + def compiler_switches(self): + return ( + "-march=armv7-a+fp", + "-mfloat-abi=hard", + "-marm", + "-mno-unaligned-access", + ) diff --git a/gen_rts_sources.py b/gen_rts_sources.py index 7fe5add1..7780ffd9 100755 --- a/gen_rts_sources.py +++ b/gen_rts_sources.py @@ -48,7 +48,7 @@ def main(): ) parser.add_argument( "--source-profile", - choices=["bb", "deos", "pikeos", "vx7r2cert", "qnx"], + choices=["bb", "deos", "freertos", "pikeos", "vx7r2cert", "qnx"], default="bb", help="platform specific source selections", ) diff --git a/support/rts_sources/sources.py b/support/rts_sources/sources.py index 31701b20..9838b659 100644 --- a/support/rts_sources/sources.py +++ b/support/rts_sources/sources.py @@ -274,6 +274,16 @@ "hie/a-textio__deos.adb", "hie/s-macres.ads", ], + "freertos_srcs": [ + "hie/s-textio__freertos.ads", + "hie/s-textio__freertos.adb", + "hie/s-macres.ads", + "hie/a-textio__c.ads", + "hie/a-textio__c.adb", + "hie/g-io__zfp.ads", + "hie/g-io__zfp.adb", + "hie/g-io-put.adb", + ], "pikeos_srcs": [ "hie/a-textio.ads", "exit.c", @@ -341,6 +351,7 @@ "hie/s-memory__light.ads", ], "bb_srcs": ["hie/a-elchha__zfp.adb"], + "freertos_srcs": ["hie/a-elchha__zfp.adb"], "pikeos_srcs": ["hie/a-elchha__zfp.adb"], "qnx_srcs": [ "hie/a-elchha__traceback.adb", @@ -1292,6 +1303,23 @@ "hie/a-nallfl__light.ads", "libgnat/a-naliop__nolibm.ads", ], + "freertos_srcs": [ + "hie/a-ngelfu__ada.ads", + "hie/a-ngelfu__ada.adb", + "hie/a-nlelfu__ada.ads", + "hie/a-nuelfu__ada.ads", + "hie/s-gcmain__ada.ads", + "hie/s-gcmain__ada.adb", + "hie/s-libdou__ada.ads", + "hie/s-libdou__ada.adb", + "hie/s-libsin__ada.ads", + "hie/s-libsin__ada.adb", + "hie/s-lidosq__ada.ads", + "hie/s-lisisq__ada.ads", + "hie/s-libm__ada.ads", + "hie/s-libm__ada.adb", + "hie/s-libpre__ada.ads", + ], "pikeos_srcs": [ "hie/a-ngelfu__ada.ads", "hie/a-ngelfu__ada.adb", @@ -1339,6 +1367,7 @@ "math/long_long_64bit": { "conditions": ["Add_Math_Lib:!no", "CPU_Family:!x86,!x86_64"], "bb_srcs": ["libgnat/a-nllefu.ads"], + "freertos_srcs": ["libgnat/a-nllefu.ads"], "pikeos_srcs": ["libgnat/a-nllefu.ads"], }, "math/long_long_80bit": { @@ -1390,21 +1419,25 @@ "math/softsp": { "conditions": ["Add_Math_Lib:softfloat,hardfloat_dp"], "bb_srcs": ["hie/s-lisisq__ada.adb"], + "freertos_srcs": ["hie/s-lisisq__ada.adb"], "pikeos_srcs": ["hie/s-lisisq__ada.adb"], }, "math/softdp": { "conditions": ["Add_Math_Lib:softfloat,hardfloat_sp"], "bb_srcs": ["hie/s-lidosq__ada.adb"], + "freertos_srcs": ["hie/s-lidosq__ada.adb"], "pikeos_srcs": ["hie/s-lidosq__ada.adb"], }, "math/hardsp": { "conditions": ["Add_Math_Lib:hardfloat,hardfloat_sp"], "bb_srcs": ["hie/s-lisisq__fpu.adb"], + "freertos_srcs": ["hie/s-lisisq__fpu.adb"], "pikeos_srcs": ["hie/s-lisisq__fpu.adb"], }, "math/harddp": { "conditions": ["Add_Math_Lib:hardfloat,hardfloat_dp"], "bb_srcs": ["hie/s-lidosq__fpu.adb"], + "freertos_srcs": ["hie/s-lidosq__fpu.adb"], "pikeos_srcs": ["hie/s-lidosq__fpu.adb"], }, # Arithmetic @@ -2188,14 +2221,17 @@ "gnat/parameters/light-small": { "conditions": ["RTS_Profile:light", "Memory_Profile:small"], "bb_srcs": ["hie/s-parame__zfp_small.ads"], + "freertos_srcs": ["hie/s-parame__zfp_small.ads"], }, "gnat/parameters/light-large": { "conditions": ["RTS_Profile:light", "Memory_Profile:large"], "bb_srcs": ["hie/s-parame__zfp.ads"], + "freertos_srcs": ["hie/s-parame__zfp.ads"], }, "gnat/parameters/light-huge": { "conditions": ["RTS_Profile:light", "Memory_Profile:huge"], "bb_srcs": ["hie/s-parame__zfp_huge.ads"], + "freertos_srcs": ["hie/s-parame__zfp_huge.ads"], }, # Cert "cert": { From 44213da364f6fa5bb36293cf7dfb4d0d9cb3ca8f Mon Sep 17 00:00:00 2001 From: Johannes Kliemann Date: Tue, 28 May 2024 13:56:31 +0000 Subject: [PATCH 2/4] Use native implementation of System.Machine_Reset The BSP for FreeRTOS already provides abort and _exit so we use these instead of the target specific version of s-macres. ref eng/toolchain/bb-runtimes#54 --- freertos/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freertos/__init__.py b/freertos/__init__.py index 0bcd98b2..34fba96e 100644 --- a/freertos/__init__.py +++ b/freertos/__init__.py @@ -5,7 +5,7 @@ class ArmFreeRTOS(Target): def __init__(self): super().__init__() - self.add_gnat_sources("src/s-macres__zynq.adb") + self.add_gnat_sources("src/s-macres__native.adb") self.add_linker_switch("-Wl,-r", loader=None) self.add_linker_switch("-nostdlib", loader=None) From 454a311347a2d4bda1c03f963682965163ec5657 Mon Sep 17 00:00:00 2001 From: Simon Kahn Date: Thu, 30 May 2024 15:13:49 -0400 Subject: [PATCH 3/4] FreeRTOS: include System.Secondary_Stack.Single_Task in the light runtime System.Secondary_Stack.Single_Task was missing from the definition of the FreeRTOS light runtime. Issue: eng/toolchain/bb-runtimes#59 --- support/rts_sources/sources.py | 1 + 1 file changed, 1 insertion(+) diff --git a/support/rts_sources/sources.py b/support/rts_sources/sources.py index 9838b659..b8747e97 100644 --- a/support/rts_sources/sources.py +++ b/support/rts_sources/sources.py @@ -380,6 +380,7 @@ "conditions": ["RTS_Profile:light,cert"], "bb_srcs": ["hie/s-sssita.ads", "hie/s-sssita.adb"], "deos_srcs": ["hie/s-thread__cert.ads", "hie/s-thread__cert.adb"], + "freertos_srcs": ["hie/s-sssita.ads", "hie/s-sssita.adb"], "pikeos_srcs": [ "hie/a-textio__pikeos-light.adb", "hie/s-sssita.ads", From 7764fa44c991d32e67e155e3be8c1ac7e506a91b Mon Sep 17 00:00:00 2001 From: Simon Kahn Date: Mon, 3 Jun 2024 15:48:52 -0400 Subject: [PATCH 4/4] FreeRTOS: Update presence of libc Update runtime configuration to reflect that FreeRTOS provides libc. Issue: eng/toolchain/bb-runtimes#58 --- freertos/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/freertos/__init__.py b/freertos/__init__.py index 34fba96e..4f1c7762 100644 --- a/freertos/__init__.py +++ b/freertos/__init__.py @@ -13,6 +13,9 @@ def __init__(self): def target(self): return "arm-eabi" + def has_libc(self, profile): + return True + @property def system_ads(self): return {