Validate ESP32 flash mode for QEMU compatibility. QEMU requires DIO/80MHz flash mode, not QIO mode. Args: build_dir: Build directory path board: Board configuration Returns: True if flash mode is compatible or successfully validated
(build_dir: Path, board: Board)
| 67 | |
| 68 | |
| 69 | def validate_esp32_flash_mode_for_qemu(build_dir: Path, board: Board) -> bool: |
| 70 | """Validate ESP32 flash mode for QEMU compatibility. |
| 71 | |
| 72 | QEMU requires DIO/80MHz flash mode, not QIO mode. |
| 73 | |
| 74 | Args: |
| 75 | build_dir: Build directory path |
| 76 | board: Board configuration |
| 77 | |
| 78 | Returns: |
| 79 | True if flash mode is compatible or successfully validated |
| 80 | """ |
| 81 | if not board.board_name.startswith("esp32"): |
| 82 | return True # Not an ESP32 board, no validation needed |
| 83 | |
| 84 | try: |
| 85 | # Check platformio.ini for flash mode settings |
| 86 | platformio_ini = build_dir / "platformio.ini" |
| 87 | if platformio_ini.exists(): |
| 88 | content = platformio_ini.read_text() |
| 89 | |
| 90 | # Look for flash mode settings in build_flags |
| 91 | if "FLASH_MODE=qio" in content.upper(): |
| 92 | print("⚠️ WARNING: QIO flash mode detected in platformio.ini") |
| 93 | print(" QEMU requires DIO flash mode for compatibility") |
| 94 | print(" Consider using DIO mode for QEMU builds") |
| 95 | return True # Warning but not blocking |
| 96 | |
| 97 | if "FLASH_MODE=dio" in content.upper(): |
| 98 | print("✅ DIO flash mode detected - compatible with QEMU") |
| 99 | return True |
| 100 | |
| 101 | # Check if build artifacts exist to examine flash settings |
| 102 | artifact_dir = build_dir / ".pio" / "build" / board.board_name |
| 103 | if artifact_dir.exists(): |
| 104 | # Look for flash_args file which contains esptool flash arguments |
| 105 | flash_args_file = artifact_dir / "flash_args" |
| 106 | if flash_args_file.exists(): |
| 107 | flash_args = flash_args_file.read_text() |
| 108 | if "--flash_mode qio" in flash_args: |
| 109 | print("⚠️ WARNING: QIO flash mode detected in build artifacts") |
| 110 | print(" QEMU may not boot properly with QIO mode") |
| 111 | elif "--flash_mode dio" in flash_args: |
| 112 | print( |
| 113 | "✅ DIO flash mode detected in build artifacts - QEMU compatible" |
| 114 | ) |
| 115 | |
| 116 | print(f"ℹ️ Flash mode validation complete for {board.board_name}") |
| 117 | return True |
| 118 | |
| 119 | except KeyboardInterrupt as ki: |
| 120 | handle_keyboard_interrupt(ki) |
| 121 | raise |
| 122 | except Exception as e: |
| 123 | print(f"WARNING: Could not validate ESP32 flash mode: {e}") |
| 124 | return True # Don't fail build for validation issues |
| 125 | |
| 126 |
no test coverage detected