You could shield sd cable. Especially near the board it might come near heated bed/extruder/stepper cables which can interfere with signals.
It could also be a problem with bad contacts on cable as you seem to have already problems with the autodetect pin. Sometimes the cables are not good or some solderings are bad. All this can lead to such problems.