Skip to content

Add QEMU multi-arch simulation, Bootgen for AMD Versal Gen 2 - #868

Open
Akshay-Belsare wants to merge 5 commits into
OP-TEE:masterfrom
Xilinx:amd_versal2_qemu
Open

Add QEMU multi-arch simulation, Bootgen for AMD Versal Gen 2#868
Akshay-Belsare wants to merge 5 commits into
OP-TEE:masterfrom
Xilinx:amd_versal2_qemu

Conversation

@Akshay-Belsare

Copy link
Copy Markdown
Contributor

Add support for building and running QEMU-based multi-architecture simulation for the AMD Versal Gen 2 platform.

Dependent on OP-TEE/manifest#352

@Akshay-Belsare
Akshay-Belsare marked this pull request as draft July 29, 2026 11:56

@jenswikl jenswikl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to follow the 80 column limit in the patches.

Comment thread versal2.mk Outdated
Comment thread versal2.mk Outdated
@Akshay-Belsare
Akshay-Belsare marked this pull request as ready for review August 7, 2026 07:24
Comment thread versal2.mk Outdated
Comment thread versal2.mk Outdated
@echo "=== Starting MicroBlaze PMC QEMU ==="
@echo "Working directory: $(BOOT_IMAGES_PATH)"
@echo "Device tree: $(DEVICE_TREE_PATH)/board-versal2-pmxc-virt.dtb"
@test -f $(QEMU_MICROBLAZE_BIN) || \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just agree that make all should be run at least once before using any of these targets?
While these error messages are friendly, it seems that they will be hard to keep accurate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment. We can't remove these file checks because these targets deliberately have no prerequisites. Adding them would let run-qemu-direct's backgrounded sub-processes independently re-trigger the same rebuild chain concurrently, and we hit a race condition this way. These checks are the only safety net for a direct invocation of make run-qemu-microblaze.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. Surely make all -j<whatever> should work without races, or something is broken.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the code accordingly.
Rebased to latest master.

Add support for building bootgen from source, required to generate
boot images for AMD Versal Gen 2 QEMU simulation.

- Add BOOTGEN_PATH variable pointing to the bootgen source tree
- Add 'bootgen' target to build bootgen and copy the resulting
  binary to out/bin/
- Add 'bootgen-clean' target to clean bootgen build artifacts
- Extend 'all' and 'clean' targets to include bootgen

Signed-off-by: Amey Avinash Raghatate <ameyavinash.raghatate@amd.com>
Signed-off-by: Akshay Belsare <akshay.belsare@amd.com>
Add support for building QEMU and the QEMU device trees required
for AMD Versal Gen 2 multi-architecture simulation.

- Add QEMU_PATH, QEMU_BUILD and QEMU_DEVICETREES_PATH variables
- Add 'qemu' target to configure and build QEMU for the three
  target architectures used by Versal2 simulation:
  aarch64-softmmu, microblazeel-softmmu, riscv32-softmmu
- Add 'qemu-clean' target to clean the QEMU build directory
- Add 'qemu-devicetrees' and 'qemu-devicetrees-clean' targets to
  build and clean the QEMU device trees
- Extend 'all' and 'clean' targets to include qemu and
  qemu-devicetrees.

Signed-off-by: Amey Avinash Raghatate <ameyavinash.raghatate@amd.com>
Signed-off-by: Akshay Belsare <akshay.belsare@amd.com>
…Gen 2

Add the bootgen boot image file (bif) and platform configuration
binaries required to generate BOOT.BIN for AMD Versal Gen 2 QEMU
simulation.

Signed-off-by: Amey Avinash Raghatate <ameyavinash.raghatate@amd.com>
Signed-off-by: Akshay Belsare <akshay.belsare@amd.com>
…ulation

Add support for generating the AMD Versal Gen 2 boot image and launching
QEMU-based multi-architecture simulation.

- Add 'bootimage' target that copies bootgen.bif and the platform
config binaries to out/bin/, invokes bootgen to create BOOT.BIN,
and generates a 256MB OSPI flash image with BOOT.BIN written to it
- Extend 'all' target to also produce the boot image, so BOOT.BIN
is available without triggering the QEMU launch flow.
- Add 'bootimage-clean' target to remove the generated boot image
artifacts
- Add QEMU path variables and individual run-qemu-{microblaze,riscv,
aarch64} targets for the PMC, ASU and PSXC QEMU instances
- Add 'run-qemu-direct' to launch all three QEMU instances:
MicroBlaze (PMC) and RISC-V (ASU) in background, AArch64 (PSXC)
interactive. Background instances are killed automatically on
AArch64 exit. No external terminal dependencies required
- Image and rootfs are pre-loaded into AArch64 QEMU memory via
-device loader, allowing boot with
'booti 0x21000000 0x30000000 $fdtcontroladdr' at the U-Boot prompt
- Add 'run-qemu-clean' to clean QEMU temporary machine-path files
- Add 'run' target for full build, boot image creation and QEMU
launch
- Add 'run-only' target to repack the boot image and launch QEMU
using already built firmware, intended for developer iteration
- Extend 'clean' target to include bootimage-clean and
run-qemu-clean

Signed-off-by: Amey Avinash Raghatate <ameyavinash.raghatate@amd.com>
Signed-off-by: Akshay Belsare <akshay.belsare@amd.com>
- Remove the 5 checks in 'bootimage'. Since 'bootimage' already
declares 'bootgen tfa optee-os u-boot dtbo' as Make prerequisites,
Make guarantees each has completed successfully before bootimage's
recipe runs, making these checks dead code.

- Remove the checks in 'run-qemu-microblaze', 'run-qemu-riscv' and
'run-qemu-aarch64'. The reviewer preferred documenting that 'make
all' should be run at least once before using these targets, over
maintaining per-target error messages that are hard to keep
accurate as the Makefile evolves.

Signed-off-by: Amey Avinash Raghatate <ameyavinash.raghatate@amd.com>
Signed-off-by: Akshay Belsare <akshay.belsare@amd.com>
Comment thread versal2.mk
qemu qemu-devicetrees bootimage
run: all
$(MAKE) run-only
run-only: bootimage run-qemu-direct

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other run-only target in fvp.mk, qemu.mk, and qemu_v8.mk, doesn't depend on anything.
Since this run-only target doesn't even do anything, only depend on stuff, how about removing it to avoid confusion?
By the way, if run-only is executed with -j<something>, run-qemu-direct might execute before bootimage is done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll keep run-only as a standalone target rather than removing it, similar to how it's done upstream. Instead of listing bootimage run-qemu-direct as prerequisites, run-only would do an explicit existence check for each required artifact (TF-A, OP-TEE, U-Boot, DTBs, bootgen, QEMU binaries, kernel Image, rootfs) before invoking the run step directly.
Let us know if this approach works, or if you'd prefer something different — will send the updated patch once confirmed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants