Background
Running the esp32 and esp32c3 emulators currently depends on qemu-system-* being available in the environment.
In practice, this means users usually need to prepare QEMU manually before running commands such as:
llgo run -target=esp32 -emulator
llgo run -target=esp32c3-basic -emulator
and before running embedded emulator-based tests.
This is inconsistent with the current esp-clang experience. When esp-clang is missing, llgo can automatically download the correct host-platform package and cache it under the crosscompile cache. ESP QEMU should follow the same model.
Problem
At the moment, ESP emulator support is still environment-dependent:
- local users need to install or prepare QEMU themselves
- CI installs ESP QEMU explicitly and injects it into
PATH
This is not the intended long-term behavior.
Proposal
When an ESP emulator is actually needed, llgo should automatically detect whether the required ESP QEMU binaries are available in the crosscompile cache. If not, it should download the correct package for the current host platform and extract it into:
crosscompile/esp-qemu-<version>
Subsequent runs should reuse the cached directory.
Scope
This change is intentionally limited to ESP emulator workflows only.
Supported emulator commands:
qemu-system-riscv32
qemu-system-xtensa
Supported target scenarios:
Supported host platforms for the first implementation:
- macOS amd64
- macOS arm64
- Linux amd64
- Linux arm64
Out of scope for now:
- Windows support
- non-ESP QEMU targets
- changing target JSON definitions
Requirements
- Keep existing target JSON
emulator fields unchanged. They should continue to use qemu-system-*.
- Only trigger automatic download when the ESP emulator is actually needed.
- Store the downloaded toolchain in:
crosscompile/esp-qemu-<version>
- The downloaded package itself should still be selected based on the current host platform.
- Reuse the cache on later runs instead of downloading again.
- Handle concurrent access safely to avoid duplicate downloads or corrupted cache state.
- Follow the existing style and behavior of the
esp-clang download/cache flow as much as possible.
Expected Behavior
If a user runs an ESP emulator command in a clean environment without preinstalled QEMU, llgo should:
- detect that the required ESP QEMU binaries are missing
- determine the correct package for the current host platform
- download and extract it into
crosscompile/esp-qemu-<version>
- execute the emulator using the cached binaries
No manual QEMU installation should be required.
Current State
CI still installs ESP QEMU explicitly before running embedded emulator tests. This confirms that ESP QEMU has not yet been integrated into llgo's own crosscompile/toolchain acquisition flow.
Acceptance Criteria
- Remove the explicit ESP QEMU installation step from CI.
- CI still passes for existing ESP emulator coverage.
- Both of the following work in a clean environment without preinstalled QEMU:
esp32c3-basic emulator runs
esp32 emulator runs
- First run downloads automatically.
- Later runs reuse the cache without re-downloading.
- Existing target JSON
emulator definitions remain unchanged.
- Automatic download is only triggered for
esp32/esp32c3 emulator scenarios, not for normal build/install flows.
Notes
This issue is not about generalizing automatic download for every QEMU-based target. The goal is to first make the ESP emulator experience consistent with the existing esp-clang auto-download behavior.
Background
Running the
esp32andesp32c3emulators currently depends onqemu-system-*being available in the environment.In practice, this means users usually need to prepare QEMU manually before running commands such as:
llgo run -target=esp32 -emulatorllgo run -target=esp32c3-basic -emulatorand before running embedded emulator-based tests.
This is inconsistent with the current
esp-clangexperience. Whenesp-clangis missing,llgocan automatically download the correct host-platform package and cache it under the crosscompile cache. ESP QEMU should follow the same model.Problem
At the moment, ESP emulator support is still environment-dependent:
PATHThis is not the intended long-term behavior.
Proposal
When an ESP emulator is actually needed,
llgoshould automatically detect whether the required ESP QEMU binaries are available in the crosscompile cache. If not, it should download the correct package for the current host platform and extract it into:crosscompile/esp-qemu-<version>Subsequent runs should reuse the cached directory.
Scope
This change is intentionally limited to ESP emulator workflows only.
Supported emulator commands:
qemu-system-riscv32qemu-system-xtensaSupported target scenarios:
esp32c3-basicesp32Supported host platforms for the first implementation:
Out of scope for now:
Requirements
emulatorfields unchanged. They should continue to useqemu-system-*.crosscompile/esp-qemu-<version>esp-clangdownload/cache flow as much as possible.Expected Behavior
If a user runs an ESP emulator command in a clean environment without preinstalled QEMU,
llgoshould:crosscompile/esp-qemu-<version>No manual QEMU installation should be required.
Current State
CI still installs ESP QEMU explicitly before running embedded emulator tests. This confirms that ESP QEMU has not yet been integrated into llgo's own crosscompile/toolchain acquisition flow.
Acceptance Criteria
esp32c3-basicemulator runsesp32emulator runsemulatordefinitions remain unchanged.esp32/esp32c3emulator scenarios, not for normal build/install flows.Notes
This issue is not about generalizing automatic download for every QEMU-based target. The goal is to first make the ESP emulator experience consistent with the existing
esp-clangauto-download behavior.