Here's another test build. Please report the values shown for AD, M1 and M2.
When CHDK is invoked by FW Update all four values are 0 (or 0x00000000)
Upon USB Plug-in
AD: cycles 0x1ff through 0x205
M1: 0x10100
M2: 0
USB: 1
Camera not seen by PC.
When CHDK is loaded on boot with a locked SD card. M2 is 0x1 instead of 0.
Thanks.
Additional details, in case anyone has ideas:
AD is the A/D channel that returns USB +5 voltage (0x1ff = 511, 5.1 volts?). This is checked by some code related to the variable at 0x2488 that triggers the HardwareDefect. Specifically ff85d6f4 calls ff860d24(11) which returns the value of MMIO 0xc0900054, which is the A/D value (with some fiddling) and sets *0x2488 = 1 if the value is < 0x15b (437). ff860d24 is also the underlying function of GetAdChValue
M1 is MMIO 0xc0720008. Some other code related to the 0x2488 checks this. On elph140, it's 0 when USB isn't present, and 0x24100000 when it is. It appears to go through some other values when USB is plugged/unplugged. Plugged into a powered hub with no computer attached, it's 0x20010200. Plugged into USB charger (presumably just +5v), it appears to be 0x00100000.
If CHDK USB remote is enabled, it stays 0.
Code around ff832104 checks for *(0xc0720008) & 0x100 and calls the ff85d6f4 function mentioned above if set. Some code around called from Restart also checks this for 0x100, skipping operations on other 0xc072* MMIOs if it's set.
Other code checks 0xc0720008 & 0x8000
I guess the 0xc072* MMIOs are maybe registers for the USB controller? Tracing back from these could maybe identify initialization code.`
M2 is the 0x2488 value.