Actually, it seems that stack pointers are always 2 bytes in all Mega AVRs, but you have two extra registers to access the flash memory (RAMPZ and EIND), so I guess they both should be saved.
You could do something like this in bertos/cpu/avr/hw/switch_ctx_avr.S:
Code:
push r28
push r29
push RAMPZ
push EIND
....
and below, when restoring the context (line 94):
Code:
out SPL-__SFR_OFFSET,r18 ; SP = *new_sp
out SPH-__SFR_OFFSET,r19
out SREG-__SFR_OFFSET,r0 ; Restore previous IRQ state
pop EIND
pop RAMPZ
pop r29
....
Of course you will need to add a
CPU_PUSH_WORD((sp), RAMPZ); \
to account for the extra register.
I don't have a Mega2560 to test the code, I hope you can make it work correctly!
Cheers,
Luca