Skip to content

Conversation

horw
Copy link
Collaborator

@horw horw commented May 11, 2024

Closes #269

@horw horw force-pushed the feat/qemu_efuse branch from d241b47 to 5959de7 Compare May 13, 2024 00:24
@horw horw requested a review from hfudev May 13, 2024 03:44
@horw
Copy link
Collaborator Author

horw commented May 13, 2024

@hfudev Hello! This MR has added support for qemu efuse.

@hfudev hfudev force-pushed the feat/qemu_efuse branch from 5959de7 to afe5548 Compare July 30, 2024 07:32
@hfudev
Copy link
Member

hfudev commented Jul 30, 2024

@igrr PTAL, thanks!

@hfudev hfudev requested a review from igrr July 30, 2024 08:11
@horw horw closed this Dec 29, 2024
'-global',
f'driver=nvram.{self.app.target}.efuse,property=drive,value=efuse',
'-serial',
f'tcp::{available_port},server,nowait',
Copy link
Member

Choose a reason for hiding this comment

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

When launching QEMU and expecting that it should communicate with another application, it is better to use -daemonize flag — as recommended by QEMU documentation. Otherwise there may be a race condition between QEMU getting ready to accept TCP connections and the launch of the other application. It seems child.expect('qemu') aims to work around that, but I am not sure this is reliable enough.

Copy link
Member

Choose a reason for hiding this comment

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

Also, now that I'm thinking of this... don't you end up with two QEMU processes running at the same time, and accessing the same eFuse file?.. One QEMU process is already launched when dut is created, another one is launched here.

Choose a reason for hiding this comment

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

When launching QEMU and expecting that it should communicate with another application, it is better to use -daemonize flag — as recommended by QEMU documentation. Otherwise there may be a race condition between QEMU getting ready to accept TCP connections and the launch of the other application. It seems child.expect('qemu') aims to work around that, but I am not sure this is reliable enough.

I think solution using pexpect and nowait flag is reliable enough. Once qemu appears in the output, it indicates that QEMU is ready to accept connections. Another solution using -daemonize also works:

run_qemu_command = [
    '-daemonize',
    '-display',
    'none',
    '-machine',
    self.app.target,
    '-drive',
    f'file={self.image_path},if=mtd,format=raw',
    '-global',
    self.QEMU_STRAP_MODE_FMT.format(self.app.target, QEMU_TARGETS[self.app.target].strap_mode),
    '-drive',
    f'file={self.efuse_path},if=none,format=raw,id=efuse',
    '-global',
    f'driver=nvram.{self.app.target}.efuse,property=drive,value=efuse',
    '-serial',
    f'tcp::{available_port},server,nowait',
]
try:
    proc = subprocess.run(
        [self.current_qemu_executable_path, *run_qemu_command],
        check=True
    )
    res = shlex.split(command)

    ...

But I suggest to keep the current implementation.

Choose a reason for hiding this comment

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

Also, now that I'm thinking of this... don't you end up with two QEMU processes running at the same time, and accessing the same eFuse file?.. One QEMU process is already launched when dut is created, another one is launched here.

Yes, but the first process never writes to the eFuse file. All write operations are performed via TCP using espefuse. So it should be ok.

@horw horw reopened this Dec 30, 2024
@achxkloel achxkloel force-pushed the feat/qemu_efuse branch 3 times, most recently from ee38c42 to 3083101 Compare September 15, 2025 14:51
@achxkloel
Copy link

@igrr @hfudev Hello, PTAL

Copy link
Member

@hfudev hfudev left a comment

Choose a reason for hiding this comment

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

LGTM!

@hfudev
Copy link
Member

hfudev commented Sep 16, 2025

@igrr PTAL again. Thank you!

@hfudev
Copy link
Member

hfudev commented Sep 16, 2025

Two Wokwi tests are failing due to missing access to secrets. These failures are unrelated to the current changes.

@horw
Copy link
Collaborator Author

horw commented Sep 16, 2025

@achxkloel Thank you!

@hfudev hfudev requested a review from igrr September 16, 2025 09:44
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.

Add support for running efuse-related tests in pytest-embedded-qemu (RDT-747)
4 participants