Skip to content

QNice sometimes hangs on MOVE @R5++, R12 after reset #59

@Rhialto

Description

@Rhialto

I'm just reporting this here to make sure that the details I researched so far get recorded.

In v0.000012 of the MegaPET core I changed the storage of the floppy disk images to HyperRAM. I suspect this issue is related. I mentioned it in the discord, so I'll just copy it here.

Sometimes when resetting the core, it doesn't reset properly, and sometimes (quite rarely) it doesn't even work when long-resetting it (until the power LED goes blue). I thought I had found some circumstances when this could happen, but it wasn't repeatable enough to debug so far. At first it seemed related to setting the 8296 memory to userport-control, and later
I thought it might be related to having a disk image inserted in the disk, but neither proved very repeatable.

For reference: when the reset doesn't complete, I have seen the QNice PC stuck at address $1EFE. That seems to correspond to this code. Meanwhile, the HELP key is unresponsive (I have learned that this usually means that QNice is busy with something else).

    007278                    ; Handle read request from drive number in R8:
    007279                    ;
    007280                    ; Transfer the data requested by the core from the linear disk image buffer
    007281                    ; to the internal buffer inside the core
    007282                    ;
    007283                    ; @TODO: Sanity check as described in vdrives.vhd protocol comment (3)
    007284  1ECE  FF90  005E  HANDLE_DRV_RD               ASUB enter, 1
    ...
    007314  1EF5  C600        _HDR_SEND_LOOP              CMP R6, R0                       ; transmission done?
    007315  1EF6  FFA3  0025                              RBRA _HDR_SEND_DONE, Z           ; yes
    007316
    007317  1EF8  0FA4  81DA                              MOVE VDRIVES_BUFS, R9            ; array of buf RAM device IDs
    007318  1EFA  1B24                                    ADD R11, R9                      ; select right ID for vdrive
    007319  1EFB  094D                                    MOVE @R9, @R3                    ; select device
    007320  1EFC  0111                                    MOVE R1, @R4                     ; select window in RAM
    007321  1EFD  05B0                                    MOVE @R5++, R12                  ; R12=next byte from disk img
    007322
    007323  1EFE  0FA0  7005                              MOVE VD_B_ADDR, R8               ; write buffer: address
    007324  1F00  0624                                    MOVE R6, R9
    007325  1F01  FFB0  2921                              RSUB VD_CAD_WRITE, 1
    007326
    007327  1F03  0FA0  7006                              MOVE VD_B_DOUT, R8               ; write buffer: data out
    007328  1F05  0C24                                    MOVE R12, R9
    007329  1F06  FFB0  291C                              RSUB VD_CAD_WRITE, 1

where I assume that the PC has already increased to the next instruction but the CPU is somehow stuck on the MOVE @R5++, R12.

So I'm getting a bit of a suspicion it is about the disk image which is now in Attic RAM.

Looking though the various vhdl files, there is the signal s_qnice_wait_o from each entity work.qnice2hyperram that eventually (if I traced it right) reaches /M2M/vhdl/QNICE/qnice.vhd where it is connected to entity work.QNICE_CPU as WAIT_FOR_DATA => cpu_wait_for_data or ramrom_wait_i,.

I suspect that the MOVE instruction is waiting for that (but I haven't put a 'scope on that to prove it yet).

As to why the s_qnice_wait_o might be active for "ever", I have no clue yet. Too much contention on the hyperram? The display meanwhile goes on fine, and so does the PET, as long as you don't try to access the disk.

Here is how I use the hyperram, which I hopefully correctly cribbed from the POC for the C64 core: https://github.com/Rhialto/PET_MEGA65/blob/v0.00012/CORE/vhdl/mega65.vhd#L681

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions