crozone / ipodloader2

Bootloader for classic iPods. Supports Rockbox, iPod Linux, and stock iPod OS.
44 stars 1 forks source link

Crashes on Clicky emulator: GPIO Port:A ContractViolation #8

Closed crozone closed 5 months ago

crozone commented 5 months ago

iPodLoader 2 is doing a 32 bit write to GPIO Port A, which Clicky specifies as an 8 bit GPIO port. This crashes the emulator with an illegal read:

ERROR clicky_desktop                           > Fatal Error! Caused by: FatalMemException {
    context: MemExceptionCtx {
        pc: 0x40008018,
        access: MemAccess {
            kind: Write,
            offset: 0x6000d060,
            val: U32(
                0xffffffdf,
            ),
        },
        in_device: "4xGPIO Port Block > GPIO Port:A > IntLevel",
    },
    reason: ContractViolation {
        msg: ">8-bit access to a 8-bit interface",
        severity: Error,
        stub_val: None,
    },
}

Real hardware is seemingly unaffected.

The offending code is here, the inl and outl, which should be changed to inb and outb:

https://github.com/crozone/ipodloader2/blob/754db7dd36846656ed398b64f86475c0e194e5fa/keypad.c#L542-L544

https://github.com/crozone/ipodloader2/blob/754db7dd36846656ed398b64f86475c0e194e5fa/keypad.c#L588-L590

According to the iPod Linux docs, the port is really 8 bits, so it looks like an open and shut mistake in iPodLoader2.

For reference, here is how Rockbox reads the port:

https://github.com/daniel5151/clicky/blob/e199dcfe70510c7ff16ee9e55add5b3095e36c5c/resources/documentation/Rockbox/pp5020.h#L338-L345