I/O toggling while uploading a sketch

I have two Arduino Dues working in tandem for a project. One interprets the signals from a hand full of membrane keypads, and is connected to the other Due via several (9ish) digital pins. The two arduinos share a common ground. The second arduino has motion algorithms on it that operate a several degree of freedom machine (stepper motors).

When a kepyad is pressed, arduino #1 sets a digital pin to high, which is read by arduino #2, and a motor is jogged.

A problem I am encountering is that when I am uploading a sketch to arduino #1 (the one responsible for interpreting the keypads) it sets random pins to high. As a result, when I am uploading a sketch random motors start turning. As soon as the sketch is successfully uploaded the strange behavior stops.

Anyone have any idea what this could be?

I guess glitches at startup time are responsable for the "weird" behaviour. One might hook pull_down résistors to selected pins at Arduino DUE #1, this will mask the issue.

If it's still not enough, activate the Input Glitch Filter Register PIO_IFER for selected pins in Arduino DUE #2.

If it's still not enough, activate the Debouncing Input Filter Select Register PIO_DIFSR in Arduino DUE #2.