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

SPI-Core crashes python kernel / linux kernel when access register_map #1435

Open
TRnhld opened this issue Nov 21, 2023 · 0 comments
Open

SPI-Core crashes python kernel / linux kernel when access register_map #1435

TRnhld opened this issue Nov 21, 2023 · 0 comments

Comments

@TRnhld
Copy link

TRnhld commented Nov 21, 2023

  • PYNQ version: 3.0.1
  • Board name: MicroZed 7020 (AES-Z7MB-7Z020)
  • Pull request type: bug fix
  • Description:
    • I've got a desigh with AXI Quad SPI (V3.2) Core. with following Configuration
      • Performance Mode = Disabled
      • Mode = Quad
      • No. of Slaves = 1
      • Slave Device = Spansion
      • FIFO Depth = 16 (also tried 256)
      • STARTUP Primitive = disabled
    • after loading the Overlay and accessing the IP's register_map, the python kernel crashes
o = Overlay(r'overlay/design7.xsa')
o.qspi_master_hier.axi_quad_spi.register_map

Screenshot 2023-11-21 095214

  • Locating error-source
    • tracking the error in the pynq libraris i noticed, the registers ger acessed when calling *.register_map
    • the AXI Quad SPI-IP seems to have the has a special behaviour when accessing an empty RX-FIFO SPI DRR - causing timeout on AXI when FIFO is empty
    • the call for accessing this address happens in __init__-function of class pynq.registers.RegisterMap

based on this I created some sample code to see where the python kernel crashes:

from pynq import Overlay
o = Overlay(r'overlay/design7.xsa')
rs = pynq.registers.RegisterMap.create_subclass(o.qspi_master_hier.axi_quad_spi._register_name, o.qspi_master_hier.axi_quad_spi._registers)(o.qspi_master_hier.axi_quad_spi.mmio.array)
buf = o.qspi_master_hier.axi_quad_spi.mmio.array

array32 = buf.view(dtype='u4')

array32[0x10] = 0xa # resetting spi core

for k, v in rs._register_classes.items():
    index = v[1] // 4
    print("%02X "  % (v[1]//4), end='')

sleep(1)
print("\n")

for k, v in rs._register_classes.items():
    index = v[1] // 4
    if index == 0x1B:
        continue
    print("%02X "  % (v[1]//4), end='')
    sleep(0.1)
    array = array32[index:index+1]
    print("= %02X" % array[0])
    
sleep(1)
print("\n")

for k, v in rs._register_classes.items():
    index = v[1] // 4
    print("%02X "  % (v[1]//4), end='')
    sleep(0.1)
    array = array32[index:index+1] # axi bus gets timeout when trying to excess empty rx fifo
    print("= %02X" % array[0])

Output:

18 19 10 18 19 1C 1D 1E 07 1A 1B 08 0A 

18 = 180
19 = AD
10 = 00
18 = 180
19 = AD
1C = 01
1D = 00
1E = 00
07 = 00
1A = 00
08 = 400
0A = 00


18 = 180
19 = AD
10 = 00
18 = 180
19 = AD
1C = 01
1D = 00
1E = 00
07 # *Python kernel Restarts here*
  • Additional tries and findings
    • I also did an implementation with same settings of AXI Quad SPI accept putting the core into performance mode
      • Note: having to do some other "going around bugs" - See here
      • here, the core gets accessed by mmap - library
      • in class pynq.pl_server.embedded_device.EmbeddedDevice the function mmap() will be called.
        • the line 599 array = np.frombuffer(mem, np.uint32, length >> 2, virt_offset) will cause the whole linux kernel to crash.
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

No branches or pull requests

1 participant