7 from datetime import datetime
8 from buildutils.builder import Device, Compiler, Axis, Step, BuildStep, RunModelStep, Builder, Filter
13 Device.CM0 : { 'cmd': "FVP_MPS2_Cortex-M0_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM0_config.txt" } },
14 Device.CM0PLUS : { 'cmd': "FVP_MPS2_Cortex-M0plus_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM0plus_config.txt" } },
15 Device.CM3 : { 'cmd': "FVP_MPS2_Cortex-M3_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM3_config.txt" } },
16 Device.CM4 : { 'cmd': "FVP_MPS2_Cortex-M4_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM4_config.txt" } },
17 Device.CM4FP : { 'cmd': "FVP_MPS2_Cortex-M4_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM4FP_config.txt" } },
18 Device.CM7 : { 'cmd': "FVP_MPS2_Cortex-M7_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM7_config.txt" } },
19 Device.CM7SP : { 'cmd': "FVP_MPS2_Cortex-M7_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM7SP_config.txt" } },
20 Device.CM7DP : { 'cmd': "FVP_MPS2_Cortex-M7_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM7DP_config.txt" } },
21 Device.CM23 : { 'cmd': "FVP_MPS2_Cortex-M23_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM23_config.txt", 'target': "cpu0" } },
22 Device.CM33 : { 'cmd': "FVP_MPS2_Cortex-M33_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM33_config.txt", 'target': "cpu0" } },
23 Device.CM23NS : { 'cmd': "FVP_MPS2_Cortex-M23_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM23_TZ_config.txt", 'target': "cpu0" } },
24 Device.CM33NS : { 'cmd': "FVP_MPS2_Cortex-M33_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM33_DSP_FP_TZ_config.txt", 'target': "cpu0" } },
25 Device.CM23S : { 'cmd': "FVP_MPS2_Cortex-M23_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM23_TZ_config.txt", 'target': "cpu0" } },
26 Device.CM33S : { 'cmd': "FVP_MPS2_Cortex-M33_MDK.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCM33_DSP_FP_TZ_config.txt", 'target': "cpu0" } },
27 Device.CA5 : { 'cmd': "fvp_ve_cortex-a5x1.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCA5_config.txt" } },
28 Device.CA7 : { 'cmd': "fvp_ve_cortex-a7x1.exe", 'args': { 'limit': "170000000", 'config': "config/ARMCA7_config.txt" } },
29 Device.CA9 : { 'cmd': "fvp_ve_cortex-a9x1.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCA9_config.txt" } },
30 Device.CA5NEON : { 'cmd': "fvp_ve_cortex-a5x1.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCA5neon_config.txt" } },
31 Device.CA7NEON : { 'cmd': "fvp_ve_cortex-a7x1.exe", 'args': { 'limit': "170000000", 'config': "config/ARMCA7neon_config.txt" } },
32 Device.CA9NEON : { 'cmd': "fvp_ve_cortex-a9x1.exe", 'args': { 'limit': "100000000", 'config': "config/ARMCA9neon_config.txt" } }
35 def format(str, dev, cc, target = "FVP", **kwargs):
36 return str.format(dev = dev.value[0], cc = cc.value, target = target, **kwargs)
38 def testProject(dev, cc, target):
39 rtebuild = format("{dev}/{cc}/default.rtebuild", dev = dev, cc = cc, target=target)
40 if os.path.exists(rtebuild):
43 format("{dev}/{cc}/build/{target}/{target}.elf", dev = dev, cc = cc, target=target)
45 elif (cc == Compiler.AC5) or (cc == Compiler.AC6):
47 format("{dev}/{cc}/CMSIS_CV.uvprojx", dev = dev, cc = cc),
48 format("{dev}/{cc}/Objects/CMSIS_CV.axf", dev = dev, cc = cc)
50 elif (cc == Compiler.AC6LTM):
52 format("{dev}/{cc}/CMSIS_CV.uvprojx", dev = dev, cc = Compiler.AC6),
53 format("{dev}/{cc}/Objects/CMSIS_CV.axf", dev = dev, cc = Compiler.AC6)
55 elif (cc == Compiler.GCC):
57 format("{dev}/{cc}/CMSIS_CV.uvprojx", dev = dev, cc = cc),
58 format("{dev}/{cc}/Objects/CMSIS_CV.elf", dev = dev, cc = cc)
60 elif (cc == Compiler.IAR):
62 format("{dev}/{cc}/CMSIS_CV.ewp", dev = dev, cc = cc),
63 format("{dev}/{cc}/{target}/Exe/CMSIS_CV.out", dev = dev, cc = cc, target = target)
65 raise "Unknown compiler!"
67 def bootloaderProject(dev, cc, target):
68 rtebuild = format("{dev}/{cc}/Bootloader/default.rtebuild", dev = dev, cc = cc, target=target)
69 if os.path.exists(rtebuild):
72 format("{dev}/{cc}/Bootloader/build/{target}/{target}.elf", dev = dev, cc = cc, target=target)
74 elif (cc == Compiler.AC5) or (cc == Compiler.AC6):
76 format("{dev}/{cc}/Bootloader/Bootloader.uvprojx", dev = dev, cc = cc),
77 format("{dev}/{cc}/Bootloader/Objects/Bootloader.axf", dev = dev, cc = cc)
79 elif (cc == Compiler.AC6LTM):
81 format("{dev}/{cc}/Bootloader/Bootloader.uvprojx", dev = dev, cc = Compiler.AC6),
82 format("{dev}/{cc}/Bootloader/Objects/Bootloader.axf", dev = dev, cc = Compiler.AC6)
84 elif (cc == Compiler.GCC):
86 format("{dev}/{cc}/Bootloader/Bootloader.uvprojx", dev = dev, cc = cc),
87 format("{dev}/{cc}/Bootloader/Objects/Bootloader.elf", dev = dev, cc = cc)
89 elif (cc == Compiler.IAR):
91 format("{dev}/{cc}/Bootloader/Bootloader.ewp", dev = dev, cc = cc),
92 format("{dev}/{cc}/Bootloader/{target}/Exe/Bootloader.out", dev = dev, cc = cc, target = target)
94 raise "Unknown compiler!"
96 def projects(step, config):
97 dev = config['device']
98 cc = config['compiler']
99 target = config['target']
102 blPrj = bootloaderProject(dev, cc, target)
103 if os.path.exists(blPrj[0]):
104 projects += [ blPrj[0] ]
106 projects += [ testProject(dev, cc, target)[0] ]
110 def images(step, config):
111 dev = config['device']
112 cc = config['compiler']
113 target = config['target']
116 blPrj = bootloaderProject(dev, cc, target)
117 if os.path.exists(blPrj[1]):
118 images += [ blPrj[1] ]
120 images += [ testProject(dev, cc, target)[1] ]
124 def storeResult(step, config, cmd):
125 result = format("{dev}/{cc}/result_{target}_{now}.xml", config['device'], config['compiler'], config['target'], now = datetime.now().strftime("%Y%m%d%H%M%S"))
126 step.storeResult(cmd, result)
129 deviceAxis = Axis("device", abbrev="d", values=Device, desc="Device(s) to be considered.")
130 compilerAxis = Axis("compiler", abbrev="c", values=Compiler, desc="Compiler(s) to be considered.")
131 targetAxis = Axis("target", abbrev="t", values=[ TARGET_FVP ], desc="Target(s) to be considered.")
133 buildStep = BuildStep("build", abbrev="b", desc="Build the selected configurations.")
134 buildStep.projects = projects
135 buildStep.target = lambda step, config: config['target']
137 runStep = RunModelStep("run", abbrev="r", desc="Run the selected configurations.")
138 runStep.images = images
139 runStep.model = lambda step, config: FVP_MODELS[config['device']]
140 runStep.post = storeResult
142 filterAC5 = Filter().addAxis(compilerAxis, Compiler.AC5).addAxis(deviceAxis, "CM[23]3*")
143 filterAC6LTM = Filter().addAxis(compilerAxis, Compiler.AC6LTM).addAxis(deviceAxis, "CM[23]3*").addAxis(deviceAxis, "CM0*")
146 builder.addAxis([ compilerAxis, deviceAxis, targetAxis ])
147 builder.addStep([ buildStep, runStep ])
148 builder.addFilter([ filterAC5, filterAC6LTM ])