|
31 | 31 | platform = env.PioPlatform()
|
32 | 32 | board = env.BoardConfig()
|
33 | 33 | core = board.get("build.core")
|
| 34 | +mcu = board.get("build.mcu", "") |
| 35 | +is_asr6601 = mcu.startswith("asr6601") |
| 36 | +arch = "asr6601" if is_asr6601 else "asr650x" |
34 | 37 |
|
35 |
| -FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoasrmicro650x") |
| 38 | +FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoasrmicro") |
| 39 | +CORE_DIR = os.path.join(FRAMEWORK_DIR, "cores", core) |
36 | 40 | assert os.path.isdir(FRAMEWORK_DIR)
|
37 | 41 |
|
38 | 42 | env.Append(
|
39 | 43 | CPPDEFINES=[
|
40 |
| - ("ARDUINO", 10813), |
41 |
| - "ARDUINO_ARCH_ASR650X", |
42 |
| - "__%s__" % board.get("build.mcu").upper(), |
43 |
| - "__asr650x__", |
| 44 | + ("ARDUINO", 10815), |
| 45 | + "ARDUINO_ARCH_%s" % arch.upper(), |
| 46 | + "__%s__" % mcu.upper(), |
| 47 | + "__%s__" % arch, |
44 | 48 | ("CONFIG_MANUFACTURER", '\\"ASR\\"'),
|
45 |
| - ("CONFIG_DEVICE_MODEL", '\\"6501\\"'), |
| 49 | + ("CONFIG_DEVICE_MODEL", '\\"%s\\"' % mcu), |
46 | 50 | ("CONFIG_VERSION", '\\"v4.0\\"'),
|
47 | 51 | ("CY_CORE_ID", 0),
|
48 | 52 | "CONFIG_LORA_USE_TCXO",
|
49 | 53 | ("F_CPU", "$BOARD_F_CPU"),
|
50 | 54 | "SOFT_SE",
|
51 | 55 | ],
|
52 |
| - |
53 | 56 | CCFLAGS=[
|
54 | 57 | "-w",
|
55 | 58 | "-Wall",
|
|
68 | 71 | "-fno-builtin-snprintf",
|
69 | 72 | "-Wno-strict-aliasing",
|
70 | 73 | ],
|
71 |
| - |
72 | 74 | CXXFLAGS=[
|
73 | 75 | "-fno-exceptions",
|
74 | 76 | "-fno-rtti",
|
75 | 77 | ],
|
76 |
| - |
77 | 78 | LINKFLAGS=[
|
78 | 79 | "-Os",
|
79 | 80 | "-Wl,--gc-sections",
|
|
85 | 86 | "-mthumb",
|
86 | 87 | "-mthumb-interwork",
|
87 | 88 | "-specs=nano.specs",
|
88 |
| - "-ffat-lto-objects" |
89 |
| - ], |
90 |
| - |
91 |
| - CPPPATH=[ |
92 |
| - os.path.join(FRAMEWORK_DIR, "cores", core), |
93 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "board"), |
94 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "board", "src"), |
95 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "board", "inc"), |
96 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "device", "sx126x"), |
97 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "lora"), |
98 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "lora", "radio"), |
99 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "lora", "system"), |
100 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "lora", "system", "crypto"), |
101 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "port"), |
102 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "port", "include"), |
103 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "projects"), |
104 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "projects", "PSoC4"), |
105 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "cores"), |
106 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "Serial"), |
107 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "Wire"), |
108 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "SPI"), |
109 |
| - ], |
110 |
| - |
111 |
| - LIBS=[ |
112 |
| - "stdc++", |
113 |
| - "m" |
| 89 | + "-specs=nosys.specs", |
| 90 | + "-ffat-lto-objects", |
114 | 91 | ],
|
115 |
| - |
116 |
| - LIBSOURCE_DIRS=[ |
117 |
| - os.path.join(FRAMEWORK_DIR, "libraries") |
118 |
| - ] |
| 92 | + LIBS=["stdc++", "m"], |
| 93 | + LIBSOURCE_DIRS=[os.path.join(FRAMEWORK_DIR, "libraries")], |
119 | 94 | )
|
120 | 95 |
|
121 | 96 | env.Prepend(
|
122 | 97 | ASFLAGS=env.get("CCFLAGS", [])[:],
|
123 |
| - _LIBFLAGS='"%s" ' % os.path.join( |
124 |
| - FRAMEWORK_DIR, "cores", core, "projects", "CubeCellLib.a") |
| 98 | + _LIBFLAGS='"%s" ' |
| 99 | + % ( |
| 100 | + os.path.join(CORE_DIR, "asr6601.a") |
| 101 | + if is_asr6601 |
| 102 | + else os.path.join(CORE_DIR, "projects", "CubeCellLib.a") |
| 103 | + ), |
125 | 104 | )
|
126 | 105 |
|
| 106 | +if is_asr6601: |
| 107 | + env.Append( |
| 108 | + CPPPATH=[ |
| 109 | + CORE_DIR, |
| 110 | + os.path.join(CORE_DIR, "drivers", "peripheral", "inc"), |
| 111 | + os.path.join(CORE_DIR, "drivers", "crypto", "inc"), |
| 112 | + os.path.join(CORE_DIR, "platform", "CMSIS"), |
| 113 | + os.path.join(CORE_DIR, "platform", "system"), |
| 114 | + os.path.join(CORE_DIR, "lora", "driver"), |
| 115 | + os.path.join(CORE_DIR, "lora", "radio"), |
| 116 | + os.path.join(CORE_DIR, "lora"), |
| 117 | + os.path.join(CORE_DIR, "lora", "radio", "sx126x"), |
| 118 | + os.path.join(CORE_DIR, "lora", "system"), |
| 119 | + os.path.join(CORE_DIR, "lora", "system", "crypto"), |
| 120 | + os.path.join(CORE_DIR, "base"), |
| 121 | + os.path.join(CORE_DIR, "peripheral"), |
| 122 | + ], |
| 123 | + ) |
| 124 | +else: |
| 125 | + env.Append( |
| 126 | + CPPPATH=[ |
| 127 | + CORE_DIR, |
| 128 | + os.path.join(CORE_DIR, "board"), |
| 129 | + os.path.join(CORE_DIR, "board", "src"), |
| 130 | + os.path.join(CORE_DIR, "board", "inc"), |
| 131 | + os.path.join(CORE_DIR, "device", "sx126x"), |
| 132 | + os.path.join(CORE_DIR, "lora"), |
| 133 | + os.path.join(CORE_DIR, "lora", "system"), |
| 134 | + os.path.join(CORE_DIR, "lora", "system", "crypto"), |
| 135 | + os.path.join(CORE_DIR, "port"), |
| 136 | + os.path.join(CORE_DIR, "port", "include"), |
| 137 | + os.path.join(CORE_DIR, "projects"), |
| 138 | + os.path.join(CORE_DIR, "projects", "PSoC4"), |
| 139 | + os.path.join(CORE_DIR, "cores"), |
| 140 | + os.path.join(CORE_DIR, "Serial"), |
| 141 | + os.path.join(CORE_DIR, "Wire"), |
| 142 | + os.path.join(CORE_DIR, "SPI"), |
| 143 | + ], |
| 144 | + ) |
| 145 | + |
| 146 | + |
127 | 147 | if not board.get("build.ldscript", ""):
|
128 | 148 | env.Append(
|
129 | 149 | LIBPATH=[
|
130 |
| - os.path.join(FRAMEWORK_DIR, "cores", core, "projects", "PSoC4"), |
| 150 | + CORE_DIR if is_asr6601 else os.path.join(CORE_DIR, "projects", "PSoC4"), |
131 | 151 | ]
|
132 | 152 | )
|
133 | 153 | env.Replace(
|
134 |
| - LDSCRIPT_PATH=board.get("build.arduino.ldscript", "cm0plusgcc.ld") |
| 154 | + LDSCRIPT_PATH=board.get( |
| 155 | + "build.arduino.ldscript", "gcc.ld" if is_asr6601 else "cm0plusgcc.ld" |
| 156 | + ) |
135 | 157 | )
|
136 | 158 |
|
137 | 159 | #
|
|
147 | 169 | "REGION_%s" % region,
|
148 | 170 | ("ACTIVE_REGION", "LORAMAC_REGION_%s" % region),
|
149 | 171 | ("LORAWAN_CLASS", lorawan_config.get("class", "CLASS_A")),
|
150 |
| - ("LORAWAN_NETMODE", "true" if lorawan_config.get( |
151 |
| - "netmode", "OTAA") == "OTAA" else "false"), |
| 172 | + ( |
| 173 | + "LORAWAN_NETMODE", |
| 174 | + "true" if lorawan_config.get("netmode", "OTAA") == "OTAA" else "false", |
| 175 | + ), |
152 | 176 | ("LORAWAN_ADR", "true" if lorawan_config.get("adr", "ON") == "ON" else "false"),
|
153 |
| - ("LORAWAN_UPLINKMODE", "true" if lorawan_config.get( |
154 |
| - "uplinkmode", "CONFIRMED") == "CONFIRMED" else "false"), |
155 |
| - ("LORAWAN_NET_RESERVE", "true" if lorawan_config.get( |
156 |
| - "net_reserve", "OFF") == "ON" else "false"), |
| 177 | + ( |
| 178 | + "LORAWAN_UPLINKMODE", |
| 179 | + "true" |
| 180 | + if lorawan_config.get("uplinkmode", "CONFIRMED") == "CONFIRMED" |
| 181 | + else "false", |
| 182 | + ), |
| 183 | + ( |
| 184 | + "LORAWAN_NET_RESERVE", |
| 185 | + "true" if lorawan_config.get("net_reserve", "OFF") == "ON" else "false", |
| 186 | + ), |
157 | 187 | ("AT_SUPPORT", 1 if lorawan_config.get("at_support", "ON") == "ON" else 0),
|
158 |
| - ("LORAWAN_DEVEUI_AUTO", 0 if lorawan_config.get("deveui", "CUSTOM") == "CUSTOM" else 1), |
159 |
| - ("LoraWan_RGB", 1 if lorawan_config.get( |
160 |
| - "rgb", "ACTIVE") == "ACTIVE" else 0), |
161 |
| - ("LoRaWAN_DEBUG_LEVEL", 2 if debug_level == "FREQ_AND_DIO" else ( |
162 |
| - 1 if debug_level == "FREQ" else 0)) |
| 188 | + ( |
| 189 | + "LORAWAN_DEVEUI_AUTO", |
| 190 | + 0 if lorawan_config.get("deveui", "CUSTOM") == "CUSTOM" else 1, |
| 191 | + ), |
| 192 | + ("LoraWan_RGB", 1 if lorawan_config.get("rgb", "ACTIVE") == "ACTIVE" else 0), |
| 193 | + ("LORAWAN_PREAMBLE_LENGTH", lorawan_config.get("preamble_length", 8)), |
| 194 | + ( |
| 195 | + "LoRaWAN_DEBUG_LEVEL", |
| 196 | + 2 if debug_level == "FREQ_AND_DIO" else (1 if debug_level == "FREQ" else 0), |
| 197 | + ), |
163 | 198 | ]
|
164 | 199 | )
|
165 | 200 |
|
|
169 | 204 |
|
170 | 205 | libs = []
|
171 | 206 |
|
172 |
| -if "build.variant" in env.BoardConfig(): |
173 |
| - variants_dir = os.path.join( |
174 |
| - "$PROJECT_DIR", board.get("build.variants_dir")) if board.get( |
175 |
| - "build.variants_dir", "") else os.path.join(FRAMEWORK_DIR, "variants") |
176 |
| - env.Append( |
177 |
| - CPPPATH=[ |
178 |
| - os.path.join(variants_dir, board.get("build.variant")) |
179 |
| - ] |
| 207 | +if "build.variant" in board: |
| 208 | + variants_dir = ( |
| 209 | + os.path.join("$PROJECT_DIR", board.get("build.variants_dir")) |
| 210 | + if board.get("build.variants_dir", "") |
| 211 | + else os.path.join(FRAMEWORK_DIR, "variants") |
180 | 212 | )
|
181 |
| - libs.append(env.BuildLibrary( |
182 |
| - os.path.join("$BUILD_DIR", "FrameworkArduinoVariant"), |
183 |
| - os.path.join(variants_dir, board.get("build.variant")) |
184 |
| - )) |
185 |
| - |
186 |
| -libs.append(env.BuildLibrary( |
187 |
| - os.path.join("$BUILD_DIR", "FrameworkArduino"), |
188 |
| - os.path.join(FRAMEWORK_DIR, "cores", core), |
189 |
| - src_filter=[ |
190 |
| - "+<*>", |
191 |
| - "-<projects/PSoC4/CyBootAsmIar.s>", |
192 |
| - "-<projects/PSoC4/CyBootAsmRv.s>" |
193 |
| - ] |
194 |
| -)) |
| 213 | + env.Append(CPPPATH=[os.path.join(variants_dir, board.get("build.variant"))]) |
| 214 | + libs.append( |
| 215 | + env.BuildLibrary( |
| 216 | + os.path.join("$BUILD_DIR", "FrameworkArduinoVariant"), |
| 217 | + os.path.join(variants_dir, board.get("build.variant")), |
| 218 | + ) |
| 219 | + ) |
| 220 | + |
| 221 | +libs.append( |
| 222 | + env.BuildLibrary( |
| 223 | + os.path.join("$BUILD_DIR", "FrameworkArduino"), |
| 224 | + CORE_DIR, |
| 225 | + # Only applicable to ASR6501 |
| 226 | + src_filter=[ |
| 227 | + "+<*>", |
| 228 | + "-<projects/PSoC4/CyBootAsmIar.s>", |
| 229 | + "-<projects/PSoC4/CyBootAsmRv.s>", |
| 230 | + ], |
| 231 | + ) |
| 232 | +) |
195 | 233 |
|
196 | 234 | env.Prepend(LIBS=libs)
|
0 commit comments