Skip to content

Commit

Permalink
hw/xtensa: add ESP32 machine
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed Feb 3, 2022
1 parent 5212ec7 commit 440ff71
Show file tree
Hide file tree
Showing 8 changed files with 938 additions and 0 deletions.
1 change: 1 addition & 0 deletions configs/devices/xtensa-softmmu/default.mak
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ CONFIG_SEMIHOSTING=y
CONFIG_XTENSA_SIM=y
CONFIG_XTENSA_VIRT=y
CONFIG_XTENSA_XTFPGA=y
CONFIG_XTENSA_ESP32=y
11 changes: 11 additions & 0 deletions hw/xtensa/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ config XTENSA_XTFPGA
select OPENCORES_ETH
select PFLASH_CFI01
select SERIAL

config XTENSA_ESP32
bool
select SSI
select SSI_M25P80
select UNIMP
select OPENCORES_ETH
select DWC_SDMMC
select TMP105


Loading

6 comments on commit 440ff71

@amotl
Copy link

@amotl amotl commented on 440ff71 Feb 3, 2022

Choose a reason for hiding this comment

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

Sweet! 💯

I know this is still fresh. 1 May I still ask if you could outline a small documentation how this is supposed to be used and what will be possible with it? When working on the Terkin Datalogger the other day, I would have loved such an infrastructure to be able to run code completely on my workstation.

Footnotes

  1. I now can see that this is already around for a while (https://github.com/espressif/qemu/releases). We probably should have used it earlier. Thank you!

@igrr
Copy link
Member Author

@igrr igrr commented on 440ff71 Feb 3, 2022

Choose a reason for hiding this comment

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

@amotl please take a look at https://github.com/espressif/qemu/wiki, it should give some general overview

@amotl
Copy link

@amotl amotl commented on 440ff71 Feb 3, 2022

Choose a reason for hiding this comment

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

That looks pretty thorough, I can spot support for things like esptool.py, networking, and SD host controller emulation. Well done, thank you very much!

If this is still the right spot, may I ask if support for Opencores Ethernet MAC will be accompanied by support to provide the networking emulation also as a WiFi device to the userspace program in the future? Or is it already possible?

@amotl
Copy link

@amotl amotl commented on 440ff71 Feb 3, 2022

Choose a reason for hiding this comment

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

To answer myself here: In #23 you are stating that:

There is no Wi-Fi emulation, unfortunately.

A quick search revealed that the repository qemu_esp32 1, conceived by @Ebiroll, @sunnet-si and contributors, apparently supports mapping the Ethernet device communication to the WiFi stack already. I didn't research thoroughly, but @emb-team's patch to the ESP IDF 2 also seems to play a role here, as outlined at 3. Kudos!

It might make sense to wrap that up into another issue on this repository instead of attached to this commit. I will do that later, sorry for the noise.

Footnotes

  1. https://github.com/Ebiroll/qemu_esp32

  2. https://github.com/emb-team/esp-idf-qemu/commit/5c0cbfaffbc0ad

  3. https://emb-team.com/esp32-wifi-ble-emulation-in-qemu/

@igrr
Copy link
Member Author

@igrr igrr commented on 440ff71 Feb 3, 2022

Choose a reason for hiding this comment

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

Thanks for letting me know about @emb-team's work. I was not aware of it!
I'll discuss with my colleagues responsible for the Wi-Fi stack and see if this could be integrated into ESP-IDF.

@dzo
Copy link

@dzo dzo commented on 440ff71 Apr 26, 2022

Choose a reason for hiding this comment

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

I have a branch of this with wifi emulation here:

https://github.com/a159x36/qemu/commits/esp-dev

This emulates the actual wifi hardware so runs unmodified binaries (emb-team's wifi needs a modified wifi lib)

It emulates both station and access point modes.

The wifi hardware is here:
https://github.com/a159x36/qemu/blob/esp-dev/hw/misc/esp32_wifi.c
and the access point is here:
https://github.com/a159x36/qemu/blob/esp-dev/hw/misc/esp32_wifi_ap.c
(this also handles emulating a station when the esp32 is in ap mode)

If you want to see it working you can try a prebuilt emulator (linux, windows and macOS) by opening my demo code from the platformio ide here:

https://github.com/a159x36/TTGODemo

Please sign in to comment.