fbuild 1.2.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. fbuild/__init__.py +390 -0
  2. fbuild/assets/example.txt +1 -0
  3. fbuild/build/__init__.py +117 -0
  4. fbuild/build/archive_creator.py +186 -0
  5. fbuild/build/binary_generator.py +444 -0
  6. fbuild/build/build_component_factory.py +131 -0
  7. fbuild/build/build_info_generator.py +624 -0
  8. fbuild/build/build_state.py +325 -0
  9. fbuild/build/build_utils.py +93 -0
  10. fbuild/build/compilation_executor.py +422 -0
  11. fbuild/build/compiler.py +165 -0
  12. fbuild/build/compiler_avr.py +574 -0
  13. fbuild/build/configurable_compiler.py +664 -0
  14. fbuild/build/configurable_linker.py +637 -0
  15. fbuild/build/flag_builder.py +214 -0
  16. fbuild/build/library_dependency_processor.py +185 -0
  17. fbuild/build/linker.py +708 -0
  18. fbuild/build/orchestrator.py +67 -0
  19. fbuild/build/orchestrator_avr.py +651 -0
  20. fbuild/build/orchestrator_esp32.py +878 -0
  21. fbuild/build/orchestrator_rp2040.py +719 -0
  22. fbuild/build/orchestrator_stm32.py +696 -0
  23. fbuild/build/orchestrator_teensy.py +580 -0
  24. fbuild/build/source_compilation_orchestrator.py +218 -0
  25. fbuild/build/source_scanner.py +516 -0
  26. fbuild/cli.py +717 -0
  27. fbuild/cli_utils.py +314 -0
  28. fbuild/config/__init__.py +16 -0
  29. fbuild/config/board_config.py +542 -0
  30. fbuild/config/board_loader.py +92 -0
  31. fbuild/config/ini_parser.py +369 -0
  32. fbuild/config/mcu_specs.py +88 -0
  33. fbuild/daemon/__init__.py +42 -0
  34. fbuild/daemon/async_client.py +531 -0
  35. fbuild/daemon/client.py +1505 -0
  36. fbuild/daemon/compilation_queue.py +293 -0
  37. fbuild/daemon/configuration_lock.py +865 -0
  38. fbuild/daemon/daemon.py +585 -0
  39. fbuild/daemon/daemon_context.py +293 -0
  40. fbuild/daemon/error_collector.py +263 -0
  41. fbuild/daemon/file_cache.py +332 -0
  42. fbuild/daemon/firmware_ledger.py +546 -0
  43. fbuild/daemon/lock_manager.py +508 -0
  44. fbuild/daemon/logging_utils.py +149 -0
  45. fbuild/daemon/messages.py +957 -0
  46. fbuild/daemon/operation_registry.py +288 -0
  47. fbuild/daemon/port_state_manager.py +249 -0
  48. fbuild/daemon/process_tracker.py +366 -0
  49. fbuild/daemon/processors/__init__.py +18 -0
  50. fbuild/daemon/processors/build_processor.py +248 -0
  51. fbuild/daemon/processors/deploy_processor.py +664 -0
  52. fbuild/daemon/processors/install_deps_processor.py +431 -0
  53. fbuild/daemon/processors/locking_processor.py +777 -0
  54. fbuild/daemon/processors/monitor_processor.py +285 -0
  55. fbuild/daemon/request_processor.py +457 -0
  56. fbuild/daemon/shared_serial.py +819 -0
  57. fbuild/daemon/status_manager.py +238 -0
  58. fbuild/daemon/subprocess_manager.py +316 -0
  59. fbuild/deploy/__init__.py +21 -0
  60. fbuild/deploy/deployer.py +67 -0
  61. fbuild/deploy/deployer_esp32.py +310 -0
  62. fbuild/deploy/docker_utils.py +315 -0
  63. fbuild/deploy/monitor.py +519 -0
  64. fbuild/deploy/qemu_runner.py +603 -0
  65. fbuild/interrupt_utils.py +34 -0
  66. fbuild/ledger/__init__.py +52 -0
  67. fbuild/ledger/board_ledger.py +560 -0
  68. fbuild/output.py +352 -0
  69. fbuild/packages/__init__.py +66 -0
  70. fbuild/packages/archive_utils.py +1098 -0
  71. fbuild/packages/arduino_core.py +412 -0
  72. fbuild/packages/cache.py +256 -0
  73. fbuild/packages/concurrent_manager.py +510 -0
  74. fbuild/packages/downloader.py +518 -0
  75. fbuild/packages/fingerprint.py +423 -0
  76. fbuild/packages/framework_esp32.py +538 -0
  77. fbuild/packages/framework_rp2040.py +349 -0
  78. fbuild/packages/framework_stm32.py +459 -0
  79. fbuild/packages/framework_teensy.py +346 -0
  80. fbuild/packages/github_utils.py +96 -0
  81. fbuild/packages/header_trampoline_cache.py +394 -0
  82. fbuild/packages/library_compiler.py +203 -0
  83. fbuild/packages/library_manager.py +549 -0
  84. fbuild/packages/library_manager_esp32.py +725 -0
  85. fbuild/packages/package.py +163 -0
  86. fbuild/packages/platform_esp32.py +383 -0
  87. fbuild/packages/platform_rp2040.py +400 -0
  88. fbuild/packages/platform_stm32.py +581 -0
  89. fbuild/packages/platform_teensy.py +312 -0
  90. fbuild/packages/platform_utils.py +131 -0
  91. fbuild/packages/platformio_registry.py +369 -0
  92. fbuild/packages/sdk_utils.py +231 -0
  93. fbuild/packages/toolchain.py +436 -0
  94. fbuild/packages/toolchain_binaries.py +196 -0
  95. fbuild/packages/toolchain_esp32.py +489 -0
  96. fbuild/packages/toolchain_metadata.py +185 -0
  97. fbuild/packages/toolchain_rp2040.py +436 -0
  98. fbuild/packages/toolchain_stm32.py +417 -0
  99. fbuild/packages/toolchain_teensy.py +404 -0
  100. fbuild/platform_configs/esp32.json +150 -0
  101. fbuild/platform_configs/esp32c2.json +144 -0
  102. fbuild/platform_configs/esp32c3.json +143 -0
  103. fbuild/platform_configs/esp32c5.json +151 -0
  104. fbuild/platform_configs/esp32c6.json +151 -0
  105. fbuild/platform_configs/esp32p4.json +149 -0
  106. fbuild/platform_configs/esp32s3.json +151 -0
  107. fbuild/platform_configs/imxrt1062.json +56 -0
  108. fbuild/platform_configs/rp2040.json +70 -0
  109. fbuild/platform_configs/rp2350.json +76 -0
  110. fbuild/platform_configs/stm32f1.json +59 -0
  111. fbuild/platform_configs/stm32f4.json +63 -0
  112. fbuild/py.typed +0 -0
  113. fbuild-1.2.8.dist-info/METADATA +468 -0
  114. fbuild-1.2.8.dist-info/RECORD +121 -0
  115. fbuild-1.2.8.dist-info/WHEEL +5 -0
  116. fbuild-1.2.8.dist-info/entry_points.txt +5 -0
  117. fbuild-1.2.8.dist-info/licenses/LICENSE +21 -0
  118. fbuild-1.2.8.dist-info/top_level.txt +2 -0
  119. fbuild_lint/__init__.py +0 -0
  120. fbuild_lint/ruff_plugins/__init__.py +0 -0
  121. fbuild_lint/ruff_plugins/keyboard_interrupt_checker.py +158 -0
@@ -0,0 +1,581 @@
1
+ """STM32 Platform Package Management.
2
+
3
+ This module coordinates STM32 platform components including toolchain and framework.
4
+ It provides a unified interface for managing STM32 Arduino builds.
5
+
6
+ Platform Components:
7
+ - ARM GCC Toolchain (arm-none-eabi-gcc)
8
+ - STM32duino Framework (Arduino core for STM32)
9
+
10
+ Supported Boards:
11
+ - BluePill F103C8 (STM32F103C8T6, ARM Cortex-M3 @ 72MHz)
12
+ - Nucleo F446RE (STM32F446RET6, ARM Cortex-M4 @ 180MHz)
13
+ - Nucleo F411RE (STM32F411RET6, ARM Cortex-M4 @ 100MHz)
14
+ - Nucleo L476RG (STM32L476RGT6, ARM Cortex-M4 @ 80MHz)
15
+ - And many more STM32 boards
16
+ """
17
+
18
+ from pathlib import Path
19
+ from typing import Any, Dict, List
20
+
21
+ from .cache import Cache
22
+ from .framework_stm32 import FrameworkErrorSTM32, FrameworkSTM32
23
+ from .package import IPackage, PackageError
24
+ from .toolchain_stm32 import ToolchainErrorSTM32, ToolchainSTM32
25
+
26
+
27
+ class PlatformErrorSTM32(PackageError):
28
+ """Raised when STM32 platform operations fail."""
29
+
30
+ pass
31
+
32
+
33
+ class PlatformSTM32(IPackage):
34
+ """Manages STM32 platform components and configuration.
35
+
36
+ This class coordinates the ARM GCC toolchain and STM32duino framework to provide
37
+ a complete build environment for STM32 boards.
38
+ """
39
+
40
+ def __init__(self, cache: Cache, board_mcu: str, show_progress: bool = True):
41
+ """Initialize STM32 platform manager.
42
+
43
+ Args:
44
+ cache: Cache manager instance
45
+ board_mcu: MCU type (e.g., "stm32f446ret6", "stm32f103c8t6")
46
+ show_progress: Whether to show download/extraction progress
47
+ """
48
+ self.cache = cache
49
+ self.board_mcu = board_mcu
50
+ self.show_progress = show_progress
51
+
52
+ # Initialize toolchain and framework
53
+ self.toolchain = ToolchainSTM32(cache, show_progress=show_progress)
54
+ self.framework = FrameworkSTM32(cache, show_progress=show_progress)
55
+
56
+ def ensure_package(self) -> Path:
57
+ """Ensure platform components are downloaded and extracted.
58
+
59
+ Returns:
60
+ Path to the framework directory (main platform directory)
61
+
62
+ Raises:
63
+ PlatformErrorSTM32: If download or extraction fails
64
+ """
65
+ try:
66
+ # Ensure toolchain is installed
67
+ self.toolchain.ensure_toolchain()
68
+
69
+ # Ensure framework is installed
70
+ framework_path = self.framework.ensure_framework()
71
+
72
+ return framework_path
73
+
74
+ except (ToolchainErrorSTM32, FrameworkErrorSTM32) as e:
75
+ raise PlatformErrorSTM32(f"Failed to install STM32 platform: {e}")
76
+ except KeyboardInterrupt as ke:
77
+ from fbuild.interrupt_utils import handle_keyboard_interrupt_properly
78
+
79
+ handle_keyboard_interrupt_properly(ke)
80
+ raise # Never reached, but satisfies type checker
81
+ except Exception as e:
82
+ raise PlatformErrorSTM32(f"Unexpected error installing platform: {e}")
83
+
84
+ def is_installed(self) -> bool:
85
+ """Check if platform is already installed.
86
+
87
+ Returns:
88
+ True if both toolchain and framework are installed
89
+ """
90
+ return self.toolchain.is_installed() and self.framework.is_installed()
91
+
92
+ def _get_mcu_family(self, mcu: str) -> str:
93
+ """Extract MCU family from MCU name.
94
+
95
+ Args:
96
+ mcu: MCU name (e.g., "stm32f446ret6")
97
+
98
+ Returns:
99
+ MCU family (e.g., "STM32F4xx")
100
+ """
101
+ mcu_upper = mcu.upper()
102
+ if mcu_upper.startswith("STM32F0"):
103
+ return "STM32F0xx"
104
+ elif mcu_upper.startswith("STM32F1"):
105
+ return "STM32F1xx"
106
+ elif mcu_upper.startswith("STM32F2"):
107
+ return "STM32F2xx"
108
+ elif mcu_upper.startswith("STM32F3"):
109
+ return "STM32F3xx"
110
+ elif mcu_upper.startswith("STM32F4"):
111
+ return "STM32F4xx"
112
+ elif mcu_upper.startswith("STM32F7"):
113
+ return "STM32F7xx"
114
+ elif mcu_upper.startswith("STM32G0"):
115
+ return "STM32G0xx"
116
+ elif mcu_upper.startswith("STM32G4"):
117
+ return "STM32G4xx"
118
+ elif mcu_upper.startswith("STM32H7"):
119
+ return "STM32H7xx"
120
+ elif mcu_upper.startswith("STM32L0"):
121
+ return "STM32L0xx"
122
+ elif mcu_upper.startswith("STM32L1"):
123
+ return "STM32L1xx"
124
+ elif mcu_upper.startswith("STM32L4"):
125
+ return "STM32L4xx"
126
+ elif mcu_upper.startswith("STM32L5"):
127
+ return "STM32L5xx"
128
+ elif mcu_upper.startswith("STM32U5"):
129
+ return "STM32U5xx"
130
+ elif mcu_upper.startswith("STM32WB"):
131
+ return "STM32WBxx"
132
+ elif mcu_upper.startswith("STM32WL"):
133
+ return "STM32WLxx"
134
+ else:
135
+ return "STM32F4xx" # Default fallback
136
+
137
+ def _get_cpu_type(self, mcu: str) -> str:
138
+ """Get CPU type from MCU name.
139
+
140
+ Args:
141
+ mcu: MCU name (e.g., "stm32f446ret6")
142
+
143
+ Returns:
144
+ CPU type (e.g., "cortex-m4")
145
+ """
146
+ mcu_upper = mcu.upper()
147
+ if mcu_upper.startswith("STM32F0") or mcu_upper.startswith("STM32G0") or mcu_upper.startswith("STM32L0"):
148
+ return "cortex-m0plus"
149
+ elif mcu_upper.startswith("STM32F1") or mcu_upper.startswith("STM32F2") or mcu_upper.startswith("STM32L1"):
150
+ return "cortex-m3"
151
+ elif mcu_upper.startswith("STM32F3") or mcu_upper.startswith("STM32F4") or mcu_upper.startswith("STM32G4") or mcu_upper.startswith("STM32L4"):
152
+ return "cortex-m4"
153
+ elif mcu_upper.startswith("STM32F7") or mcu_upper.startswith("STM32H7"):
154
+ return "cortex-m7"
155
+ elif mcu_upper.startswith("STM32L5") or mcu_upper.startswith("STM32U5"):
156
+ return "cortex-m33"
157
+ else:
158
+ return "cortex-m4" # Default fallback
159
+
160
+ def get_compiler_flags(self, board_config: Any, mcu: str = "") -> List[str]:
161
+ """Get compiler flags for STM32 builds.
162
+
163
+ Args:
164
+ board_config: Board configuration object
165
+ mcu: MCU type (e.g., "stm32f446ret6")
166
+
167
+ Returns:
168
+ List of compiler flags
169
+ """
170
+ if not mcu:
171
+ mcu = self.board_mcu
172
+
173
+ cpu_type = self._get_cpu_type(mcu)
174
+ mcu_family = self._get_mcu_family(mcu)
175
+
176
+ # Base flags common to all STM32
177
+ flags = [
178
+ # Optimization and debug
179
+ "-Os",
180
+ "-g",
181
+ "-ffunction-sections",
182
+ "-fdata-sections",
183
+ "-fno-exceptions",
184
+ # Warnings
185
+ "-Wall",
186
+ "-Wno-unused-parameter",
187
+ "-Wno-sign-compare",
188
+ "-Wno-error=unused-function",
189
+ "-Wno-error=unused-variable",
190
+ "-Wno-error=deprecated-declarations",
191
+ # Standards
192
+ "-std=gnu17", # For C files
193
+ # Arduino defines
194
+ "-DARDUINO_ARCH_STM32",
195
+ "-DSTM32_CORE_VERSION_MAJOR=2",
196
+ "-DSTM32_CORE_VERSION_MINOR=12",
197
+ f"-D{mcu_family.replace('xx', '')}",
198
+ ]
199
+
200
+ # CPU-specific flags
201
+ if cpu_type == "cortex-m0plus":
202
+ flags.extend(
203
+ [
204
+ "-mcpu=cortex-m0plus",
205
+ "-mthumb",
206
+ "-march=armv6-m",
207
+ ]
208
+ )
209
+ elif cpu_type == "cortex-m3":
210
+ flags.extend(
211
+ [
212
+ "-mcpu=cortex-m3",
213
+ "-mthumb",
214
+ "-march=armv7-m",
215
+ ]
216
+ )
217
+ elif cpu_type == "cortex-m4":
218
+ flags.extend(
219
+ [
220
+ "-mcpu=cortex-m4",
221
+ "-mthumb",
222
+ "-march=armv7e-m",
223
+ "-mfloat-abi=hard",
224
+ "-mfpu=fpv4-sp-d16",
225
+ ]
226
+ )
227
+ elif cpu_type == "cortex-m7":
228
+ flags.extend(
229
+ [
230
+ "-mcpu=cortex-m7",
231
+ "-mthumb",
232
+ "-march=armv7e-m",
233
+ "-mfloat-abi=hard",
234
+ "-mfpu=fpv5-sp-d16",
235
+ ]
236
+ )
237
+ elif cpu_type == "cortex-m33":
238
+ flags.extend(
239
+ [
240
+ "-mcpu=cortex-m33",
241
+ "-mthumb",
242
+ "-march=armv8-m.main+dsp",
243
+ "-mfloat-abi=hard",
244
+ "-mfpu=fpv5-sp-d16",
245
+ ]
246
+ )
247
+
248
+ # Add CPU frequency
249
+ if hasattr(board_config, "f_cpu"):
250
+ flags.append(f"-DF_CPU={board_config.f_cpu}")
251
+ else:
252
+ # Default frequencies by family
253
+ default_freqs = {
254
+ "STM32F0xx": "48000000L",
255
+ "STM32F1xx": "72000000L",
256
+ "STM32F2xx": "120000000L",
257
+ "STM32F3xx": "72000000L",
258
+ "STM32F4xx": "180000000L",
259
+ "STM32F7xx": "216000000L",
260
+ "STM32G0xx": "64000000L",
261
+ "STM32G4xx": "170000000L",
262
+ "STM32H7xx": "480000000L",
263
+ "STM32L0xx": "32000000L",
264
+ "STM32L1xx": "32000000L",
265
+ "STM32L4xx": "80000000L",
266
+ "STM32L5xx": "110000000L",
267
+ }
268
+ f_cpu = default_freqs.get(mcu_family, "72000000L")
269
+ flags.append(f"-DF_CPU={f_cpu}")
270
+
271
+ return flags
272
+
273
+ def get_compiler_flags_cpp(self, board_config: Any, mcu: str = "") -> List[str]:
274
+ """Get C++ compiler flags for STM32 builds.
275
+
276
+ Args:
277
+ board_config: Board configuration object
278
+ mcu: MCU type (e.g., "stm32f446ret6")
279
+
280
+ Returns:
281
+ List of C++ compiler flags
282
+ """
283
+ # Start with base C flags
284
+ flags = self.get_compiler_flags(board_config, mcu)
285
+
286
+ # Replace C standard with C++ standard
287
+ flags = [f for f in flags if not f.startswith("-std=gnu17")]
288
+ flags.extend(
289
+ [
290
+ "-std=gnu++17",
291
+ "-fno-exceptions",
292
+ "-fno-rtti",
293
+ "-fno-threadsafe-statics",
294
+ ]
295
+ )
296
+
297
+ return flags
298
+
299
+ def get_linker_flags(self, board_config: Any, mcu: str = "") -> List[str]:
300
+ """Get linker flags for STM32 builds.
301
+
302
+ Args:
303
+ board_config: Board configuration object
304
+ mcu: MCU type (e.g., "stm32f446ret6")
305
+
306
+ Returns:
307
+ List of linker flags
308
+ """
309
+ if not mcu:
310
+ mcu = self.board_mcu
311
+
312
+ cpu_type = self._get_cpu_type(mcu)
313
+
314
+ flags = [
315
+ # Optimization
316
+ "-Os",
317
+ # Linker options
318
+ "-Wl,--cref",
319
+ "-Wl,--check-sections",
320
+ "-Wl,--gc-sections",
321
+ "-Wl,--unresolved-symbols=report-all",
322
+ "-Wl,--warn-common",
323
+ "-Wl,--warn-section-align",
324
+ # Entry point
325
+ "-Wl,--entry=Reset_Handler",
326
+ # No default libs - we provide our own
327
+ "--specs=nano.specs",
328
+ "--specs=nosys.specs",
329
+ ]
330
+
331
+ # CPU-specific flags
332
+ if cpu_type == "cortex-m0plus":
333
+ flags.extend(
334
+ [
335
+ "-mcpu=cortex-m0plus",
336
+ "-mthumb",
337
+ ]
338
+ )
339
+ elif cpu_type == "cortex-m3":
340
+ flags.extend(
341
+ [
342
+ "-mcpu=cortex-m3",
343
+ "-mthumb",
344
+ ]
345
+ )
346
+ elif cpu_type == "cortex-m4":
347
+ flags.extend(
348
+ [
349
+ "-mcpu=cortex-m4",
350
+ "-mthumb",
351
+ "-mfloat-abi=hard",
352
+ "-mfpu=fpv4-sp-d16",
353
+ ]
354
+ )
355
+ elif cpu_type == "cortex-m7":
356
+ flags.extend(
357
+ [
358
+ "-mcpu=cortex-m7",
359
+ "-mthumb",
360
+ "-mfloat-abi=hard",
361
+ "-mfpu=fpv5-sp-d16",
362
+ ]
363
+ )
364
+ elif cpu_type == "cortex-m33":
365
+ flags.extend(
366
+ [
367
+ "-mcpu=cortex-m33",
368
+ "-mthumb",
369
+ "-mfloat-abi=hard",
370
+ "-mfpu=fpv5-sp-d16",
371
+ ]
372
+ )
373
+
374
+ return flags
375
+
376
+ def get_include_dirs(self, board_config: Any) -> List[Path]:
377
+ """Get include directories for STM32 builds.
378
+
379
+ Args:
380
+ board_config: Board configuration object
381
+
382
+ Returns:
383
+ List of include directory paths
384
+ """
385
+ includes = []
386
+
387
+ # Core includes
388
+ try:
389
+ core_includes = self.framework.get_core_includes("arduino")
390
+ includes.extend(core_includes)
391
+ except FrameworkErrorSTM32:
392
+ pass
393
+
394
+ # Variant includes (if board_config has variant info)
395
+ if hasattr(board_config, "variant"):
396
+ variant_dir = self.framework.get_variant_dir(board_config.variant)
397
+ if variant_dir:
398
+ includes.append(variant_dir)
399
+
400
+ # System includes
401
+ system_dir = self.framework.framework_path / "system"
402
+ if system_dir.exists():
403
+ includes.append(system_dir)
404
+
405
+ return includes
406
+
407
+ def get_core_sources(self) -> List[Path]:
408
+ """Get core source files for STM32 builds.
409
+
410
+ Returns:
411
+ List of core source file paths
412
+ """
413
+ try:
414
+ return self.framework.get_core_sources("arduino")
415
+ except FrameworkErrorSTM32:
416
+ return []
417
+
418
+ def get_toolchain_binaries(self) -> Dict[str, Path]:
419
+ """Get paths to toolchain binaries.
420
+
421
+ Returns:
422
+ Dictionary mapping tool names to paths
423
+
424
+ Raises:
425
+ PlatformErrorSTM32: If toolchain binaries are not found
426
+ """
427
+ tools = self.toolchain.get_all_tool_paths()
428
+
429
+ # Verify all required tools exist
430
+ required_tools = ["gcc", "g++", "ar", "objcopy", "size"]
431
+ for tool_name in required_tools:
432
+ if tool_name not in tools or tools[tool_name] is None:
433
+ raise PlatformErrorSTM32(f"Required tool not found: {tool_name}")
434
+
435
+ # Filter out None values
436
+ return {name: path for name, path in tools.items() if path is not None}
437
+
438
+ def get_package_info(self) -> Dict[str, Any]:
439
+ """Get information about the installed platform.
440
+
441
+ Returns:
442
+ Dictionary with platform information
443
+ """
444
+ return self.get_platform_info()
445
+
446
+ def get_board_json(self, board_id: str) -> Dict[str, Any]:
447
+ """Get board configuration in JSON format.
448
+
449
+ This method returns board configuration compatible with the format
450
+ expected by ConfigurableCompiler and ConfigurableLinker.
451
+
452
+ Args:
453
+ board_id: Board identifier (e.g., "nucleo_f446re", "bluepill_f103c8")
454
+
455
+ Returns:
456
+ Dictionary containing board configuration
457
+
458
+ Raises:
459
+ PlatformErrorSTM32: If board is not supported
460
+ """
461
+ # Map board IDs to their configurations
462
+ # Note: "core" must be "arduino" as that's the directory name in STM32duino framework
463
+ board_configs = {
464
+ "nucleo_f446re": {
465
+ "build": {
466
+ "mcu": "stm32f446ret6",
467
+ "f_cpu": "180000000L",
468
+ "core": "arduino",
469
+ "cpu": "cortex-m4",
470
+ "variant": "STM32F4xx/F446R(C-E)T",
471
+ "extra_flags": "-DSTM32F4 -DSTM32F446xx",
472
+ "product_line": "STM32F446xx",
473
+ },
474
+ "name": "ST Nucleo F446RE",
475
+ "upload": {
476
+ "maximum_size": 524288, # 512KB flash
477
+ "maximum_ram_size": 131072, # 128KB RAM
478
+ },
479
+ },
480
+ "nucleo_f411re": {
481
+ "build": {
482
+ "mcu": "stm32f411ret6",
483
+ "f_cpu": "100000000L",
484
+ "core": "arduino",
485
+ "cpu": "cortex-m4",
486
+ "variant": "STM32F4xx/F411R(C-E)T",
487
+ "extra_flags": "-DSTM32F4 -DSTM32F411xE",
488
+ "product_line": "STM32F411xE",
489
+ },
490
+ "name": "ST Nucleo F411RE",
491
+ "upload": {
492
+ "maximum_size": 524288, # 512KB flash
493
+ "maximum_ram_size": 131072, # 128KB RAM
494
+ },
495
+ },
496
+ "bluepill_f103c8": {
497
+ "build": {
498
+ "mcu": "stm32f103c8t6",
499
+ "f_cpu": "72000000L",
500
+ "core": "arduino",
501
+ "cpu": "cortex-m3",
502
+ "variant": "STM32F1xx/F103C8T_F103CB(T-U)",
503
+ "extra_flags": "-DSTM32F1 -DSTM32F103xB",
504
+ "product_line": "STM32F103xB",
505
+ },
506
+ "name": "BluePill F103C8",
507
+ "upload": {
508
+ "maximum_size": 65536, # 64KB flash
509
+ "maximum_ram_size": 20480, # 20KB RAM
510
+ },
511
+ },
512
+ "blackpill_f411ce": {
513
+ "build": {
514
+ "mcu": "stm32f411ceu6",
515
+ "f_cpu": "100000000L",
516
+ "core": "arduino",
517
+ "cpu": "cortex-m4",
518
+ "variant": "STM32F4xx/F411C(C-E)(U-Y)",
519
+ "extra_flags": "-DSTM32F4 -DSTM32F411xE",
520
+ "product_line": "STM32F411xE",
521
+ },
522
+ "name": "BlackPill F411CE",
523
+ "upload": {
524
+ "maximum_size": 524288, # 512KB flash
525
+ "maximum_ram_size": 131072, # 128KB RAM
526
+ },
527
+ },
528
+ "nucleo_l476rg": {
529
+ "build": {
530
+ "mcu": "stm32l476rgt6",
531
+ "f_cpu": "80000000L",
532
+ "core": "arduino",
533
+ "cpu": "cortex-m4",
534
+ "variant": "STM32L4xx/L476R(C-E-G)T",
535
+ "extra_flags": "-DSTM32L4 -DSTM32L476xx",
536
+ "product_line": "STM32L476xx",
537
+ },
538
+ "name": "ST Nucleo L476RG",
539
+ "upload": {
540
+ "maximum_size": 1048576, # 1MB flash
541
+ "maximum_ram_size": 131072, # 128KB RAM
542
+ },
543
+ },
544
+ "nucleo_f103rb": {
545
+ "build": {
546
+ "mcu": "stm32f103rbt6",
547
+ "f_cpu": "72000000L",
548
+ "core": "arduino",
549
+ "cpu": "cortex-m3",
550
+ "variant": "STM32F1xx/F103R(8-B)T",
551
+ "extra_flags": "-DSTM32F1 -DSTM32F103xB",
552
+ "product_line": "STM32F103xB",
553
+ },
554
+ "name": "ST Nucleo F103RB",
555
+ "upload": {
556
+ "maximum_size": 131072, # 128KB flash
557
+ "maximum_ram_size": 20480, # 20KB RAM
558
+ },
559
+ },
560
+ }
561
+
562
+ if board_id not in board_configs:
563
+ raise PlatformErrorSTM32(f"Unsupported board: {board_id}. " + f"Supported boards: {', '.join(board_configs.keys())}")
564
+
565
+ return board_configs[board_id]
566
+
567
+ def get_platform_info(self) -> Dict[str, Any]:
568
+ """Get information about the installed platform.
569
+
570
+ Returns:
571
+ Dictionary with platform information
572
+ """
573
+ info = {
574
+ "platform": "ststm32",
575
+ "mcu": self.board_mcu,
576
+ "installed": self.is_installed(),
577
+ "toolchain": self.toolchain.get_toolchain_info(),
578
+ "framework": self.framework.get_framework_info(),
579
+ }
580
+
581
+ return info