There is a bug in the SAM-BA 2.16 bootloader for the SAMD21 supplied as an Atmel Studio 7.0 example project that causes stack overflow.
In the SAM0 SAM-BA Bootloader Example for SAMD21 Xplained Pro:
Line: 160: sp = __get_MSP(); should not be in function call_applet.
Move it before line 265 (the "Go" command that calls call_applet):
sp = __get_MSP();
Otherwise the stack overflows and overwrites user variables.
In my case it showed up trying to transfer a ~8k (0x2000) byte file.