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

Function _update_elf_sections

ci/util/bin_2_elf.py:327–376  ·  view source on GitHub ↗

Update the ELF file sections with binary data (platform-specific). Args: objcopy_path (Path): Path to the objcopy executable. bin_file (Path): Path to the binary file. elf_file (Path): Path to the ELF file. platform (str): Target platform.

(
    objcopy_path: Path, bin_file: Path, elf_file: Path, platform: str
)

Source from the content-addressed store, hash-verified

325
326
327def _update_elf_sections(
328 objcopy_path: Path, bin_file: Path, elf_file: Path, platform: str
329):
330 """
331 Update the ELF file sections with binary data (platform-specific).
332
333 Args:
334 objcopy_path (Path): Path to the objcopy executable.
335 bin_file (Path): Path to the binary file.
336 elf_file (Path): Path to the ELF file.
337 platform (str): Target platform.
338 """
339 print(f"Updating {platform} ELF sections...")
340
341 # Platform-specific section names
342 section_mapping = {"esp32": ".flash.text", "avr": ".text", "arm": ".text"}
343
344 section_name = section_mapping.get(platform, ".text")
345
346 try:
347 command = [
348 str(objcopy_path),
349 "--update-section",
350 f"{section_name}={bin_file}",
351 str(elf_file),
352 ]
353 print(
354 f"Updating {platform} ELF file '{elf_file}' section '{section_name}' with binary file '{bin_file}'"
355 )
356 _run_command(command, show_output=True)
357 print(f"Successfully updated {section_name} section")
358 except RuntimeError as e:
359 print(f"Warning: Could not update {section_name} section: {e}")
360 # Try alternative section names
361 alternative_sections = [".text", ".data", ".rodata"]
362 for alt_section in alternative_sections:
363 if alt_section != section_name:
364 try:
365 command = [
366 str(objcopy_path),
367 "--update-section",
368 f"{alt_section}={bin_file}",
369 str(elf_file),
370 ]
371 print(f"Trying alternative section: {alt_section}")
372 _run_command(command, show_output=True)
373 print(f"Successfully updated {alt_section} section")
374 break
375 except RuntimeError:
376 continue
377
378
379def bin_to_elf(

Callers 1

bin_to_elfFunction · 0.85

Calls 3

_run_commandFunction · 0.85
printFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected