GDB allows very easy batch programming. I use this batch file to start the server and program my file:
REM Start P&E GDB Server with single session
call "cmd /c start C:\Freescale\KDS_3.0.0\eclipse\plugins\com.pemicro.debug.gdbjtag.pne_2.0.8.201504092111\win32\pegdbserver_console.exe -startserver -singlesession -device=Freescale_K6x_K64FN1M0M12"
REM start gdb with script
arm-none-eabi-gdb -x gdbScript.txt
The content of the script gdbScript file is this:
# script for gdb. Run it with
# gdb -x <commandFile>
# disable confirmation messages (y or no):
set confirm off
# connect to P&E gdb server:
target remote localhost:7224
# reset target:
monitor reset
# load symbols for application:
file MyProject/Debug/MyProject.elf
# load application:
load MyProject/Debug/MyProject.elf
# detach from target. As a side effect, this will start it:
detach
# quit gdb
quit
I hope this helps,
Erich