MCPcopy Create free account
hub / github.com/FastLED/FastLED / run_upload

Function run_upload

ci/debug_attached.py:250–323  ·  view source on GitHub ↗

Upload firmware to device. This function uses `pio run -t upload` which will upload the firmware. PlatformIO's incremental build system only rebuilds if source files changed since the last compilation, making this fast when nothing changed. On Windows Git Bash: Runs via cmd.exe wit

(
    build_dir: Path,
    environment: str | None = None,
    upload_port: str | None = None,
    verbose: bool = False,
)

Source from the content-addressed store, hash-verified

248
249
250def run_upload(
251 build_dir: Path,
252 environment: str | None = None,
253 upload_port: str | None = None,
254 verbose: bool = False,
255) -> bool:
256 """Upload firmware to device.
257
258 This function uses `pio run -t upload` which will upload the firmware.
259 PlatformIO's incremental build system only rebuilds if source files changed
260 since the last compilation, making this fast when nothing changed.
261
262 On Windows Git Bash: Runs via cmd.exe with clean environment (no Git Bash indicators)
263 On other platforms: Runs directly with UTF-8 environment
264
265 Args:
266 build_dir: Project directory containing platformio.ini
267 environment: PlatformIO environment to upload (None = default)
268 upload_port: Serial port to use (None = auto-detect)
269 verbose: Enable verbose output
270
271 Returns:
272 True if upload succeeded, False otherwise.
273 """
274 cmd = [
275 "pio",
276 "run",
277 "--project-dir",
278 str(build_dir),
279 "-t",
280 "upload",
281 ]
282 if environment:
283 cmd.extend(["--environment", environment])
284 if upload_port:
285 cmd.extend(["--upload-port", upload_port])
286 if verbose:
287 cmd.append("--verbose")
288
289 print("=" * 60)
290 print("UPLOADING")
291 print("=" * 60)
292
293 formatter = TimestampFormatter()
294 # Use create_pio_process() for Git Bash compatibility
295 proc = create_pio_process(
296 cmd,
297 cwd=build_dir,
298 output_formatter=formatter,
299 auto_run=True,
300 )
301
302 try:
303 # 15 minute timeout per CLAUDE.md standards
304 while line := proc.get_next_line(timeout=900):
305 if isinstance(line, EndOfStream):
306 break
307 print(line)

Callers 1

deployMethod · 0.90

Calls 7

TimestampFormatterClass · 0.90
create_pio_processFunction · 0.90
terminateMethod · 0.80
printFunction · 0.50
appendMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected