unable to flash code greater than 256kb in at91sam7s512

I am unable to flash program more than 256kb to at91sam7s512 using openocd 0.2.0 version. i get an error as gdbinit:46: Error in sourced command file:Error erasing flash with vFlashErase packet.

please can anyone help me out.

gdbinit script

#shell openocd -f interface/arm-usb-ocd.cfg -f target/sam7x256.cfg &

#Connect to the remote GDB server

target remote localhost:3333

#OpenOCD command to halt the processor and wait

monitor soft_reset_halt

#OpenOCD command to select the core state

monitor armv4_5 core_state arm

#force a peripheral RESET AT91C_RSTC_RCR. I am not sure if this is better done here or later

monitor mww 0xfffffd00 0xa5000004

#Configure the system clock

#set flash wait state (AT91C_MC_FMR)

monitor mww 0xffffff60 0x00320100

#watchdog disable (AT91C_WDTC_WDMR)

monitor mww 0xfffffd44 0xa0008000

#enable main oscillator (AT91C_PMC_MOR)

monitor mww 0xfffffc20 0xa0000601

monitor wait 100

#set PLL register (AT91C_PMC_PLLR)

monitor mww 0xfffffc2c 0x00480a0e

monitor wait 200

#set master clock to PLL (AT91C_PMC_MCKR)

monitor mww 0xfffffc30 0x7

monitor wait 100

#Enable reset button on the AT91SAM7S-EK

#monitor mww 0xfffffd08 0xa5000401 # enable user reset AT91C_RSTC_RMR

#Increase GDB packet size to 1024 to increase speed

set remote memory-write-packet-size 1024

#set remote memory-write-packet-size fixed

set remote memory-read-packet-size 1024

#set remote memory-read-packet-size fixed

#enable use of software breakpoints

monitor arm7_9 sw_bkpts enable

#Load the application

load

Insert a break point at main

#b main

resume execution from reset vector

#continue

and i am using sam7x256.cfg as an config file.