As per the lpc11xx manual the stack pointer should be set before IAP
calls are made.  

In lpc11xx_flash_prepare() and lpc11xx_flash_erase() bug in calculating
the ending sector number.