25
25
from shutil import rmtree
26
26
from distutils .version import LooseVersion
27
27
28
+ from tools .targets import CORE_ARCH
28
29
from tools .toolchains import mbedToolchain , TOOLCHAIN_PATHS
29
30
from tools .hooks import hook_tool
30
31
from tools .utils import mkdir , NotSupportedException , run_cmd
@@ -363,7 +364,7 @@ class ARMC6(ARM_STD):
363
364
SUPPORTED_CORES = ["Cortex-M0" , "Cortex-M0+" , "Cortex-M3" , "Cortex-M4" ,
364
365
"Cortex-M4F" , "Cortex-M7" , "Cortex-M7F" , "Cortex-M7FD" ,
365
366
"Cortex-M23" , "Cortex-M23-NS" , "Cortex-M33" , "Cortex-M33F" ,
366
- "Cortex-M33-NS" , "Cortex-M33F-NS" , "Cortex-M33FD -NS" , "Cortex-M33FD " ,
367
+ "Cortex-M33-NS" , "Cortex-M33F-NS" , "Cortex-M33FE -NS" , "Cortex-M33FE " ,
367
368
"Cortex-A9" ]
368
369
ARMCC_RANGE = (LooseVersion ("6.10" ), LooseVersion ("7.0" ))
369
370
@@ -380,76 +381,67 @@ def __init__(self, target, *args, **kwargs):
380
381
if not set (("ARM" , "ARMC6" )).intersection (set (target .supported_toolchains )):
381
382
raise NotSupportedException ("ARM/ARMC6 compiler support is required for ARMC6 build" )
382
383
383
- if target .core .lower ().endswith ("fd" ):
384
- self .flags ['common' ].append ("-mcpu=%s" % target .core .lower ()[:- 2 ])
385
- self .flags ['ld' ].append ("--cpu=%s" % target .core .lower ()[:- 2 ])
386
- self .SHEBANG += " -mcpu=%s" % target .core .lower ()[:- 2 ]
387
- elif target .core .lower ().endswith ("fd-ns" ):
388
- self .flags ['common' ].append ("-mcpu=%s" % target .core .lower ()[:- 5 ])
389
- self .flags ['ld' ].append ("--cpu=%s" % target .core .lower ()[:- 5 ])
390
- self .SHEBANG += " -mcpu=%s" % target .core .lower ()[:- 5 ]
391
- elif target .core .lower ().endswith ("f" ):
392
- self .flags ['common' ].append ("-mcpu=%s" % target .core .lower ()[:- 1 ])
393
- self .flags ['ld' ].append ("--cpu=%s" % target .core .lower ()[:- 1 ])
394
- self .SHEBANG += " -mcpu=%s" % target .core .lower ()[:- 1 ]
395
- elif target .core .startswith ("Cortex-M33" ):
396
- self .flags ['common' ].append ("-mcpu=cortex-m33+nodsp" )
397
- self .flags ['common' ].append ("-mfpu=none" )
398
- self .flags ['ld' ].append ("--cpu=Cortex-M33.no_dsp.no_fp" )
399
- elif not target .core .startswith ("Cortex-M23" ):
400
- self .flags ['common' ].append ("-mcpu=%s" % target .core .lower ())
401
- self .flags ['ld' ].append ("--cpu=%s" % target .core .lower ())
402
- self .SHEBANG += " -mcpu=%s" % target .core .lower ()
403
-
404
- if target .core == "Cortex-M4F" :
384
+ core = target .core
385
+ if CORE_ARCH [target .core ] == 8 :
386
+ if (not target .core .endswith ("-NS" )) and kwargs .get ('build_dir' , False ):
387
+ # Create Secure library
388
+ build_dir = kwargs ['build_dir' ]
389
+ secure_file = join (build_dir , "cmse_lib.o" )
390
+ self .flags ["ld" ] += ["--import_cmse_lib_out=%s" % secure_file ]
391
+
392
+ # Add linking time preprocessor macro DOMAIN_NS
393
+ if target .core .endswith ("-NS" ):
394
+ define_string = self .make_ld_define ("DOMAIN_NS" , "0x1" )
395
+ self .flags ["ld" ].append (define_string )
396
+ core = target .core [:- 3 ]
397
+ else :
398
+ # Add secure build flag
399
+ self .flags ['cxx' ].append ("-mcmse" )
400
+ self .flags ['c' ].append ("-mcmse" )
401
+
402
+ cpu = {
403
+ "Cortex-M0+" : "cortex-m0plus" ,
404
+ "Cortex-M4F" : "cortex-m4" ,
405
+ "Cortex-M7F" : "cortex-m7" ,
406
+ "Cortex-M7FD" : "cortex-m7" ,
407
+ "Cortex-M33" : "cortex-m33+no_dsp+no_fp" ,
408
+ "Cortex-M33F" : "cortex-m33+no_dsp" ,
409
+ "Cortex-M33FE" : "cortex-m33" }.get (core , core )
410
+
411
+ cpu = cpu .lower ()
412
+ self .flags ['common' ].append ("-mcpu=%s" % cpu )
413
+ self .SHEBANG += " -mcpu=%s" % cpu
414
+
415
+ # FPU handling
416
+ if core == "Cortex-M4F" :
405
417
self .flags ['common' ].append ("-mfpu=fpv4-sp-d16" )
406
418
self .flags ['common' ].append ("-mfloat-abi=hard" )
407
- elif target .core == "Cortex-M7F" :
419
+ self .flags ['ld' ].append ("--cpu=cortex-m4" )
420
+ elif core == "Cortex-M7F" :
408
421
self .flags ['common' ].append ("-mfpu=fpv5-sp-d16" )
409
422
self .flags ['common' ].append ("-mfloat-abi=hard" )
410
- elif target .core == "Cortex-M7FD" :
423
+ self .flags ['ld' ].append ("--cpu=cortex-m7.fp.sp" )
424
+ elif core == "Cortex-M7FD" :
411
425
self .flags ['common' ].append ("-mfpu=fpv5-d16" )
412
426
self .flags ['common' ].append ("-mfloat-abi=hard" )
413
- elif target .core .startswith ("Cortex-M23" ):
414
- self .flags ['common' ].append ("-march=armv8-m.base" )
415
- elif target .core .startswith ("Cortex-M33F" ):
427
+ self .flags ['ld' ].append ("--cpu=cortex-m7" )
428
+ elif core == "Cortex-M33F" :
416
429
self .flags ['common' ].append ("-mfpu=fpv5-sp-d16" )
417
430
self .flags ['common' ].append ("-mfloat-abi=hard" )
418
-
419
- if ((target .core .startswith ("Cortex-M23" ) or
420
- target .core .startswith ("Cortex-M33" )) and
421
- not target .core .endswith ("-NS" )):
422
- self .flags ['cxx' ].append ("-mcmse" )
423
- self .flags ['c' ].append ("-mcmse" )
424
-
425
- # Create Secure library
426
- if ((target .core .startswith ("Cortex-M23" ) or
427
- target .core .startswith ("Cortex-M33" )) and
428
- not target .core .endswith ("-NS" ) and
429
- kwargs .get ('build_dir' , False )):
430
- build_dir = kwargs ['build_dir' ]
431
- secure_file = join (build_dir , "cmse_lib.o" )
432
- self .flags ["ld" ] += ["--import_cmse_lib_out=%s" % secure_file ]
433
-
434
- # Add linking time preprocessor macro DOMAIN_NS
435
- if ((target .core .startswith ("Cortex-M23" ) or
436
- target .core .startswith ("Cortex-M33" )) and
437
- target .core .endswith ("-NS" )):
438
- define_string = self .make_ld_define ("DOMAIN_NS" , "0x1" )
439
- self .flags ["ld" ].append (define_string )
431
+ self .flags ['ld' ].append ("--cpu=cortex-m33.no_dsp" )
432
+ elif core == "Cortex-M33" :
433
+ self .flags ['ld' ].append ("--cpu=cortex-m33.no_dsp.no_fp" )
434
+ else :
435
+ self .flags ['ld' ].append ("--cpu=%s" % cpu )
440
436
441
437
asm_cpu = {
442
438
"Cortex-M0+" : "Cortex-M0" ,
443
439
"Cortex-M4F" : "Cortex-M4.fp" ,
444
440
"Cortex-M7F" : "Cortex-M7.fp.sp" ,
445
441
"Cortex-M7FD" : "Cortex-M7.fp.dp" ,
446
- "Cortex-M23-NS" : "Cortex-M23" ,
447
442
"Cortex-M33" : "Cortex-M33.no_dsp.no_fp" ,
448
- "Cortex-M33-NS" : "Cortex-M33.no_dsp.no_fp" ,
449
443
"Cortex-M33F" : "Cortex-M33.no_dsp" ,
450
- "Cortex-M33F-NS" : "Cortex-M33.no_dsp" ,
451
- "Cortex-M33FD" : "Cortex-M33" ,
452
- "Cortex-M33FD-NS" : "Cortex-M33" }.get (target .core , target .core )
444
+ "Cortex-M33FE" : "Cortex-M33" }.get (core , core )
453
445
454
446
self .flags ['asm' ].append ("--cpu=%s" % asm_cpu )
455
447
0 commit comments