Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hw/ssi: update trans_done #40

Closed
wants to merge 26 commits into from

Conversation

amirgon
Copy link

@amirgon amirgon commented Apr 1, 2022

Fixes #39

igrr and others added 26 commits December 16, 2021 10:44
GDB considers window registers as pseudo registers, meaning that they
are calculated by GDB using the values of AR registers and windowbase.
This patch removes the window registers from the total number of
registers that QEMU will send to GDB, making the number of registers
match the one that GDB expects to see.
This commit introduces two environment variables which can be used
to adjust the list of registers sent from QEMU to GDB:
* If QEMU_XTENSA_CORE_REGS_ONLY is set, only non-privileged registers
  will be sent to GDB. This behavior is compatible with Espressif
  builds of GDB up to esp-2021r1.
* If QEMU_XTENSA_COUNT_WINDOW_REGS is set, QEMU will send window
  registers (a0-a15) to GDB. Enable this if you don't have a build of
  GDB which considers a0-a15 to be "raw" registers.
DP83848C PHY emulated by opencores_eth has several vendor-specific
MII registers at 0x10-0x1d. Reading these registers resulted in an
out-of-bounds access to the regs array.
Part of this commit adds bounds checking.
Since the PHYSTS vendor-specific register is accessed by some of the
embedded DP83848C drivers, the rest of the commit adds simple
emulation of this register, setting the bits depending on the link
status.
This is an SSIPeripheral instance that knows how to respond to read_id
command. It doesn't store any data. It is sufficient for the IDF
driver to decide to turn on the PSRAM cache. Actual data storage in
PSRAM is emulated in DPORT.
@github-actions github-actions bot closed this Apr 1, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 1, 2022
@igrr igrr reopened this Apr 1, 2022
@espressif espressif unlocked this conversation Apr 1, 2022
@igrr
Copy link
Member

igrr commented Apr 1, 2022

@amirgon thank you for the PR and sorry for the Github Action closing it. The "repo lockdown" is an upstream QEMU feature which we haven't deleted in this fork. I have disabled this workflow now.
On the topic of the PR, could you please describe the use case where this change is necessary? This is so that we can add a regression test to cover that use case. If your use case can be tested with one of IDF examples, it would be the easiest option.

@amirgon
Copy link
Author

amirgon commented Apr 1, 2022

could you please describe the use case where this change is necessary?

I'm attempting to emulate ESP32+ILI9341 device on QEMU in order to run Micropython + LVGL.
These are really just the first few steps to see if I can connect an ILI9341 display device in QEMU to your SPI master emulation.
In this process when I suspect some wrong/missing functionality I'm opening an issue to start a discussion.

In this specific case I'm trying to initialize a SPI display driver which calls spi_device_polling_transmit at some point and gets stuck, as described in #39

@igrr
Copy link
Member

igrr commented Apr 2, 2022

I see, thanks for the explanation! I think you may run into more parts of SPI master which aren't implemented in QEMU, like for example DMA transfers. If you end up implementing more things, please feel free to push additional changes to the PR.

Regarding display emulation, you might also be interested in this display emulation code written by @a159x36: a159x36@ad9de5f. (That fork also seems to include Wi-Fi emulation, which is another awesome feature!)

@amirgon
Copy link
Author

amirgon commented Apr 2, 2022

I think you may run into more parts of SPI master which aren't implemented in QEMU, like for example DMA transfers.

I will definitely need DMA transfers.

If you end up implementing more things, please feel free to push additional changes to the PR.

Sure.

Regarding display emulation, you might also be interested in this display emulation code written by @a159x36: a159x36@ad9de5f. (That fork also seems to include Wi-Fi emulation, which is another awesome feature!)

Wow that's one big commit! It seems to also implement DMA transfers on SPI, and attach st7789v to the SPI device, exactly what I planned to do for ili9341...
That's very interesting, thank you very much for sharing this with me.

Do you have any plans to integrate @a159x36's (@dzo) changes (wifi, spi dma etc.) into Espressif QEMU?

igrr pushed a commit that referenced this pull request Aug 2, 2022
Include the qtest reproducer provided by Alexander Bulekov
in https://gitlab.com/qemu-project/qemu/-/issues/542.
Without the previous commit, we get:

  $ make check-qtest-i386
  ...
  Running test tests/qtest/intel-hda-test
  AddressSanitizer:DEADLYSIGNAL
  =================================================================
  ==1580408==ERROR: AddressSanitizer: stack-overflow on address 0x7ffc3d566fe0
      #0 0x63d297cf in address_space_translate_internal softmmu/physmem.c:356
      #1 0x63d27260 in flatview_do_translate softmmu/physmem.c:499:15
      #2 0x63d27af5 in flatview_translate softmmu/physmem.c:565:15
      #3 0x63d4ce84 in flatview_write softmmu/physmem.c:2850:10
      #4 0x63d4cb18 in address_space_write softmmu/physmem.c:2950:18
      #5 0x63d4d387 in address_space_rw softmmu/physmem.c:2960:16
      #6 0x62ae12f2 in dma_memory_rw_relaxed include/sysemu/dma.h:89:12
      #7 0x62ae104a in dma_memory_rw include/sysemu/dma.h:132:12
      #8 0x62ae6157 in dma_memory_write include/sysemu/dma.h:173:12
      #9 0x62ae5ec0 in stl_le_dma include/sysemu/dma.h:275:1
      #10 0x62ae5ba2 in stl_le_pci_dma include/hw/pci/pci.h:871:1
      #11 0x62ad59a6 in intel_hda_response hw/audio/intel-hda.c:372:12
      #12 0x62ad2afb in hda_codec_response hw/audio/intel-hda.c:107:5
      #13 0x62aec4e1 in hda_audio_command hw/audio/hda-codec.c:655:5
      #14 0x62ae05d9 in intel_hda_send_command hw/audio/intel-hda.c:307:5
      #15 0x62adff54 in intel_hda_corb_run hw/audio/intel-hda.c:342:9
      #16 0x62adc13b in intel_hda_set_corb_wp hw/audio/intel-hda.c:548:5
      #17 0x62ae5942 in intel_hda_reg_write hw/audio/intel-hda.c:977:9
      #18 0x62ada10a in intel_hda_mmio_write hw/audio/intel-hda.c:1054:5
      #19 0x63d8f383 in memory_region_write_accessor softmmu/memory.c:492:5
      #20 0x63d8ecc1 in access_with_adjusted_size softmmu/memory.c:554:18
      #21 0x63d8d5d6 in memory_region_dispatch_write softmmu/memory.c:1504:16
      #22 0x63d5e85e in flatview_write_continue softmmu/physmem.c:2812:23
      #23 0x63d4d05b in flatview_write softmmu/physmem.c:2854:12
      #24 0x63d4cb18 in address_space_write softmmu/physmem.c:2950:18
      #25 0x63d4d387 in address_space_rw softmmu/physmem.c:2960:16
      #26 0x62ae12f2 in dma_memory_rw_relaxed include/sysemu/dma.h:89:12
      #27 0x62ae104a in dma_memory_rw include/sysemu/dma.h:132:12
      #28 0x62ae6157 in dma_memory_write include/sysemu/dma.h:173:12
      #29 0x62ae5ec0 in stl_le_dma include/sysemu/dma.h:275:1
      #30 0x62ae5ba2 in stl_le_pci_dma include/hw/pci/pci.h:871:1
      #31 0x62ad59a6 in intel_hda_response hw/audio/intel-hda.c:372:12
      #32 0x62ad2afb in hda_codec_response hw/audio/intel-hda.c:107:5
      #33 0x62aec4e1 in hda_audio_command hw/audio/hda-codec.c:655:5
      #34 0x62ae05d9 in intel_hda_send_command hw/audio/intel-hda.c:307:5
      #35 0x62adff54 in intel_hda_corb_run hw/audio/intel-hda.c:342:9
      #36 0x62adc13b in intel_hda_set_corb_wp hw/audio/intel-hda.c:548:5
      #37 0x62ae5942 in intel_hda_reg_write hw/audio/intel-hda.c:977:9
      #38 0x62ada10a in intel_hda_mmio_write hw/audio/intel-hda.c:1054:5
      #39 0x63d8f383 in memory_region_write_accessor softmmu/memory.c:492:5
      #40 0x63d8ecc1 in access_with_adjusted_size softmmu/memory.c:554:18
      #41 0x63d8d5d6 in memory_region_dispatch_write softmmu/memory.c:1504:16
      #42 0x63d5e85e in flatview_write_continue softmmu/physmem.c:2812:23
      #43 0x63d4d05b in flatview_write softmmu/physmem.c:2854:12
      #44 0x63d4cb18 in address_space_write softmmu/physmem.c:2950:18
      #45 0x63d4d387 in address_space_rw softmmu/physmem.c:2960:16
      #46 0x62ae12f2 in dma_memory_rw_relaxed include/sysemu/dma.h:89:12
      qemu#47 0x62ae104a in dma_memory_rw include/sysemu/dma.h:132:12
      #48 0x62ae6157 in dma_memory_write include/sysemu/dma.h:173:12
      ...
  SUMMARY: AddressSanitizer: stack-overflow softmmu/physmem.c:356 in address_space_translate_internal
  ==1580408==ABORTING
  Broken pipe
  Aborted (core dumped)

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20211218160912.1591633-4-philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
@igrr
Copy link
Member

igrr commented Aug 2, 2022

Have picked your fix into https://github.com/espressif/qemu/releases/tag/esp-develop-20220802 release, thanks again!

@igrr igrr closed this Aug 2, 2022
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.

SPI master device never updates trans_done
5 participants