@@ -650,21 +650,21 @@ def _get_mem_specs(self, memories, cmsis_part, exception_text):
650
650
raise ConfigException (exception_text )
651
651
652
652
def get_all_active_memories (self , memory_list ):
653
- """Get information of all available rom/ram memories in the form of dictionary
654
- {Memory: [start_addr, size]}. Takes in the argument, a list of all available
653
+ """Get information of all available rom/ram memories in the form of dictionary
654
+ {Memory: [start_addr, size]}. Takes in the argument, a list of all available
655
655
regions within the ram/rom memory"""
656
656
# Override rom_start/rom_size
657
657
#
658
658
# This is usually done for a target which:
659
659
# 1. Doesn't support CMSIS pack, or
660
660
# 2. Supports TrustZone and user needs to change its flash partition
661
-
661
+
662
662
available_memories = {}
663
663
# Counter to keep track of ROM/RAM memories supported by target
664
664
active_memory_counter = 0
665
665
# Find which memory we are dealing with, RAM/ROM
666
666
active_memory = 'ROM' if any ('ROM' in mem_list for mem_list in memory_list ) else 'RAM'
667
-
667
+
668
668
try :
669
669
cmsis_part = self ._get_cmsis_part ()
670
670
except ConfigException :
@@ -683,7 +683,7 @@ def get_all_active_memories(self, memory_list):
683
683
684
684
present_memories = set (cmsis_part ['memory' ].keys ())
685
685
valid_memories = set (memory_list ).intersection (present_memories )
686
-
686
+
687
687
for memory in valid_memories :
688
688
mem_start , mem_size = self ._get_mem_specs (
689
689
[memory ],
@@ -709,7 +709,7 @@ def get_all_active_memories(self, memory_list):
709
709
mem_start = int (mem_start , 0 )
710
710
mem_size = int (mem_size , 0 )
711
711
available_memories [memory ] = [mem_start , mem_size ]
712
-
712
+
713
713
return available_memories
714
714
715
715
@property
@@ -1078,17 +1078,37 @@ def _check_required_parameters(params):
1078
1078
"' doesn't have a value" )
1079
1079
1080
1080
@staticmethod
1081
- def parameters_to_macros (params ):
1082
- """ Encode the configuration parameters as C macro definitions.
1081
+ def _parameters_and_config_macros_to_macros (params , macros ):
1082
+ """ Return the macro definitions generated for a dictionary of
1083
+ ConfigParameters and a dictionary of ConfigMacros (as returned by
1084
+ get_config_data). The ConfigMacros override any matching macros set by
1085
+ the ConfigParameters.
1083
1086
1084
1087
Positional arguments:
1085
1088
params - a dictionary mapping a name to a ConfigParameter
1089
+ macros - a dictionary mapping a name to a ConfigMacro
1086
1090
1087
- Return: a list of strings that encode the configuration parameters as
1088
- C pre-processor macros
1091
+ Return: a list of strings that are the C pre-processor macros
1089
1092
"""
1090
- return ['%s=%s' % (m .macro_name , m .value ) for m in params .values ()
1091
- if m .value is not None ]
1093
+ all_macros = {
1094
+ p .macro_name : p .value for p in params .values () if p .value is not None
1095
+ }
1096
+
1097
+ config_macros = {
1098
+ m .macro_name : m .macro_value for m in macros .values ()
1099
+ }
1100
+
1101
+ all_macros .update (config_macros )
1102
+ macro_list = []
1103
+ for name , value in all_macros .items ():
1104
+ # If the macro does not have a value, just append the name.
1105
+ # Otherwise, append the macro as NAME=VALUE
1106
+ if value is None :
1107
+ macro_list .append (name )
1108
+ else :
1109
+ macro_list .append ("%s=%s" % (name , value ))
1110
+
1111
+ return macro_list
1092
1112
1093
1113
@staticmethod
1094
1114
def config_macros_to_macros (macros ):
@@ -1112,8 +1132,7 @@ def config_to_macros(config):
1112
1132
"""
1113
1133
params , macros = config [0 ], config [1 ]
1114
1134
Config ._check_required_parameters (params )
1115
- return Config .config_macros_to_macros (macros ) + \
1116
- Config .parameters_to_macros (params )
1135
+ return Config ._parameters_and_config_macros_to_macros (params , macros )
1117
1136
1118
1137
def get_config_data_macros (self ):
1119
1138
""" Convert a Config object to a list of C macros
0 commit comments