Code works on boot loader but not when directly programmed

No a program written to work with a bootloader needs the bootloader to work. A program written to work without a bootloader will not (most likely) work with it.

When your processor starts up the bootloader at location x is called, the bootloader does its thing and then transfers control to your program at location y. x is defined by BOOTRST.

So you need to change BOOTRST from x to y. You also need to do any initialisation of the processor that the bootloader does for you!

Mark